Commit 747b28e47f5e45d37c19f3a4980c1bde839175d6
1 parent
5a6b514e61
Exists in
develop
git push origin master
Showing
2 changed files
with
5 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', 'parametros', | 24 | '$uibModalInstance', '$scope', 'parametros', | 
| 25 | function($uibModalInstance, $scope, parametros) { | 25 | function($uibModalInstance, $scope, parametros) { | 
| 26 | $scope.parametros = parametros; | 26 | $scope.parametros = parametros; | 
| 27 | $scope.fecha = new Date(); | 27 | $scope.fecha = new Date(); | 
| 28 | $scope.options = {}; | 28 | $scope.options = {}; | 
| 29 | 29 | ||
| 30 | if (parametros.minDate) $scope.options.minDate = parametros.minDate; | 30 | if (parametros.minDate) $scope.options.minDate = parametros.minDate; | 
| 31 | 31 | ||
| 32 | $scope.cancelar = function() { | 32 | $scope.cancelar = function() { | 
| 33 | $uibModalInstance.dismiss(); | 33 | $uibModalInstance.dismiss(); | 
| 34 | }; | 34 | }; | 
| 35 | $scope.aceptar = function() { | 35 | $scope.aceptar = function() { | 
| 36 | $uibModalInstance.close($scope.fecha); | 36 | $uibModalInstance.close($scope.fecha); | 
| 37 | }; | 37 | }; | 
| 38 | } | 38 | } | 
| 39 | ]) | 39 | ]) | 
| 40 | .controller('focaModalPromptController', [ | 40 | .controller('focaModalPromptController', [ | 
| 41 | '$uibModalInstance', '$scope', 'options', 'focaModalService', | 41 | '$uibModalInstance', '$scope', 'options', 'focaModalService', | 
| 42 | function($uibModalInstance, $scope, options, focaModalService) { | 42 | function($uibModalInstance, $scope, options, focaModalService) { | 
| 43 | 43 | ||
| 44 | $scope.options = options; | 44 | $scope.options = options; | 
| 45 | |||
| 46 | if (!$scope.options.tipo) { | ||
| 47 | $scope.options.tipo = 'text' | ||
| 48 | } | ||
| 45 | $scope.cancelar = function() { | 49 | $scope.cancelar = function() { | 
| 46 | $uibModalInstance.dismiss(); | 50 | $uibModalInstance.dismiss(); | 
| 47 | }; | 51 | }; | 
| 48 | $scope.aceptar = function(key) { | 52 | $scope.aceptar = function(key) { | 
| 49 | if (key === 13) { | 53 | if (key === 13) { | 
| 50 | if (options.email && !validateEmails($scope.options.value)) { | 54 | if (options.email && !validateEmails($scope.options.value)) { | 
| 51 | focaModalService.alert('Ingrese email/s válido/s'); | 55 | focaModalService.alert('Ingrese email/s válido/s'); | 
| 52 | return; | 56 | return; | 
| 53 | } | 57 | } | 
| 54 | $uibModalInstance.close($scope.options.value); | 58 | $uibModalInstance.close($scope.options.value); | 
| 55 | } | 59 | } | 
| 56 | }; | 60 | }; | 
| 57 | 61 | ||
| 58 | function validateEmails(emails) { | 62 | function validateEmails(emails) { | 
| 59 | 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,}))$/; | 63 | 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,}))$/; | 
| 60 | var arr = emails.split(','); | 64 | var arr = emails.split(','); | 
| 61 | var result = true; | 65 | var result = true; | 
| 62 | 66 | ||
| 63 | arr.forEach(function(email) { | 67 | arr.forEach(function(email) { | 
| 64 | var val = String(email).trim().toLowerCase(); | 68 | var val = String(email).trim().toLowerCase(); | 
| 65 | 69 | ||
| 66 | if (!re.test(val)) result = false; | 70 | if (!re.test(val)) result = false; | 
| 67 | }); | 71 | }); | 
| 68 | 72 | ||
| 69 | return result; | 73 | return result; | 
| 70 | } | 74 | } | 
| 71 | } | 75 | } | 
| 72 | ]); | 76 | ]); | 
| 73 | 77 | 
src/views/modal-prompt.html
| 1 | <div class="modal-header"> | 1 | <div class="modal-header"> | 
| 2 | <h4 ng-bind="options.titulo"></h4> | 2 | <h4 ng-bind="options.titulo"></h4> | 
| 3 | </div> | 3 | </div> | 
| 4 | <div class="modal-body"> | 4 | <div class="modal-body"> | 
| 5 | <input | 5 | <input | 
| 6 | type="text" | 6 | type="{{options.tipo}}" | 
| 7 | class="form-control" | 7 | class="form-control" | 
| 8 | ng-model="options.value" | 8 | ng-model="options.value" | 
| 9 | ng-show="!options.textarea" | 9 | ng-show="!options.textarea" | 
| 10 | maxlength="{{options.maxlength}}" | 10 | maxlength="{{options.maxlength}}" | 
| 11 | ng-readonly="options.readonly" | 11 | ng-readonly="options.readonly" | 
| 12 | ng-keypress="aceptar($event.keyCode)" | 12 | ng-keypress="aceptar($event.keyCode)" | 
| 13 | teclado-virtual | 13 | teclado-virtual | 
| 14 | > | 14 | > | 
| 15 | 15 | ||
| 16 | <textarea | 16 | <textarea | 
| 17 | rows="5" | 17 | rows="5" | 
| 18 | class="form-control text-uppercase" | 18 | class="form-control text-uppercase" | 
| 19 | ng-model="options.value" | 19 | ng-model="options.value" | 
| 20 | ng-show="options.textarea" | 20 | ng-show="options.textarea" | 
| 21 | maxlength="{{options.maxlength}}" | 21 | maxlength="{{options.maxlength}}" | 
| 22 | ng-readonly="options.readonly" | 22 | ng-readonly="options.readonly" | 
| 23 | ng-keypress="aceptar($event.keyCode)" | 23 | ng-keypress="aceptar($event.keyCode)" | 
| 24 | teclado-virtual | 24 | teclado-virtual | 
| 25 | ></textarea> | 25 | ></textarea> | 
| 26 | </div> | 26 | </div> | 
| 27 | <div class="modal-footer"> | 27 | <div class="modal-footer"> | 
| 28 | <button class="btn btn-primary" ng-click="aceptar(13)" foca-focus="true">Aceptar</button> | 28 | <button class="btn btn-primary" ng-click="aceptar(13)" foca-focus="true">Aceptar</button> | 
| 29 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | 29 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | 
| 30 | </div> | 30 | </div> | 
| 31 | 31 |