Commit fbf7b6b29f299f3eb3ea77eb5a4536345a34ce9e

Authored by Eric Fernandez
Exists in master and in 1 other branch develop

Merge branch 'master' into 'develop'

Master(mpuebla)

See merge request !147

13.4 KB

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 '$uibModalStack', 6 '$uibModalStack',
7 '$uibModal', 7 function ($scope, $rootScope, $timeout, $uibModalStack) {
8 function ($scope, $rootScope, $timeout, $uibModalStack, $uibModal) {
9 $scope.usarTeclado = false; 8 $scope.usarTeclado = false;
10 $rootScope.$broadcast('usarTeclado', false); 9 $rootScope.$broadcast('usarTeclado', false);
11 $scope.mostrarTeclado = false; 10 $scope.mostrarTeclado = false;
12 //Envía broadcast para avisar que el teclado está en funcionamiento o no 11 //Envía broadcast para avisar que el teclado está en funcionamiento o no
13 //para su uso cambiar ng-click del boton por esta función 12 //para su uso cambiar ng-click del boton por esta función
14 $scope.cambioUsoTeclado = function () { 13 $scope.cambioUsoTeclado = function () {
15 if ($scope.usarTeclado) { 14 if ($scope.usarTeclado) {
16 $scope.usarTeclado = false; 15 $scope.usarTeclado = false;
17 $rootScope.$broadcast('usarTeclado', false); 16 $rootScope.$broadcast('usarTeclado', false);
18 return; 17 return;
19 } 18 }
20 $scope.usarTeclado = true; 19 $scope.usarTeclado = true;
21 $rootScope.$broadcast('usarTeclado', true); 20 $rootScope.$broadcast('usarTeclado', true);
22 }; 21 };
23 22
24 $rootScope.$on('focus', function () { 23 $rootScope.$on('focus', function () {
25 if (!$scope.usarTeclado) { 24 if (!$scope.usarTeclado) {
26 return; 25 return;
27 } 26 }
28 $scope.mostrarTeclado = true; 27 $scope.mostrarTeclado = true;
29 $timeout.cancel($scope.timeout); 28 $timeout.cancel($scope.timeout);
30 if (!$scope.$$phase) { 29 if (!$scope.$$phase) {
31 $scope.$apply(); 30 $scope.$apply();
32 } 31 }
33 }); 32 });
34 $rootScope.$on('blur', function () { 33 $rootScope.$on('blur', function () {
35 $scope.timeout = $timeout(function () { 34 $scope.timeout = $timeout(function () {
36 $scope.mostrarTeclado = false; 35 $scope.mostrarTeclado = false;
37 if (!$scope.$$phase) { 36 if (!$scope.$$phase) {
38 $scope.$apply(); 37 $scope.$apply();
39 } 38 }
40 }, 150); 39 }, 150);
41 }); 40 });
42 41
43 // Close all modals 42 // Close all modals
44 $rootScope.$on('$locationChangeSuccess', function () { 43 $rootScope.$on('$locationChangeSuccess', function () {
45 $uibModalStack.dismissAll('close'); 44 $uibModalStack.dismissAll('close');
46 }); 45 });
47 } 46 }
48 ]); 47 ]);
49 48