Skip to content

Instantly share code, notes, and snippets.

@mmorton
Created May 27, 2010 07:03
Show Gist options
  • Save mmorton/415555 to your computer and use it in GitHub Desktop.
Save mmorton/415555 to your computer and use it in GitHub Desktop.
if (/android/i.test(navigator.userAgent))
{
/*
* there is an issue with click "bleed through" on absolutely positioned elements on
* android devices which is why we need to go though the trouble of preventing the actual
* click event.
* see: http://code.google.com/p/android/issues/detail?id=6721
*/
var prevent = false;
this.el
.on('touchstart', function(evt, el, o) {
var source = Ext.get(el);
var target;
prevent = true;
if (source.is('a[target="_tool"]') || (target = source.up('a[target="_tool"]')))
{
var name = (target || source).dom.hash.substring(1);
if (this.tools.hasOwnProperty(name))
this.execute(this.tools[name]);
}
else if (source.is('.' + this.cls) || (target = source.up('.' + this.cls)))
{
this.toggle();
}
}, this);
var handleClick = function(evt) {
if (prevent)
{
if (evt.preventBubble) evt.preventBubble();
if (evt.preventDefault) evt.preventDefault();
if (evt.stopPropagation) evt.stopPropagation();
if (evt.stopImmediatePropagation) evt.stopImmediatePropagation();
prevent = false;
return false;
}
};
Ext.getBody().dom.addEventListener('click', handleClick, true); /* capture phase */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment