Commit 4cc241c9bf319689b232e8b214dc6e04cc397c56
1 parent
e8b47a55ed
Exists in
master
espacio
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
src/js/controller.js
1 | angular.module('appWrapperDemo') | 1 | angular.module('appWrapperDemo') |
2 | .controller('appWrapperDemoController', [ | 2 | .controller('appWrapperDemoController', [ |
3 | '$scope', | 3 | '$scope', |
4 | '$rootScope', | 4 | '$rootScope', |
5 | '$timeout', | 5 | '$timeout', |
6 | 'focaSqliteService', | 6 | 'focaSqliteService', |
7 | 'focaModalService', | 7 | 'focaModalService', |
8 | 'API_ENDPOINT', | 8 | 'API_ENDPOINT', |
9 | '$localStorage', | 9 | '$localStorage', |
10 | function($scope, $rootScope, $timeout, focaSqliteService, focaModalService, API_ENDPOINT, $localStorage) { | 10 | function($scope, $rootScope, $timeout, focaSqliteService, focaModalService, API_ENDPOINT, $localStorage) { |
11 | document.addEventListener('deviceready', function() { | 11 | document.addEventListener('deviceready', function() { |
12 | focaSqliteService.openDataBase(); | 12 | focaSqliteService.openDataBase(); |
13 | }); | 13 | }); |
14 | 14 | ||
15 | if(!API_ENDPOINT.URL) { | 15 | if (!API_ENDPOINT.URL) { |
16 | API_ENDPOINT.getUrl().then(success, err); | 16 | API_ENDPOINT.getUrl().then(success, err); |
17 | } | 17 | } |
18 | 18 | ||
19 | function success(res) { | 19 | function success(res) { |
20 | 20 | ||
21 | API_ENDPOINT.setUrl(res.data); | 21 | API_ENDPOINT.setUrl(res.data); |
22 | } | 22 | } |
23 | function err() { | 23 | function err() { |
24 | 24 | ||
25 | $timeout(function() { | 25 | $timeout(function() { |
26 | focaModalService.alert('Terminal no configurada: \n' + $localStorage.terminalKey); | 26 | focaModalService.alert('Terminal no configurada: \n' + $localStorage.terminalKey); |
27 | }, 1000); | 27 | }, 1000); |
28 | } | 28 | } |
29 | $scope.usarTeclado = false; | 29 | $scope.usarTeclado = false; |
30 | $rootScope.$broadcast('usarTeclado', false); | 30 | $rootScope.$broadcast('usarTeclado', false); |
31 | $scope.mostrarTeclado = false; | 31 | $scope.mostrarTeclado = false; |
32 | //Envía broadcast para avisar que el teclado está en funcionamiento o no | 32 | //Envía broadcast para avisar que el teclado está en funcionamiento o no |
33 | //para su uso cambiar ng-click del boton por esta función | 33 | //para su uso cambiar ng-click del boton por esta función |
34 | $scope.cambioUsoTeclado = function() { | 34 | $scope.cambioUsoTeclado = function() { |
35 | if($scope.usarTeclado) { | 35 | if($scope.usarTeclado) { |
36 | $scope.usarTeclado = false; | 36 | $scope.usarTeclado = false; |
37 | $rootScope.$broadcast('usarTeclado', false); | 37 | $rootScope.$broadcast('usarTeclado', false); |
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | $scope.usarTeclado = true; | 40 | $scope.usarTeclado = true; |
41 | $rootScope.$broadcast('usarTeclado', true); | 41 | $rootScope.$broadcast('usarTeclado', true); |
42 | }; | 42 | }; |
43 | 43 | ||
44 | $rootScope.$on('focus', function() { | 44 | $rootScope.$on('focus', function() { |
45 | if(!$scope.usarTeclado) { | 45 | if(!$scope.usarTeclado) { |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | $scope.mostrarTeclado = true; | 48 | $scope.mostrarTeclado = true; |
49 | $timeout.cancel($scope.timeout); | 49 | $timeout.cancel($scope.timeout); |
50 | if(!$scope.$$phase) { | 50 | if(!$scope.$$phase) { |
51 | $scope.$apply(); | 51 | $scope.$apply(); |
52 | } | 52 | } |
53 | }); | 53 | }); |
54 | $rootScope.$on('blur', function() { | 54 | $rootScope.$on('blur', function() { |
55 | $scope.timeout = $timeout(function() { | 55 | $scope.timeout = $timeout(function() { |
56 | $scope.mostrarTeclado = false; | 56 | $scope.mostrarTeclado = false; |
57 | if(!$scope.$$phase) { | 57 | if(!$scope.$$phase) { |
58 | $scope.$apply(); | 58 | $scope.$apply(); |
59 | } | 59 | } |
60 | }, 150); | 60 | }, 150); |
61 | }); | 61 | }); |
62 | } | 62 | } |
63 | ]); | 63 | ]); |
64 | 64 |