Created
September 19, 2014 08:35
-
-
Save h4/575209422f694087d908 to your computer and use it in GitHub Desktop.
Coast bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
/// #import "webview.js" | |
*/ | |
window.OperaIce||(window.OperaIce={});OperaIce.Navigation||(OperaIce.Navigation={}); | |
OperaIce.Navigation.BodyClickNotifier=function(){this.lastClickEvent=null;this.onClick=function(b){if(b&&b.target){var a=b.target;if("INPUT"!=a.tagName.toUpperCase()||"submit"!=a.type.toLowerCase()&&"button"!=a.type.toLowerCase()){var a=this.targetRect(a),c=this.screenSize();this.lastClickEvent=b;OperaIce.WebView.performCallback("document-onclick",a,c)}}};this.register=function(){var b=this;document.addEventListener("click",function(a){b.onClick(a)},!1)};this.targetRect=function(b){var a=b.getBoundingClientRect(), | |
a={top:a.top,left:a.left,width:Math.round(a.width),height:Math.round(a.height)};try{for(;b=b.ownerDocument.defaultView.frameElement;){var c=getComputedStyle(b,null),d=b.getBoundingClientRect();a.top+=d.top+parseFloat(c.borderTopWidth)+parseFloat(c.paddingTop);a.left+=d.left+parseFloat(c.borderLeftWidth)+parseFloat(c.paddingLeft)}a.top=Math.round(a.top);a.left=Math.round(a.left)}catch(e){a.top=a.left=a.width=a.height=0}return a};this.screenSize=function(){return{width:Math.round(window.innerWidth), | |
height:Math.round(window.innerHeight)}};this.simulateLastClick=function(){var b=this.lastClickEvent;if(null==b)return!1;this.lastClickEvent=null;var a=document.createEvent("MouseEvents");a.initMouseEvent(b.type,b.bubbles,b.cancelable,window,b.detail,b.screenX,b.screenY,b.clientX,b.clientY,b.ctrlKey,b.altKey,b.shiftKey,b.metaKey,b.button,b.relatedTarget);b.target.dispatchEvent(a);return!0}};OperaIce.Navigation.sharedBodyClickNotifier=new OperaIce.Navigation.BodyClickNotifier;OperaIce.Navigation.sharedBodyClickNotifier.register(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment