/* global _, angular, i18n */ 'use strict'; var controllers = angular.module('DinsorApp.controllers', []); controllers.controller('app', ['$scope','$location','$q','$window','$timeout','$cookies','app','user','member', function($scope, $location, $q, $window, $timeout, $cookies, app, user, member) { // //$scope.apikey = '[#apikey]'; //$scope.mobile = false; $scope.year = new Date().getFullYear(); // $scope.service = {app, user, member}; // $scope.currentUrl = $location.host(); $scope.resourceUrl = '//valuecreation.ditp.go.th/public/uploads/'; $scope.defaultBanner = '//valuecreation.ditp.go.th/assets/images/default_image.jpg'; //$scope.navigator = {}; //$scope.academyService = academy; //$scope.bgAcademy = {'background-color':'#f5f5f5'}; $scope.route = ''; /* layout */ $scope.headbar = true; $scope.fullpage = false; $scope.intro = false; // $scope.loading = false; // $scope.member = true; $scope.authorize = false; $scope.authorized = {}; $scope.barCookies = false; $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(); $scope.navigationChange(); }, 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.navigationChange(); }); // privacy policy cookie $scope.checkCookies = function(){ var accept = $cookies.get('privacy'); if(accept != 'accept'){ $scope.barCookies = true; } } $scope.setCookies = function(){ var expireDate = new Date(); expireDate.setDate(expireDate.getDate() + 360); document.cookie = "privacy=accept; expires=" + expireDate + "; path=/"; $scope.barCookies = false; } // navigation background change $scope.navigationChange = function() { if($location.path() == '/') { $('.navbar').removeClass('black').addClass('bg-linear-gradient'); }else { $('.navbar').removeClass('bg-linear-gradient').addClass('black'); } } }]); controllers.controller('home', ['$scope', '$location', function($scope, $location) { // // $scope.service.app.feature().then(function(data) { // console.log(data) // }); }]); controllers.controller('user', ['$scope', function($scope) { // }]); controllers.controller('form', ['$scope','$routeParams', function($scope, $routeParams) { // $scope['formId'] = $routeParams.id //var query = $routeParams; //console.log(query) // $scope.service.user.form(query).then(function(form) { // // }) }]); controllers.controller('member',['$scope','$window','$location','$routeParams', function($scope, $window, $location, $routeParams) { // var query = $routeParams //console.log(query) // $scope.service.app.projects(query).then(function(data) { // // console.log(data) // }); }]); controllers.controller('logout',['$scope','$window', function($scope, $window) { // $scope.service.member.logout(); $window.location.href = '/'; //var query = $location.hash().split('&'); //console.log(query) /* $scope.service.app.projects(query).then(function(data) { // console.log(data) }); */ //$location.url($location.path()); }]); /* controllers.controller('api', ['$scope','$window', function($scope, $window) { // //var query = $routeParams; $window.location.href = "https://google.com" }]); */