Commit 989496c437d6f32151b8f41593f725bff1c2d797
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !5
Showing
1 changed file
Show diff stats
src/js/uppercaseOnly-directive.js
| ... | ... | @@ -2,36 +2,19 @@ angular.module('focaDirectivas') |
| 2 | 2 | .directive('input', [ |
| 3 | 3 | function() { |
| 4 | 4 | return { |
| 5 | - restrict: 'E', | |
| 6 | 5 | require: '?ngModel', |
| 7 | - link: function(scope, element, attrs, ctrl) { | |
| 8 | - | |
| 9 | - function parser(value) { | |
| 10 | - if (ctrl.$isEmpty(value) || angular.isDate(value)) { | |
| 11 | - return value; | |
| 12 | - } | |
| 13 | - var formatedValue = value.toUpperCase(); | |
| 14 | - if (ctrl.$viewValue !== formatedValue) { | |
| 15 | - ctrl.$setViewValue(formatedValue); | |
| 16 | - ctrl.$render(); | |
| 17 | - } | |
| 18 | - return formatedValue; | |
| 19 | - } | |
| 20 | - | |
| 21 | - function formatter(value) { | |
| 22 | - if (ctrl.$isEmpty(value) || typeof value !== 'string') { | |
| 23 | - return value; | |
| 24 | - } | |
| 25 | - return value.toUpperCase(); | |
| 26 | - } | |
| 27 | - | |
| 6 | + link: function(scope, element, attrs, modelCtrl) { | |
| 28 | 7 | if(attrs.type === 'text' && |
| 29 | 8 | !attrs.readonly && |
| 30 | - !attrs.disabled) { | |
| 9 | + !attrs.disabled && | |
| 10 | + !attrs.uibDatepickerPopup) { | |
| 31 | 11 | |
| 32 | - ctrl.$formatters.push(formatter); | |
| 33 | - ctrl.$parsers.push(parser); | |
| 12 | + modelCtrl.$parsers.push(function(input) { | |
| 13 | + return input ? input.toUpperCase() : ''; | |
| 14 | + }); | |
| 34 | 15 | } |
| 16 | + | |
| 17 | + element.addClass('text-uppercase'); | |
| 35 | 18 | } |
| 36 | 19 | }; |
| 37 | 20 | } |