0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-02-27 09:15:57 -05:00
Squire/build/ie8.js

1 line
7.3 KiB
JavaScript
Raw Normal View History

2012-03-29 16:26:01 +11:00
/* Copyright © 2011 by Neil Jenkins. Licensed under the MIT license. */(function(a){Array.prototype.indexOf=function(a,b){var c=this.length;for(var d=b<0?Math.max(0,c+b):b||0;d<c;d+=1)if(this[d]===a)return d;return-1},Array.prototype.forEach=function(a,b){var c=this.length>>>0;if(typeof a!="function")throw new TypeError;for(var d=0;d<c;d+=1)a.call(b,this[d],d,this)},Array.prototype.filter=function(a,b){var c=[];for(var d=0,e=this.length;d<e;d+=1){var f=this[d];a.call(b,f,d,this)&&c.push(f)}return c},Object.keyOf=function(a,b){for(var c in a)if(a[c]===b)return c},Date.now=function(){return+(new Date)},String.prototype.trim=function(){var a=this.replace(/^\s\s*/,""),b=/\s/,c=a.length;while(b.test(a.charAt(c-=1)));return a.slice(0,c+1)}})(),function(){function d(a){var d=a.type,e=document,f=a.srcElement||e,g=(f.ownerDocument||e).documentElement,h=c.length,i;while(h--)i=c[h],this[i]=a[i];d==="propertychange"&&(d=f.nodeName==="INPUT"&&f.type!=="text"&&f.type!=="password"?"change":"input"),this.type=Object.keyOf(b,d)||d,this.target=f,this.pageX=a.clientX+g.scrollLeft,this.pageY=a.clientY+g.scrollTop,a.button&&(this.button=a.button&4?1:a.button&2?2:0,this.which=this.button+1),this.relatedTarget=a.fromElement===f?a.toElement:a.fromElement,this._event=a}function e(){return!0}function f(){return!1}var a=document;window.ie=8,a.defaultView=window;var b={focus:"focusin",blur:"focusout"},c="altKey ctrlKey metaKey shiftKey clientX clientY charCode keyCode".split(" ");d.prototype={constructor:d,isEvent:!0,preventDefault:function(){this.isDefaultPrevented=e,this._event.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=e,this._event.cancelBubble=!0},isDefaultPrevented:f,isPropagationStopped:f},[a,Element.prototype].forEach(function(a){a.addEventListener=function(a,c,e){var f=c._ie_handleEvent||(c._ie_handleEvent=function(){var a=new d(window.event);typeof c=="object"?c.handleEvent(a):c.call(this,a)}),g=/paste|cut/.test(a)?this.body||this:this;c._ie_registeredCount=(c._ie_registeredCount||0)+1,g.attachEvent("on"+(b[a]||a),f)},a.addEventListener.isFake=!0,a.removeEventListener=function(a,c,d){var e=c._ie_handleEvent,f=/paste|cut/.test(a)?this.body||this:this;(c._ie_registeredCount-=1)||delete c._ie_handleEvent,e&&f.detachEvent("on"+(b[a]||a),e)},a.removeEventListener.isFake=!0}),a.defaultView.addEventListener=function(b,c,d){return a.addEventListener(b,c,d)},Object.defineProperty(Element.prototype,"textContent",{get:function(){return this.innerText},set:function(a){this.innerText=a}}),Element.prototype.compareDocumentPosition=function(a){a.nodeType!==1&&(a=a.parentNode);var b=this,c=b!==a,d=b.sourceIndex,e=a.sourceIndex;return(c&&b.contains(a)?16:0)+(c&&a.contains(b)?8:0)+(d<e?4:0)+(e<d?2:0)},HTMLDocument.prototype.normalize=function(){var a=this.childNodes,b=a.length,c;while(b--)c=a[b],c.nodeType===1&&c.normalize()}}();var Range;(function(){var a=Array.prototype.indexOf,b=0,c=1,d=2,e=3,f=function(a,b){while(b=b.parentNode)if(a===b)return!0;return!1},g=function(a,b){var c,d,e,g,h;if(a===b||f(a,b))c=a;else if(f(b,a))c=b;else{d=[],e=[];while(a=a.parentNode)d.push(a);while(b=b.parentNode)e.push(b);g=d.length,h=e.length;while(g--&&h--)if(d[g]!==e[h]){c=d[g+1];break}c||(c=g===-1?d[0]:e[0])}return c};Range=function(a,b,c,d){a=a||document,b=b||0,this.startContainer=a,this.startOffset=b,this.endContainer=c||a,this.endOffset=d!==undefined?d:b,this._updateCollapsedAndAncestor()},Range.prototype={constructor:Range,_updateCollapsedAndAncestor:function(){this.collapsed=this.startContainer===this.endContainer&&this.startOffset===this.endOffset,this.commonAncestorContainer=g(this.startContainer,this.endContainer)},setStart:function(a,b){this.startContainer=a,this.startOffset=b,this._updateCollapsedAndAncestor()},setEnd:function(a,b){this.endContainer=a,this.endOffset=b,this._updateCollapsedAndAncestor()},setStartAfter:function(b){var c=b.parentNode;this.setStart(c,a.call(c.childNodes,b)+1)},setEndBefore:function(b){var c=b.parentNode;this.setEnd(c,a.call(c.childNodes,b))},selectNode:function(b){var c=b.parentNode,d=a.call(c.childNodes