UNPKG

ashleshajs

Version:

AshleshaJS is a framework to build high performance and maintainable single page web applications. It uses ExpressJS and YUI3 as foundation. It is tightly coupled with Twitter Bootstrap for the CSS framework but you can use any other framework as well.

123 lines (119 loc) 104 kB
/* wysihtml5 v0.2.0 https://github.com/xing/wysihtml5 Author: Christopher Blum (https://github.com/tiff) Copyright (C) 2011 XING AG Licensed under GNU General Public License Rangy, a cross-browser JavaScript range and selection library http://code.google.com/p/rangy/ Copyright 2011, Tim Down Licensed under the MIT license. Version: 1.1 Build date: 12 March 2011 */ var wysihtml5={version:"0.2.0",commands:{},dom:{},quirks:{},toolbar:{},lang:{},selection:{},views:{},INVISIBLE_SPACE:"\ufeff",EMPTY_FUNCTION:function(){},ELEMENT_NODE:1,TEXT_NODE:3,BACKSPACE_KEY:8,ENTER_KEY:13,ESCAPE_KEY:27,SPACE_KEY:32,DELETE_KEY:46},rangy=function(){function a(a,b){var c=typeof a[b];return c==k||!!(c==i&&a[b])||"unknown"==c}function c(a,b){return!!(typeof a[b]==i&&a[b])}function b(a,b){return typeof a[b]!=j}function d(a){return function(b,c){for(var g=c.length;g--;)if(!a(b,c[g]))return!1; return!0}}function e(a){window.alert("Rangy not supported in your browser. Reason: "+a);r.initialized=!0;r.supported=!1}function f(){if(!r.initialized){var b,d=!1,j=!1;a(document,"createRange")&&(b=document.createRange(),t(b,l)&&w(b,g)&&(d=!0),b.detach());if((b=c(document,"body")?document.body:document.getElementsByTagName("body")[0])&&a(b,"createTextRange"))b=b.createTextRange(),t(b,q)&&w(b,n)&&(j=!0);!d&&!j&&e("Neither Range nor TextRange are implemented");r.initialized=!0;r.features={implementsDomRange:d, implementsTextRange:j};d=x.concat(s);j=0;for(b=d.length;j<b;++j)try{d[j](r)}catch(f){c(window,"console")&&a(window.console,"log")&&console.log("Init listener threw an exception. Continuing.",f)}}}function h(a){this.name=a;this.supported=this.initialized=!1}var i="object",k="function",j="undefined",g="startContainer,startOffset,endContainer,endOffset,collapsed,commonAncestorContainer,START_TO_START,START_TO_END,END_TO_START,END_TO_END".split(","),l="setStart,setStartBefore,setStartAfter,setEnd,setEndBefore,setEndAfter,collapse,selectNode,selectNodeContents,compareBoundaryPoints,deleteContents,extractContents,cloneContents,insertNode,surroundContents,cloneRange,toString,detach".split(","), n="boundingHeight,boundingLeft,boundingTop,boundingWidth,htmlText,text".split(","),q="collapse,compareEndPoints,duplicate,getBookmark,moveToBookmark,moveToElementText,parentElement,pasteHTML,select,setEndPoint".split(","),t=d(a),o=d(c),w=d(b),r={initialized:!1,supported:!0,util:{isHostMethod:a,isHostObject:c,isHostProperty:b,areHostMethods:t,areHostObjects:o,areHostProperties:w},features:{},modules:{},config:{alertOnWarn:!1}};r.fail=e;r.warn=function(a){a="Rangy warning: "+a;r.config.alertOnWarn? window.alert(a):typeof window.console!=j&&typeof window.console.log!=j&&window.console.log(a)};r.init=f;var s=[],x=[];r.addInitListener=function(a){r.initialized?a(r):s.push(a)};var p=[];r.addCreateMissingNativeApiListener=function(a){p.push(a)};r.createMissingNativeApi=function(a){a=a||window;f();for(var b=0,c=p.length;b<c;++b)p[b](a)};h.prototype.fail=function(a){this.initialized=!0;this.supported=!1;throw Error("Module '"+this.name+"' failed to load: "+a);};h.prototype.createError=function(a){return Error("Error in Rangy "+ this.name+" module: "+a)};r.createModule=function(a,b){var c=new h(a);r.modules[a]=c;x.push(function(a){b(a,c);c.initialized=!0;c.supported=!0})};r.requireModules=function(a){for(var b=0,c=a.length,g,d;b<c;++b){d=a[b];g=r.modules[d];if(!g||!(g instanceof h))throw Error("Module '"+d+"' not found");if(!g.supported)throw Error("Module '"+d+"' not supported");}};var v=!1,o=function(){v||(v=!0,r.initialized||f())};if(typeof window==j)e("No window found");else if(typeof document==j)e("No document found"); else return a(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",o,!1),a(window,"addEventListener")?window.addEventListener("load",o,!1):a(window,"attachEvent")?window.attachEvent("onload",o):e("Window does not have required addEventListener or attachEvent method"),r}(); rangy.createModule("DomUtil",function(a,c){function b(a){for(var b=0;a=a.previousSibling;)b++;return b}function d(a,b){var c=[],g;for(g=a;g;g=g.parentNode)c.push(g);for(g=b;g;g=g.parentNode)if(o(c,g))return g;return null}function e(a,b,c){for(c=c?a:a.parentNode;c;){a=c.parentNode;if(a===b)return c;c=a}return null}function f(a){a=a.nodeType;return 3==a||4==a||8==a}function h(a,b){var c=b.nextSibling,g=b.parentNode;c?g.insertBefore(a,c):g.appendChild(a);return a}function i(a){if(9==a.nodeType)return a; if(typeof a.ownerDocument!=n)return a.ownerDocument;if(typeof a.document!=n)return a.document;if(a.parentNode)return i(a.parentNode);throw Error("getDocument: no document found for node");}function k(a){return!a?"[No node]":f(a)?'"'+a.data+'"':1==a.nodeType?"<"+a.nodeName+(a.id?' id="'+a.id+'"':"")+">["+a.childNodes.length+"]":a.nodeName}function j(a){this._next=this.root=a}function g(a,b){this.node=a;this.offset=b}function l(a){this.code=this[a];this.codeName=a;this.message="DOMException: "+this.codeName} var n="undefined",q=a.util;q.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||c.fail("document missing a Node creation method");q.isHostMethod(document,"getElementsByTagName")||c.fail("document missing getElementsByTagName method");var t=document.createElement("div");q.areHostMethods(t,["insertBefore","appendChild","cloneNode"])||c.fail("Incomplete Element implementation");t=document.createTextNode("test");q.areHostMethods(t,["splitText","deleteData","insertData", "appendData","cloneNode"])||c.fail("Incomplete Text Node implementation");var o=function(a,b){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1};j.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next,b;if(this._current){b=a.firstChild;if(!b)for(b=null;a!==this.root&&!(b=a.nextSibling);)a=a.parentNode;this._next=b}return this._current},detach:function(){this._current=this._next=this.root=null}};g.prototype={equals:function(a){return this.node=== a.node&this.offset==a.offset},inspect:function(){return"[DomPosition("+k(this.node)+":"+this.offset+")]"}};l.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11};l.prototype.toString=function(){return this.message};a.dom={arrayContains:o,getNodeIndex:b,getCommonAncestor:d,isAncestorOf:function(a,b,c){for(b=c?b:b.parentNode;b;){if(b===a)return!0;b=b.parentNode}return!1},getClosestAncestorIn:e, isCharacterDataNode:f,insertAfter:h,splitDataNode:function(a,b){var c;3==a.nodeType?c=a.splitText(b):(c=a.cloneNode(),c.deleteData(0,b),a.deleteData(0,a.length-b),h(c,a));return c},getDocument:i,getWindow:function(a){a=i(a);if(typeof a.defaultView!=n)return a.defaultView;if(typeof a.parentWindow!=n)return a.parentWindow;throw Error("Cannot get a window object for node");},getIframeWindow:function(a){if(typeof a.contentWindow!=n)return a.contentWindow;if(typeof a.contentDocument!=n)return a.contentDocument.defaultView; throw Error("getIframeWindow: No Window object found for iframe element");},getIframeDocument:function(a){if(typeof a.contentDocument!=n)return a.contentDocument;if(typeof a.contentWindow!=n)return a.contentWindow.document;throw Error("getIframeWindow: No Document object found for iframe element");},getBody:function(a){return q.isHostObject(a,"body")?a.body:a.getElementsByTagName("body")[0]},comparePoints:function(a,c,g,j){var f;if(a==g)return c===j?0:c<j?-1:1;if(f=e(g,a,!0))return c<=b(f)?-1:1;if(f= e(a,g,!0))return b(f)<j?-1:1;c=d(a,g);a=a===c?c:e(a,c,!0);g=g===c?c:e(g,c,!0);if(a===g)throw Error("comparePoints got to case 4 and childA and childB are the same!");for(c=c.firstChild;c;){if(c===a)return-1;if(c===g)return 1;c=c.nextSibling}throw Error("Should not be here!");},inspectNode:k,createIterator:function(a){return new j(a)},DomPosition:g};a.DOMException=l}); rangy.createModule("DomRange",function(a){function c(a,b){this.range=a;this.clonePartiallySelectedTextNodes=b;if(!a.collapsed){this.sc=a.startContainer;this.so=a.startOffset;this.ec=a.endContainer;this.eo=a.endOffset;var c=a.commonAncestorContainer;this.sc===this.ec&&m.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc===c&&!m.isCharacterDataNode(this.sc)?this.sc.childNodes[this.so]:m.getClosestAncestorIn(this.sc, c,!0),this._last=this.ec===c&&!m.isCharacterDataNode(this.ec)?this.ec.childNodes[this.eo-1]:m.getClosestAncestorIn(this.ec,c,!0))}}function b(a){this.code=this[a];this.codeName=a;this.message="RangeException: "+this.codeName}function d(a){return m.getDocument(a.startContainer)}function e(a,b,c){if(b=a._listeners[b])for(var g=0,d=b.length;g<d;++g)b[g].call(a,{target:a,args:c})}function f(a){return new K(a.parentNode,m.getNodeIndex(a))}function h(a){return new K(a.parentNode,m.getNodeIndex(a)+1)}function i(a){return m.isCharacterDataNode(a)? a.length:a.childNodes?a.childNodes.length:0}function k(a,b,c){var g=11==a.nodeType?a.firstChild:a;m.isCharacterDataNode(b)?c==b.length?m.insertAfter(a,b):b.parentNode.insertBefore(a,0==c?b:m.splitDataNode(b,c)):c>=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[c]);return g}function j(a){for(var b,c,g=d(a.range).createDocumentFragment();c=a.next();){b=a.isPartiallySelectedSubtree();c=c.cloneNode(!b);b&&(b=a.getSubtreeIterator(),c.appendChild(j(b)),b.detach(!0));if(10==c.nodeType)throw new D("HIERARCHY_REQUEST_ERR"); g.appendChild(c)}return g}function g(a,b,c){for(var d,j,c=c||{stop:!1};d=a.next();)if(a.isPartiallySelectedSubtree())if(!1===b(d)){c.stop=!0;break}else{if(d=a.getSubtreeIterator(),g(d,b,c),d.detach(!0),c.stop)break}else for(d=m.createIterator(d);j=d.next();)if(!1===b(j)){c.stop=!0;return}}function l(a){for(var b;a.next();)a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),l(b),b.detach(!0)):a.remove()}function n(a){for(var b,c=d(a.range).createDocumentFragment(),g;b=a.next();){a.isPartiallySelectedSubtree()? (b=b.cloneNode(!1),g=a.getSubtreeIterator(),b.appendChild(n(g)),g.detach(!0)):a.remove();if(10==b.nodeType)throw new D("HIERARCHY_REQUEST_ERR");c.appendChild(b)}return c}function q(a,b,d){var j=!(!b||!b.length),f,h=!!d;j&&(f=RegExp("^("+b.join("|")+")$"));var e=[];g(new c(a,!1),function(a){(!j||f.test(a.nodeType))&&(!h||d(a))&&e.push(a)});return e}function t(a){return"["+("undefined"==typeof a.getName?"Range":a.getName())+"("+m.inspectNode(a.startContainer)+":"+a.startOffset+", "+m.inspectNode(a.endContainer)+ ":"+a.endOffset+")]"}function o(a,b,c){this.nodes=q(a,b,c);this._next=this.nodes[0];this._pointer=0}function w(a,b){return 3!=a.nodeType&&(m.isAncestorOf(a,b.startContainer,!0)||m.isAncestorOf(a,b.endContainer,!0))}function r(a){return function(b,c){for(var g,d=c?b:b.parentNode;d;){g=d.nodeType;if(m.arrayContains(a,g))return d;d=d.parentNode}return null}}function s(a){for(var b;b=a.parentNode;)a=b;return a}function x(a,c){if(U(a,c))throw new b("INVALID_NODE_TYPE_ERR");}function p(a){if(!a.startContainer)throw new D("INVALID_STATE_ERR"); }function v(a,c){if(!m.arrayContains(c,a.nodeType))throw new b("INVALID_NODE_TYPE_ERR");}function B(a,b){if(0>b||b>(m.isCharacterDataNode(a)?a.length:a.childNodes.length))throw new D("INDEX_SIZE_ERR");}function A(a,b){if(I(a,!0)!==I(b,!0))throw new D("WRONG_DOCUMENT_ERR");}function F(a){if(V(a,!0))throw new D("NO_MODIFICATION_ALLOWED_ERR");}function H(a,b){if(!a)throw new D(b);}function y(a){if(!I(a.startContainer,!0)||!I(a.endContainer,!0)||!(a.startOffset<=(m.isCharacterDataNode(a.startContainer)? a.startContainer.length:a.startContainer.childNodes.length))||!(a.endOffset<=(m.isCharacterDataNode(a.endContainer)?a.endContainer.length:a.endContainer.childNodes.length)))throw Error("Range Range error: Range is no longer valid after DOM mutation ("+a.inspect()+")");}function G(a){a.START_TO_START=L;a.START_TO_END=O;a.END_TO_END=W;a.END_TO_START=P;a.NODE_BEFORE=Q;a.NODE_AFTER=R;a.NODE_BEFORE_AND_AFTER=S;a.NODE_INSIDE=M}function u(a){G(a);G(a.prototype)}function E(a,e,K){function r(a,b){return function(c){p(this); v(c,T);v(s(c),X);c=(a?f:h)(c);(b?I:C)(this,c.node,c.offset)}}function I(a,b,c){var g=a.endContainer,d=a.endOffset;if(b!==a.startContainer||c!==this.startOffset){if(s(b)!=s(g)||1==m.comparePoints(b,c,g,d))g=b,d=c;e(a,b,c,g,d)}}function C(a,b,c){var g=a.startContainer,d=a.startOffset;if(b!==a.endContainer||c!==this.endOffset){if(s(b)!=s(g)||-1==m.comparePoints(b,c,g,d))g=b,d=c;e(a,g,d,b,c)}}function G(a,b,c){(b!==a.startContainer||c!==this.startOffset||b!==a.endContainer||c!==this.endOffset)&&e(a,b, c,b,c)}function E(a){return function(){p(this);y(this);var b=this.startContainer,d=this.startOffset,j=this.commonAncestorContainer,f=new c(this,!0);if(b!==j)b=m.getClosestAncestorIn(b,j,!0),d=h(b),b=d.node,d=d.offset;g(f,F);f.reset();j=a(f);f.detach();e(this,b,d,b,d);return j}}a.prototype={attachListener:function(a,b){this._listeners[a].push(b)},setStart:function(a,b){p(this);x(a,!0);B(a,b);I(this,a,b)},setEnd:function(a,b){p(this);x(a,!0);B(a,b);C(this,a,b)},setStartBefore:r(!0,!0),setStartAfter:r(!1, !0),setEndBefore:r(!0,!1),setEndAfter:r(!1,!1),collapse:function(a){p(this);y(this);a?e(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):e(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(a){p(this);x(a,!0);e(this,a,0,a,i(a))},selectNode:function(a){p(this);x(a,!1);v(a,T);var b=f(a),a=h(a);e(this,b.node,b.offset,a.node,a.offset)},compareBoundaryPoints:function(a,b){p(this);y(this);A(this.startContainer,b.startContainer); var c=a==P||a==L?"start":"end",g=a==O||a==L?"start":"end";return m.comparePoints(this[c+"Container"],this[c+"Offset"],b[g+"Container"],b[g+"Offset"])},insertNode:function(a){p(this);y(this);v(a,Y);F(this.startContainer);if(m.isAncestorOf(a,this.startContainer,!0))throw new D("HIERARCHY_REQUEST_ERR");this.setStartBefore(k(a,this.startContainer,this.startOffset))},cloneContents:function(){p(this);y(this);var a,b;if(this.collapsed)return d(this).createDocumentFragment();if(this.startContainer===this.endContainer&& m.isCharacterDataNode(this.startContainer))return a=this.startContainer.cloneNode(!0),a.data=a.data.slice(this.startOffset,this.endOffset),b=d(this).createDocumentFragment(),b.appendChild(a),b;b=new c(this,!0);a=j(b);b.detach();return a},extractContents:E(n),deleteContents:E(l),canSurroundContents:function(){p(this);y(this);F(this.startContainer);F(this.endContainer);var a=new c(this,!0),b=a._first&&w(a._first,this)||a._last&&w(a._last,this);a.detach();return!b},surroundContents:function(a){v(a,Z); if(!this.canSurroundContents())throw new b("BAD_BOUNDARYPOINTS_ERR");var c=this.extractContents();if(a.hasChildNodes())for(;a.lastChild;)a.removeChild(a.lastChild);k(a,this.startContainer,this.startOffset);a.appendChild(c);this.selectNode(a)},cloneRange:function(){p(this);y(this);for(var a=new z(d(this)),b=N.length,c;b--;)c=N[b],a[c]=this[c];return a},detach:function(){K(this)},toString:function(){p(this);y(this);var a=this.startContainer;if(a===this.endContainer&&m.isCharacterDataNode(a))return 3== a.nodeType||4==a.nodeType?a.data.slice(this.startOffset,this.endOffset):"";var b=[],a=new c(this,!0);g(a,function(a){(3==a.nodeType||4==a.nodeType)&&b.push(a.data)});a.detach();return b.join("")},compareNode:function(a){p(this);y(this);var b=a.parentNode,c=m.getNodeIndex(a);if(!b)throw new D("NOT_FOUND_ERR");a=this.comparePoint(b,c);b=this.comparePoint(b,c+1);return 0>a?0<b?S:Q:0<b?R:M},comparePoint:function(a,b){p(this);y(this);H(a,"HIERARCHY_REQUEST_ERR");A(a,this.startContainer);return 0>m.comparePoints(a, b,this.startContainer,this.startOffset)?-1:0<m.comparePoints(a,b,this.endContainer,this.endOffset)?1:0},createContextualFragment:function(a){p(this);var b=d(this),c=b.createElement("div");c.innerHTML=a;for(a=b.createDocumentFragment();b=c.firstChild;)a.appendChild(b);return a},intersectsNode:function(a,b){p(this);y(this);H(a,"NOT_FOUND_ERR");if(m.getDocument(a)!==d(this))return!1;var c=a.parentNode,g=m.getNodeIndex(a);H(c,"NOT_FOUND_ERR");var j=m.comparePoints(c,g,this.endContainer,this.endOffset), c=m.comparePoints(c,g+1,this.startContainer,this.startOffset);return b?0>=j&&0<=c:0>j&&0<c},isPointInRange:function(a,b){p(this);y(this);H(a,"HIERARCHY_REQUEST_ERR");A(a,this.startContainer);return 0<=m.comparePoints(a,b,this.startContainer,this.startOffset)&&0>=m.comparePoints(a,b,this.endContainer,this.endOffset)},intersectsRange:function(a){p(this);y(this);if(d(a)!=d(this))throw new D("WRONG_DOCUMENT_ERR");return 0>m.comparePoints(this.startContainer,this.startOffset,a.endContainer,a.endOffset)&& 0<m.comparePoints(this.endContainer,this.endOffset,a.startContainer,a.startOffset)},intersection:function(a){if(this.intersectsRange(a)){var b=m.comparePoints(this.startContainer,this.startOffset,a.startContainer,a.startOffset),c=m.comparePoints(this.endContainer,this.endOffset,a.endContainer,a.endOffset),g=this.cloneRange();-1==b&&g.setStart(a.startContainer,a.startOffset);1==c&&g.setEnd(a.endContainer,a.endOffset);return g}return null},containsNode:function(a,b){return b?this.intersectsNode(a,!1): this.compareNode(a)==M},containsNodeContents:function(a){return 0<=this.comparePoint(a,0)&&0>=this.comparePoint(a,i(a))},splitBoundaries:function(){p(this);y(this);var a=this.startContainer,b=this.startOffset,c=this.endContainer,g=this.endOffset,d=a===c;m.isCharacterDataNode(c)&&g<c.length&&m.splitDataNode(c,g);m.isCharacterDataNode(a)&&0<b&&(a=m.splitDataNode(a,b),d&&(g-=b,c=a),b=0);e(this,a,b,c,g)},normalizeBoundaries:function(){p(this);y(this);var a=this.startContainer,b=this.startOffset,c=this.endContainer, g=this.endOffset,d=function(a){var b=a.nextSibling;if(b&&b.nodeType==a.nodeType)c=a,g=a.length,a.appendData(b.data),b.parentNode.removeChild(b)},j=function(d){var j=d.previousSibling;if(j&&j.nodeType==d.nodeType)a=d,b=j.length,d.insertData(0,j.data),j.parentNode.removeChild(j),a==c&&(g+=b,c=a)},f=!0;m.isCharacterDataNode(c)?c.length==g&&d(c):(0<g&&(f=c.childNodes[g-1])&&m.isCharacterDataNode(f)&&d(f),f=!this.collapsed);f?m.isCharacterDataNode(a)?0==b&&j(a):b<a.childNodes.length&&(d=a.childNodes[b])&& m.isCharacterDataNode(d)&&j(d):(a=c,b=g);e(this,a,b,c,g)},createNodeIterator:function(a,b){p(this);y(this);return new o(this,a,b)},getNodes:function(a,b){p(this);y(this);return q(this,a,b)},collapseToPoint:function(a,b){p(this);y(this);x(a,!0);B(a,b);G(this,a,b)},collapseBefore:function(a){p(this);this.setEndBefore(a);this.collapse(!1)},collapseAfter:function(a){p(this);this.setStartAfter(a);this.collapse(!0)},getName:function(){return"DomRange"},equals:function(a){return z.rangesEqual(this,a)},inspect:function(){return t(this)}}; u(a)}function J(a){a.collapsed=a.startContainer===a.endContainer&&a.startOffset===a.endOffset;a.commonAncestorContainer=a.collapsed?a.startContainer:m.getCommonAncestor(a.startContainer,a.endContainer)}function C(a,b,c,g,d){var j=a.startContainer!==b||a.startOffset!==c,f=a.endContainer!==g||a.endOffset!==d;a.startContainer=b;a.startOffset=c;a.endContainer=g;a.endOffset=d;J(a);e(a,"boundarychange",{startMoved:j,endMoved:f})}function z(a){this.startContainer=a;this.startOffset=0;this.endContainer=a; this.endOffset=0;this._listeners={boundarychange:[],detach:[]};J(this)}a.requireModules(["DomUtil"]);var m=a.dom,K=m.DomPosition,D=a.DOMException;c.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null;this._next=this._first},hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next;if(a)this._next=a!==this._last?a.nextSibling:null,m.isCharacterDataNode(a)&&this.clonePartiallySelectedTextNodes&&(a=== this.ec&&(a=a.cloneNode(!0)).deleteData(this.eo,a.length-this.eo),this._current===this.sc&&(a=a.cloneNode(!0)).deleteData(0,this.so));return a},remove:function(){var a=this._current,b,c;m.isCharacterDataNode(a)&&(a===this.sc||a===this.ec)?(b=a===this.sc?this.so:0,c=a===this.ec?this.eo:a.length,b!=c&&a.deleteData(b,c-b)):a.parentNode&&a.parentNode.removeChild(a)},isPartiallySelectedSubtree:function(){return w(this._current,this.range)},getSubtreeIterator:function(){var a;if(this.isSingleCharacterDataNode)a= this.range.cloneRange(),a.collapse();else{a=new z(d(this.range));var b=this._current,g=b,j=0,f=b,e=i(b);if(m.isAncestorOf(b,this.sc,!0))g=this.sc,j=this.so;if(m.isAncestorOf(b,this.ec,!0))f=this.ec,e=this.eo;C(a,g,j,f,e)}return new c(a,this.clonePartiallySelectedTextNodes)},detach:function(a){a&&this.range.detach();this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}};b.prototype={BAD_BOUNDARYPOINTS_ERR:1,INVALID_NODE_TYPE_ERR:2};b.prototype.toString=function(){return this.message}; o.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){this._current=this._next;this._next=this.nodes[++this._pointer];return this._current},detach:function(){this._current=this._next=this.nodes=null}};var T=[1,3,4,5,7,8,10],X=[2,9,11],Y=[1,3,4,5,7,8,10,11],Z=[1,3,4,5,7,8],I=r([9,11]),V=r([5,6,10,12]),U=r([6,10,12]),N="startContainer,startOffset,endContainer,endOffset,collapsed,commonAncestorContainer".split(","),L=0,O=1,W=2,P=3,Q=0,R=1,S=2,M=3;E(z,C,function(a){p(a);a.startContainer= a.startOffset=a.endContainer=a.endOffset=null;a.collapsed=a.commonAncestorContainer=null;e(a,"detach",null);a._listeners=null});z.fromRange=function(a){var b=new z(d(a));C(b,a.startContainer,a.startOffset,a.endContainer,a.endOffset);return b};z.rangeProperties=N;z.RangeIterator=c;z.copyComparisonConstants=u;z.createPrototypeRange=E;z.inspect=t;z.getRangeDocument=d;z.rangesEqual=function(a,b){return a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&& a.endOffset===b.endOffset};z.getEndOffset=i;a.DomRange=z;a.RangeException=b}); rangy.createModule("WrappedRange",function(a){function c(a,b,c,d){var h=a.duplicate();h.collapse(c);var i=h.parentElement();e.isAncestorOf(b,i,!0)||(i=b);if(!i.canHaveHTML)return new f(i.parentNode,e.getNodeIndex(i));var b=e.getDocument(i).createElement("span"),t,o=c?"StartToStart":"StartToEnd";do i.insertBefore(b,b.previousSibling),h.moveToElementText(b);while(0<(t=h.compareEndPoints(o,a))&&b.previousSibling);o=b.nextSibling;if(-1==t&&o&&e.isCharacterDataNode(o)){h.setEndPoint(c?"EndToStart":"EndToEnd", a);if(/[\r\n]/.test(o.data)){i=h.duplicate();c=i.text.replace(/\r\n/g,"\r").length;for(c=i.moveStart("character",c);-1==i.compareEndPoints("StartToEnd",i);)c++,i.moveStart("character",1)}else c=h.text.length;i=new f(o,c)}else o=(d||!c)&&b.previousSibling,i=(c=(d||c)&&b.nextSibling)&&e.isCharacterDataNode(c)?new f(c,0):o&&e.isCharacterDataNode(o)?new f(o,o.length):new f(i,e.getNodeIndex(b));b.parentNode.removeChild(b);return i}function b(a,b){var c,d,f=a.offset,h=e.getDocument(a.node),i=h.body.createTextRange(), o=e.isCharacterDataNode(a.node);o?(c=a.node,d=c.parentNode):(c=a.node.childNodes,c=f<c.length?c[f]:null,d=a.node);h=h.createElement("span");h.innerHTML="&#feff;";c?d.insertBefore(h,c):d.appendChild(h);i.moveToElementText(h);i.collapse(!b);d.removeChild(h);if(o)i[b?"moveStart":"moveEnd"]("character",f);return i}a.requireModules(["DomUtil","DomRange"]);var d,e=a.dom,f=e.DomPosition,h=a.DomRange;if(a.features.implementsDomRange)(function(){function a(b){for(var d=c.length,f;d--;)f=c[d],b[f]=b.nativeRange[f]} var b,c=h.rangeProperties,f;d=function(b){if(!b)throw Error("Range must be specified");this.nativeRange=b;a(this)};h.createPrototypeRange(d,function(a,b,c,g,d){var f=a.startContainer!==b||a.startOffset!=c;(a.endContainer!==g||a.endOffset!=d)&&a.setEnd(g,d);f&&a.setStart(b,c)},function(a){a.nativeRange.detach();a.detached=!0;for(var b=c.length,d;b--;)d=c[b],a[d]=null});b=d.prototype;b.selectNode=function(b){this.nativeRange.selectNode(b);a(this)};b.deleteContents=function(){this.nativeRange.deleteContents(); a(this)};b.extractContents=function(){var b=this.nativeRange.extractContents();a(this);return b};b.cloneContents=function(){return this.nativeRange.cloneContents()};b.surroundContents=function(b){this.nativeRange.surroundContents(b);a(this)};b.collapse=function(b){this.nativeRange.collapse(b);a(this)};b.cloneRange=function(){return new d(this.nativeRange.cloneRange())};b.refresh=function(){a(this)};b.toString=function(){return this.nativeRange.toString()};var i=document.createTextNode("test");e.getBody(document).appendChild(i); var q=document.createRange();q.setStart(i,0);q.setEnd(i,0);try{q.setStart(i,1),b.setStart=function(b,c){this.nativeRange.setStart(b,c);a(this)},b.setEnd=function(b,c){this.nativeRange.setEnd(b,c);a(this)},f=function(b){return function(c){this.nativeRange[b](c);a(this)}}}catch(t){b.setStart=function(b,c){try{this.nativeRange.setStart(b,c)}catch(g){this.nativeRange.setEnd(b,c),this.nativeRange.setStart(b,c)}a(this)},b.setEnd=function(b,c){try{this.nativeRange.setEnd(b,c)}catch(g){this.nativeRange.setStart(b, c),this.nativeRange.setEnd(b,c)}a(this)},f=function(b,c){return function(g){try{this.nativeRange[b](g)}catch(d){this.nativeRange[c](g),this.nativeRange[b](g)}a(this)}}}b.setStartBefore=f("setStartBefore","setEndBefore");b.setStartAfter=f("setStartAfter","setEndAfter");b.setEndBefore=f("setEndBefore","setStartBefore");b.setEndAfter=f("setEndAfter","setStartAfter");q.selectNodeContents(i);b.selectNodeContents=q.startContainer==i&&q.endContainer==i&&0==q.startOffset&&q.endOffset==i.length?function(b){this.nativeRange.selectNodeContents(b); a(this)}:function(a){this.setStart(a,0);this.setEnd(a,h.getEndOffset(a))};q.selectNodeContents(i);q.setEnd(i,3);f=document.createRange();f.selectNodeContents(i);f.setEnd(i,4);f.setStart(i,2);b.compareBoundaryPoints=-1==q.compareBoundaryPoints(q.START_TO_END,f)&&1==q.compareBoundaryPoints(q.END_TO_START,f)?function(a,b){b=b.nativeRange||b;if(a==b.START_TO_END)a=b.END_TO_START;else if(a==b.END_TO_START)a=b.START_TO_END;return this.nativeRange.compareBoundaryPoints(a,b)}:function(a,b){return this.nativeRange.compareBoundaryPoints(a, b.nativeRange||b)};e.getBody(document).removeChild(i);q.detach();f.detach()})();else if(a.features.implementsTextRange){d=function(a){this.textRange=a;this.refresh()};d.prototype=new h(document);d.prototype.refresh=function(){var a,b,g=this.textRange;a=g.parentElement();var d=g.duplicate();d.collapse(!0);b=d.parentElement();d=g.duplicate();d.collapse(!1);g=d.parentElement();b=b==g?b:e.getCommonAncestor(b,g);b=b==a?b:e.getCommonAncestor(a,b);0==this.textRange.compareEndPoints("StartToEnd",this.textRange)? b=a=c(this.textRange,b,!0,!0):(a=c(this.textRange,b,!0,!1),b=c(this.textRange,b,!1,!1));this.setStart(a.node,a.offset);this.setEnd(b.node,b.offset)};d.rangeToTextRange=function(a){if(a.collapsed)return b(new f(a.startContainer,a.startOffset),!0,!0);var c=b(new f(a.startContainer,a.startOffset),!0,!1),g=b(new f(a.endContainer,a.endOffset),!1,!1),a=e.getDocument(a.startContainer).body.createTextRange();a.setEndPoint("StartToStart",c);a.setEndPoint("EndToEnd",g);return a};h.copyComparisonConstants(d); var i=function(){return this}();if("undefined"==typeof i.Range)i.Range=d}d.prototype.getName=function(){return"WrappedRange"};a.WrappedRange=d;a.createNativeRange=function(b){b=b||document;if(a.features.implementsDomRange)return b.createRange();if(a.features.implementsTextRange)return b.body.createTextRange()};a.createRange=function(b){return new d(a.createNativeRange(b||document))};a.createRangyRange=function(a){return new h(a||document)};a.createIframeRange=function(b){return a.createRange(e.getIframeDocument(b))}; a.createIframeRangyRange=function(b){return a.createRangyRange(e.getIframeDocument(b))};a.addCreateMissingNativeApiListener(function(b){b=b.document;if("undefined"==typeof b.createRange)b.createRange=function(){return a.createRange(this)};b=b=null})}); rangy.createModule("WrappedSelection",function(a,c){function b(a,b,c){var g=c?"end":"start",c=c?"start":"end";a.anchorNode=b[g+"Container"];a.anchorOffset=b[g+"Offset"];a.focusNode=b[c+"Container"];a.focusOffset=b[c+"Offset"]}function d(a){a.anchorNode=a.focusNode=null;a.anchorOffset=a.focusOffset=0;a.rangeCount=0;a.isCollapsed=!0;a._ranges.length=0}function e(b){var c;if(b instanceof n){if(c=b._selectionNativeRange,!c)c=a.createNativeRange(g.getDocument(b.startContainer)),c.setEnd(b.endContainer, b.endOffset),c.setStart(b.startContainer,b.startOffset),b._selectionNativeRange=c,b.attachListener("detach",function(){this._selectionNativeRange=null})}else b instanceof q?c=b.nativeRange:window.Range&&b instanceof Range&&(c=b);return c}function f(a){var b=a.getNodes(),c;a:if(!b.length||1!=b[0].nodeType)c=!1;else{c=1;for(var d=b.length;c<d;++c)if(!g.isAncestorOf(b[0],b[c])){c=!1;break a}c=!0}if(!c)throw Error("getSingleElementFromRange: range "+a.inspect()+" did not consist of a single element"); return b[0]}function h(c){c._ranges.length=0;if("None"==c.nativeSelection.type)d(c);else{var f=c.nativeSelection.createRange();c.rangeCount=f.length;for(var j,h=g.getDocument(f.item(0)),e=0;e<c.rangeCount;++e)j=a.createRange(h),j.selectNode(f.item(e)),c._ranges.push(j);c.isCollapsed=1==c.rangeCount&&c._ranges[0].collapsed;b(c,c._ranges[c.rangeCount-1],!1)}}function i(a){this.nativeSelection=a;this._ranges=[];this.refresh()}function k(a,b){if(a.anchorNode&&g.getDocument(a.anchorNode)!==g.getDocument(b))throw new t("WRONG_DOCUMENT_ERR"); }function j(a){var b=[],c=new o(a.anchorNode,a.anchorOffset),g=new o(a.focusNode,a.focusOffset),d="function"==typeof a.getName?a.getName():"Selection";if("undefined"!=typeof a.rangeCount)for(var f=0,j=a.rangeCount;f<j;++f)b[f]=n.inspect(a.getRangeAt(f));return"["+d+"(Ranges: "+b.join(", ")+")(anchor: "+c.inspect()+", focus: "+g.inspect()+"]"}a.requireModules(["DomUtil","DomRange","WrappedRange"]);a.config.checkSelectionRanges=!0;var g=a.dom,l=a.util,n=a.DomRange,q=a.WrappedRange,t=a.DOMException, o=g.DomPosition,w,r;a.util.isHostMethod(window,"getSelection")?w=function(a){return(a||window).getSelection()}:a.util.isHostObject(document,"selection")?w=function(a){return(a||window).document.selection}:c.fail("No means of obtaining a selection object");a.getNativeSelection=w;var s=w(),x=a.createNativeRange(document),p=g.getBody(document),v=l.areHostObjects(s,l.areHostProperties(s,["anchorOffset","focusOffset"]));a.features.selectionHasAnchorAndFocus=v;var B=l.isHostMethod(s,"extend");a.features.selectionHasExtend= B;var A="number"==typeof s.rangeCount;a.features.selectionHasRangeCount=A;var F=!1,H=!0;l.areHostMethods(s,["addRange","getRangeAt","removeAllRanges"])&&"number"==typeof s.rangeCount&&a.features.implementsDomRange&&function(){var b=p.appendChild(document.createTextNode("One")),c=p.appendChild(document.createTextNode("Two")),g=a.createNativeRange(document);g.selectNodeContents(b);var d=a.createNativeRange(document);d.selectNodeContents(c);s.removeAllRanges();s.addRange(g);s.addRange(d);F=2==s.rangeCount; s.removeAllRanges();b.parentNode.removeChild(b);c.parentNode.removeChild(c);b=document.createElement("p");b.contentEditable=!1;c=b.appendChild(document.createTextNode("test"));p.appendChild(b);g=a.createRange();g.collapseToPoint(c,1);s.addRange(g.nativeRange);H=1==s.rangeCount;s.removeAllRanges();p.removeChild(b)}();a.features.selectionSupportsMultipleRanges=F;a.features.collapsedNonEditableSelectionsSupported=H;var y=l.isHostProperty(s,"type"),G=!1,u;p&&l.isHostMethod(p,"createControlRange")&&(u= p.createControlRange(),l.areHostProperties(u,["item","add"])&&(G=!0));a.features.implementsControlRange=G;r=v?function(a){return a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset}:function(a){return a.rangeCount?a.getRangeAt(a.rangeCount-1).collapsed:!1};var E;l.isHostMethod(s,"getRangeAt")?E=function(a,b){try{return a.getRangeAt(b)}catch(c){return null}}:v&&(E=function(b){var c=g.getDocument(b.anchorNode),c=a.createRange(c);c.setStart(b.anchorNode,b.anchorOffset);c.setEnd(b.focusNode,b.focusOffset); c.collapsed!==this.isCollapsed&&(c.setStart(b.focusNode,b.focusOffset),c.setEnd(b.anchorNode,b.anchorOffset));return c});a.getSelection=function(a){var a=a||window,b=a._rangySelection;b?(b.nativeSelection=w(a),b.refresh()):(b=new i(w(a)),a._rangySelection=b);return b};a.getIframeSelection=function(b){return a.getSelection(g.getIframeWindow(b))};u=i.prototype;if(v&&l.areHostMethods(s,["removeAllRanges","addRange"])){u.removeAllRanges=function(){this.nativeSelection.removeAllRanges();d(this)};var J= function(b,c){var g=n.getRangeDocument(c),g=a.createRange(g);g.collapseToPoint(c.endContainer,c.endOffset);b.nativeSelection.addRange(e(g));b.nativeSelection.extend(c.startContainer,c.startOffset);b.refresh()};u.addRange=A?function(c,g){if(g&&B)J(this,c);else{var d;F?d=this.rangeCount:(this.removeAllRanges(),d=0);this.nativeSelection.addRange(e(c));this.rangeCount=this.nativeSelection.rangeCount;this.rangeCount==d+1?(a.config.checkSelectionRanges&&(d=E(this.nativeSelection,this.rangeCount-1))&&!n.rangesEqual(d, c)&&(c=new q(d)),this._ranges[this.rangeCount-1]=c,b(this,c,m(this.nativeSelection)),this.isCollapsed=r(this)):this.refresh()}}:function(a,b){b&&B?J(this,a):(this.nativeSelection.addRange(e(a)),this.refresh())};u.setRanges=function(a){this.removeAllRanges();for(var b=0,c=a.length;b<c;++b)this.addRange(a[b])}}else if(l.isHostMethod(s,"empty")&&l.isHostMethod(x,"select")&&y&&G)u.removeAllRanges=function(){try{if(this.nativeSelection.empty(),"None"!=this.nativeSelection.type){var a;if(this.anchorNode)a= g.getDocument(this.anchorNode);else if("Control"==this.nativeSelection.type){var b=this.nativeSelection.createRange();b.length&&(a=g.getDocument(b.item(0)).body.createTextRange())}a&&(a.body.createTextRange().select(),this.nativeSelection.empty())}}catch(c){}d(this)},u.addRange=function(a){if("Control"==this.nativeSelection.type){for(var c=this.nativeSelection.createRange(),a=f(a),d=g.getDocument(c.item(0)),d=g.getBody(d).createControlRange(),j=0,e=c.length;j<e;++j)d.add(c.item(j));try{d.add(a)}catch(i){throw Error("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)"); }d.select();h(this)}else q.rangeToTextRange(a).select(),this._ranges[0]=a,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,b(this,a,!1)},u.setRanges=function(a){this.removeAllRanges();var b=a.length;if(1<b){for(var c=g.getDocument(a[0].startContainer),c=g.getBody(c).createControlRange(),d=0,j;d<b;++d){j=f(a[d]);try{c.add(j)}catch(e){throw Error("setRanges(): Element within the one of the specified Ranges could not be added to control selection (does it have layout?)");}}c.select();h(this)}else b&& this.addRange(a[0])};else return c.fail("No means of selecting a Range or TextRange was found"),!1;u.getRangeAt=function(a){if(0>a||a>=this.rangeCount)throw new t("INDEX_SIZE_ERR");return this._ranges[a]};var C;if(l.isHostMethod(s,"getRangeAt")&&"number"==typeof s.rangeCount)C=function(c){c._ranges.length=c.rangeCount=c.nativeSelection.rangeCount;if(c.rangeCount){for(var g=0,f=c.rangeCount;g<f;++g)c._ranges[g]=new a.WrappedRange(c.nativeSelection.getRangeAt(g));b(c,c._ranges[c.rangeCount-1],m(c.nativeSelection)); c.isCollapsed=r(c)}else d(c)};else if(v&&"boolean"==typeof s.isCollapsed&&"boolean"==typeof x.collapsed&&a.features.implementsDomRange)C=function(a){var b;b=a.nativeSelection;b.anchorNode?(b=E(b,0),a._ranges=[b],a.rangeCount=1,b=a.nativeSelection,a.anchorNode=b.anchorNode,a.anchorOffset=b.anchorOffset,a.focusNode=b.focusNode,a.focusOffset=b.focusOffset,a.isCollapsed=r(a)):d(a)};else if(l.isHostMethod(s,"createRange")&&a.features.implementsTextRange)C=function(a){var c=a.nativeSelection.createRange(); "Control"==a.nativeSelection.type?h(a):c&&"undefined"!=typeof c.text?(c=new q(c),a._ranges=[c],b(a,c,!1),a.rangeCount=1,a.isCollapsed=c.collapsed):d(a)};else return c.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;u.refresh=function(a){var b=a?this._ranges.slice(0):null;C(this);if(a){a=b.length;if(a!=this._ranges.length)return!1;for(;a--;)if(!n.rangesEqual(b[a],this._ranges[a]))return!1;return!0}};var z=function(a,b){var c=a.getAllRanges(),g=!1;a.removeAllRanges(); for(var f=0,j=c.length;f<j;++f)g||b!==c[f]?a.addRange(c[f]):g=!0;a.rangeCount||d(a)};u.removeRange=y&&G?function(a){if("Control"==this.nativeSelection.type){for(var b=this.nativeSelection.createRange(),a=f(a),c=g.getDocument(b.item(0)),c=g.getBody(c).createControlRange(),d,j=!1,e=0,i=b.length;e<i;++e)d=b.item(e),d!==a||j?c.add(b.item(e)):j=!0;c.select();h(this)}else z(this,a)}:function(a){z(this,a)};var m;v&&a.features.implementsDomRange?(m=function(a){var b=!1;a.anchorNode&&(b=1==g.comparePoints(a.anchorNode, a.anchorOffset,a.focusNode,a.focusOffset));return b},u.isBackwards=function(){return m(this)}):m=u.isBackwards=function(){return!1};u.toString=function(){for(var a=[],b=0,c=this.rangeCount;b<c;++b)a[b]=""+this._ranges[b];return a.join("")};u.collapse=function(b,c){k(this,b);var d=a.createRange(g.getDocument(b));d.collapseToPoint(b,c);this.removeAllRanges();this.addRange(d);this.isCollapsed=!0};u.collapseToStart=function(){if(this.rangeCount){var a=this._ranges[0];this.collapse(a.startContainer,a.startOffset)}else throw new t("INVALID_STATE_ERR"); };u.collapseToEnd=function(){if(this.rangeCount){var a=this._ranges[this.rangeCount-1];this.collapse(a.endContainer,a.endOffset)}else throw new t("INVALID_STATE_ERR");};u.selectAllChildren=function(b){k(this,b);var c=a.createRange(g.getDocument(b));c.selectNodeContents(b);this.removeAllRanges();this.addRange(c)};u.deleteFromDocument=function(){if(this.rangeCount){var a=this.getAllRanges();this.removeAllRanges();for(var b=0,c=a.length;b<c;++b)a[b].deleteContents();this.addRange(a[c-1])}};u.getAllRanges= function(){return this._ranges.slice(0)};u.setSingleRange=function(a){this.setRanges([a])};u.containsNode=function(a,b){for(var c=0,g=this._ranges.length;c<g;++c)if(this._ranges[c].containsNode(a,b))return!0;return!1};u.getName=function(){return"WrappedSelection"};u.inspect=function(){return j(this)};u.detach=function(){this.anchorNode&&(g.getWindow(this.anchorNode)._rangySelection=null)};i.inspect=j;a.Selection=i;a.addCreateMissingNativeApiListener(function(b){if("undefined"==typeof b.getSelection)b.getSelection= function(){return a.getSelection(this)};b=null})});var Base=function(){}; Base.extend=function(a,c){var b=Base.prototype.extend;Base._prototyping=!0;var d=new this;b.call(d,a);d.base=function(){};delete Base._prototyping;var e=d.constructor,f=d.constructor=function(){if(!Base._prototyping)if(this._constructing||this.constructor==f)this._constructing=!0,e.apply(this,arguments),delete this._constructing;else if(null!=arguments[0])return(arguments[0].extend||b).call(arguments[0],d)};f.ancestor=this;f.extend=this.extend;f.forEach=this.forEach;f.implement=this.implement;f.prototype= d;f.toString=this.toString;f.valueOf=function(a){return"object"==a?f:e.valueOf()};b.call(f,c);"function"==typeof f.init&&f.init();return f}; Base.prototype={extend:function(a,c){if(1<arguments.length){var b=this[a];if(b&&"function"==typeof c&&(!b.valueOf||b.valueOf()!=c.valueOf())&&/\bbase\b/.test(c)){var d=c.valueOf(),c=function(){var a=this.base||Base.prototype.base;this.base=b;var c=d.apply(this,arguments);this.base=a;return c};c.valueOf=function(a){return"object"==a?c:d};c.toString=Base.toString}this[a]=c}else if(a){var e=Base.prototype.extend;!Base._prototyping&&"function"!=typeof this&&(e=this.extend||e);for(var f={toSource:null}, h=["constructor","toString","valueOf"],i=Base._prototyping?0:1;k=h[i++];)a[k]!=f[k]&&e.call(this,k,a[k]);for(var k in a)f[k]||e.call(this,k,a[k])}return this}}; Base=Base.extend({constructor:function(a){this.extend(a)}},{ancestor:Object,version:"1.1",forEach:function(a,c,b){for(var d in a)void 0===this.prototype[d]&&c.call(b,a[d],d,a)},implement:function(){for(var a=0;a<arguments.length;a++)if("function"==typeof arguments[a])arguments[a](this.prototype);else this.prototype.extend(arguments[a]);return this},toString:function(){return""+this.valueOf()}}); wysihtml5.browser=function(){var a=navigator.userAgent,c=document.createElement("div"),b=-1!==a.indexOf("MSIE")&&-1===a.indexOf("Opera"),d=-1!==a.indexOf("Gecko")&&-1===a.indexOf("KHTML"),e=-1!==a.indexOf("AppleWebKit/"),f=-1!==a.indexOf("Opera/");return{USER_AGENT:a,supported:function(){var a=this.USER_AGENT.toLowerCase(),b="contentEditable"in c,d=document.execCommand&&document.queryCommandSupported&&document.queryCommandState,f=document.querySelector&&document.querySelectorAll,a=-1!==a.indexOf("webkit")&& -1!==a.indexOf("mobile")||-1!==a.indexOf("opera mobi");return b&&d&&f&&!a},supportsSandboxedIframes:function(){return b},throwsMixedContentWarningWhenIframeSrcIsEmpty:function(){return!("querySelector"in document)},displaysCaretInEmptyContentEditableCorrectly:function(){return!d},hasCurrentStyleProperty:function(){return"currentStyle"in c},insertsLineBreaksOnReturn:function(){return d},supportsPlaceholderAttributeOn:function(a){return"placeholder"in a},supportsEvent:function(a){var b;if(!(b="on"+ a in c))c.setAttribute("on"+a,"return;"),b="function"===typeof c["on"+a];return b},supportsEventsInIframeCorrectly:function(){return!f},firesOnDropOnlyWhenOnDragOverIsCancelled:function(){return e||d},supportsDataTransfer:function(){try{return e&&(window.Clipboard||window.DataTransfer).prototype.getData}catch(a){return!1}},supportsHTML5Tags:function(a){a=a.createElement("div");a.innerHTML="<article>foo</article>";return"<article>foo</article>"===a.innerHTML.toLowerCase()},supportsCommand:function(){var a= {formatBlock:b,insertUnorderedList:b||f,insertOrderedList:b||f};return function(b,c){if(!a[c]){try{return b.queryCommandSupported(c)}catch(d){}try{return b.queryCommandEnabled(c)}catch(g){}}return!1}}(),doesAutoLinkingInContentEditable:function(){return b},canDisableAutoLinking:function(){return this.supportsCommand(document,"AutoUrlDetect")},clearsContentEditableCorrectly:function(){return d||f||e},supportsGetAttributeCorrectly:function(){return"1"!=document.createElement("td").getAttribute("rowspan")}, canSelectImagesInContentEditable:function(){return d||b||f},clearsListsInContentEditableCorrectly:function(){return d||b||e},autoScrollsToCaret:function(){return!e},autoClosesUnclosedTags:function(){var a=c.cloneNode(!1),b;a.innerHTML="<p><div></div>";a=a.innerHTML.toLowerCase();b="<p></p><div></div>"===a||"<p><div></div></p>"===a;this.autoClosesUnclosedTags=function(){return b};return b},supportsNativeGetElementsByClassName:function(){return-1!==(""+document.getElementsByClassName).indexOf("[native code]")}, supportsSelectionModify:function(){return"getSelection"in window&&"modify"in window.getSelection()},supportsClassList:function(){return"classList"in c},needsSpaceAfterLineBreak:function(){return f},supportsSpeechApiOn:function(b){return 11<=(a.match(/Chrome\/(\d+)/)||[,0])[1]&&("onwebkitspeechchange"in b||"speech"in b)},crashesWhenDefineProperty:function(a){return b&&("XMLHttpRequest"===a||"XDomainRequest"===a)}}}(); wysihtml5.lang.array=function(a){return{contains:function(c){if(a.indexOf)return-1!==a.indexOf(c);for(var b=0,d=a.length;b<d;b++)if(a[b]===c)return!0;return!1},without:function(c){for(var c=wysihtml5.lang.array(c),b=[],d=0,e=a.length;d<e;d++)c.contains(a[d])||b.push(a[d]);return b},get:function(){for(var c=0,b=a.length,d=[];c<b;c++)d.push(a[c]);return d}}}; wysihtml5.lang.Dispatcher=Base.extend({observe:function(a,c){this.events=this.events||{};this.events[a]=this.events[a]||[];this.events[a].push(c);return this},fire:function(a,c){this.events=this.events||{};for(var b=this.events[a]||[],d=0;d<b.length;d++)b[d].call(this,c);return this},stopObserving:function(a,c){this.events=this.events||{};var b=0,d,e;if(a){for(d=this.events[a]||[],e=[];b<d.length;b++)d[b]!==c&&e.push(d[b]);this.events[a]=e}else this.events={};return this}}); wysihtml5.lang.object=function(a){return{merge:function(c){for(var b in c)a[b]=c[b];return this},get:function(){return a},clone:function(){var c={},b;for(b in a)c[b]=a[b];return c},isArray:function(){return"[object Array]"===Object.prototype.toString.call(a)}}};(function(){var a=/^\s+/,c=/\s+$/;wysihtml5.lang.string=function(b){b=""+b;return{trim:function(){return b.replace(a,"").replace(c,"")},interpolate:function(a){for(var c in a)b=this.replace("#{"+c+"}").by(a[c]);return b},replace:function(a){return{by:function(c){return b.split(a).join(c)}}}}}})(); (function(a){function c(a){return a.replace(e,function(a,b){var c=(b.match(f)||[])[1]||"",d=i[c],b=b.replace(f,"");b.split(d).length>b.split(c).length&&(b+=c,c="");var e=d=b;b.length>h&&(e=e.substr(0,h)+"...");"www."===d.substr(0,4)&&(d="http://"+d);return'<a href="'+d+'">'+e+"</a>"+c})}function b(f){if(!d.contains(f.nodeName))if(f.nodeType===a.TEXT_NODE&&f.data.match(e)){var j=f.parentNode,g;g=j.ownerDocument;var h=g._wysihtml5_tempElement;if(!h)h=g._wysihtml5_tempElement=g.createElement("div"); g=h;g.innerHTML="<span></span>"+c(f.data);for(g.removeChild(g.firstChild);g.firstChild;)j.insertBefore(g.firstChild,f);j.removeChild(f)}else{j=a.lang.array(f.childNodes).get();g=j.length;for(h=0;h<g;h++)b(j[h]);return f}}var d=a.lang.array("CODE,PRE,A,SCRIPT,HEAD,TITLE,STYLE".split(",")),e=/((https?:\/\/|www\.)[^\s<]{3,})/gi,f=/([^\w\/\-](,?))$/i,h=100,i={")":"(","]":"[","}":"{"};a.dom.autoLink=function(a){var c;a:{c=a;for(var g;c.parentNode;){c=c.parentNode;g=c.nodeName;if(d.contains(g)){c=!0;break a}if("body"=== g)break}c=!1}if(c)return a;if(a===a.ownerDocument.documentElement)a=a.ownerDocument.body;return b(a)};a.dom.autoLink.URL_REG_EXP=e})(wysihtml5); (function(a){var c=a.browser.supportsClassList(),b=a.dom;b.addClass=function(a,e){if(c)return a.classList.add(e);b.hasClass(a,e)||(a.className+=" "+e)};b.removeClass=function(a,b){if(c)return a.classList.remove(b);a.className=a.className.replace(RegExp("(^|\\s+)"+b+"(\\s+|$)")," ")};b.hasClass=function(a,b){if(c)return a.classList.contains(b);var f=a.className;return 0<f.length&&(f==b||RegExp("(^|\\s)"+b+"(\\s|$)").test(f))}})(wysihtml5); wysihtml5.dom.contains=function(){var a=document.documentElement;if(a.contains)return function(a,b){if(b.nodeType!==wysihtml5.ELEMENT_NODE)b=b.parentNode;return a!==b&&a.contains(b)};if(a.compareDocumentPosition)return function(a,b){return!!(a.compareDocumentPosition(b)&16)}}(); wysihtml5.dom.convertToList=function(){function a(a,b){var d=a.createElement("li");b.appendChild(d);return d}return function(c,b){if("UL"===c.nodeName||"OL"===c.nodeName||"MENU"===c.nodeName)return c;for(var d=c.ownerDocument,e=d.createElement(b),f=wysihtml5.lang.array(c.childNodes).get(),h=f.length,i,k,j,g,l=0;l<h;l++)g=g||a(d,e),i=f[l],k="block"===wysihtml5.dom.getStyle("display").from(i),j="BR"===i.nodeName,k?(g=g.firstChild?a(d,e):g,g.appendChild(i),g=null):j?g=g.firstChild?null:g:g.appendChild(i); c.parentNode.replaceChild(e,c);return e}}();wysihtml5.dom.copyAttributes=function(a){return{from:function(c){return{to:function(b){for(var d,e=0,f=a.length;e<f;e++)d=a[e],c[d]&&(b[d]=c[d]);return{andTo:arguments.callee}}}}}}; (function(a){var c=["-webkit-box-sizing","-moz-box-sizing","-ms-box-sizing","box-sizing"],b=function(b){for(var e=0,f=c.length;e<f;e++)if("border-box"===a.getStyle(c[e]).from(b))return c[e]};a.copyStyles=function(d){return{from:function(e){b(e)&&parseInt(a.getStyle("width").from(e),10)<e.offsetWidth&&(d=wysihtml5.lang.array(d).without(c));for(var f="",h=d.length,i=0,k;i<h;i++)k=d[i],f+=k+":"+a.getStyle(k).from(e)+";";return{to:function(b){a.setStyles(f).on(b);return{andTo:arguments.callee}}}}}}})(wysihtml5.dom); (function(a){a.dom.delegate=function(c,b,d,e){return a.dom.observe(c,d,function(d){for(var h=d.target,i=a.lang.array(c.querySelectorAll(b));h&&h!==c;){if(i.contains(h)){e.call(h,d);break}h=h.parentNode}})}})(wysihtml5); wysihtml5.dom.getAsDom=function(){var a="abbr,article,aside,audio,bdi,canvas,command,datalist,details,figcaption,figure,footer,header,hgroup,keygen,mark,meter,nav,output,progress,rp,rt,ruby,svg,section,source,summary,time,track,video,wbr".split(",");return function(c,b){var b=b||document,d;if("object"===typeof c&&c.nodeType)d=b.createElement("div"),d.appendChild(c);else if(wysihtml5.browser.supportsHTML5Tags(b))d=b.createElement("div"),d.innerHTML=c;else{d=b;if(!d._wysihtml5_supportsHTML5Tags){for(var e= 0,f=a.length;e<f;e++)d.createElement(a[e]);d._wysihtml5_supportsHTML5Tags=!0}d=b;e=d.createElement("div");e.style.display="none";d.body.appendChild(e);try{e.innerHTML=c}catch(h){}d.body.removeChild(e);d=e}return d}}(); wysihtml5.dom.getParentElement=function(){function a(a,b){return!b||!b.length?!0:"string"===typeof b?a===b:wysihtml5.lang.array(b).contains(a)}return function(c,b,d){d=d||50;if(b.className||b.classRegExp)a:{for(var e=b.nodeName,f=b.className,b=b.classRegExp;d--&&c&&"BODY"!==c.nodeName;){var h;if(h=c.nodeType===wysihtml5.ELEMENT_NODE)if(h=a(c.nodeName,e)){h=f;var i=(c.className||"").match(b)||[];h=!h?!!i.length:i[i.length-1]===h}if(h)break a;c=c.parentNode}c=null}else a:{e=b.nodeName;for(f=d;f--&& c&&"BODY"!==c.nodeName;){if(a(c.nodeName,e))break a;c=c.parentNode}c=null}return c}}(); wysihtml5.dom.getStyle=function(){function a(a){return a.replace(b,function(a){return a.charAt(1).toUpperCase()})}var c={"float":"styleFloat"in document.createElement("div").style?"styleFloat":"cssFloat"},b=/\-[a-z]/g;return function(b){return{from:function(e){if(e.nodeType===wysihtml5.ELEMENT_NODE){var f=e.ownerDocument,h=c[b]||a(b),i=e.style,k=e.currentStyle,j=i[h];if(j)return j;if(k)return k[h];var h=f.defaultView||f.parentWindow,f=("height"===b||"width"===b)&&"TEXTAREA"===e.nodeName,g;if(h.getComputedStyle){if(f)g= i.overflow,i.overflow="hidden";e=h.getComputedStyle(e,null).getPropertyValue(b);if(f)i.overflow=g||"";return e}}}}}}();wysihtml5.dom.hasElementWithTagName=function(){var a={},c=1;return function(b,d){var e=(b._wysihtml5_identifier||(b._wysihtml5_identifier=c++))+":"+d,f=a[e];f||(f=a[e]=b.getElementsByTagName(d));return 0<f.length}}(); (function(a){var c={},b=1;a.dom.hasElementWithClassNam