(scope, element, attr, ctrl, $sniffer, $browser)
| 11619 | } |
| 11620 | |
| 11621 | function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) { |
| 11622 | textInputType(scope, element, attr, ctrl, $sniffer, $browser); |
| 11623 | |
| 11624 | ctrl.$parsers.push(function(value) { |
| 11625 | var empty = isEmpty(value); |
| 11626 | if (empty || NUMBER_REGEXP.test(value)) { |
| 11627 | ctrl.$setValidity('number', true); |
| 11628 | return value === '' ? null : (empty ? value : parseFloat(value)); |
| 11629 | } else { |
| 11630 | ctrl.$setValidity('number', false); |
| 11631 | return undefined; |
| 11632 | } |
| 11633 | }); |
| 11634 | |
| 11635 | ctrl.$formatters.push(function(value) { |
| 11636 | return isEmpty(value) ? '' : '' + value; |
| 11637 | }); |
| 11638 | |
| 11639 | if (attr.min) { |
| 11640 | var min = parseFloat(attr.min); |
| 11641 | var minValidator = function(value) { |
| 11642 | if (!isEmpty(value) && value < min) { |
| 11643 | ctrl.$setValidity('min', false); |
| 11644 | return undefined; |
| 11645 | } else { |
| 11646 | ctrl.$setValidity('min', true); |
| 11647 | return value; |
| 11648 | } |
| 11649 | }; |
| 11650 | |
| 11651 | ctrl.$parsers.push(minValidator); |
| 11652 | ctrl.$formatters.push(minValidator); |
| 11653 | } |
| 11654 | |
| 11655 | if (attr.max) { |
| 11656 | var max = parseFloat(attr.max); |
| 11657 | var maxValidator = function(value) { |
| 11658 | if (!isEmpty(value) && value > max) { |
| 11659 | ctrl.$setValidity('max', false); |
| 11660 | return undefined; |
| 11661 | } else { |
| 11662 | ctrl.$setValidity('max', true); |
| 11663 | return value; |
| 11664 | } |
| 11665 | }; |
| 11666 | |
| 11667 | ctrl.$parsers.push(maxValidator); |
| 11668 | ctrl.$formatters.push(maxValidator); |
| 11669 | } |
| 11670 | |
| 11671 | ctrl.$formatters.push(function(value) { |
| 11672 | |
| 11673 | if (isEmpty(value) || isNumber(value)) { |
| 11674 | ctrl.$setValidity('number', true); |
| 11675 | return value; |
| 11676 | } else { |
| 11677 | ctrl.$setValidity('number', false); |
| 11678 | return undefined; |
nothing calls this directly
no test coverage detected