tap polyfill removeClickPrevent and label fixes

This commit is contained in:
Adam Bradley
2014-02-18 13:27:14 -06:00
parent c168b489b5
commit ec8862a7cc
2 changed files with 20 additions and 16 deletions

View File

@@ -68,8 +68,13 @@
<label class="label1">
<input type="radio" name="radio" id="radio1" class="radio1">
</label>
<input type="radio" name="radio" id="radio2" class="radio2">
</label> &nbsp;
<input type="radio" name="radio" id="radio2" class="radio2"> &nbsp;
<label class="label2">
<input type="checkbox" name="checkbox1" id="checkbox1" class="checkbox1">
</label> &nbsp;
<input type="checkbox" name="checkbox2" id="checkbox2" class="checkbox2">
</div>
@@ -241,7 +246,7 @@
// console.debug('mousemove', 'clientX: ' + event.clientX, 'clientY: ' + event.clientY);
// });
document.addEventListener('click', function(event){
console.debug('click', 'clientX: ' + event.clientX, 'clientY: ' + event.clientY);
console.debug('click', 'clientX: ' + event.clientX, 'clientY: ' + event.clientY, event.target.tagName);
});
document.getElementById('clear').addEventListener('click', function(){
setTimeout(clearMsgs, 200);

View File

@@ -18,8 +18,11 @@
})();
// polyfill use to simulate native "tap"
ionic.tapElement = function(ele, e) {
ionic.tapElement = function(target, e) {
// simulate a normal click by running the element's click method then focus on it
var ele = target.control || target;
if(ele.disabled) return;
console.debug('tapElement', ele.tagName, ele.className);
@@ -46,6 +49,11 @@
if( !isRecentTap(e) ) {
recordCoordinates(e);
}
if(target.control) {
console.debug('tapElement, target.control, stop');
return stopEvent(e);
}
};
function tapPolyfill(orgEvent) {
@@ -66,16 +74,11 @@
if( ele.tagName === "INPUT" ||
ele.tagName === "A" ||
ele.tagName === "BUTTON" ||
ele.tagName === "LABEL" ||
ele.tagName === "TEXTAREA" ||
ele.tagName === "SELECT" ) {
return ionic.tapElement(ele, e);
} else if( ele.tagName === "LABEL" ) {
// check if the tapped label has an input associated to it
if(ele.control) {
return ionic.tapElement(ele.control, e);
}
}
ele = ele.parentElement;
}
@@ -158,13 +161,9 @@
function removeClickPrevent(e) {
setTimeout(function(){
if(e.target && e.target.control && e.target.control.labelLastTap) {
e.target.control.labelLastTap = null;
}
var c = isRecentTap(e);
if(c) delete tapCoordinates[c.id];
var tap = isRecentTap(e);
if(tap) delete tapCoordinates[tap.id];
}, REMOVE_PREVENT_DELAY);
return stopEvent(e);
}
function stopEvent(e){