Commit 470aca5c32a12a961ae2e6f9c6f2133c979bf068
Exists in
master
Merge branch 'master' into 'master'
funcion emitir broadcast cuando cambia el uso del teclado See merge request Wrappers/wrapper-demo!36
Showing
1 changed file
 
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 | function($scope, $rootScope, $timeout) { | 6 | function($scope, $rootScope, $timeout) { | 
| 7 | $scope.usarTeclado = false; | 7 | $scope.usarTeclado = false; | 
| 8 | $scope.mostrarTeclado = false; | 8 | $scope.mostrarTeclado = false; | 
| 9 | //Envía broadcast para avisar que el teclado está en funcionamiento o no | ||
| 10 | //para su uso cambiar ng-click del boton por esta función | ||
| 11 | // $scope.cambioUsoTeclado = function() { | ||
| 12 | // if($scope.usarTeclado) { | ||
| 13 | // $scope.usarTeclado = false; | ||
| 14 | // $rootScope.$broadcast('usarTeclado', false); | ||
| 15 | // return | ||
| 16 | // } | ||
| 17 | // $scope.usarTeclado = true; | ||
| 18 | // $rootScope.$broadcast('usarTeclado', true); | ||
| 19 | // } | ||
| 9 | $rootScope.$on('focus', function(event) { | 20 | $rootScope.$on('focus', function(event) { | 
| 10 | if(!$scope.usarTeclado) { | 21 | if(!$scope.usarTeclado) { | 
| 11 | return; | 22 | return; | 
| 12 | } | 23 | } | 
| 13 | $scope.mostrarTeclado = true; | 24 | $scope.mostrarTeclado = true; | 
| 14 | $timeout.cancel($scope.timeout); | 25 | $timeout.cancel($scope.timeout); | 
| 15 | if(!$scope.$$phase) { | 26 | if(!$scope.$$phase) { | 
| 16 | $scope.$apply(); | 27 | $scope.$apply(); | 
| 17 | } | 28 | } | 
| 18 | }); | 29 | }); | 
| 19 | $rootScope.$on('blur', function(event) { | 30 | $rootScope.$on('blur', function(event) { | 
| 20 | $scope.timeout = $timeout(function() { | 31 | $scope.timeout = $timeout(function() { | 
| 21 | $scope.mostrarTeclado = false; | 32 | $scope.mostrarTeclado = false; | 
| 22 | if(!$scope.$$phase) { | 33 | if(!$scope.$$phase) { | 
| 23 | $scope.$apply(); | 34 | $scope.$apply(); | 
| 24 | } | 35 | } | 
| 25 | }, 150); | 36 | }, 150); | 
| 26 | }); | 37 | }); | 
| 27 | } | 38 | } | 
| 28 | ]); | 39 | ]); | 
| 29 | 40 | 
