Commit ddedbbb5cda0061f421c4e7810a227edb5283cc9
Exists in
master
Merge branch 'master' into 'develop'
Master See merge request !18
Showing
2 changed files
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 | $scope.cancelar = function() { | 45 | $scope.cancelar = function() { |
| 46 | $uibModalInstance.dismiss(); | 46 | $uibModalInstance.dismiss(); |
| 47 | }; | 47 | }; |
| 48 | $scope.aceptar = function(key) { | 48 | $scope.aceptar = function(key) { |
| 49 | if (key === 13) { | 49 | if (key === 13) { |
| 50 | if (options.email && !validateEmails($scope.options.value)) { | 50 | if (options.email && !validateEmails($scope.options.value)) { |
| 51 | focaModalService.alert('Ingrese email/s válido/s'); | 51 | focaModalService.alert('Ingrese email/s válido/s'); |
| 52 | return; | 52 | return; |
| 53 | } | 53 | } |
| 54 | |||
| 55 | $uibModalInstance.close($scope.options.value); | 54 | $uibModalInstance.close($scope.options.value); |
| 56 | } | 55 | } |
| 57 | }; | 56 | }; |
| 58 | 57 | ||
| 59 | function validateEmails(emails) { | 58 | function validateEmails(emails) { |
| 60 | 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,}))$/; | 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,}))$/; |
| 61 | var arr = emails.split(','); | 60 | var arr = emails.split(','); |
| 62 | var result = true; | 61 | var result = true; |
| 63 | 62 | ||
| 64 | arr.forEach(function(email) { | 63 | arr.forEach(function(email) { |
| 65 | var val = String(email).trim().toLowerCase(); | 64 | var val = String(email).trim().toLowerCase(); |
| 66 | 65 | ||
| 67 | if (!re.test(val)) result = false; | 66 | if (!re.test(val)) result = false; |
| 68 | }); | 67 | }); |
| 69 | 68 | ||
| 70 | return result; | 69 | return result; |
| 71 | } | 70 | } |
| 72 | } | 71 | } |
| 73 | ]); | 72 | ]); |
| 74 | 73 |
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="text" |
| 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 | ng-readonly="options.readonly" | 11 | ng-readonly="options.readonly" |
| 11 | ng-keypress="aceptar($event.keyCode)"> | 12 | ng-keypress="aceptar($event.keyCode)"> |
| 12 | 13 | ||
| 13 | <textarea | 14 | <textarea |
| 14 | rows="5" | 15 | rows="5" |
| 15 | class="form-control text-uppercase" | 16 | class="form-control text-uppercase" |
| 16 | ng-model="options.value" | 17 | ng-model="options.value" |
| 17 | ng-show="options.textarea" | 18 | ng-show="options.textarea" |
| 19 | maxlength="{{options.maxlength}}" | ||
| 18 | ng-readonly="options.readonly" | 20 | ng-readonly="options.readonly" |
| 19 | ng-keypress="aceptar($event.keyCode)"></textarea> | 21 | ng-keypress="aceptar($event.keyCode)"></textarea> |
| 20 | </div> | 22 | </div> |
| 21 | <div class="modal-footer"> | 23 | <div class="modal-footer"> |
| 22 | <button class="btn btn-primary" ng-click="aceptar(13)" foca-focus="true">Aceptar</button> | 24 | <button class="btn btn-primary" ng-click="aceptar(13)" foca-focus="true">Aceptar</button> |
| 23 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | 25 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> |
| 24 | </div> | 26 | </div> |
| 25 | 27 |