/* global _, angular, i18n */ 'use strict'; var controllers = angular.module('DinsorApp.controllers', []); controllers.controller('app', ['$scope', '$location', '$q', '$window', '$timeout', '$cookies', 'app', function ($scope, $location, $q, $window, $timeout, $cookies, app) { // $scope.year = new Date().getFullYear(); // $scope.service = { app }; // $scope.currentUrl = $location.host(); $scope.route = ''; /* layout */ $scope.headbar = true; $scope.footer = true; $scope.sitemap = true; // $scope.loading = true; // $scope.member = true; $scope.authorize = false; $scope.authorized = {}; $scope.barCookie = false; // responsive device $scope.mobile = screen.width <= 600; $scope.tablet = screen.width > 600 && screen.width <= 1024; // $scope.init = function () { var interval = setInterval(function () { if (document.readyState == 'complete') { //console.log(document.readyState) $window.scrollTo(0, 0); clearInterval(interval); } }, 500); return; }; $scope.scrollToTop = function () { // Scroll to Top of Page. var deferred = $q.defer(); deferred.resolve(angular.element("html, body").animate({ "scrollTop": 0 })); return deferred.promise; } $scope.back = function () { //console.log('back'); $window.history.back(); }; $scope.timeout = function (delay, callback) { $timeout(function () { if (callback != undefined) { callback; } else true; }, delay); } $scope.gotoUrl = function (uri) { $window.location = uri; } $scope.openUrl = function (uri, target) { $window.open(uri, target); } $scope.active = function (path) { //console.log(path) return $location.path().match(new RegExp(path + '.*', 'i')) != null; }; $scope.logout = function () { $scope.service.member.logout().then(function () { $window.location.reload(); }); }; // $scope.$on('$viewContentLoaded', function (event, viewConfig) { //Here your view content is fully loaded !! $timeout(function () { $scope.loading = false; $scope.checkCookies(); }, 900) // $(window).focus(function () { //console.log('window active') }); // $(window).blur(function () { //console.log('window inactive') }); }); $scope.$on("$routeChangeStart", function (event, route, current) { $scope.member = true; $scope.loading = true; }); // privacy policy cookie $scope.checkCookies = function () { var accept = $cookies.get('cookie-privacy'); if (accept != 'accept') { $scope.barCookie = true; } } $scope.setCookies = function () { var expireDate = new Date(); expireDate.setDate(expireDate.getDate() + 360); document.cookie = "cookie-privacy=accept; expires=" + expireDate + "; path=/"; $scope.barCookie = false; } }]); controllers.controller('home', ['$scope', '$location', '$routeParams', 'ngMeta', function ($scope, $location, $routeParams, ngMeta) { // // console.log($scope.ngMeta.title); }]); controllers.controller('user', ['$scope', function ($scope) { // }]); controllers.controller('dinsorworks', ['$scope', '$window', function ($scope, $window) { // $window.location.href = 'https://services.dinsor.co.th/app/client/suchatvee/dinsorworks'; }]);