diff --git a/js/angular/directive/input.js b/js/angular/directive/input.js new file mode 100644 index 00000000000..b2738c7e684 --- /dev/null +++ b/js/angular/directive/input.js @@ -0,0 +1,70 @@ +/** +* @ngdoc directive +* @name ionInput +* @parent ionic.directive:ionList +* @module ionic +* @restrict E +* Creates a text input group that can easily be focused +* +* @usage +* +* ```html +* +* +* +* +* +* ``` +*/ + +var labelIds = -1; + +IonicModule +.directive('ionInput', ['$$rAF', function($$rAF) { + return { + restrict: 'E', + controller: ['$scope', '$element', function($scope, $element) { + this.$scope = $scope; + this.$element = $element; + + this.input = $element[0].querySelector('input,textarea'); + }], + scope: true, + compile: function($element, $attrs) { + + var element = $element[0]; + + return function link($scope, $element, $attrs) { + } + } + }; +}]); + +/** + * Input label adds accessibility to . + */ +IonicModule +.directive('inputLabel', ['$$rAF', function($$rAF) { + return { + restrict: 'C', + scope: true, + require: '?^ionInput', + compile: function($element, $attrs) { + + return function link($scope, $element, $attrs, ionInputCtrl) { + var element = $element[0]; + + $element.attr('aria-label', $element.text()); + var id = element.id || '_label-' + ++labelIds; + + if(!element.id) { + $element.attr('id', id); + } + + if(ionInputCtrl && ionInputCtrl.input) { + ionInputCtrl.input.setAttribute('aria-labelledby', id); + } + } + } + }; +}]); diff --git a/js/utils/tap.js b/js/utils/tap.js index 7cea7a22810..70c863e9f1f 100644 --- a/js/utils/tap.js +++ b/js/utils/tap.js @@ -431,6 +431,7 @@ function tapTouchStart(e) { var textInput = tapTargetElement(tapContainingElement(e.target)); if (textInput !== tapActiveEle) { // don't preventDefault on an already focused input or else iOS's text caret isn't usable + console.log('Would prevent default here'); e.preventDefault(); } } diff --git a/test/html/content.html b/test/html/content.html index 4dedff7cc87..abc9e2449a6 100644 --- a/test/html/content.html +++ b/test/html/content.html @@ -36,16 +36,20 @@

Title

- - - -
+ + + + + + + + + + + Username + + +