Commit 206b3151dc7d5845abcd6286ff579dca0bf45039
1 parent
4a6f50c9b0
Exists in
master
espacio
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaModal') | 1 | angular.module('focaModal') |
2 | .controller('focaModalConfirmController', [ | 2 | .controller('focaModalConfirmController', [ |
3 | '$uibModalInstance', '$scope', 'textoModal', | 3 | '$uibModalInstance', '$scope', 'textoModal', |
4 | function($uibModalInstance, $scope, textoModal) { | 4 | function($uibModalInstance, $scope, textoModal) { |
5 | $scope.textoModal = textoModal; | 5 | $scope.textoModal = textoModal; |
6 | $scope.cancelar = function() { | 6 | $scope.cancelar = function() { |
7 | $uibModalInstance.dismiss(false); | 7 | $uibModalInstance.dismiss(false); |
8 | }; | 8 | }; |
9 | $scope.aceptar = function() { | 9 | $scope.aceptar = function() { |
10 | $uibModalInstance.close(true); | 10 | $uibModalInstance.close(true); |
11 | }; | 11 | }; |
12 | } | 12 | } |
13 | ]) | 13 | ]) |
14 | .controller('focaModalAlertController', [ | 14 | .controller('focaModalAlertController', [ |
15 | '$uibModalInstance', '$scope', 'textoModal', | 15 | '$uibModalInstance', '$scope', 'textoModal', |
16 | function($uibModalInstance, $scope, textoModal) { | 16 | function($uibModalInstance, $scope, textoModal) { |
17 | $scope.textoModal = textoModal; | 17 | $scope.textoModal = textoModal; |
18 | $scope.aceptar = function() { | 18 | $scope.aceptar = function() { |
19 | $uibModalInstance.close(true); | 19 | $uibModalInstance.close(true); |
20 | }; | 20 | }; |
21 | } | 21 | } |
22 | ]) | 22 | ]) |
23 | .controller('focaModalFechaController', [ | 23 | .controller('focaModalFechaController', [ |
24 | '$uibModalInstance', '$scope', 'titulo', | 24 | '$uibModalInstance', '$scope', 'titulo', |
25 | function($uibModalInstance, $scope, titulo) { | 25 | function($uibModalInstance, $scope, titulo) { |
26 | $scope.titulo = titulo; | 26 | $scope.titulo = titulo; |
27 | $scope.fecha = new Date(); | 27 | $scope.fecha = new Date(); |
28 | $scope.cancelar = function() { | 28 | $scope.cancelar = function() { |
29 | $uibModalInstance.dismiss(); | 29 | $uibModalInstance.dismiss(); |
30 | }; | 30 | }; |
31 | $scope.aceptar = function() { | 31 | $scope.aceptar = function() { |
32 | $uibModalInstance.close($scope.fecha); | 32 | $uibModalInstance.close($scope.fecha); |
33 | }; | 33 | }; |
34 | } | 34 | } |
35 | ]) | 35 | ]) |
36 | .controller('focaModalPromptController', [ | 36 | .controller('focaModalPromptController', [ |
37 | '$uibModalInstance', '$scope', 'options', 'focaModalService', | 37 | '$uibModalInstance', '$scope', 'options', 'focaModalService', |
38 | function($uibModalInstance, $scope, options, focaModalService) { | 38 | function($uibModalInstance, $scope, options, focaModalService) { |
39 | 39 | ||
40 | $scope.options = options; | 40 | $scope.options = options; |
41 | $scope.cancelar = function() { | 41 | $scope.cancelar = function() { |
42 | $uibModalInstance.dismiss(); | 42 | $uibModalInstance.dismiss(); |
43 | }; | 43 | }; |
44 | $scope.aceptar = function(key) { | 44 | $scope.aceptar = function(key) { |
45 | if (key === 13) { | 45 | if (key === 13) { |
46 | if(options.email && !validateEmails($scope.options.value)) { | 46 | if (options.email && !validateEmails($scope.options.value)) { |
47 | focaModalService.alert('Ingrese email/s válido/s'); | 47 | focaModalService.alert('Ingrese email/s válido/s'); |
48 | return; | 48 | return; |
49 | } | 49 | } |
50 | 50 | ||
51 | $uibModalInstance.close($scope.options.value); | 51 | $uibModalInstance.close($scope.options.value); |
52 | } | 52 | } |
53 | }; | 53 | }; |
54 | 54 | ||
55 | function validateEmails(emails) { | 55 | function validateEmails(emails) { |
56 | var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | 56 | var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; |
57 | var arr = emails.split(','); | 57 | var arr = emails.split(','); |
58 | var result = true; | 58 | var result = true; |
59 | 59 | ||
60 | arr.forEach(function(email) { | 60 | arr.forEach(function(email) { |
61 | var val = String(email).trim().toLowerCase(); | 61 | var val = String(email).trim().toLowerCase(); |
62 | 62 | ||
63 | if(!re.test(val)) result = false; | 63 | if(!re.test(val)) result = false; |
64 | }); | 64 | }); |
65 | 65 | ||
66 | return result; | 66 | return result; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | ]); | 69 | ]); |
70 | 70 |