Commit ff4f683623cec52261f4ca7308f8e90a5526ecb6

Authored by Jose Pinto
1 parent e4431065bb
Exists in master

fix escribir en input text

Showing 1 changed file with 6 additions and 23 deletions   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)) {
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   - }
  6 + link: function(scope, element, attrs, modelCtrl) {
27 7 if(attrs.type === 'text' &&
28 8 !attrs.readonly &&
29 9 !attrs.disabled &&
30 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 }