Fixed #136 duplicate ng-click

This commit is contained in:
Max Lynch
2013-11-14 12:03:49 -06:00
parent c087f96243
commit 51215b5937
3 changed files with 6 additions and 114 deletions

57
dist/js/ionic.js vendored
View File

@ -1801,63 +1801,6 @@ window.ionic = {
})(window.ionic); })(window.ionic);
; ;
(function(window, document, ionic) {
// polyfill use to simulate native "tap"
function inputTapPolyfill(ele, e) {
if(ele.type === "radio" || ele.type === "checkbox") {
ele.checked = !ele.checked;
} else if(ele.type === "submit" || ele.type === "button") {
ele.click();
} else {
ele.focus();
}
e.stopPropagation();
e.preventDefault();
return false;
}
function tapPolyfill(e) {
// if the source event wasn't from a touch event then don't use this polyfill
if(!e.gesture || e.gesture.pointerType !== "touch" || !e.gesture.srcEvent) return;
e = e.gesture.srcEvent; // evaluate the actual source event, not the created event by gestures.js
var ele = e.target;
while(ele) {
if( ele.tagName === "INPUT" || ele.tagName === "TEXTAREA" || ele.tagName === "SELECT" ) {
return inputTapPolyfill(ele, e);
} else if( ele.tagName === "LABEL" ) {
if(ele.control) {
return inputTapPolyfill(ele.control, e);
}
} else if( ele.tagName === "A" || ele.tagName === "BUTTON" ) {
ele.click();
e.stopPropagation();
e.preventDefault();
return false;
}
ele = ele.parentElement;
}
// they didn't tap one of the above elements
// if the currently active element is an input, and they tapped outside
// of the current input, then unset its focus (blur) so the keyboard goes away
var activeElement = document.activeElement;
if(activeElement && (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA" || activeElement.tagName === "SELECT")) {
activeElement.blur();
e.stopPropagation();
e.preventDefault();
return false;
}
}
// global tap event listener polyfill for HTML elements that were "tapped" by the user
ionic.on("tap", tapPolyfill, window);
})(this, document, ionic);
;
(function(ionic) { (function(ionic) {
/** /**

View File

@ -41,7 +41,8 @@
<script id="page.html" type="text/ng-template"> <script id="page.html" type="text/ng-template">
<div title="Home home home home home home home home home" ng-controller="CatsCtrl" class="nav-content"> <div title="Home home home home home home home home home" ng-controller="CatsCtrl" class="nav-content">
<h1></h1> <h1></h1>
<a href="#" class="button button-success" ng-click="goNext()">Next</a> <a href="#" class="button button-royal" ng-click="goNext()">Next</a>
<button class="button button-assertive" ng-click="thisThing()">Doit</button>
<list><list-item ng-repeat="item in items" on-select="goNext()">Test</list-item></list> <list><list-item ng-repeat="item in items" on-select="goNext()">Test</list-item></list>
</div> </div>
</script> </script>
@ -79,6 +80,10 @@
console.log('HIDDEN'); console.log('HIDDEN');
}); });
$scope.thisThing = function() {
console.log("THIS THING");
};
var items = []; var items = [];
for(var i = 0; i < 100; i++) { for(var i = 0; i < 100; i++) {
items.push({}); items.push({});

View File

@ -1,56 +0,0 @@
(function(window, document, ionic) {
// polyfill use to simulate native "tap"
function inputTapPolyfill(ele, e) {
if(ele.type === "radio" || ele.type === "checkbox") {
ele.checked = !ele.checked;
} else if(ele.type === "submit" || ele.type === "button") {
ele.click();
} else {
ele.focus();
}
e.stopPropagation();
e.preventDefault();
return false;
}
function tapPolyfill(e) {
// if the source event wasn't from a touch event then don't use this polyfill
if(!e.gesture || e.gesture.pointerType !== "touch" || !e.gesture.srcEvent) return;
e = e.gesture.srcEvent; // evaluate the actual source event, not the created event by gestures.js
var ele = e.target;
while(ele) {
if( ele.tagName === "INPUT" || ele.tagName === "TEXTAREA" || ele.tagName === "SELECT" ) {
return inputTapPolyfill(ele, e);
} else if( ele.tagName === "LABEL" ) {
if(ele.control) {
return inputTapPolyfill(ele.control, e);
}
} else if( ele.tagName === "A" || ele.tagName === "BUTTON" ) {
ele.click();
e.stopPropagation();
e.preventDefault();
return false;
}
ele = ele.parentElement;
}
// they didn't tap one of the above elements
// if the currently active element is an input, and they tapped outside
// of the current input, then unset its focus (blur) so the keyboard goes away
var activeElement = document.activeElement;
if(activeElement && (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA" || activeElement.tagName === "SELECT")) {
activeElement.blur();
e.stopPropagation();
e.preventDefault();
return false;
}
}
// global tap event listener polyfill for HTML elements that were "tapped" by the user
ionic.on("tap", tapPolyfill, window);
})(this, document, ionic);