1app.directive('igValidation', ['$parse', '$translate', 'resourceService', function ($parse, $translate, resourceService) { 2 //igValidator default configuration 3 $.ui.igValidator.defaults.showAllErrorsOnSubmit = true; 4 5 //Add validator to element 6 var _setValidator = function ($scope, $element, attrs) { 7 //ValidatorOptions default settings 8 var vo = { 9 onblur: true, 10 keepFocus: "none", 11 formSubmit: true 12 }; 13 14 //Adds custom validations 15 if (attrs.required) { 16 vo.onchange = false; 17 vo.required = attrs.required; 18 vo.requiredMessage = resourceService.Strings.Error_Requerido; 19 //TODO: usar mensajes regionalizados 20 //vo.errorShowing = function (evt, ui) { 21 // ui.message = $scope.translations.Error_Requerido; 22 //} 23 } 24 if (attrs.email != null) { 25 vo.regExp = resourceService.Helpers.RE_Mail; 26 vo.regExpMessage = resourceService.Strings.Error_Mail_Invalido; 27 //TODO: usar mensajes regionalizados 28 //vo.errorShowing = function (evt, ui) { 29 // ui.message = $scope.translations.Error_Mail_Invalido; 30 //} 31 } 32 if (attrs.tel != null) { 33 vo.checkValue = function (evt, ui) { 34 var result = phoneNumberParser(); 35 ui.message = result.text; 36 return result.result; 37 }; 38 } 39 if (attrs.ngEqualTo != null) { 40 vo.onchange = false; 41 vo.checkValue = function (evt, ui) { 42 ui.message = $scope.ngEqualToMessage; 43 return ui.value == $scope.ngEqualTo(); 44 }; 45 } 46 47 //Set igValidation 48 $element.igTextEditor({ 49 validatorOptions: vo, 50 textChanged: function () { 51 //DataBing: When jquery's element updates 52 $scope.$parent.$apply(function () { 53 var modelAccessor = $parse(attrs.ngModel); 54 modelAccessor.assign($scope.$parent, $element.val()); 55 }); 56 } 57 }); 58 }; 59 60 return { 61 restrict: "A", //Restriction level 62 replace: false, //Replace original html 63 require: 'ngModel', //Required attributes 64 scope: { ngModel: '=ngModel', ngEqualTo: '&ngEqualTo', ngEqualToMessage: '@ngEqualToMessage' }, //Isolated scope 65 //TODO: usar mensajes regionalizados 66 //controller: function ($scope) { 67 // $translate(['Error_Requerido', 'Error_Mail_Invalido']).then(function (data) { 68 // $scope.translations = data; 69 // }); 70 //}, 71 link: function ($scope, $element, attrs, ctrl) { 72 73 //Set the igValidator to $element 74 _setValidator($scope, $element, attrs); 75 76 //Check if new value is valid when scope updates 77 ctrl.$validators.igValidation = function (modelValue, viewValue) { 78 //Validation method 79 var valid = $element.igValidator('isValidState'); 80 81 //Tells angular the value is valid or not 82 ctrl.$setValidity($element.attr('name'), valid); 83 84 return valid; 85 }; 86 } 87 88 }; 89}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.