1 line
No EOL
2.5 KiB
JavaScript
1 line
No EOL
2.5 KiB
JavaScript
this.Element&&Element.prototype.attachEvent&&!Element.prototype.addEventListener&&function(){function e(e,t){Window.prototype[e]=HTMLDocument.prototype[e]=Element.prototype[e]=t}function t(e){t.interval&&document.body&&(t.interval=clearInterval(t.interval),document.dispatchEvent(new CustomEvent("DOMContentLoaded")))}e("addEventListener",function(e,t){var n=this,r=n.addEventListener.listeners=n.addEventListener.listeners||{},a=r[e]=r[e]||[];a.length||n.attachEvent("on"+e,a.event=function(e){var t=n.document&&n.document.documentElement||n.documentElement||{scrollLeft:0,scrollTop:0};e.currentTarget=n,e.pageX=e.clientX+t.scrollLeft,e.pageY=e.clientY+t.scrollTop,e.preventDefault=function(){e.returnValue=!1},e.relatedTarget=e.fromElement||null,e.stopImmediatePropagation=function(){c=!1,e.cancelBubble=!0},e.stopPropagation=function(){e.cancelBubble=!0},e.target=e.srcElement||n,e.timeStamp=+new Date;var r={};for(var o in e)r[o]=e[o];for(var i,o=0,l=[].concat(a),c=!0;c&&(i=l[o]);++o)for(var s,u=0;s=a[u];++u)if(s==i){s.call(n,r);break}}),a.push(t)}),e("removeEventListener",function(e,t){for(var n,r=this,a=r.addEventListener.listeners=r.addEventListener.listeners||{},o=a[e]=a[e]||[],i=o.length-1;n=o[i];--i)if(n==t){o.splice(i,1);break}!o.length&&o.event&&r.detachEvent("on"+e,o.event)}),e("dispatchEvent",function(e){var t=this,n=e.type,r=t.addEventListener.listeners=t.addEventListener.listeners||{},a=r[n]=r[n]||[];try{return t.fireEvent("on"+n,e)}catch(o){return void(a.event&&a.event(e))}}),Object.defineProperty(Window.prototype,"CustomEvent",{get:function(){var e=this;return function(t,n){var r,a=e.document.createEventObject();a.type=t;for(r in n)"cancelable"==r?a.returnValue=!n.cancelable:"bubbles"==r?a.cancelBubble=!n.bubbles:"detail"==r&&(a.detail=n.detail);return a}}}),t.interval=setInterval(t,1),window.addEventListener("load",t)}(),(!this.CustomEvent||"object"==typeof this.CustomEvent)&&function(){this.CustomEvent=function(e,t){var n;t=t||{bubbles:!1,cancelable:!1,detail:void 0};try{n=document.createEvent("CustomEvent"),n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail)}catch(r){n=document.createEvent("Event"),n.initEvent(e,t.bubbles,t.cancelable),n.detail=t.detail}return n}}(),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var n;if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),a=r.length>>>0;if(0===a)return-1;var o=+t||0;if(Math.abs(o)===1/0&&(o=0),o>=a)return-1;for(n=Math.max(o>=0?o:a-Math.abs(o),0);a>n;){if(n in r&&r[n]===e)return n;n++}return-1}); |