diff --git a/bower.json b/bower.json index 5f7798a..10531e4 100644 --- a/bower.json +++ b/bower.json @@ -1,24 +1,18 @@ { "name": "rangy-official", - "version": "1.3.0-alpha.20140827", + "version": "1.3.0-alpha.20140921", "homepage": "https://github.com/timdown/rangy", "authors": [ "Tim Down " ], "description": "A cross-browser JavaScript range and selection library.", "main": [ - "rangy-core.js", - "rangy-classapplier.js", - "rangy-highlighter.js", - "rangy-selectionsaverestore.js", - "rangy-serializer.js", - "rangy-textrange.js", "rangy-core.min.js", "rangy-classapplier.min.js", "rangy-highlighter.min.js", "rangy-selectionsaverestore.min.js", "rangy-serializer.min.js", - "rangy-textrangemin..js" + "rangy-textrange.min.js" ], "moduleType": [ "amd", diff --git a/rangy-classapplier.js b/rangy-classapplier.js index 1a20962..926540a 100644 --- a/rangy-classapplier.js +++ b/rangy-classapplier.js @@ -3,14 +3,14 @@ * Adds, removes and toggles classes on Ranges and Selections * * Part of Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ (function(factory, root) { if (typeof define == "function" && define.amd) { diff --git a/rangy-classapplier.min.js b/rangy-classapplier.min.js index a3d8d56..9033516 100644 --- a/rangy-classapplier.min.js +++ b/rangy-classapplier.min.js @@ -3,13 +3,13 @@ * Adds, removes and toggles classes on Ranges and Selections * * Part of Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ !function(e,t){"function"==typeof define&&define.amd?define(["./rangy-core"],e):"undefined"!=typeof module&&"object"==typeof exports?module.exports=e(require("rangy")):e(t.rangy)}(function(e){e.createModule("ClassApplier",["WrappedSelection"],function(e,t){function n(e,t){for(var n in e)if(e.hasOwnProperty(n)&&t(n,e[n])===!1)return!1;return!0}function r(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function i(e,t){return e.className&&new RegExp("(?:^|\\s)"+t+"(?:\\s|$)").test(e.className)}function o(e,t){e.className?i(e,t)||(e.className+=" "+t):e.className=t}function s(e){return e&&e.split(/\s+/).sort().join(" ")}function a(e){return s(e.className)}function l(e,t){return a(e)==a(t)}function f(e,t,n,r,i){var o=e.node,s=e.offset,a=o,l=s;o==r&&s>i&&++l,o!=t||s!=n&&s!=n+1||(a=r,l+=i-n),o==t&&s>n+1&&--l,e.node=a,e.offset=l}function d(e,t,n){e.node==t&&e.offset>n&&--e.offset}function u(e,t,n,r){-1==n&&(n=t.childNodes.length);for(var i,o=e.parentNode,s=M.getNodeIndex(e),a=0;i=r[a++];)f(i,o,s,t,n);t.childNodes.length==n?t.appendChild(e):t.insertBefore(e,t.childNodes[n])}function p(e,t){for(var n,r=e.parentNode,i=M.getNodeIndex(e),o=0;n=t[o++];)d(n,r,i);e.parentNode.removeChild(e)}function c(e,t,n,r,i){for(var o,s=[];o=e.firstChild;)u(o,t,n++,i),s.push(o);return r&&p(e,i),s}function h(e,t){return c(e,e.parentNode,M.getNodeIndex(e),!0,t)}function g(e,t){var n=e.cloneRange();n.selectNodeContents(t);var r=n.intersection(e),i=r?r.toString():"";return""!=i}function m(e){for(var t,n=e.getNodes([3]),r=0;(t=n[r])&&!g(e,t);)++r;for(var i=n.length-1;(t=n[i])&&!g(e,t);)--i;return n.slice(r,i+1)}function N(e,t){if(e.attributes.length!=t.attributes.length)return!1;for(var n,r,i,o=0,s=e.attributes.length;s>o;++o)if(n=e.attributes[o],i=n.name,"class"!=i){if(r=t.attributes.getNamedItem(i),null===n!=(null===r))return!1;if(n.specified!=r.specified)return!1;if(n.specified&&n.nodeValue!==r.nodeValue)return!1}return!0}function v(e,t){for(var n,r=0,i=e.attributes.length;i>r;++r)if(n=e.attributes[r].name,(!t||!j(t,n))&&e.attributes[r].specified&&"class"!=n)return!0;return!1}function y(e,t){return n(t,function(t,n){if("object"==typeof n){if(!y(e[t],n))return!1}else if(e[t]!==n)return!1})}function C(e){var t;return e&&1==e.nodeType&&((t=e.parentNode)&&9==t.nodeType&&"on"==t.designMode||$(e)&&!$(e.parentNode))}function T(e){return($(e)||1!=e.nodeType&&$(e.parentNode))&&!C(e)}function E(e){return e&&1==e.nodeType&&!U.test(H(e,"display"))}function b(e){if(0==e.data.length)return!0;if(V.test(e.data))return!1;var t=H(e.parentNode,"whiteSpace");switch(t){case"pre":case"pre-wrap":case"-moz-pre-wrap":return!1;case"pre-line":if(/[\r\n]/.test(e.data))return!1}return E(e.previousSibling)||E(e.nextSibling)}function A(e){var t,n,r=[];for(t=0;n=e[t++];)r.push(new L(n.startContainer,n.startOffset),new L(n.endContainer,n.endOffset));return r}function S(e,t){for(var n,r,i,o=0,s=e.length;s>o;++o)n=e[o],r=t[2*o],i=t[2*o+1],n.setStartAndEnd(r.node,r.offset,i.node,i.offset)}function x(e,t){return M.isCharacterDataNode(e)?0==t?!!e.previousSibling:t==e.length?!!e.nextSibling:!0:t>0&&ts;++s)"*"==i[s]?f.applyToAnyTagName=!0:f.tagNames.push(i[s].toLowerCase());else f.tagNames=[f.elementTagName]}function W(e,t,n){return new I(e,t,n)}var M=e.dom,L=M.DomPosition,j=M.arrayContains,z=M.isHtmlNamespace,B="span",D=function(){function e(e,t,n){return t&&n?" ":""}return function(t,n){t.className&&(t.className=t.className.replace(new RegExp("(^|\\s)"+n+"(\\s|$)"),e))}}(),H=M.getComputedStyleProperty,$=function(){var e=document.createElement("div");return"boolean"==typeof e.isContentEditable?function(e){return e&&1==e.nodeType&&e.isContentEditable}:function(e){return e&&1==e.nodeType&&"false"!=e.contentEditable?"true"==e.contentEditable||$(e.parentNode):!1}}(),U=/^inline(-block|-table)?$/i,V=/[^\r\n\t\f \u200B]/,k=P(!1),q=P(!0);O.prototype={doMerge:function(e){var t=this.textNodes,n=t[0];if(t.length>1){for(var r,i,o,s,a=M.getNodeIndex(n),l=[],f=0,d=0,u=t.length;u>d;++d){if(r=t[d],i=r.parentNode,d>0&&(i.removeChild(r),i.hasChildNodes()||i.parentNode.removeChild(i),e))for(o=0;s=e[o++];)s.node==r&&(s.node=n,s.offset+=f),s.node==i&&s.offset>a&&(--s.offset,s.offset==a+1&&u-1>d&&(s.node=n,s.offset=f));l[d]=r.data,f+=r.data.length}n.data=l.join("")}return n.data},getLength:function(){for(var e=this.textNodes.length,t=0;e--;)t+=this.textNodes[e].length;return t},toString:function(){for(var e=[],t=0,n=this.textNodes.length;n>t;++t)e[t]="'"+this.textNodes[t].data+"'";return"[Merge("+e.join(",")+")]"}};var F=["elementTagName","ignoreWhiteSpace","applyToEditableOnly","useExistingElements","removeEmptyElements","onElementCreate"],G={};I.prototype={elementTagName:B,elementProperties:{},elementAttributes:{},ignoreWhiteSpace:!0,applyToEditableOnly:!1,useExistingElements:!0,removeEmptyElements:!0,onElementCreate:null,copyPropertiesToElement:function(e,t,n){var r,i,a,l,f,d,u={};for(var p in e)if(e.hasOwnProperty(p))if(l=e[p],f=t[p],"className"==p)o(t,l),o(t,this.className),t[p]=s(t[p]),n&&(u[p]=t[p]);else if("style"==p){i=f,n&&(u[p]=a={});for(r in e[p])i[r]=l[r],n&&(a[r]=i[r]);this.attrExceptions.push(p)}else t[p]=l,n&&(u[p]=t[p],d=G.hasOwnProperty(p)?G[p]:p,this.attrExceptions.push(d));return n?u:""},copyAttributesToElement:function(e,t){for(var n in e)e.hasOwnProperty(n)&&t.setAttribute(n,e[n])},hasClass:function(e){return 1==e.nodeType&&j(this.tagNames,e.tagName.toLowerCase())&&i(e,this.className)},getSelfOrAncestorWithClass:function(e){for(;e;){if(this.hasClass(e))return e;e=e.parentNode}return null},isModifiable:function(e){return!this.applyToEditableOnly||T(e)},isIgnorableWhiteSpaceNode:function(e){return this.ignoreWhiteSpace&&e&&3==e.nodeType&&b(e)},postApply:function(e,t,n,r){for(var i,o,s,a=e[0],l=e[e.length-1],f=[],d=a,u=l,p=0,c=l.length,h=0,g=e.length;g>h;++h)o=e[h],s=k(o,!r),s?(i||(i=new O(s),f.push(i)),i.textNodes.push(o),o===a&&(d=i.textNodes[0],p=d.length),o===l&&(u=i.textNodes[0],c=i.getLength())):i=null;var m=q(l,!r);if(m&&(i||(i=new O(l),f.push(i)),i.textNodes.push(m)),f.length){for(h=0,g=f.length;g>h;++h)f[h].doMerge(n);t.setStartAndEnd(d,p,u,c)}},createContainer:function(e){var t=e.createElement(this.elementTagName);return this.copyPropertiesToElement(this.elementProperties,t,!1),this.copyAttributesToElement(this.elementAttributes,t),o(t,this.className),this.onElementCreate&&this.onElementCreate(t,this),t},applyToTextNode:function(e){var t=e.parentNode;if(1==t.childNodes.length&&this.useExistingElements&&z(t)&&j(this.tagNames,t.tagName.toLowerCase())&&y(t,this.elementProperties))o(t,this.className);else{var n=this.createContainer(M.getDocument(e));e.parentNode.insertBefore(n,e),n.appendChild(e)}},isRemovable:function(e){return z(e)&&e.tagName.toLowerCase()==this.elementTagName&&a(e)==this.elementSortedClassName&&y(e,this.elementProperties)&&!v(e,this.attrExceptions)&&this.isModifiable(e)},isEmptyContainer:function(e){var t=e.childNodes.length;return 1==e.nodeType&&this.isRemovable(e)&&(0==t||1==t&&this.isEmptyContainer(e.firstChild))},removeEmptyContainers:function(e){for(var t,n=this,r=e.getNodes([1],function(e){return n.isEmptyContainer(e)}),i=[e],o=A(i),s=0;t=r[s++];)p(t,o);S(i,o)},undoToTextNode:function(e,t,n,r){if(!t.containsNode(n)){var i=t.cloneRange();i.selectNode(n),i.isPointInRange(t.endContainer,t.endOffset)&&(R(n,t.endContainer,t.endOffset,r),t.setEndAfter(n)),i.isPointInRange(t.startContainer,t.startOffset)&&(n=R(n,t.startContainer,t.startOffset,r))}this.isRemovable(n)?h(n,r):D(n,this.className)},applyToRange:function(e,t){t=t||[];var n=A(t||[]);e.splitBoundariesPreservingPositions(n),this.removeEmptyElements&&this.removeEmptyContainers(e);var r=m(e);if(r.length){for(var i,o=0;i=r[o++];)this.isIgnorableWhiteSpaceNode(i)||this.getSelfOrAncestorWithClass(i)||!this.isModifiable(i)||this.applyToTextNode(i,n);i=r[r.length-1],e.setStartAndEnd(r[0],0,i,i.length),this.normalize&&this.postApply(r,e,n,!1),S(t,n)}},applyToRanges:function(e){for(var t=e.length;t--;)this.applyToRange(e[t],e);return e},applyToSelection:function(t){var n=e.getSelection(t);n.setRanges(this.applyToRanges(n.getAllRanges()))},undoToRange:function(e,t){t=t||[];var n=A(t);e.splitBoundariesPreservingPositions(n),this.removeEmptyElements&&this.removeEmptyContainers(e,n);var r,i,o=m(e),s=o[o.length-1];if(o.length){for(var a=0,l=o.length;l>a;++a)r=o[a],i=this.getSelfOrAncestorWithClass(r),i&&this.isModifiable(r)&&this.undoToTextNode(r,e,i,n),e.setStartAndEnd(o[0],0,s,s.length);this.normalize&&this.postApply(o,e,n,!0),S(t,n)}},undoToRanges:function(e){for(var t=e.length;t--;)this.undoToRange(e[t],e);return e},undoToSelection:function(t){var n=e.getSelection(t),r=e.getSelection(t).getAllRanges();this.undoToRanges(r),n.setRanges(r)},isAppliedToRange:function(e){if(e.collapsed||""==e.toString())return!!this.getSelfOrAncestorWithClass(e.commonAncestorContainer);var t=e.getNodes([3]);if(t.length)for(var n,r=0;n=t[r++];)if(!this.isIgnorableWhiteSpaceNode(n)&&g(e,n)&&this.isModifiable(n)&&!this.getSelfOrAncestorWithClass(n))return!1;return!0},isAppliedToRanges:function(e){var t=e.length;if(0==t)return!1;for(;t--;)if(!this.isAppliedToRange(e[t]))return!1;return!0},isAppliedToSelection:function(t){var n=e.getSelection(t);return this.isAppliedToRanges(n.getAllRanges())},toggleRange:function(e){this.isAppliedToRange(e)?this.undoToRange(e):this.applyToRange(e)},toggleSelection:function(e){this.isAppliedToSelection(e)?this.undoToSelection(e):this.applyToSelection(e)},getElementsWithClassIntersectingRange:function(e){var t=[],n=this;return e.getNodes([3],function(e){var r=n.getSelfOrAncestorWithClass(e);r&&!j(t,r)&&t.push(r)}),t},detach:function(){}},I.util={hasClass:i,addClass:o,removeClass:D,hasSameClasses:l,replaceWithOwnChildren:h,elementsHaveSameNonClassAttributes:N,elementHasNonClassAttributes:v,splitNodeAt:R,isEditableElement:$,isEditingHost:C,isEditable:T},e.CssClassApplier=e.ClassApplier=I,e.createCssClassApplier=e.createClassApplier=W})},this); \ No newline at end of file diff --git a/rangy-core.js b/rangy-core.js index f7cc30a..6468a05 100644 --- a/rangy-core.js +++ b/rangy-core.js @@ -1,11 +1,11 @@ /** * Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ (function(factory, root) { @@ -98,7 +98,7 @@ }; var api = { - version: "1.3.0-alpha.20140827", + version: "1.3.0-alpha.20140921", initialized: false, isBrowser: isBrowser, supported: true, @@ -167,7 +167,7 @@ var options = {}; extend(options, defaults); if (optionsParam) { - extend(options, optionsParam, true); + extend(options, optionsParam); } return options; }; @@ -387,6 +387,9 @@ } catch (ex) { var errorMessage = "Module '" + name + "' failed to load: " + getErrorDesc(ex); consoleLog(errorMessage); + if (ex.stack) { + consoleLog(ex.stack); + } } } }); @@ -3736,7 +3739,7 @@ if (isBrowser) { // Test whether the document has already been loaded and initialize immediately if so - if (/^(?:complete|interactive)$/.test(document.readyState)) { + if (document.readyState == "complete") { loadHandler(); } else { if (isHostMethod(document, "addEventListener")) { @@ -3749,4 +3752,4 @@ } return api; -}, /* build:replaceWithGlobalObject */this/* build:replaceWithGlobalObjectEnd */); \ No newline at end of file +}, this); \ No newline at end of file diff --git a/rangy-core.min.js b/rangy-core.min.js index 234814c..5cfcad4 100644 --- a/rangy-core.min.js +++ b/rangy-core.min.js @@ -1,11 +1,11 @@ /** * Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ -!function(e,t){"function"==typeof define&&define.amd?define(e):"undefined"!=typeof module&&"object"==typeof exports?module.exports=e():t.rangy=e()}(function(){function e(e,t){var n=typeof e[t];return n==v||!(n!=R||!e[t])||"unknown"==n}function t(e,t){return!(typeof e[t]!=R||!e[t])}function n(e,t){return typeof e[t]!=C}function r(e){return function(t,n){for(var r=n.length;r--;)if(!e(t,n[r]))return!1;return!0}}function o(e){return e&&w(e,y)&&T(e,S)}function i(e){return t(e,"body")?e.body:e.getElementsByTagName("body")[0]}function a(t){typeof console!=C&&e(console,"log")&&console.log(t)}function s(e,t){D&&t?alert(e):a(e)}function c(e){A.initialized=!0,A.supported=!1,s("Rangy is not supported in this environment. Reason: "+e,A.config.alertOnFail)}function d(e){s("Rangy warning: "+e,A.config.alertOnWarn)}function f(e){return e.message||e.description||String(e)}function u(){if(D&&!A.initialized){var t,n=!1,r=!1;e(document,"createRange")&&(t=document.createRange(),w(t,E)&&T(t,N)&&(n=!0));var s=i(document);if(!s||"body"!=s.nodeName.toLowerCase())return void c("No body element found");if(s&&e(s,"createTextRange")&&(t=s.createTextRange(),o(t)&&(r=!0)),!n&&!r)return void c("Neither Range nor TextRange are available");A.initialized=!0,A.features={implementsDomRange:n,implementsTextRange:r};var d,u;for(var l in _)(d=_[l])instanceof h&&d.init(d,A);for(var g=0,p=I.length;p>g;++g)try{I[g](A)}catch(m){u="Rangy init listener threw an exception. Continuing. Detail: "+f(m),a(u)}}}function l(e){e=e||window,u();for(var t=0,n=B.length;n>t;++t)B[t](e)}function h(e,t,n){this.name=e,this.dependencies=t,this.initialized=!1,this.supported=!1,this.initializer=n}function g(e,t,n){var r=new h(e,t,function(t){if(!t.initialized){t.initialized=!0;try{n(A,t),t.supported=!0}catch(r){var o="Module '"+e+"' failed to load: "+f(r);a(o)}}});return _[e]=r,r}function p(){}function m(){}var R="object",v="function",C="undefined",N=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],E=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],S=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],y=["collapse","compareEndPoints","duplicate","moveToElementText","parentElement","select","setEndPoint","getBoundingClientRect"],w=r(e),O=r(t),T=r(n),_={},D=typeof window!=C&&typeof document!=C,x={isHostMethod:e,isHostObject:t,isHostProperty:n,areHostMethods:w,areHostObjects:O,areHostProperties:T,isTextRange:o,getBody:i},A={version:"1.3.0-alpha.20140827",initialized:!1,isBrowser:D,supported:!0,util:x,features:{},modules:_,config:{alertOnFail:!0,alertOnWarn:!1,preferTextRange:!1,autoInitialize:typeof rangyAutoInitialize==C?!0:rangyAutoInitialize}};A.fail=c,A.warn=d;var b;({}).hasOwnProperty?(x.extend=b=function(e,t,n){var r,o;for(var i in t)t.hasOwnProperty(i)&&(r=e[i],o=t[i],n&&null!==r&&"object"==typeof r&&null!==o&&"object"==typeof o&&b(r,o,!0),e[i]=o);return t.hasOwnProperty("toString")&&(e.toString=t.toString),e},x.createOptions=function(e,t){var n={};return b(n,t),e&&b(n,e,!0),n}):c("hasOwnProperty not supported"),D||c("Rangy can only run in a browser"),function(){var e;if(D){var t=document.createElement("div");t.appendChild(document.createElement("span"));var n=[].slice;try{1==n.call(t.childNodes,0)[0].nodeType&&(e=function(e){return n.call(e,0)})}catch(r){}}e||(e=function(e){for(var t=[],n=0,r=e.length;r>n;++n)t[n]=e[n];return t}),x.toArray=e}();var P;D&&(e(document,"addEventListener")?P=function(e,t,n){e.addEventListener(t,n,!1)}:e(document,"attachEvent")?P=function(e,t,n){e.attachEvent("on"+t,n)}:c("Document does not have required addEventListener or attachEvent method"),x.addListener=P);var I=[];A.init=u,A.addInitListener=function(e){A.initialized?e(A):I.push(e)};var B=[];A.addShimListener=function(e){B.push(e)},D&&(A.shim=A.createMissingNativeApi=l),h.prototype={init:function(){for(var e,t,n=this.dependencies||[],r=0,o=n.length;o>r;++r){if(t=n[r],e=_[t],!(e&&e instanceof h))throw new Error("required module '"+t+"' not found");if(e.init(),!e.supported)throw new Error("required module '"+t+"' not supported")}this.initializer(this)},fail:function(e){throw this.initialized=!0,this.supported=!1,new Error("Module '"+this.name+"' failed to load: "+e)},warn:function(e){A.warn("Module "+this.name+": "+e)},deprecationNotice:function(e,t){A.warn("DEPRECATED: "+e+" in module "+this.name+"is deprecated. Please use "+t+" instead")},createError:function(e){return new Error("Error in Rangy "+this.name+" module: "+e)}},A.createModule=function(e){var t,n;2==arguments.length?(t=arguments[1],n=[]):(t=arguments[2],n=arguments[1]);var r=g(e,n,t);A.initialized&&A.supported&&r.init()},A.createCoreModule=function(e,t,n){g(e,t,n)},A.RangePrototype=p,A.rangePrototype=new p,A.selectionPrototype=new m,A.createCoreModule("DomUtil",[],function(e,t){function n(e){var t;return typeof e.namespaceURI==x||null===(t=e.namespaceURI)||"http://www.w3.org/1999/xhtml"==t}function r(e){var t=e.parentNode;return 1==t.nodeType?t:null}function o(e){for(var t=0;e=e.previousSibling;)++t;return t}function i(e){switch(e.nodeType){case 7:case 10:return 0;case 3:case 8:return e.length;default:return e.childNodes.length}}function a(e,t){var n,r=[];for(n=e;n;n=n.parentNode)r.push(n);for(n=t;n;n=n.parentNode)if(I(r,n))return n;return null}function s(e,t,n){for(var r=n?t:t.parentNode;r;){if(r===e)return!0;r=r.parentNode}return!1}function c(e,t){return s(e,t,!0)}function d(e,t,n){for(var r,o=n?e:e.parentNode;o;){if(r=o.parentNode,r===t)return o;o=r}return null}function f(e){var t=e.nodeType;return 3==t||4==t||8==t}function u(e){if(!e)return!1;var t=e.nodeType;return 3==t||8==t}function l(e,t){var n=t.nextSibling,r=t.parentNode;return n?r.insertBefore(e,n):r.appendChild(e),e}function h(e,t,n){var r=e.cloneNode(!1);if(r.deleteData(0,t),e.deleteData(t,e.length-t),l(r,e),n)for(var i,a=0;i=n[a++];)i.node==e&&i.offset>t?(i.node=r,i.offset-=t):i.node==e.parentNode&&i.offset>o(e)&&++i.offset;return r}function g(e){if(9==e.nodeType)return e;if(typeof e.ownerDocument!=x)return e.ownerDocument;if(typeof e.document!=x)return e.document;if(e.parentNode)return g(e.parentNode);throw t.createError("getDocument: no document found for node")}function p(e){var n=g(e);if(typeof n.defaultView!=x)return n.defaultView;if(typeof n.parentWindow!=x)return n.parentWindow;throw t.createError("Cannot get a window object for node")}function m(e){if(typeof e.contentDocument!=x)return e.contentDocument;if(typeof e.contentWindow!=x)return e.contentWindow.document;throw t.createError("getIframeDocument: No Document object found for iframe element")}function R(e){if(typeof e.contentWindow!=x)return e.contentWindow;if(typeof e.contentDocument!=x)return e.contentDocument.defaultView;throw t.createError("getIframeWindow: No Window object found for iframe element")}function v(e){return e&&A.isHostMethod(e,"setTimeout")&&A.isHostObject(e,"document")}function C(e,t,n){var r;if(e?A.isHostProperty(e,"nodeType")?r=1==e.nodeType&&"iframe"==e.tagName.toLowerCase()?m(e):g(e):v(e)&&(r=e.document):r=document,!r)throw t.createError(n+"(): Parameter must be a Window object or DOM node");return r}function N(e){for(var t;t=e.parentNode;)e=t;return e}function E(e,n,r,i){var s,c,f,u,l;if(e==r)return n===i?0:i>n?-1:1;if(s=d(r,e,!0))return n<=o(s)?-1:1;if(s=d(e,r,!0))return o(s)[index:"+o(e)+",length:"+e.childNodes.length+"]["+(e.innerHTML||"[innerHTML not supported]").slice(0,25)+"]"}return e.nodeName}function w(e){for(var t,n=g(e).createDocumentFragment();t=e.firstChild;)n.appendChild(t);return n}function O(e){this.root=e,this._next=e}function T(e){return new O(e)}function _(e,t){this.node=e,this.offset=t}function D(e){this.code=this[e],this.codeName=e,this.message="DOMException: "+this.codeName}var x="undefined",A=e.util;A.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||t.fail("document missing a Node creation method"),A.isHostMethod(document,"getElementsByTagName")||t.fail("document missing getElementsByTagName method");var b=document.createElement("div");A.areHostMethods(b,["insertBefore","appendChild","cloneNode"]||!A.areHostObjects(b,["previousSibling","nextSibling","childNodes","parentNode"]))||t.fail("Incomplete Element implementation"),A.isHostProperty(b,"innerHTML")||t.fail("Element is missing innerHTML property");var P=document.createTextNode("test");A.areHostMethods(P,["splitText","deleteData","insertData","appendData","cloneNode"]||!A.areHostObjects(b,["previousSibling","nextSibling","childNodes","parentNode"])||!A.areHostProperties(P,["data"]))||t.fail("Incomplete Text Node implementation");var I=function(e,t){for(var n=e.length;n--;)if(e[n]===t)return!0;return!1},B=!1;!function(){var t=document.createElement("b");t.innerHTML="1";var n=t.firstChild;t.innerHTML="
",B=S(n),e.features.crashyTextNodes=B}();var H;typeof window.getComputedStyle!=x?H=function(e,t){return p(e).getComputedStyle(e,null)[t]}:typeof document.documentElement.currentStyle!=x?H=function(e,t){return e.currentStyle[t]}:t.fail("No means of obtaining computed style properties found"),O.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var e,t,n=this._current=this._next;if(this._current)if(e=n.firstChild)this._next=e;else{for(t=null;n!==this.root&&!(t=n.nextSibling);)n=n.parentNode;this._next=t}return this._current},detach:function(){this._current=this._next=this.root=null}},_.prototype={equals:function(e){return!!e&&this.node===e.node&&this.offset==e.offset},inspect:function(){return"[DomPosition("+y(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}},D.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,INVALID_NODE_TYPE_ERR:24},D.prototype.toString=function(){return this.message},e.dom={arrayContains:I,isHtmlNamespace:n,parentElement:r,getNodeIndex:o,getNodeLength:i,getCommonAncestor:a,isAncestorOf:s,isOrIsAncestorOf:c,getClosestAncestorIn:d,isCharacterDataNode:f,isTextOrCommentNode:u,insertAfter:l,splitDataNode:h,getDocument:g,getWindow:p,getIframeWindow:R,getIframeDocument:m,getBody:A.getBody,isWindow:v,getContentDocument:C,getRootContainer:N,comparePoints:E,isBrokenNode:S,inspectNode:y,getComputedStyleProperty:H,fragmentFromNodeChildren:w,createIterator:T,DomPosition:_},e.DOMException=D}),A.createCoreModule("DomRange",["DomUtil"],function(e){function t(e,t){return 3!=e.nodeType&&(F(e,t.startContainer)||F(e,t.endContainer))}function n(e){return e.document||j(e.startContainer)}function r(e){return new M(e.parentNode,k(e))}function o(e){return new M(e.parentNode,k(e)+1)}function i(e,t,n){var r=11==e.nodeType?e.firstChild:e;return W(t)?n==t.length?B.insertAfter(e,t):t.parentNode.insertBefore(e,0==n?t:U(t,n)):n>=t.childNodes.length?t.appendChild(e):t.insertBefore(e,t.childNodes[n]),r}function a(e,t,r){if(w(e),w(t),n(t)!=n(e))throw new L("WRONG_DOCUMENT_ERR");var o=z(e.startContainer,e.startOffset,t.endContainer,t.endOffset),i=z(e.endContainer,e.endOffset,t.startContainer,t.startOffset);return r?0>=o&&i>=0:0>o&&i>0}function s(e){for(var t,r,o,i=n(e.range).createDocumentFragment();r=e.next();){if(t=e.isPartiallySelectedSubtree(),r=r.cloneNode(!t),t&&(o=e.getSubtreeIterator(),r.appendChild(s(o)),o.detach()),10==r.nodeType)throw new L("HIERARCHY_REQUEST_ERR");i.appendChild(r)}return i}function c(e,t,n){var r,o;n=n||{stop:!1};for(var i,a;i=e.next();)if(e.isPartiallySelectedSubtree()){if(t(i)===!1)return void(n.stop=!0);if(a=e.getSubtreeIterator(),c(a,t,n),a.detach(),n.stop)return}else for(r=B.createIterator(i);o=r.next();)if(t(o)===!1)return void(n.stop=!0)}function d(e){for(var t;e.next();)e.isPartiallySelectedSubtree()?(t=e.getSubtreeIterator(),d(t),t.detach()):e.remove()}function f(e){for(var t,r,o=n(e.range).createDocumentFragment();t=e.next();){if(e.isPartiallySelectedSubtree()?(t=t.cloneNode(!1),r=e.getSubtreeIterator(),t.appendChild(f(r)),r.detach()):e.remove(),10==t.nodeType)throw new L("HIERARCHY_REQUEST_ERR");o.appendChild(t)}return o}function u(e,t,n){var r,o=!(!t||!t.length),i=!!n;o&&(r=new RegExp("^("+t.join("|")+")$"));var a=[];return c(new h(e,!1),function(t){if(!(o&&!r.test(t.nodeType)||i&&!n(t))){var s=e.startContainer;if(t!=s||!W(s)||e.startOffset!=s.length){var c=e.endContainer;t==c&&W(c)&&0==e.endOffset||a.push(t)}}}),a}function l(e){var t="undefined"==typeof e.getName?"Range":e.getName();return"["+t+"("+B.inspectNode(e.startContainer)+":"+e.startOffset+", "+B.inspectNode(e.endContainer)+":"+e.endOffset+")]"}function h(e,t){if(this.range=e,this.clonePartiallySelectedTextNodes=t,!e.collapsed){this.sc=e.startContainer,this.so=e.startOffset,this.ec=e.endContainer,this.eo=e.endOffset;var n=e.commonAncestorContainer;this.sc===this.ec&&W(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==n||W(this.sc)?V(this.sc,n,!0):this.sc.childNodes[this.so],this._last=this.ec!==n||W(this.ec)?V(this.ec,n,!0):this.ec.childNodes[this.eo-1])}}function g(e){return function(t,n){for(var r,o=n?t:t.parentNode;o;){if(r=o.nodeType,Y(e,r))return o;o=o.parentNode}return null}}function p(e,t){if(nt(e,t))throw new L("INVALID_NODE_TYPE_ERR")}function m(e,t){if(!Y(t,e.nodeType))throw new L("INVALID_NODE_TYPE_ERR")}function R(e,t){if(0>t||t>(W(e)?e.length:e.childNodes.length))throw new L("INDEX_SIZE_ERR")}function v(e,t){if(et(e,!0)!==et(t,!0))throw new L("WRONG_DOCUMENT_ERR")}function C(e){if(tt(e,!0))throw new L("NO_MODIFICATION_ALLOWED_ERR")}function N(e,t){if(!e)throw new L(t)}function E(e){return G&&B.isBrokenNode(e)||!Y(Z,e.nodeType)&&!et(e,!0)}function S(e,t){return t<=(W(e)?e.length:e.childNodes.length)}function y(e){return!!e.startContainer&&!!e.endContainer&&!E(e.startContainer)&&!E(e.endContainer)&&S(e.startContainer,e.startOffset)&&S(e.endContainer,e.endOffset)}function w(e){if(!y(e))throw new Error("Range error: Range is no longer valid after DOM mutation ("+e.inspect()+")")}function O(e,t){w(e);var n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,a=n===o;W(o)&&i>0&&i0&&r=k(n)&&i++,r=0),e.setStartAndEnd(n,r,o,i)}function T(e){w(e);var t=e.commonAncestorContainer.parentNode.cloneNode(!1);return t.appendChild(e.cloneContents()),t.innerHTML}function _(e){e.START_TO_START=ct,e.START_TO_END=dt,e.END_TO_END=ft,e.END_TO_START=ut,e.NODE_BEFORE=lt,e.NODE_AFTER=ht,e.NODE_BEFORE_AND_AFTER=gt,e.NODE_INSIDE=pt}function D(e){_(e),_(e.prototype)}function x(e,t){return function(){w(this);var n,r,i=this.startContainer,a=this.startOffset,s=this.commonAncestorContainer,d=new h(this,!0);i!==s&&(n=V(i,s,!0),r=o(n),i=r.node,a=r.offset),c(d,C),d.reset();var f=e(d);return d.detach(),t(this,i,a,i,a),f}}function A(n,i){function a(e,t){return function(n){m(n,X),m(Q(n),Z);var i=(e?r:o)(n);(t?s:c)(this,i.node,i.offset)}}function s(e,t,n){var r=e.endContainer,o=e.endOffset;(t!==e.startContainer||n!==e.startOffset)&&((Q(t)!=Q(r)||1==z(t,n,r,o))&&(r=t,o=n),i(e,t,n,r,o))}function c(e,t,n){var r=e.startContainer,o=e.startOffset;(t!==e.endContainer||n!==e.endOffset)&&((Q(t)!=Q(r)||-1==z(t,n,r,o))&&(r=t,o=n),i(e,r,o,t,n))}var u=function(){};u.prototype=e.rangePrototype,n.prototype=new u,H.extend(n.prototype,{setStart:function(e,t){p(e,!0),R(e,t),s(this,e,t)},setEnd:function(e,t){p(e,!0),R(e,t),c(this,e,t)},setStartAndEnd:function(){var e=arguments,t=e[0],n=e[1],r=t,o=n;switch(e.length){case 3:o=e[2];break;case 4:r=e[2],o=e[3]}i(this,t,n,r,o)},setBoundary:function(e,t,n){this["set"+(n?"Start":"End")](e,t)},setStartBefore:a(!0,!0),setStartAfter:a(!1,!0),setEndBefore:a(!0,!1),setEndAfter:a(!1,!1),collapse:function(e){w(this),e?i(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):i(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(e){p(e,!0),i(this,e,0,e,q(e))},selectNode:function(e){p(e,!1),m(e,X);var t=r(e),n=o(e);i(this,t.node,t.offset,n.node,n.offset)},extractContents:x(f,i),deleteContents:x(d,i),canSurroundContents:function(){w(this),C(this.startContainer),C(this.endContainer);var e=new h(this,!0),n=e._first&&t(e._first,this)||e._last&&t(e._last,this);return e.detach(),!n},splitBoundaries:function(){O(this)},splitBoundariesPreservingPositions:function(e){O(this,e)},normalizeBoundaries:function(){w(this);var e=this.startContainer,t=this.startOffset,n=this.endContainer,r=this.endOffset,o=function(e){var t=e.nextSibling;t&&t.nodeType==e.nodeType&&(n=e,r=e.length,e.appendData(t.data),t.parentNode.removeChild(t))},a=function(o){var i=o.previousSibling;if(i&&i.nodeType==o.nodeType){e=o;var a=o.length;if(t=i.length,o.insertData(0,i.data),i.parentNode.removeChild(i),e==n)r+=t,n=e;else if(n==o.parentNode){var s=k(o);r==s?(n=o,r=a):r>s&&r--}}},s=!0;if(W(n))n.length==r&&o(n);else{if(r>0){var c=n.childNodes[r-1];c&&W(c)&&o(c)}s=!this.collapsed}if(s){if(W(e))0==t&&a(e);else if(tx",ot=3==rt.firstChild.nodeType}catch(it){}e.features.htmlParsingConforms=ot;var at=ot?function(e){var t=this.startContainer,n=j(t);if(!t)throw new L("INVALID_STATE_ERR");var r=null;return 1==t.nodeType?r=t:W(t)&&(r=B.parentElement(t)),r=null===r||"HTML"==r.nodeName&&B.isHtmlNamespace(j(r).documentElement)&&B.isHtmlNamespace(r)?n.createElement("body"):r.cloneNode(!1),r.innerHTML=e,B.fragmentFromNodeChildren(r)}:function(e){var t=n(this),r=t.createElement("body");return r.innerHTML=e,B.fragmentFromNodeChildren(r)},st=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],ct=0,dt=1,ft=2,ut=3,lt=0,ht=1,gt=2,pt=3;H.extend(e.rangePrototype,{compareBoundaryPoints:function(e,t){w(this),v(this.startContainer,t.startContainer);var n,r,o,i,a=e==ut||e==ct?"start":"end",s=e==dt||e==ct?"start":"end";return n=this[a+"Container"],r=this[a+"Offset"],o=t[s+"Container"],i=t[s+"Offset"],z(n,r,o,i)},insertNode:function(e){if(w(this),m(e,J),C(this.startContainer),F(e,this.startContainer))throw new L("HIERARCHY_REQUEST_ERR");var t=i(e,this.startContainer,this.startOffset);this.setStartBefore(t)},cloneContents:function(){w(this);var e,t;if(this.collapsed)return n(this).createDocumentFragment();if(this.startContainer===this.endContainer&&W(this.startContainer))return e=this.startContainer.cloneNode(!0),e.data=e.data.slice(this.startOffset,this.endOffset),t=n(this).createDocumentFragment(),t.appendChild(e),t;var r=new h(this,!0);return e=s(r),r.detach(),e},canSurroundContents:function(){w(this),C(this.startContainer),C(this.endContainer);var e=new h(this,!0),n=e._first&&t(e._first,this)||e._last&&t(e._last,this);return e.detach(),!n},surroundContents:function(e){if(m(e,K),!this.canSurroundContents())throw new L("INVALID_STATE_ERR");var t=this.extractContents();if(e.hasChildNodes())for(;e.lastChild;)e.removeChild(e.lastChild);i(e,this.startContainer,this.startOffset),e.appendChild(t),this.selectNode(e)},cloneRange:function(){w(this);for(var e,t=new I(n(this)),r=st.length;r--;)e=st[r],t[e]=this[e];return t},toString:function(){w(this);var e=this.startContainer;if(e===this.endContainer&&W(e))return 3==e.nodeType||4==e.nodeType?e.data.slice(this.startOffset,this.endOffset):"";var t=[],n=new h(this,!0);return c(n,function(e){(3==e.nodeType||4==e.nodeType)&&t.push(e.data)}),n.detach(),t.join("")},compareNode:function(e){w(this);var t=e.parentNode,n=k(e);if(!t)throw new L("NOT_FOUND_ERR");var r=this.comparePoint(t,n),o=this.comparePoint(t,n+1);return 0>r?o>0?gt:lt:o>0?ht:pt},comparePoint:function(e,t){return w(this),N(e,"HIERARCHY_REQUEST_ERR"),v(e,this.startContainer),z(e,t,this.startContainer,this.startOffset)<0?-1:z(e,t,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:at,toHtml:function(){return T(this)},intersectsNode:function(e,t){if(w(this),N(e,"NOT_FOUND_ERR"),j(e)!==n(this))return!1;var r=e.parentNode,o=k(e);N(r,"NOT_FOUND_ERR");var i=z(r,o,this.endContainer,this.endOffset),a=z(r,o+1,this.startContainer,this.startOffset);return t?0>=i&&a>=0:0>i&&a>0},isPointInRange:function(e,t){return w(this),N(e,"HIERARCHY_REQUEST_ERR"),v(e,this.startContainer),z(e,t,this.startContainer,this.startOffset)>=0&&z(e,t,this.endContainer,this.endOffset)<=0},intersectsRange:function(e){return a(this,e,!1)},intersectsOrTouchesRange:function(e){return a(this,e,!0)},intersection:function(e){if(this.intersectsRange(e)){var t=z(this.startContainer,this.startOffset,e.startContainer,e.startOffset),n=z(this.endContainer,this.endOffset,e.endContainer,e.endOffset),r=this.cloneRange();return-1==t&&r.setStart(e.startContainer,e.startOffset),1==n&&r.setEnd(e.endContainer,e.endOffset),r}return null},union:function(e){if(this.intersectsOrTouchesRange(e)){var t=this.cloneRange();return-1==z(e.startContainer,e.startOffset,this.startContainer,this.startOffset)&&t.setStart(e.startContainer,e.startOffset),1==z(e.endContainer,e.endOffset,this.endContainer,this.endOffset)&&t.setEnd(e.endContainer,e.endOffset),t}throw new L("Ranges do not intersect")},containsNode:function(e,t){return t?this.intersectsNode(e,!1):this.compareNode(e)==pt},containsNodeContents:function(e){return this.comparePoint(e,0)>=0&&this.comparePoint(e,q(e))<=0},containsRange:function(e){var t=this.intersection(e);return null!==t&&e.equals(t)},containsNodeText:function(e){var t=this.cloneRange();t.selectNode(e);var n=t.getNodes([3]);if(n.length>0){t.setStart(n[0],0);var r=n.pop();return t.setEnd(r,r.length),this.containsRange(t)}return this.containsNodeContents(e)},getNodes:function(e,t){return w(this),u(this,e,t)},getDocument:function(){return n(this)},collapseBefore:function(e){this.setEndBefore(e),this.collapse(!1)},collapseAfter:function(e){this.setStartAfter(e),this.collapse(!0)},getBookmark:function(t){var r=n(this),o=e.createRange(r);t=t||B.getBody(r),o.selectNodeContents(t);var i=this.intersection(o),a=0,s=0;return i&&(o.setEnd(i.startContainer,i.startOffset),a=o.toString().length,s=a+i.toString().length),{start:a,end:s,containerNode:t}},moveToBookmark:function(e){var t=e.containerNode,n=0;this.setStart(t,0),this.collapse(!0);for(var r,o,i,a,s=[t],c=!1,d=!1;!d&&(r=s.pop());)if(3==r.nodeType)o=n+r.length,!c&&e.start>=n&&e.start<=o&&(this.setStart(r,e.start-n),c=!0),c&&e.end>=n&&e.end<=o&&(this.setEnd(r,e.end-n),d=!0),n=o;else for(a=r.childNodes,i=a.length;i--;)s.push(a[i])},getName:function(){return"DomRange"},equals:function(e){return I.rangesEqual(this,e)},isValid:function(){return y(this)},inspect:function(){return l(this)},detach:function(){}}),A(I,P),H.extend(I,{rangeProperties:st,RangeIterator:h,copyComparisonConstants:D,createPrototypeRange:A,inspect:l,toHtml:T,getRangeDocument:n,rangesEqual:function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset}}),e.DomRange=I}),A.createCoreModule("WrappedRange",["DomRange"],function(e,t){var n,r,o=e.dom,i=e.util,a=o.DomPosition,s=e.DomRange,c=o.getBody,d=o.getContentDocument,f=o.isCharacterDataNode;if(e.features.implementsDomRange&&!function(){function r(e){for(var t,n=l.length;n--;)t=l[n],e[t]=e.nativeRange[t];e.collapsed=e.startContainer===e.endContainer&&e.startOffset===e.endOffset}function a(e,t,n,r,o){var i=e.startContainer!==t||e.startOffset!=n,a=e.endContainer!==r||e.endOffset!=o,s=!e.equals(e.nativeRange);(i||a||s)&&(e.setEnd(r,o),e.setStart(t,n))}var f,u,l=s.rangeProperties;n=function(e){if(!e)throw t.createError("WrappedRange: Range must be specified");this.nativeRange=e,r(this)},s.createPrototypeRange(n,a),f=n.prototype,f.selectNode=function(e){this.nativeRange.selectNode(e),r(this)},f.cloneContents=function(){return this.nativeRange.cloneContents()},f.surroundContents=function(e){this.nativeRange.surroundContents(e),r(this)},f.collapse=function(e){this.nativeRange.collapse(e),r(this)},f.cloneRange=function(){return new n(this.nativeRange.cloneRange())},f.refresh=function(){r(this)},f.toString=function(){return this.nativeRange.toString()};var h=document.createTextNode("test");c(document).appendChild(h);var g=document.createRange();g.setStart(h,0),g.setEnd(h,0);try{g.setStart(h,1),f.setStart=function(e,t){this.nativeRange.setStart(e,t),r(this)},f.setEnd=function(e,t){this.nativeRange.setEnd(e,t),r(this)},u=function(e){return function(t){this.nativeRange[e](t),r(this)}}}catch(p){f.setStart=function(e,t){try{this.nativeRange.setStart(e,t)}catch(n){this.nativeRange.setEnd(e,t),this.nativeRange.setStart(e,t)}r(this)},f.setEnd=function(e,t){try{this.nativeRange.setEnd(e,t)}catch(n){this.nativeRange.setStart(e,t),this.nativeRange.setEnd(e,t)}r(this)},u=function(e,t){return function(n){try{this.nativeRange[e](n)}catch(o){this.nativeRange[t](n),this.nativeRange[e](n)}r(this)}}}f.setStartBefore=u("setStartBefore","setEndBefore"),f.setStartAfter=u("setStartAfter","setEndAfter"),f.setEndBefore=u("setEndBefore","setStartBefore"),f.setEndAfter=u("setEndAfter","setStartAfter"),f.selectNodeContents=function(e){this.setStartAndEnd(e,0,o.getNodeLength(e))},g.selectNodeContents(h),g.setEnd(h,3);var m=document.createRange();m.selectNodeContents(h),m.setEnd(h,4),m.setStart(h,2),f.compareBoundaryPoints=-1==g.compareBoundaryPoints(g.START_TO_END,m)&&1==g.compareBoundaryPoints(g.END_TO_START,m)?function(e,t){return t=t.nativeRange||t,e==t.START_TO_END?e=t.END_TO_START:e==t.END_TO_START&&(e=t.START_TO_END),this.nativeRange.compareBoundaryPoints(e,t)}:function(e,t){return this.nativeRange.compareBoundaryPoints(e,t.nativeRange||t)};var R=document.createElement("div");R.innerHTML="123";var v=R.firstChild,C=c(document);C.appendChild(R),g.setStart(v,1),g.setEnd(v,2),g.deleteContents(),"13"==v.data&&(f.deleteContents=function(){this.nativeRange.deleteContents(),r(this)},f.extractContents=function(){var e=this.nativeRange.extractContents();return r(this),e}),C.removeChild(R),C=null,i.isHostMethod(g,"createContextualFragment")&&(f.createContextualFragment=function(e){return this.nativeRange.createContextualFragment(e)}),c(document).removeChild(h),f.getName=function(){return"WrappedRange"},e.WrappedRange=n,e.createNativeRange=function(e){return e=d(e,t,"createNativeRange"),e.createRange()}}(),e.features.implementsTextRange){var u=function(e){var t=e.parentElement(),n=e.duplicate();n.collapse(!0);var r=n.parentElement();n=e.duplicate(),n.collapse(!1);var i=n.parentElement(),a=r==i?r:o.getCommonAncestor(r,i);return a==t?a:o.getCommonAncestor(t,a)},l=function(e){return 0==e.compareEndPoints("StartToEnd",e)},h=function(e,t,n,r,i){var s=e.duplicate();s.collapse(n);var c=s.parentElement();if(o.isOrIsAncestorOf(t,c)||(c=t),!c.canHaveHTML){var d=new a(c.parentNode,o.getNodeIndex(c));return{boundaryPosition:d,nodeInfo:{nodeIndex:d.offset,containerElement:d.node}}}var u=o.getDocument(c).createElement("span");u.parentNode&&u.parentNode.removeChild(u);for(var l,h,g,p,m,R=n?"StartToStart":"StartToEnd",v=i&&i.containerElement==c?i.nodeIndex:0,C=c.childNodes.length,N=C,E=N;;){if(E==C?c.appendChild(u):c.insertBefore(u,c.childNodes[E]),s.moveToElementText(u),l=s.compareEndPoints(R,e),0==l||v==N)break;if(-1==l){if(N==v+1)break;v=E}else N=N==v+1?v:E;E=Math.floor((v+N)/2),c.removeChild(u)}if(m=u.nextSibling,-1==l&&m&&f(m)){s.setEndPoint(n?"EndToStart":"EndToEnd",e);var S;if(/[\r\n]/.test(m.data)){var y=s.duplicate(),w=y.text.replace(/\r\n/g,"\r").length;for(S=y.moveStart("character",w);-1==(l=y.compareEndPoints("StartToEnd",y));)S++,y.moveStart("character",1)}else S=s.text.length;p=new a(m,S)}else h=(r||!n)&&u.previousSibling,g=(r||n)&&u.nextSibling,p=g&&f(g)?new a(g,0):h&&f(h)?new a(h,h.data.length):new a(c,o.getNodeIndex(u));return u.parentNode.removeChild(u),{boundaryPosition:p,nodeInfo:{nodeIndex:E,containerElement:c}}},g=function(e,t){var n,r,i,a,s=e.offset,d=o.getDocument(e.node),u=c(d).createTextRange(),l=f(e.node);return l?(n=e.node,r=n.parentNode):(a=e.node.childNodes,n=st;++t)if(!D.isAncestorOf(e[0],e[t]))return!1;return!0}function l(e){var n=e.getNodes();if(!u(n))throw t.createError("getSingleElementFromRange: range "+e.inspect()+" did not consist of a single element");return n[0]}function h(e){return!!e&&"undefined"!=typeof e.text}function g(e,t){var n=new P(t);e._ranges=[n],s(e,n,!1),e.rangeCount=1,e.isCollapsed=n.collapsed}function p(t){if(t._ranges.length=0,"None"==t.docSelection.type)d(t);else{var n=t.docSelection.createRange();if(h(n))g(t,n);else{t.rangeCount=n.length;for(var r,o=L(n.item(0)),i=0;is;++s)a.add(r.item(s));try{a.add(o)}catch(d){throw t.createError("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}a.select(),p(e)}function R(e,t,n){this.nativeSelection=e,this.docSelection=t,this._ranges=[],this.win=n,this.refresh()}function v(e){e.win=e.anchorNode=e.focusNode=e._ranges=null,e.rangeCount=e.anchorOffset=e.focusOffset=0,e.detached=!0}function C(e,t){for(var n,r,o=tt.length;o--;)if(n=tt[o],r=n.selection,"deleteAll"==t)v(r);else if(n.win==e)return"delete"==t?(tt.splice(o,1),!0):r;return"deleteAll"==t&&(tt.length=0),null}function N(e,n){for(var r,o=L(n[0].startContainer),i=W(o).createControlRange(),a=0,s=n.length;s>a;++a){r=l(n[a]);try{i.add(r)}catch(c){throw t.createError("setRanges(): Element within one of the specified Ranges could not be added to control selection (does it have layout?)")}}i.select(),p(e)}function E(e,t){if(e.win.document!=L(t))throw new I("WRONG_DOCUMENT_ERR")}function S(t){return function(n,r){var o;this.rangeCount?(o=this.getRangeAt(0),o["set"+(t?"Start":"End")](n,r)):(o=e.createRange(this.win.document),o.setStartAndEnd(n,r)),this.setSingleRange(o,this.isBackward())}}function y(e){var t=[],n=new B(e.anchorNode,e.anchorOffset),r=new B(e.focusNode,e.focusOffset),o="function"==typeof e.getName?e.getName():"Selection";if("undefined"!=typeof e.rangeCount)for(var i=0,a=e.rangeCount;a>i;++i)t[i]=b.inspect(e.getRangeAt(i));return"["+o+"(Ranges: "+t.join(", ")+")(anchor: "+n.inspect()+", focus: "+r.inspect()+"]"}e.config.checkSelectionRanges=!0;var w,O,T="boolean",_="number",D=e.dom,x=e.util,A=x.isHostMethod,b=e.DomRange,P=e.WrappedRange,I=e.DOMException,B=D.DomPosition,H=e.features,M="Control",L=D.getDocument,W=D.getBody,k=b.rangesEqual,F=A(window,"getSelection"),j=x.isHostObject(document,"selection");H.implementsWinGetSelection=F,H.implementsDocSelection=j;var z=j&&(!F||e.config.preferTextRange);z?(w=i,e.isSelectionValid=function(e){var t=r(e,"isSelectionValid").document,n=t.selection;return"None"!=n.type||L(n.createRange().parentElement())==t}):F?(w=o,e.isSelectionValid=function(){return!0}):t.fail("Neither document.selection or window.getSelection() detected."),e.getNativeSelection=w;var U=w(),V=e.createNativeRange(document),q=W(document),Y=x.areHostProperties(U,["anchorNode","focusNode","anchorOffset","focusOffset"]);H.selectionHasAnchorAndFocus=Y;var Q=A(U,"extend");H.selectionHasExtend=Q;var G=typeof U.rangeCount==_;H.selectionHasRangeCount=G;var X=!1,Z=!0,$=Q?function(t,n){var r=b.getRangeDocument(n),o=e.createRange(r);o.collapseToPoint(n.endContainer,n.endOffset),t.addRange(f(o)),t.extend(n.startContainer,n.startOffset)}:null;x.areHostMethods(U,["addRange","getRangeAt","removeAllRanges"])&&typeof U.rangeCount==_&&H.implementsDomRange&&!function(){var t=window.getSelection();if(t){for(var n=t.rangeCount,r=n>1,o=[],i=a(t),s=0;n>s;++s)o[s]=t.getRangeAt(s);var c=W(document),d=c.appendChild(document.createElement("div"));d.contentEditable="false";var f=d.appendChild(document.createTextNode("   ")),u=document.createRange();if(u.setStart(f,1),u.collapse(!0),t.addRange(u),Z=1==t.rangeCount,t.removeAllRanges(),!r){var l=window.navigator.appVersion.match(/Chrome\/(.*?) /);if(l&&parseInt(l[1])>=36)X=!1;else{var h=u.cloneRange();u.setStart(f,0),h.setEnd(f,3),h.setStart(f,2),t.addRange(u),t.addRange(h),X=2==t.rangeCount}}for(c.removeChild(d),t.removeAllRanges(),s=0;n>s;++s)0==s&&i?$?$(t,o[s]):(e.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because the browser does not support Selection.extend"),t.addRange(o[s])):t.addRange(o[s])}}(),H.selectionSupportsMultipleRanges=X,H.collapsedNonEditableSelectionsSupported=Z;var J,K=!1;q&&A(q,"createControlRange")&&(J=q.createControlRange(),x.areHostProperties(J,["item","add"])&&(K=!0)),H.implementsControlRange=K,O=Y?function(e){return e.anchorNode===e.focusNode&&e.anchorOffset===e.focusOffset}:function(e){return e.rangeCount?e.getRangeAt(e.rangeCount-1).collapsed:!1};var et;A(U,"getRangeAt")?et=function(e,t){try{return e.getRangeAt(t)}catch(n){return null}}:Y&&(et=function(t){var n=L(t.anchorNode),r=e.createRange(n);return r.setStartAndEnd(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset),r.collapsed!==this.isCollapsed&&r.setStartAndEnd(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset),r}),R.prototype=e.selectionPrototype;var tt=[],nt=function(e){if(e&&e instanceof R)return e.refresh(),e;e=r(e,"getNativeSelection");var t=C(e),n=w(e),o=j?i(e):null;return t?(t.nativeSelection=n,t.docSelection=o,t.refresh()):(t=new R(n,o,e),tt.push({win:e,selection:t})),t};e.getSelection=nt,e.getIframeSelection=function(n){return t.deprecationNotice("getIframeSelection()","getSelection(iframeEl)"),e.getSelection(D.getIframeWindow(n))};var rt=R.prototype;if(!z&&Y&&x.areHostMethods(U,["removeAllRanges","addRange"])){rt.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),d(this)};var ot=function(e,t){$(e.nativeSelection,t),e.refresh()};rt.addRange=G?function(t,r){if(K&&j&&this.docSelection.type==M)m(this,t);else if(n(r)&&Q)ot(this,t);else{var o;X?o=this.rangeCount:(this.removeAllRanges(),o=0);var i=f(t).cloneRange();try{this.nativeSelection.addRange(i)}catch(a){}if(this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==o+1){if(e.config.checkSelectionRanges){var c=et(this.nativeSelection,this.rangeCount-1);c&&!k(c,t)&&(t=new P(c))}this._ranges[this.rangeCount-1]=t,s(this,t,st(this.nativeSelection)),this.isCollapsed=O(this)}else this.refresh()}}:function(e,t){n(t)&&Q?ot(this,e):(this.nativeSelection.addRange(f(e)),this.refresh())},rt.setRanges=function(e){if(K&&j&&e.length>1)N(this,e);else{this.removeAllRanges();for(var t=0,n=e.length;n>t;++t)this.addRange(e[t])}}}else{if(!(A(U,"empty")&&A(V,"select")&&K&&z))return t.fail("No means of selecting a Range or TextRange was found"),!1;rt.removeAllRanges=function(){try{if(this.docSelection.empty(),"None"!=this.docSelection.type){var e;if(this.anchorNode)e=L(this.anchorNode);else if(this.docSelection.type==M){var t=this.docSelection.createRange();t.length&&(e=L(t.item(0)))}if(e){var n=W(e).createTextRange();n.select(),this.docSelection.empty()}}}catch(r){}d(this)},rt.addRange=function(t){this.docSelection.type==M?m(this,t):(e.WrappedTextRange.rangeToTextRange(t).select(),this._ranges[0]=t,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,s(this,t,!1))},rt.setRanges=function(e){this.removeAllRanges();var t=e.length;t>1?N(this,e):t&&this.addRange(e[0])}}rt.getRangeAt=function(e){if(0>e||e>=this.rangeCount)throw new I("INDEX_SIZE_ERR");return this._ranges[e].cloneRange()};var it;if(z)it=function(t){var n;e.isSelectionValid(t.win)?n=t.docSelection.createRange():(n=W(t.win.document).createTextRange(),n.collapse(!0)),t.docSelection.type==M?p(t):h(n)?g(t,n):d(t)};else if(A(U,"getRangeAt")&&typeof U.rangeCount==_)it=function(t){if(K&&j&&t.docSelection.type==M)p(t);else if(t._ranges.length=t.rangeCount=t.nativeSelection.rangeCount,t.rangeCount){for(var n=0,r=t.rangeCount;r>n;++n)t._ranges[n]=new e.WrappedRange(t.nativeSelection.getRangeAt(n));s(t,t._ranges[t.rangeCount-1],st(t.nativeSelection)),t.isCollapsed=O(t)}else d(t)};else{if(!Y||typeof U.isCollapsed!=T||typeof V.collapsed!=T||!H.implementsDomRange)return t.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;it=function(e){var t,n=e.nativeSelection;n.anchorNode?(t=et(n,0),e._ranges=[t],e.rangeCount=1,c(e),e.isCollapsed=O(e)):d(e)}}rt.refresh=function(e){var t=e?this._ranges.slice(0):null,n=this.anchorNode,r=this.anchorOffset;if(it(this),e){var o=t.length;if(o!=this._ranges.length)return!0;if(this.anchorNode!=n||this.anchorOffset!=r)return!0;for(;o--;)if(!k(t[o],this._ranges[o]))return!0;return!1}};var at=function(e,t){var n=e.getAllRanges();e.removeAllRanges();for(var r=0,o=n.length;o>r;++r)k(t,n[r])||e.addRange(n[r]);e.rangeCount||d(e)};rt.removeRange=K&&j?function(e){if(this.docSelection.type==M){for(var t,n=this.docSelection.createRange(),r=l(e),o=L(n.item(0)),i=W(o).createControlRange(),a=!1,s=0,c=n.length;c>s;++s)t=n.item(s),t!==r||a?i.add(n.item(s)):a=!0;i.select(),p(this)}else at(this,e)}:function(e){at(this,e)};var st;!z&&Y&&H.implementsDomRange?(st=a,rt.isBackward=function(){return st(this)}):st=rt.isBackward=function(){return!1},rt.isBackwards=rt.isBackward,rt.toString=function(){for(var e=[],t=0,n=this.rangeCount;n>t;++t)e[t]=""+this._ranges[t];return e.join("")},rt.collapse=function(t,n){E(this,t);var r=e.createRange(t);r.collapseToPoint(t,n),this.setSingleRange(r),this.isCollapsed=!0},rt.collapseToStart=function(){if(!this.rangeCount)throw new I("INVALID_STATE_ERR");var e=this._ranges[0];this.collapse(e.startContainer,e.startOffset)},rt.collapseToEnd=function(){if(!this.rangeCount)throw new I("INVALID_STATE_ERR");var e=this._ranges[this.rangeCount-1];this.collapse(e.endContainer,e.endOffset)},rt.selectAllChildren=function(t){E(this,t);var n=e.createRange(t);n.selectNodeContents(t),this.setSingleRange(n)},rt.deleteFromDocument=function(){if(K&&j&&this.docSelection.type==M){for(var e,t=this.docSelection.createRange();t.length;)e=t.item(0),t.remove(e),e.parentNode.removeChild(e);this.refresh()}else if(this.rangeCount){var n=this.getAllRanges();if(n.length){this.removeAllRanges();for(var r=0,o=n.length;o>r;++r)n[r].deleteContents();this.addRange(n[o-1])}}},rt.eachRange=function(e,t){for(var n=0,r=this._ranges.length;r>n;++n)if(e(this.getRangeAt(n)))return t},rt.getAllRanges=function(){var e=[];return this.eachRange(function(t){e.push(t)}),e},rt.setSingleRange=function(e,t){this.removeAllRanges(),this.addRange(e,t)},rt.callMethodOnEachRange=function(e,t){var n=[];return this.eachRange(function(r){n.push(r[e].apply(r,t))}),n},rt.setStart=S(!0),rt.setEnd=S(!1),e.rangePrototype.select=function(e){nt(this.getDocument()).setSingleRange(this,e)},rt.changeEachRange=function(e){var t=[],n=this.isBackward();this.eachRange(function(n){e(n),t.push(n)}),this.removeAllRanges(),n&&1==t.length?this.addRange(t[0],"backward"):this.setRanges(t)},rt.containsNode=function(e,t){return this.eachRange(function(n){return n.containsNode(e,t)},!0)||!1},rt.getBookmark=function(e){return{backward:this.isBackward(),rangeBookmarks:this.callMethodOnEachRange("getBookmark",[e])}},rt.moveToBookmark=function(t){for(var n,r,o=[],i=0;n=t.rangeBookmarks[i++];)r=e.createRange(this.win),r.moveToBookmark(n),o.push(r);t.backward?this.setSingleRange(o[0],"backward"):this.setRanges(o)},rt.toHtml=function(){var e=[];return this.eachRange(function(t){e.push(b.toHtml(t))}),e.join("")},H.implementsTextRange&&(rt.getNativeTextRange=function(){var n;if(n=this.docSelection){var r=n.createRange();if(h(r))return r;throw t.createError("getNativeTextRange: selection is a control selection")}if(this.rangeCount>0)return e.WrappedTextRange.rangeToTextRange(this.getRangeAt(0));throw t.createError("getNativeTextRange: selection contains no range")}),rt.getName=function(){return"WrappedSelection"},rt.inspect=function(){return y(this)},rt.detach=function(){C(this.win,"delete"),v(this)},R.detachAll=function(){C(null,"deleteAll")},R.inspect=y,R.isDirectionBackward=n,e.Selection=R,e.selectionPrototype=rt,e.addShimListener(function(e){"undefined"==typeof e.getSelection&&(e.getSelection=function(){return nt(e)}),e=null})});var H=!1,M=function(){H||(H=!0,!A.initialized&&A.config.autoInitialize&&u())};return D&&(/^(?:complete|interactive)$/.test(document.readyState)?M():(e(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",M,!1),P(window,"load",M))),A},this); \ No newline at end of file +!function(e,t){"function"==typeof define&&define.amd?define(e):"undefined"!=typeof module&&"object"==typeof exports?module.exports=e():t.rangy=e()}(function(){function e(e,t){var n=typeof e[t];return n==v||!(n!=R||!e[t])||"unknown"==n}function t(e,t){return!(typeof e[t]!=R||!e[t])}function n(e,t){return typeof e[t]!=C}function r(e){return function(t,n){for(var r=n.length;r--;)if(!e(t,n[r]))return!1;return!0}}function o(e){return e&&w(e,y)&&T(e,S)}function i(e){return t(e,"body")?e.body:e.getElementsByTagName("body")[0]}function a(t){typeof console!=C&&e(console,"log")&&console.log(t)}function s(e,t){D&&t?alert(e):a(e)}function c(e){A.initialized=!0,A.supported=!1,s("Rangy is not supported in this environment. Reason: "+e,A.config.alertOnFail)}function d(e){s("Rangy warning: "+e,A.config.alertOnWarn)}function f(e){return e.message||e.description||String(e)}function u(){if(D&&!A.initialized){var t,n=!1,r=!1;e(document,"createRange")&&(t=document.createRange(),w(t,E)&&T(t,N)&&(n=!0));var s=i(document);if(!s||"body"!=s.nodeName.toLowerCase())return void c("No body element found");if(s&&e(s,"createTextRange")&&(t=s.createTextRange(),o(t)&&(r=!0)),!n&&!r)return void c("Neither Range nor TextRange are available");A.initialized=!0,A.features={implementsDomRange:n,implementsTextRange:r};var d,u;for(var l in _)(d=_[l])instanceof h&&d.init(d,A);for(var g=0,p=I.length;p>g;++g)try{I[g](A)}catch(m){u="Rangy init listener threw an exception. Continuing. Detail: "+f(m),a(u)}}}function l(e){e=e||window,u();for(var t=0,n=B.length;n>t;++t)B[t](e)}function h(e,t,n){this.name=e,this.dependencies=t,this.initialized=!1,this.supported=!1,this.initializer=n}function g(e,t,n){var r=new h(e,t,function(t){if(!t.initialized){t.initialized=!0;try{n(A,t),t.supported=!0}catch(r){var o="Module '"+e+"' failed to load: "+f(r);a(o),r.stack&&a(r.stack)}}});return _[e]=r,r}function p(){}function m(){}var R="object",v="function",C="undefined",N=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],E=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],S=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],y=["collapse","compareEndPoints","duplicate","moveToElementText","parentElement","select","setEndPoint","getBoundingClientRect"],w=r(e),O=r(t),T=r(n),_={},D=typeof window!=C&&typeof document!=C,x={isHostMethod:e,isHostObject:t,isHostProperty:n,areHostMethods:w,areHostObjects:O,areHostProperties:T,isTextRange:o,getBody:i},A={version:"1.3.0-alpha.20140921",initialized:!1,isBrowser:D,supported:!0,util:x,features:{},modules:_,config:{alertOnFail:!0,alertOnWarn:!1,preferTextRange:!1,autoInitialize:typeof rangyAutoInitialize==C?!0:rangyAutoInitialize}};A.fail=c,A.warn=d;var b;({}).hasOwnProperty?(x.extend=b=function(e,t,n){var r,o;for(var i in t)t.hasOwnProperty(i)&&(r=e[i],o=t[i],n&&null!==r&&"object"==typeof r&&null!==o&&"object"==typeof o&&b(r,o,!0),e[i]=o);return t.hasOwnProperty("toString")&&(e.toString=t.toString),e},x.createOptions=function(e,t){var n={};return b(n,t),e&&b(n,e),n}):c("hasOwnProperty not supported"),D||c("Rangy can only run in a browser"),function(){var e;if(D){var t=document.createElement("div");t.appendChild(document.createElement("span"));var n=[].slice;try{1==n.call(t.childNodes,0)[0].nodeType&&(e=function(e){return n.call(e,0)})}catch(r){}}e||(e=function(e){for(var t=[],n=0,r=e.length;r>n;++n)t[n]=e[n];return t}),x.toArray=e}();var P;D&&(e(document,"addEventListener")?P=function(e,t,n){e.addEventListener(t,n,!1)}:e(document,"attachEvent")?P=function(e,t,n){e.attachEvent("on"+t,n)}:c("Document does not have required addEventListener or attachEvent method"),x.addListener=P);var I=[];A.init=u,A.addInitListener=function(e){A.initialized?e(A):I.push(e)};var B=[];A.addShimListener=function(e){B.push(e)},D&&(A.shim=A.createMissingNativeApi=l),h.prototype={init:function(){for(var e,t,n=this.dependencies||[],r=0,o=n.length;o>r;++r){if(t=n[r],e=_[t],!(e&&e instanceof h))throw new Error("required module '"+t+"' not found");if(e.init(),!e.supported)throw new Error("required module '"+t+"' not supported")}this.initializer(this)},fail:function(e){throw this.initialized=!0,this.supported=!1,new Error("Module '"+this.name+"' failed to load: "+e)},warn:function(e){A.warn("Module "+this.name+": "+e)},deprecationNotice:function(e,t){A.warn("DEPRECATED: "+e+" in module "+this.name+"is deprecated. Please use "+t+" instead")},createError:function(e){return new Error("Error in Rangy "+this.name+" module: "+e)}},A.createModule=function(e){var t,n;2==arguments.length?(t=arguments[1],n=[]):(t=arguments[2],n=arguments[1]);var r=g(e,n,t);A.initialized&&A.supported&&r.init()},A.createCoreModule=function(e,t,n){g(e,t,n)},A.RangePrototype=p,A.rangePrototype=new p,A.selectionPrototype=new m,A.createCoreModule("DomUtil",[],function(e,t){function n(e){var t;return typeof e.namespaceURI==x||null===(t=e.namespaceURI)||"http://www.w3.org/1999/xhtml"==t}function r(e){var t=e.parentNode;return 1==t.nodeType?t:null}function o(e){for(var t=0;e=e.previousSibling;)++t;return t}function i(e){switch(e.nodeType){case 7:case 10:return 0;case 3:case 8:return e.length;default:return e.childNodes.length}}function a(e,t){var n,r=[];for(n=e;n;n=n.parentNode)r.push(n);for(n=t;n;n=n.parentNode)if(I(r,n))return n;return null}function s(e,t,n){for(var r=n?t:t.parentNode;r;){if(r===e)return!0;r=r.parentNode}return!1}function c(e,t){return s(e,t,!0)}function d(e,t,n){for(var r,o=n?e:e.parentNode;o;){if(r=o.parentNode,r===t)return o;o=r}return null}function f(e){var t=e.nodeType;return 3==t||4==t||8==t}function u(e){if(!e)return!1;var t=e.nodeType;return 3==t||8==t}function l(e,t){var n=t.nextSibling,r=t.parentNode;return n?r.insertBefore(e,n):r.appendChild(e),e}function h(e,t,n){var r=e.cloneNode(!1);if(r.deleteData(0,t),e.deleteData(t,e.length-t),l(r,e),n)for(var i,a=0;i=n[a++];)i.node==e&&i.offset>t?(i.node=r,i.offset-=t):i.node==e.parentNode&&i.offset>o(e)&&++i.offset;return r}function g(e){if(9==e.nodeType)return e;if(typeof e.ownerDocument!=x)return e.ownerDocument;if(typeof e.document!=x)return e.document;if(e.parentNode)return g(e.parentNode);throw t.createError("getDocument: no document found for node")}function p(e){var n=g(e);if(typeof n.defaultView!=x)return n.defaultView;if(typeof n.parentWindow!=x)return n.parentWindow;throw t.createError("Cannot get a window object for node")}function m(e){if(typeof e.contentDocument!=x)return e.contentDocument;if(typeof e.contentWindow!=x)return e.contentWindow.document;throw t.createError("getIframeDocument: No Document object found for iframe element")}function R(e){if(typeof e.contentWindow!=x)return e.contentWindow;if(typeof e.contentDocument!=x)return e.contentDocument.defaultView;throw t.createError("getIframeWindow: No Window object found for iframe element")}function v(e){return e&&A.isHostMethod(e,"setTimeout")&&A.isHostObject(e,"document")}function C(e,t,n){var r;if(e?A.isHostProperty(e,"nodeType")?r=1==e.nodeType&&"iframe"==e.tagName.toLowerCase()?m(e):g(e):v(e)&&(r=e.document):r=document,!r)throw t.createError(n+"(): Parameter must be a Window object or DOM node");return r}function N(e){for(var t;t=e.parentNode;)e=t;return e}function E(e,n,r,i){var s,c,f,u,l;if(e==r)return n===i?0:i>n?-1:1;if(s=d(r,e,!0))return n<=o(s)?-1:1;if(s=d(e,r,!0))return o(s)[index:"+o(e)+",length:"+e.childNodes.length+"]["+(e.innerHTML||"[innerHTML not supported]").slice(0,25)+"]"}return e.nodeName}function w(e){for(var t,n=g(e).createDocumentFragment();t=e.firstChild;)n.appendChild(t);return n}function O(e){this.root=e,this._next=e}function T(e){return new O(e)}function _(e,t){this.node=e,this.offset=t}function D(e){this.code=this[e],this.codeName=e,this.message="DOMException: "+this.codeName}var x="undefined",A=e.util;A.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||t.fail("document missing a Node creation method"),A.isHostMethod(document,"getElementsByTagName")||t.fail("document missing getElementsByTagName method");var b=document.createElement("div");A.areHostMethods(b,["insertBefore","appendChild","cloneNode"]||!A.areHostObjects(b,["previousSibling","nextSibling","childNodes","parentNode"]))||t.fail("Incomplete Element implementation"),A.isHostProperty(b,"innerHTML")||t.fail("Element is missing innerHTML property");var P=document.createTextNode("test");A.areHostMethods(P,["splitText","deleteData","insertData","appendData","cloneNode"]||!A.areHostObjects(b,["previousSibling","nextSibling","childNodes","parentNode"])||!A.areHostProperties(P,["data"]))||t.fail("Incomplete Text Node implementation");var I=function(e,t){for(var n=e.length;n--;)if(e[n]===t)return!0;return!1},B=!1;!function(){var t=document.createElement("b");t.innerHTML="1";var n=t.firstChild;t.innerHTML="
",B=S(n),e.features.crashyTextNodes=B}();var H;typeof window.getComputedStyle!=x?H=function(e,t){return p(e).getComputedStyle(e,null)[t]}:typeof document.documentElement.currentStyle!=x?H=function(e,t){return e.currentStyle[t]}:t.fail("No means of obtaining computed style properties found"),O.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var e,t,n=this._current=this._next;if(this._current)if(e=n.firstChild)this._next=e;else{for(t=null;n!==this.root&&!(t=n.nextSibling);)n=n.parentNode;this._next=t}return this._current},detach:function(){this._current=this._next=this.root=null}},_.prototype={equals:function(e){return!!e&&this.node===e.node&&this.offset==e.offset},inspect:function(){return"[DomPosition("+y(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}},D.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,INVALID_NODE_TYPE_ERR:24},D.prototype.toString=function(){return this.message},e.dom={arrayContains:I,isHtmlNamespace:n,parentElement:r,getNodeIndex:o,getNodeLength:i,getCommonAncestor:a,isAncestorOf:s,isOrIsAncestorOf:c,getClosestAncestorIn:d,isCharacterDataNode:f,isTextOrCommentNode:u,insertAfter:l,splitDataNode:h,getDocument:g,getWindow:p,getIframeWindow:R,getIframeDocument:m,getBody:A.getBody,isWindow:v,getContentDocument:C,getRootContainer:N,comparePoints:E,isBrokenNode:S,inspectNode:y,getComputedStyleProperty:H,fragmentFromNodeChildren:w,createIterator:T,DomPosition:_},e.DOMException=D}),A.createCoreModule("DomRange",["DomUtil"],function(e){function t(e,t){return 3!=e.nodeType&&(F(e,t.startContainer)||F(e,t.endContainer))}function n(e){return e.document||j(e.startContainer)}function r(e){return new M(e.parentNode,k(e))}function o(e){return new M(e.parentNode,k(e)+1)}function i(e,t,n){var r=11==e.nodeType?e.firstChild:e;return W(t)?n==t.length?B.insertAfter(e,t):t.parentNode.insertBefore(e,0==n?t:U(t,n)):n>=t.childNodes.length?t.appendChild(e):t.insertBefore(e,t.childNodes[n]),r}function a(e,t,r){if(w(e),w(t),n(t)!=n(e))throw new L("WRONG_DOCUMENT_ERR");var o=z(e.startContainer,e.startOffset,t.endContainer,t.endOffset),i=z(e.endContainer,e.endOffset,t.startContainer,t.startOffset);return r?0>=o&&i>=0:0>o&&i>0}function s(e){for(var t,r,o,i=n(e.range).createDocumentFragment();r=e.next();){if(t=e.isPartiallySelectedSubtree(),r=r.cloneNode(!t),t&&(o=e.getSubtreeIterator(),r.appendChild(s(o)),o.detach()),10==r.nodeType)throw new L("HIERARCHY_REQUEST_ERR");i.appendChild(r)}return i}function c(e,t,n){var r,o;n=n||{stop:!1};for(var i,a;i=e.next();)if(e.isPartiallySelectedSubtree()){if(t(i)===!1)return void(n.stop=!0);if(a=e.getSubtreeIterator(),c(a,t,n),a.detach(),n.stop)return}else for(r=B.createIterator(i);o=r.next();)if(t(o)===!1)return void(n.stop=!0)}function d(e){for(var t;e.next();)e.isPartiallySelectedSubtree()?(t=e.getSubtreeIterator(),d(t),t.detach()):e.remove()}function f(e){for(var t,r,o=n(e.range).createDocumentFragment();t=e.next();){if(e.isPartiallySelectedSubtree()?(t=t.cloneNode(!1),r=e.getSubtreeIterator(),t.appendChild(f(r)),r.detach()):e.remove(),10==t.nodeType)throw new L("HIERARCHY_REQUEST_ERR");o.appendChild(t)}return o}function u(e,t,n){var r,o=!(!t||!t.length),i=!!n;o&&(r=new RegExp("^("+t.join("|")+")$"));var a=[];return c(new h(e,!1),function(t){if(!(o&&!r.test(t.nodeType)||i&&!n(t))){var s=e.startContainer;if(t!=s||!W(s)||e.startOffset!=s.length){var c=e.endContainer;t==c&&W(c)&&0==e.endOffset||a.push(t)}}}),a}function l(e){var t="undefined"==typeof e.getName?"Range":e.getName();return"["+t+"("+B.inspectNode(e.startContainer)+":"+e.startOffset+", "+B.inspectNode(e.endContainer)+":"+e.endOffset+")]"}function h(e,t){if(this.range=e,this.clonePartiallySelectedTextNodes=t,!e.collapsed){this.sc=e.startContainer,this.so=e.startOffset,this.ec=e.endContainer,this.eo=e.endOffset;var n=e.commonAncestorContainer;this.sc===this.ec&&W(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==n||W(this.sc)?V(this.sc,n,!0):this.sc.childNodes[this.so],this._last=this.ec!==n||W(this.ec)?V(this.ec,n,!0):this.ec.childNodes[this.eo-1])}}function g(e){return function(t,n){for(var r,o=n?t:t.parentNode;o;){if(r=o.nodeType,Y(e,r))return o;o=o.parentNode}return null}}function p(e,t){if(nt(e,t))throw new L("INVALID_NODE_TYPE_ERR")}function m(e,t){if(!Y(t,e.nodeType))throw new L("INVALID_NODE_TYPE_ERR")}function R(e,t){if(0>t||t>(W(e)?e.length:e.childNodes.length))throw new L("INDEX_SIZE_ERR")}function v(e,t){if(et(e,!0)!==et(t,!0))throw new L("WRONG_DOCUMENT_ERR")}function C(e){if(tt(e,!0))throw new L("NO_MODIFICATION_ALLOWED_ERR")}function N(e,t){if(!e)throw new L(t)}function E(e){return G&&B.isBrokenNode(e)||!Y(Z,e.nodeType)&&!et(e,!0)}function S(e,t){return t<=(W(e)?e.length:e.childNodes.length)}function y(e){return!!e.startContainer&&!!e.endContainer&&!E(e.startContainer)&&!E(e.endContainer)&&S(e.startContainer,e.startOffset)&&S(e.endContainer,e.endOffset)}function w(e){if(!y(e))throw new Error("Range error: Range is no longer valid after DOM mutation ("+e.inspect()+")")}function O(e,t){w(e);var n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,a=n===o;W(o)&&i>0&&i0&&r=k(n)&&i++,r=0),e.setStartAndEnd(n,r,o,i)}function T(e){w(e);var t=e.commonAncestorContainer.parentNode.cloneNode(!1);return t.appendChild(e.cloneContents()),t.innerHTML}function _(e){e.START_TO_START=ct,e.START_TO_END=dt,e.END_TO_END=ft,e.END_TO_START=ut,e.NODE_BEFORE=lt,e.NODE_AFTER=ht,e.NODE_BEFORE_AND_AFTER=gt,e.NODE_INSIDE=pt}function D(e){_(e),_(e.prototype)}function x(e,t){return function(){w(this);var n,r,i=this.startContainer,a=this.startOffset,s=this.commonAncestorContainer,d=new h(this,!0);i!==s&&(n=V(i,s,!0),r=o(n),i=r.node,a=r.offset),c(d,C),d.reset();var f=e(d);return d.detach(),t(this,i,a,i,a),f}}function A(n,i){function a(e,t){return function(n){m(n,X),m(Q(n),Z);var i=(e?r:o)(n);(t?s:c)(this,i.node,i.offset)}}function s(e,t,n){var r=e.endContainer,o=e.endOffset;(t!==e.startContainer||n!==e.startOffset)&&((Q(t)!=Q(r)||1==z(t,n,r,o))&&(r=t,o=n),i(e,t,n,r,o))}function c(e,t,n){var r=e.startContainer,o=e.startOffset;(t!==e.endContainer||n!==e.endOffset)&&((Q(t)!=Q(r)||-1==z(t,n,r,o))&&(r=t,o=n),i(e,r,o,t,n))}var u=function(){};u.prototype=e.rangePrototype,n.prototype=new u,H.extend(n.prototype,{setStart:function(e,t){p(e,!0),R(e,t),s(this,e,t)},setEnd:function(e,t){p(e,!0),R(e,t),c(this,e,t)},setStartAndEnd:function(){var e=arguments,t=e[0],n=e[1],r=t,o=n;switch(e.length){case 3:o=e[2];break;case 4:r=e[2],o=e[3]}i(this,t,n,r,o)},setBoundary:function(e,t,n){this["set"+(n?"Start":"End")](e,t)},setStartBefore:a(!0,!0),setStartAfter:a(!1,!0),setEndBefore:a(!0,!1),setEndAfter:a(!1,!1),collapse:function(e){w(this),e?i(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):i(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(e){p(e,!0),i(this,e,0,e,q(e))},selectNode:function(e){p(e,!1),m(e,X);var t=r(e),n=o(e);i(this,t.node,t.offset,n.node,n.offset)},extractContents:x(f,i),deleteContents:x(d,i),canSurroundContents:function(){w(this),C(this.startContainer),C(this.endContainer);var e=new h(this,!0),n=e._first&&t(e._first,this)||e._last&&t(e._last,this);return e.detach(),!n},splitBoundaries:function(){O(this)},splitBoundariesPreservingPositions:function(e){O(this,e)},normalizeBoundaries:function(){w(this);var e=this.startContainer,t=this.startOffset,n=this.endContainer,r=this.endOffset,o=function(e){var t=e.nextSibling;t&&t.nodeType==e.nodeType&&(n=e,r=e.length,e.appendData(t.data),t.parentNode.removeChild(t))},a=function(o){var i=o.previousSibling;if(i&&i.nodeType==o.nodeType){e=o;var a=o.length;if(t=i.length,o.insertData(0,i.data),i.parentNode.removeChild(i),e==n)r+=t,n=e;else if(n==o.parentNode){var s=k(o);r==s?(n=o,r=a):r>s&&r--}}},s=!0;if(W(n))n.length==r&&o(n);else{if(r>0){var c=n.childNodes[r-1];c&&W(c)&&o(c)}s=!this.collapsed}if(s){if(W(e))0==t&&a(e);else if(tx",ot=3==rt.firstChild.nodeType}catch(it){}e.features.htmlParsingConforms=ot;var at=ot?function(e){var t=this.startContainer,n=j(t);if(!t)throw new L("INVALID_STATE_ERR");var r=null;return 1==t.nodeType?r=t:W(t)&&(r=B.parentElement(t)),r=null===r||"HTML"==r.nodeName&&B.isHtmlNamespace(j(r).documentElement)&&B.isHtmlNamespace(r)?n.createElement("body"):r.cloneNode(!1),r.innerHTML=e,B.fragmentFromNodeChildren(r)}:function(e){var t=n(this),r=t.createElement("body");return r.innerHTML=e,B.fragmentFromNodeChildren(r)},st=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],ct=0,dt=1,ft=2,ut=3,lt=0,ht=1,gt=2,pt=3;H.extend(e.rangePrototype,{compareBoundaryPoints:function(e,t){w(this),v(this.startContainer,t.startContainer);var n,r,o,i,a=e==ut||e==ct?"start":"end",s=e==dt||e==ct?"start":"end";return n=this[a+"Container"],r=this[a+"Offset"],o=t[s+"Container"],i=t[s+"Offset"],z(n,r,o,i)},insertNode:function(e){if(w(this),m(e,J),C(this.startContainer),F(e,this.startContainer))throw new L("HIERARCHY_REQUEST_ERR");var t=i(e,this.startContainer,this.startOffset);this.setStartBefore(t)},cloneContents:function(){w(this);var e,t;if(this.collapsed)return n(this).createDocumentFragment();if(this.startContainer===this.endContainer&&W(this.startContainer))return e=this.startContainer.cloneNode(!0),e.data=e.data.slice(this.startOffset,this.endOffset),t=n(this).createDocumentFragment(),t.appendChild(e),t;var r=new h(this,!0);return e=s(r),r.detach(),e},canSurroundContents:function(){w(this),C(this.startContainer),C(this.endContainer);var e=new h(this,!0),n=e._first&&t(e._first,this)||e._last&&t(e._last,this);return e.detach(),!n},surroundContents:function(e){if(m(e,K),!this.canSurroundContents())throw new L("INVALID_STATE_ERR");var t=this.extractContents();if(e.hasChildNodes())for(;e.lastChild;)e.removeChild(e.lastChild);i(e,this.startContainer,this.startOffset),e.appendChild(t),this.selectNode(e)},cloneRange:function(){w(this);for(var e,t=new I(n(this)),r=st.length;r--;)e=st[r],t[e]=this[e];return t},toString:function(){w(this);var e=this.startContainer;if(e===this.endContainer&&W(e))return 3==e.nodeType||4==e.nodeType?e.data.slice(this.startOffset,this.endOffset):"";var t=[],n=new h(this,!0);return c(n,function(e){(3==e.nodeType||4==e.nodeType)&&t.push(e.data)}),n.detach(),t.join("")},compareNode:function(e){w(this);var t=e.parentNode,n=k(e);if(!t)throw new L("NOT_FOUND_ERR");var r=this.comparePoint(t,n),o=this.comparePoint(t,n+1);return 0>r?o>0?gt:lt:o>0?ht:pt},comparePoint:function(e,t){return w(this),N(e,"HIERARCHY_REQUEST_ERR"),v(e,this.startContainer),z(e,t,this.startContainer,this.startOffset)<0?-1:z(e,t,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:at,toHtml:function(){return T(this)},intersectsNode:function(e,t){if(w(this),N(e,"NOT_FOUND_ERR"),j(e)!==n(this))return!1;var r=e.parentNode,o=k(e);N(r,"NOT_FOUND_ERR");var i=z(r,o,this.endContainer,this.endOffset),a=z(r,o+1,this.startContainer,this.startOffset);return t?0>=i&&a>=0:0>i&&a>0},isPointInRange:function(e,t){return w(this),N(e,"HIERARCHY_REQUEST_ERR"),v(e,this.startContainer),z(e,t,this.startContainer,this.startOffset)>=0&&z(e,t,this.endContainer,this.endOffset)<=0},intersectsRange:function(e){return a(this,e,!1)},intersectsOrTouchesRange:function(e){return a(this,e,!0)},intersection:function(e){if(this.intersectsRange(e)){var t=z(this.startContainer,this.startOffset,e.startContainer,e.startOffset),n=z(this.endContainer,this.endOffset,e.endContainer,e.endOffset),r=this.cloneRange();return-1==t&&r.setStart(e.startContainer,e.startOffset),1==n&&r.setEnd(e.endContainer,e.endOffset),r}return null},union:function(e){if(this.intersectsOrTouchesRange(e)){var t=this.cloneRange();return-1==z(e.startContainer,e.startOffset,this.startContainer,this.startOffset)&&t.setStart(e.startContainer,e.startOffset),1==z(e.endContainer,e.endOffset,this.endContainer,this.endOffset)&&t.setEnd(e.endContainer,e.endOffset),t}throw new L("Ranges do not intersect")},containsNode:function(e,t){return t?this.intersectsNode(e,!1):this.compareNode(e)==pt},containsNodeContents:function(e){return this.comparePoint(e,0)>=0&&this.comparePoint(e,q(e))<=0},containsRange:function(e){var t=this.intersection(e);return null!==t&&e.equals(t)},containsNodeText:function(e){var t=this.cloneRange();t.selectNode(e);var n=t.getNodes([3]);if(n.length>0){t.setStart(n[0],0);var r=n.pop();return t.setEnd(r,r.length),this.containsRange(t)}return this.containsNodeContents(e)},getNodes:function(e,t){return w(this),u(this,e,t)},getDocument:function(){return n(this)},collapseBefore:function(e){this.setEndBefore(e),this.collapse(!1)},collapseAfter:function(e){this.setStartAfter(e),this.collapse(!0)},getBookmark:function(t){var r=n(this),o=e.createRange(r);t=t||B.getBody(r),o.selectNodeContents(t);var i=this.intersection(o),a=0,s=0;return i&&(o.setEnd(i.startContainer,i.startOffset),a=o.toString().length,s=a+i.toString().length),{start:a,end:s,containerNode:t}},moveToBookmark:function(e){var t=e.containerNode,n=0;this.setStart(t,0),this.collapse(!0);for(var r,o,i,a,s=[t],c=!1,d=!1;!d&&(r=s.pop());)if(3==r.nodeType)o=n+r.length,!c&&e.start>=n&&e.start<=o&&(this.setStart(r,e.start-n),c=!0),c&&e.end>=n&&e.end<=o&&(this.setEnd(r,e.end-n),d=!0),n=o;else for(a=r.childNodes,i=a.length;i--;)s.push(a[i])},getName:function(){return"DomRange"},equals:function(e){return I.rangesEqual(this,e)},isValid:function(){return y(this)},inspect:function(){return l(this)},detach:function(){}}),A(I,P),H.extend(I,{rangeProperties:st,RangeIterator:h,copyComparisonConstants:D,createPrototypeRange:A,inspect:l,toHtml:T,getRangeDocument:n,rangesEqual:function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset}}),e.DomRange=I}),A.createCoreModule("WrappedRange",["DomRange"],function(e,t){var n,r,o=e.dom,i=e.util,a=o.DomPosition,s=e.DomRange,c=o.getBody,d=o.getContentDocument,f=o.isCharacterDataNode;if(e.features.implementsDomRange&&!function(){function r(e){for(var t,n=l.length;n--;)t=l[n],e[t]=e.nativeRange[t];e.collapsed=e.startContainer===e.endContainer&&e.startOffset===e.endOffset}function a(e,t,n,r,o){var i=e.startContainer!==t||e.startOffset!=n,a=e.endContainer!==r||e.endOffset!=o,s=!e.equals(e.nativeRange);(i||a||s)&&(e.setEnd(r,o),e.setStart(t,n))}var f,u,l=s.rangeProperties;n=function(e){if(!e)throw t.createError("WrappedRange: Range must be specified");this.nativeRange=e,r(this)},s.createPrototypeRange(n,a),f=n.prototype,f.selectNode=function(e){this.nativeRange.selectNode(e),r(this)},f.cloneContents=function(){return this.nativeRange.cloneContents()},f.surroundContents=function(e){this.nativeRange.surroundContents(e),r(this)},f.collapse=function(e){this.nativeRange.collapse(e),r(this)},f.cloneRange=function(){return new n(this.nativeRange.cloneRange())},f.refresh=function(){r(this)},f.toString=function(){return this.nativeRange.toString()};var h=document.createTextNode("test");c(document).appendChild(h);var g=document.createRange();g.setStart(h,0),g.setEnd(h,0);try{g.setStart(h,1),f.setStart=function(e,t){this.nativeRange.setStart(e,t),r(this)},f.setEnd=function(e,t){this.nativeRange.setEnd(e,t),r(this)},u=function(e){return function(t){this.nativeRange[e](t),r(this)}}}catch(p){f.setStart=function(e,t){try{this.nativeRange.setStart(e,t)}catch(n){this.nativeRange.setEnd(e,t),this.nativeRange.setStart(e,t)}r(this)},f.setEnd=function(e,t){try{this.nativeRange.setEnd(e,t)}catch(n){this.nativeRange.setStart(e,t),this.nativeRange.setEnd(e,t)}r(this)},u=function(e,t){return function(n){try{this.nativeRange[e](n)}catch(o){this.nativeRange[t](n),this.nativeRange[e](n)}r(this)}}}f.setStartBefore=u("setStartBefore","setEndBefore"),f.setStartAfter=u("setStartAfter","setEndAfter"),f.setEndBefore=u("setEndBefore","setStartBefore"),f.setEndAfter=u("setEndAfter","setStartAfter"),f.selectNodeContents=function(e){this.setStartAndEnd(e,0,o.getNodeLength(e))},g.selectNodeContents(h),g.setEnd(h,3);var m=document.createRange();m.selectNodeContents(h),m.setEnd(h,4),m.setStart(h,2),f.compareBoundaryPoints=-1==g.compareBoundaryPoints(g.START_TO_END,m)&&1==g.compareBoundaryPoints(g.END_TO_START,m)?function(e,t){return t=t.nativeRange||t,e==t.START_TO_END?e=t.END_TO_START:e==t.END_TO_START&&(e=t.START_TO_END),this.nativeRange.compareBoundaryPoints(e,t)}:function(e,t){return this.nativeRange.compareBoundaryPoints(e,t.nativeRange||t)};var R=document.createElement("div");R.innerHTML="123";var v=R.firstChild,C=c(document);C.appendChild(R),g.setStart(v,1),g.setEnd(v,2),g.deleteContents(),"13"==v.data&&(f.deleteContents=function(){this.nativeRange.deleteContents(),r(this)},f.extractContents=function(){var e=this.nativeRange.extractContents();return r(this),e}),C.removeChild(R),C=null,i.isHostMethod(g,"createContextualFragment")&&(f.createContextualFragment=function(e){return this.nativeRange.createContextualFragment(e)}),c(document).removeChild(h),f.getName=function(){return"WrappedRange"},e.WrappedRange=n,e.createNativeRange=function(e){return e=d(e,t,"createNativeRange"),e.createRange()}}(),e.features.implementsTextRange){var u=function(e){var t=e.parentElement(),n=e.duplicate();n.collapse(!0);var r=n.parentElement();n=e.duplicate(),n.collapse(!1);var i=n.parentElement(),a=r==i?r:o.getCommonAncestor(r,i);return a==t?a:o.getCommonAncestor(t,a)},l=function(e){return 0==e.compareEndPoints("StartToEnd",e)},h=function(e,t,n,r,i){var s=e.duplicate();s.collapse(n);var c=s.parentElement();if(o.isOrIsAncestorOf(t,c)||(c=t),!c.canHaveHTML){var d=new a(c.parentNode,o.getNodeIndex(c));return{boundaryPosition:d,nodeInfo:{nodeIndex:d.offset,containerElement:d.node}}}var u=o.getDocument(c).createElement("span");u.parentNode&&u.parentNode.removeChild(u);for(var l,h,g,p,m,R=n?"StartToStart":"StartToEnd",v=i&&i.containerElement==c?i.nodeIndex:0,C=c.childNodes.length,N=C,E=N;;){if(E==C?c.appendChild(u):c.insertBefore(u,c.childNodes[E]),s.moveToElementText(u),l=s.compareEndPoints(R,e),0==l||v==N)break;if(-1==l){if(N==v+1)break;v=E}else N=N==v+1?v:E;E=Math.floor((v+N)/2),c.removeChild(u)}if(m=u.nextSibling,-1==l&&m&&f(m)){s.setEndPoint(n?"EndToStart":"EndToEnd",e);var S;if(/[\r\n]/.test(m.data)){var y=s.duplicate(),w=y.text.replace(/\r\n/g,"\r").length;for(S=y.moveStart("character",w);-1==(l=y.compareEndPoints("StartToEnd",y));)S++,y.moveStart("character",1)}else S=s.text.length;p=new a(m,S)}else h=(r||!n)&&u.previousSibling,g=(r||n)&&u.nextSibling,p=g&&f(g)?new a(g,0):h&&f(h)?new a(h,h.data.length):new a(c,o.getNodeIndex(u));return u.parentNode.removeChild(u),{boundaryPosition:p,nodeInfo:{nodeIndex:E,containerElement:c}}},g=function(e,t){var n,r,i,a,s=e.offset,d=o.getDocument(e.node),u=c(d).createTextRange(),l=f(e.node);return l?(n=e.node,r=n.parentNode):(a=e.node.childNodes,n=st;++t)if(!D.isAncestorOf(e[0],e[t]))return!1;return!0}function l(e){var n=e.getNodes();if(!u(n))throw t.createError("getSingleElementFromRange: range "+e.inspect()+" did not consist of a single element");return n[0]}function h(e){return!!e&&"undefined"!=typeof e.text}function g(e,t){var n=new P(t);e._ranges=[n],s(e,n,!1),e.rangeCount=1,e.isCollapsed=n.collapsed}function p(t){if(t._ranges.length=0,"None"==t.docSelection.type)d(t);else{var n=t.docSelection.createRange();if(h(n))g(t,n);else{t.rangeCount=n.length;for(var r,o=L(n.item(0)),i=0;is;++s)a.add(r.item(s));try{a.add(o)}catch(d){throw t.createError("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}a.select(),p(e)}function R(e,t,n){this.nativeSelection=e,this.docSelection=t,this._ranges=[],this.win=n,this.refresh()}function v(e){e.win=e.anchorNode=e.focusNode=e._ranges=null,e.rangeCount=e.anchorOffset=e.focusOffset=0,e.detached=!0}function C(e,t){for(var n,r,o=tt.length;o--;)if(n=tt[o],r=n.selection,"deleteAll"==t)v(r);else if(n.win==e)return"delete"==t?(tt.splice(o,1),!0):r;return"deleteAll"==t&&(tt.length=0),null}function N(e,n){for(var r,o=L(n[0].startContainer),i=W(o).createControlRange(),a=0,s=n.length;s>a;++a){r=l(n[a]);try{i.add(r)}catch(c){throw t.createError("setRanges(): Element within one of the specified Ranges could not be added to control selection (does it have layout?)")}}i.select(),p(e)}function E(e,t){if(e.win.document!=L(t))throw new I("WRONG_DOCUMENT_ERR")}function S(t){return function(n,r){var o;this.rangeCount?(o=this.getRangeAt(0),o["set"+(t?"Start":"End")](n,r)):(o=e.createRange(this.win.document),o.setStartAndEnd(n,r)),this.setSingleRange(o,this.isBackward())}}function y(e){var t=[],n=new B(e.anchorNode,e.anchorOffset),r=new B(e.focusNode,e.focusOffset),o="function"==typeof e.getName?e.getName():"Selection";if("undefined"!=typeof e.rangeCount)for(var i=0,a=e.rangeCount;a>i;++i)t[i]=b.inspect(e.getRangeAt(i));return"["+o+"(Ranges: "+t.join(", ")+")(anchor: "+n.inspect()+", focus: "+r.inspect()+"]"}e.config.checkSelectionRanges=!0;var w,O,T="boolean",_="number",D=e.dom,x=e.util,A=x.isHostMethod,b=e.DomRange,P=e.WrappedRange,I=e.DOMException,B=D.DomPosition,H=e.features,M="Control",L=D.getDocument,W=D.getBody,k=b.rangesEqual,F=A(window,"getSelection"),j=x.isHostObject(document,"selection");H.implementsWinGetSelection=F,H.implementsDocSelection=j;var z=j&&(!F||e.config.preferTextRange);z?(w=i,e.isSelectionValid=function(e){var t=r(e,"isSelectionValid").document,n=t.selection;return"None"!=n.type||L(n.createRange().parentElement())==t}):F?(w=o,e.isSelectionValid=function(){return!0}):t.fail("Neither document.selection or window.getSelection() detected."),e.getNativeSelection=w;var U=w(),V=e.createNativeRange(document),q=W(document),Y=x.areHostProperties(U,["anchorNode","focusNode","anchorOffset","focusOffset"]);H.selectionHasAnchorAndFocus=Y;var Q=A(U,"extend");H.selectionHasExtend=Q;var G=typeof U.rangeCount==_;H.selectionHasRangeCount=G;var X=!1,Z=!0,$=Q?function(t,n){var r=b.getRangeDocument(n),o=e.createRange(r);o.collapseToPoint(n.endContainer,n.endOffset),t.addRange(f(o)),t.extend(n.startContainer,n.startOffset)}:null;x.areHostMethods(U,["addRange","getRangeAt","removeAllRanges"])&&typeof U.rangeCount==_&&H.implementsDomRange&&!function(){var t=window.getSelection();if(t){for(var n=t.rangeCount,r=n>1,o=[],i=a(t),s=0;n>s;++s)o[s]=t.getRangeAt(s);var c=W(document),d=c.appendChild(document.createElement("div"));d.contentEditable="false";var f=d.appendChild(document.createTextNode("   ")),u=document.createRange();if(u.setStart(f,1),u.collapse(!0),t.addRange(u),Z=1==t.rangeCount,t.removeAllRanges(),!r){var l=window.navigator.appVersion.match(/Chrome\/(.*?) /);if(l&&parseInt(l[1])>=36)X=!1;else{var h=u.cloneRange();u.setStart(f,0),h.setEnd(f,3),h.setStart(f,2),t.addRange(u),t.addRange(h),X=2==t.rangeCount}}for(c.removeChild(d),t.removeAllRanges(),s=0;n>s;++s)0==s&&i?$?$(t,o[s]):(e.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because the browser does not support Selection.extend"),t.addRange(o[s])):t.addRange(o[s])}}(),H.selectionSupportsMultipleRanges=X,H.collapsedNonEditableSelectionsSupported=Z;var J,K=!1;q&&A(q,"createControlRange")&&(J=q.createControlRange(),x.areHostProperties(J,["item","add"])&&(K=!0)),H.implementsControlRange=K,O=Y?function(e){return e.anchorNode===e.focusNode&&e.anchorOffset===e.focusOffset}:function(e){return e.rangeCount?e.getRangeAt(e.rangeCount-1).collapsed:!1};var et;A(U,"getRangeAt")?et=function(e,t){try{return e.getRangeAt(t)}catch(n){return null}}:Y&&(et=function(t){var n=L(t.anchorNode),r=e.createRange(n);return r.setStartAndEnd(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset),r.collapsed!==this.isCollapsed&&r.setStartAndEnd(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset),r}),R.prototype=e.selectionPrototype;var tt=[],nt=function(e){if(e&&e instanceof R)return e.refresh(),e;e=r(e,"getNativeSelection");var t=C(e),n=w(e),o=j?i(e):null;return t?(t.nativeSelection=n,t.docSelection=o,t.refresh()):(t=new R(n,o,e),tt.push({win:e,selection:t})),t};e.getSelection=nt,e.getIframeSelection=function(n){return t.deprecationNotice("getIframeSelection()","getSelection(iframeEl)"),e.getSelection(D.getIframeWindow(n))};var rt=R.prototype;if(!z&&Y&&x.areHostMethods(U,["removeAllRanges","addRange"])){rt.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),d(this)};var ot=function(e,t){$(e.nativeSelection,t),e.refresh()};rt.addRange=G?function(t,r){if(K&&j&&this.docSelection.type==M)m(this,t);else if(n(r)&&Q)ot(this,t);else{var o;X?o=this.rangeCount:(this.removeAllRanges(),o=0);var i=f(t).cloneRange();try{this.nativeSelection.addRange(i)}catch(a){}if(this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==o+1){if(e.config.checkSelectionRanges){var c=et(this.nativeSelection,this.rangeCount-1);c&&!k(c,t)&&(t=new P(c))}this._ranges[this.rangeCount-1]=t,s(this,t,st(this.nativeSelection)),this.isCollapsed=O(this)}else this.refresh()}}:function(e,t){n(t)&&Q?ot(this,e):(this.nativeSelection.addRange(f(e)),this.refresh())},rt.setRanges=function(e){if(K&&j&&e.length>1)N(this,e);else{this.removeAllRanges();for(var t=0,n=e.length;n>t;++t)this.addRange(e[t])}}}else{if(!(A(U,"empty")&&A(V,"select")&&K&&z))return t.fail("No means of selecting a Range or TextRange was found"),!1;rt.removeAllRanges=function(){try{if(this.docSelection.empty(),"None"!=this.docSelection.type){var e;if(this.anchorNode)e=L(this.anchorNode);else if(this.docSelection.type==M){var t=this.docSelection.createRange();t.length&&(e=L(t.item(0)))}if(e){var n=W(e).createTextRange();n.select(),this.docSelection.empty()}}}catch(r){}d(this)},rt.addRange=function(t){this.docSelection.type==M?m(this,t):(e.WrappedTextRange.rangeToTextRange(t).select(),this._ranges[0]=t,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,s(this,t,!1))},rt.setRanges=function(e){this.removeAllRanges();var t=e.length;t>1?N(this,e):t&&this.addRange(e[0])}}rt.getRangeAt=function(e){if(0>e||e>=this.rangeCount)throw new I("INDEX_SIZE_ERR");return this._ranges[e].cloneRange()};var it;if(z)it=function(t){var n;e.isSelectionValid(t.win)?n=t.docSelection.createRange():(n=W(t.win.document).createTextRange(),n.collapse(!0)),t.docSelection.type==M?p(t):h(n)?g(t,n):d(t)};else if(A(U,"getRangeAt")&&typeof U.rangeCount==_)it=function(t){if(K&&j&&t.docSelection.type==M)p(t);else if(t._ranges.length=t.rangeCount=t.nativeSelection.rangeCount,t.rangeCount){for(var n=0,r=t.rangeCount;r>n;++n)t._ranges[n]=new e.WrappedRange(t.nativeSelection.getRangeAt(n));s(t,t._ranges[t.rangeCount-1],st(t.nativeSelection)),t.isCollapsed=O(t)}else d(t)};else{if(!Y||typeof U.isCollapsed!=T||typeof V.collapsed!=T||!H.implementsDomRange)return t.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;it=function(e){var t,n=e.nativeSelection;n.anchorNode?(t=et(n,0),e._ranges=[t],e.rangeCount=1,c(e),e.isCollapsed=O(e)):d(e)}}rt.refresh=function(e){var t=e?this._ranges.slice(0):null,n=this.anchorNode,r=this.anchorOffset;if(it(this),e){var o=t.length;if(o!=this._ranges.length)return!0;if(this.anchorNode!=n||this.anchorOffset!=r)return!0;for(;o--;)if(!k(t[o],this._ranges[o]))return!0;return!1}};var at=function(e,t){var n=e.getAllRanges();e.removeAllRanges();for(var r=0,o=n.length;o>r;++r)k(t,n[r])||e.addRange(n[r]);e.rangeCount||d(e)};rt.removeRange=K&&j?function(e){if(this.docSelection.type==M){for(var t,n=this.docSelection.createRange(),r=l(e),o=L(n.item(0)),i=W(o).createControlRange(),a=!1,s=0,c=n.length;c>s;++s)t=n.item(s),t!==r||a?i.add(n.item(s)):a=!0;i.select(),p(this)}else at(this,e)}:function(e){at(this,e)};var st;!z&&Y&&H.implementsDomRange?(st=a,rt.isBackward=function(){return st(this)}):st=rt.isBackward=function(){return!1},rt.isBackwards=rt.isBackward,rt.toString=function(){for(var e=[],t=0,n=this.rangeCount;n>t;++t)e[t]=""+this._ranges[t];return e.join("")},rt.collapse=function(t,n){E(this,t);var r=e.createRange(t);r.collapseToPoint(t,n),this.setSingleRange(r),this.isCollapsed=!0},rt.collapseToStart=function(){if(!this.rangeCount)throw new I("INVALID_STATE_ERR");var e=this._ranges[0];this.collapse(e.startContainer,e.startOffset)},rt.collapseToEnd=function(){if(!this.rangeCount)throw new I("INVALID_STATE_ERR");var e=this._ranges[this.rangeCount-1];this.collapse(e.endContainer,e.endOffset)},rt.selectAllChildren=function(t){E(this,t);var n=e.createRange(t);n.selectNodeContents(t),this.setSingleRange(n)},rt.deleteFromDocument=function(){if(K&&j&&this.docSelection.type==M){for(var e,t=this.docSelection.createRange();t.length;)e=t.item(0),t.remove(e),e.parentNode.removeChild(e);this.refresh()}else if(this.rangeCount){var n=this.getAllRanges();if(n.length){this.removeAllRanges();for(var r=0,o=n.length;o>r;++r)n[r].deleteContents();this.addRange(n[o-1])}}},rt.eachRange=function(e,t){for(var n=0,r=this._ranges.length;r>n;++n)if(e(this.getRangeAt(n)))return t},rt.getAllRanges=function(){var e=[];return this.eachRange(function(t){e.push(t)}),e},rt.setSingleRange=function(e,t){this.removeAllRanges(),this.addRange(e,t)},rt.callMethodOnEachRange=function(e,t){var n=[];return this.eachRange(function(r){n.push(r[e].apply(r,t))}),n},rt.setStart=S(!0),rt.setEnd=S(!1),e.rangePrototype.select=function(e){nt(this.getDocument()).setSingleRange(this,e)},rt.changeEachRange=function(e){var t=[],n=this.isBackward();this.eachRange(function(n){e(n),t.push(n)}),this.removeAllRanges(),n&&1==t.length?this.addRange(t[0],"backward"):this.setRanges(t)},rt.containsNode=function(e,t){return this.eachRange(function(n){return n.containsNode(e,t)},!0)||!1},rt.getBookmark=function(e){return{backward:this.isBackward(),rangeBookmarks:this.callMethodOnEachRange("getBookmark",[e])}},rt.moveToBookmark=function(t){for(var n,r,o=[],i=0;n=t.rangeBookmarks[i++];)r=e.createRange(this.win),r.moveToBookmark(n),o.push(r);t.backward?this.setSingleRange(o[0],"backward"):this.setRanges(o)},rt.toHtml=function(){var e=[];return this.eachRange(function(t){e.push(b.toHtml(t))}),e.join("")},H.implementsTextRange&&(rt.getNativeTextRange=function(){var n;if(n=this.docSelection){var r=n.createRange();if(h(r))return r;throw t.createError("getNativeTextRange: selection is a control selection")}if(this.rangeCount>0)return e.WrappedTextRange.rangeToTextRange(this.getRangeAt(0));throw t.createError("getNativeTextRange: selection contains no range")}),rt.getName=function(){return"WrappedSelection"},rt.inspect=function(){return y(this)},rt.detach=function(){C(this.win,"delete"),v(this)},R.detachAll=function(){C(null,"deleteAll")},R.inspect=y,R.isDirectionBackward=n,e.Selection=R,e.selectionPrototype=rt,e.addShimListener(function(e){"undefined"==typeof e.getSelection&&(e.getSelection=function(){return nt(e)}),e=null})});var H=!1,M=function(){H||(H=!0,!A.initialized&&A.config.autoInitialize&&u())};return D&&("complete"==document.readyState?M():(e(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",M,!1),P(window,"load",M))),A},this); \ No newline at end of file diff --git a/rangy-highlighter.js b/rangy-highlighter.js index e4a26b9..c54aa86 100644 --- a/rangy-highlighter.js +++ b/rangy-highlighter.js @@ -1,13 +1,13 @@ /** * Highlighter module for Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core, TextRange and CssClassApplier modules. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ (function(factory, root) { if (typeof define == "function" && define.amd) { diff --git a/rangy-highlighter.min.js b/rangy-highlighter.min.js index 5aa4b61..90e6e0d 100644 --- a/rangy-highlighter.min.js +++ b/rangy-highlighter.min.js @@ -1,12 +1,12 @@ /** * Highlighter module for Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core, TextRange and CssClassApplier modules. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ !function(e,t){"function"==typeof define&&define.amd?define(["./rangy-core"],e):"undefined"!=typeof module&&"object"==typeof exports?module.exports=e(require("rangy")):e(t.rangy)}(function(e){e.createModule("Highlighter",["ClassApplier"],function(e){function t(e,t){return e.characterRange.start-t.characterRange.start}function n(e,t){this.type=e,this.converterCreator=t}function r(e,t){f[e]=new n(e,t)}function i(e){var t=f[e];if(t instanceof n)return t.create();throw new Error("Highlighter type '"+e+"' is not valid")}function a(e,t){this.start=e,this.end=t}function s(e,t,n,r,i,a){i?(this.id=i,p=Math.max(p,i+1)):this.id=p++,this.characterRange=t,this.doc=e,this.classApplier=n,this.converter=r,this.containerElementId=a||null,this.applied=!1}function h(e,t){t=t||"textContent",this.doc=e||document,this.classAppliers={},this.highlights=[],this.converter=i(t)}var o=e.dom,c=o.arrayContains,l=o.getBody,g=e.util.createOptions,u=[].forEach?function(e,t){e.forEach(t)}:function(e,t){for(var n=0,r=e.length;r>n;++n)t(e[n])},p=1,f={};n.prototype.create=function(){var e=this.converterCreator();return e.type=this.type,e},e.registerHighlighterType=r,a.prototype={intersects:function(e){return this.starte.start},isContiguousWith:function(e){return this.start==e.end||this.end==e.start},union:function(e){return new a(Math.min(this.start,e.start),Math.max(this.end,e.end))},intersection:function(e){return new a(Math.max(this.start,e.start),Math.min(this.end,e.end))},getComplements:function(e){var t=[];if(this.start>=e.start){if(this.end<=e.end)return[];t.push(new a(e.end,this.end))}else t.push(new a(this.start,Math.min(this.end,e.start))),this.end>e.end&&t.push(new a(e.end,this.end));return t},toString:function(){return"[CharacterRange("+this.start+", "+this.end+")]"}},a.fromCharacterRange=function(e){return new a(e.start,e.end)};var d={rangeToCharacterRange:function(e,t){var n=e.getBookmark(t);return new a(n.start,n.end)},characterRangeToRange:function(t,n,r){var i=e.createRange(t);return i.moveToBookmark({start:n.start,end:n.end,containerNode:r}),i},serializeSelection:function(e,t){for(var n=e.getAllRanges(),r=n.length,i=[],a=1==r&&e.isBackward(),s=0,h=n.length;h>s;++s)i[s]={characterRange:this.rangeToCharacterRange(n[s],t),backward:a};return i},restoreSelection:function(e,t,n){e.removeAllRanges();for(var r,i,a,s=e.win.document,h=0,o=t.length;o>h;++h)i=t[h],a=i.characterRange,r=this.characterRangeToRange(s,i.characterRange,n),e.addRange(r,i.backward)}};r("textContent",function(){return d}),r("TextRange",function(){var t;return function(){if(!t){var n=e.modules.TextRange;if(!n)throw new Error("TextRange module is missing.");if(!n.supported)throw new Error("TextRange module is present but not supported.");t={rangeToCharacterRange:function(e,t){return a.fromCharacterRange(e.toCharacterRange(t))},characterRangeToRange:function(t,n,r){var i=e.createRange(t);return i.selectCharacters(r,n.start,n.end),i},serializeSelection:function(e,t){return e.saveCharacterRanges(t)},restoreSelection:function(e,t,n){e.restoreCharacterRanges(n,t)}}}return t}}()),s.prototype={getContainerElement:function(){return this.containerElementId?this.doc.getElementById(this.containerElementId):l(this.doc)},getRange:function(){return this.converter.characterRangeToRange(this.doc,this.characterRange,this.getContainerElement())},fromRange:function(e){this.characterRange=this.converter.rangeToCharacterRange(e,this.getContainerElement())},getText:function(){return this.getRange().toString()},containsElement:function(e){return this.getRange().containsNodeContents(e.firstChild)},unapply:function(){this.classApplier.undoToRange(this.getRange()),this.applied=!1},apply:function(){this.classApplier.applyToRange(this.getRange()),this.applied=!0},getHighlightElements:function(){return this.classApplier.getElementsWithClassIntersectingRange(this.getRange())},toString:function(){return"[Highlight(ID: "+this.id+", class: "+this.classApplier.className+", character range: "+this.characterRange.start+" - "+this.characterRange.end+")]"}},h.prototype={addClassApplier:function(e){this.classAppliers[e.className]=e},getHighlightForElement:function(e){for(var t=this.highlights,n=0,r=t.length;r>n;++n)if(t[n].containsElement(e))return t[n];return null},removeHighlights:function(e){for(var t,n=0,r=this.highlights.length;r>n;++n)t=this.highlights[n],c(e,t)&&(t.unapply(),this.highlights.splice(n--,1))},removeAllHighlights:function(){this.removeHighlights(this.highlights)},getIntersectingHighlights:function(e){{var t=[],n=this.highlights;this.converter}return u(e,function(e){u(n,function(n){e.intersectsRange(n.getRange())&&!c(t,n)&&t.push(n)})}),t},highlightCharacterRanges:function(t,n,r){var i,h,o,c=this.highlights,l=this.converter,p=this.doc,f=[],d=t?this.classAppliers[t]:null;r=g(r,{containerElementId:null,exclusive:!0});var v,R,m,C=r.containerElementId,w=r.exclusive;C&&(v=this.doc.getElementById(C),v&&(R=e.createRange(this.doc),R.selectNodeContents(v),m=new a(0,R.toString().length)));var E,y,x,I,T,A;for(i=0,h=n.length;h>i;++i)if(E=n[i],T=[],m&&(E=E.intersection(m)),E.start!=E.end){for(o=0;o0},serialize:function(e){var n=this.highlights;n.sort(t);var r=["type:"+this.converter.type];return e=g(e,{serializeHighlightText:!1}),u(n,function(t){var n=t.characterRange,i=[n.start,n.end,t.id,t.classApplier.className,t.containerElementId];e.serializeHighlightText&&i.push(t.getText()),r.push(i.join("$"))}),r.join("|")},deserialize:function(e){var t,n,r,h=e.split("|"),o=[],c=h[0],g=!1;if(!c||!(t=/^type:(\w+)$/.exec(c)))throw new Error("Serialized highlights are invalid.");n=t[1],n!=this.converter.type&&(r=i(n),g=!0),h.shift();for(var u,p,f,d,v,R,m=h.length;m-->0;){if(R=h[m].split("$"),f=new a(+R[0],+R[1]),d=R[4]||null,v=d?this.doc.getElementById(d):l(this.doc),g&&(f=this.converter.rangeToCharacterRange(r.characterRangeToRange(this.doc,f,v),v)),u=this.classAppliers[R[3]],!u)throw new Error("No class applier found for class '"+R[3]+"'");p=new s(this.doc,f,u,this.converter,parseInt(R[2]),d),p.apply(),o.push(p)}this.highlights=o}},e.Highlighter=h,e.createHighlighter=function(e,t){return new h(e,t)}})},this); \ No newline at end of file diff --git a/rangy-selectionsaverestore.js b/rangy-selectionsaverestore.js index 0a00bd4..4909eef 100644 --- a/rangy-selectionsaverestore.js +++ b/rangy-selectionsaverestore.js @@ -3,14 +3,14 @@ * Saves and restores user selections using marker invisible elements in the DOM. * * Part of Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ (function(factory, root) { if (typeof define == "function" && define.amd) { diff --git a/rangy-selectionsaverestore.min.js b/rangy-selectionsaverestore.min.js index 5965a45..eca2c58 100644 --- a/rangy-selectionsaverestore.min.js +++ b/rangy-selectionsaverestore.min.js @@ -3,13 +3,13 @@ * Saves and restores user selections using marker invisible elements in the DOM. * * Part of Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ !function(e,n){"function"==typeof define&&define.amd?define(["./rangy-core"],e):"undefined"!=typeof module&&"object"==typeof exports?module.exports=e(require("rangy")):e(n.rangy)}(function(e){e.createModule("SaveRestore",["WrappedRange"],function(e,n){function r(e,n){return(n||document).getElementById(e)}function t(e,n){var r,t="selectionBoundary_"+ +new Date+"_"+(""+Math.random()).slice(2),a=m.getDocument(e.startContainer),o=e.cloneRange();return o.collapse(n),r=a.createElement("span"),r.id=t,r.style.lineHeight="0",r.style.display="none",r.className="rangySelectionBoundary",r.appendChild(a.createTextNode(p)),o.insertNode(r),r}function a(e,t,a,o){var d=r(a,e);d?(t[o?"setStartBefore":"setEndBefore"](d),d.parentNode.removeChild(d)):n.warn("Marker element has been removed. Cannot restore selection.")}function o(e,n){return n.compareBoundaryPoints(e.START_TO_START,e)}function d(n,r){var a,o,d=e.DomRange.getRangeDocument(n),s=n.toString();return n.collapsed?(o=t(n,!1),{document:d,markerId:o.id,collapsed:!0}):(o=t(n,!1),a=t(n,!0),{document:d,startMarkerId:a.id,endMarkerId:o.id,collapsed:!1,backward:r,toString:function(){return"original text: '"+s+"', new text: '"+n.toString()+"'"}})}function s(t,o){var d=t.document;"undefined"==typeof o&&(o=!0);var s=e.createRange(d);if(t.collapsed){var l=r(t.markerId,d);if(l){l.style.display="inline";var i=l.previousSibling;i&&3==i.nodeType?(l.parentNode.removeChild(l),s.collapseToPoint(i,i.length)):(s.collapseBefore(l),l.parentNode.removeChild(l))}else n.warn("Marker element has been removed. Cannot restore selection.")}else a(d,s,t.startMarkerId,!0),a(d,s,t.endMarkerId,!1);return o&&s.normalizeBoundaries(),s}function l(n,t){var a,s,l=[];n=n.slice(0),n.sort(o);for(var i=0,c=n.length;c>i;++i)l[i]=d(n[i],t);for(i=c-1;i>=0;--i)a=n[i],s=e.DomRange.getRangeDocument(a),a.collapsed?a.collapseAfter(r(l[i].markerId,s)):(a.setEndBefore(r(l[i].endMarkerId,s)),a.setStartAfter(r(l[i].startMarkerId,s)));return l}function i(r){if(!e.isSelectionValid(r))return n.warn("Cannot save selection. This usually happens when the selection is collapsed and the selection document has lost focus."),null;var t=e.getSelection(r),a=t.getAllRanges(),o=1==a.length&&t.isBackward(),d=l(a,o);return o?t.setSingleRange(a[0],"backward"):t.setRanges(a),{win:r,rangeInfos:d,restored:!1}}function c(e){for(var n=[],r=e.length,t=r-1;t>=0;t--)n[t]=s(e[t],!0);return n}function u(n,r){if(!n.restored){var t=n.rangeInfos,a=e.getSelection(n.win),o=c(t),d=t.length;1==d&&r&&e.features.selectionHasExtend&&t[0].backward?(a.removeAllRanges(),a.addRange(o[0],!0)):a.setRanges(o),n.restored=!0}}function f(e,n){var t=r(n,e);t&&t.parentNode.removeChild(t)}function g(e){for(var n,r=e.rangeInfos,t=0,a=r.length;a>t;++t)n=r[t],n.collapsed?f(e.doc,n.markerId):(f(e.doc,n.startMarkerId),f(e.doc,n.endMarkerId))}var m=e.dom,p="";e.util.extend(e,{saveRange:d,restoreRange:s,saveRanges:l,restoreRanges:c,saveSelection:i,restoreSelection:u,removeMarkerElement:f,removeMarkers:g})})},this); \ No newline at end of file diff --git a/rangy-serializer.js b/rangy-serializer.js index dd0fe04..0686eba 100644 --- a/rangy-serializer.js +++ b/rangy-serializer.js @@ -4,14 +4,14 @@ * cookie or local storage and restore it on the user's next visit to the same page. * * Part of Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ (function(factory, root) { if (typeof define == "function" && define.amd) { diff --git a/rangy-serializer.min.js b/rangy-serializer.min.js index 0ee1a61..c095318 100644 --- a/rangy-serializer.min.js +++ b/rangy-serializer.min.js @@ -4,13 +4,13 @@ * cookie or local storage and restore it on the user's next visit to the same page. * * Part of Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ !function(e,n){"function"==typeof define&&define.amd?define(["./rangy-core"],e):"undefined"!=typeof module&&"object"==typeof exports?module.exports=e(require("rangy")):e(n.rangy)}(function(e){e.createModule("Serializer",["WrappedSelection"],function(e,n){function o(e){return e.replace(//g,">")}function t(e,n){n=n||[];var r=e.nodeType,i=e.childNodes,c=i.length,a=[r,e.nodeName,c].join(":"),d="",u="";switch(r){case 3:d=o(e.nodeValue);break;case 8:d="";break;default:d="<"+a+">",u=""}d&&n.push(d);for(var s=0;c>s;++s)t(i[s],n);return u&&n.push(u),n}function r(e){var n=t(e).join("");return v(n).toString(16)}function i(e,n,o){var t=[],r=e;for(o=o||w.getDocument(e).documentElement;r&&r!=o;)t.push(w.getNodeIndex(r,!0)),r=r.parentNode;return t.join("/")+":"+n}function c(e,o,t){o||(o=(t||document).documentElement);for(var r,i=e.split(":"),c=o,a=i[0]?i[0].split("/"):[],d=a.length;d--;){if(r=parseInt(a[d],10),!(rc;++c)i[c]=a(r[c],o,t);return i.join("|")}function l(n,o,t){o?t=t||w.getWindow(o):(t=t||window,o=t.document.documentElement);for(var r=n.split("|"),i=e.getSelection(t),c=[],a=0,u=r.length;u>a;++a)c[a]=d(r[a],o,t.document);return i.setRanges(c),i}function f(e,n,o){var t;n?t=o?o.document:w.getDocument(n):(o=o||window,n=o.document.documentElement);for(var r=e.split("|"),i=0,c=r.length;c>i;++i)if(!u(r[i],n,t))return!1;return!0}function m(e){for(var n,o,t=e.split(/[;,]/),r=0,i=t.length;i>r;++r)if(n=t[r].split("="),n[0].replace(/^\s+/,"")==S&&(o=n[1]))return decodeURIComponent(o.replace(/\s+$/,""));return null}function p(e){e=e||window;var n=m(e.document.cookie);n&&l(n,e.doc)}function g(n,o){n=n||window,o="object"==typeof o?o:{};var t=o.expires?";expires="+o.expires.toUTCString():"",r=o.path?";path="+o.path:"",i=o.domain?";domain="+o.domain:"",c=o.secure?";secure":"",a=s(e.getSelection(n));n.document.cookie=encodeURIComponent(S)+"="+encodeURIComponent(a)+t+r+i+c}var h="undefined";(typeof encodeURIComponent==h||typeof decodeURIComponent==h)&&n.fail("encodeURIComponent and/or decodeURIComponent method is missing");var v=function(){function e(e){for(var n,o=[],t=0,r=e.length;r>t;++t)n=e.charCodeAt(t),128>n?o.push(n):2048>n?o.push(n>>6|192,63&n|128):o.push(n>>12|224,n>>6&63|128,63&n|128);return o}function n(){for(var e,n,o=[],t=0;256>t;++t){for(n=t,e=8;e--;)1==(1&n)?n=n>>>1^3988292384:n>>>=1;o[t]=n>>>0}return o}function o(){return t||(t=n()),t}var t=null;return function(n){for(var t,r=e(n),i=-1,c=o(),a=0,d=r.length;d>a;++a)t=255&(i^r[a]),i=i>>>8^c[t];return(-1^i)>>>0}}(),w=e.dom,R=/^([^,]+),([^,\{]+)(\{([^}]+)\})?$/,S="rangySerializedSelection";e.serializePosition=i,e.deserializePosition=c,e.serializeRange=a,e.deserializeRange=d,e.canDeserializeRange=u,e.serializeSelection=s,e.deserializeSelection=l,e.canDeserializeSelection=f,e.restoreSelectionFromCookie=p,e.saveSelectionCookie=g,e.getElementChecksum=r,e.nodeToInfoString=t})},this); \ No newline at end of file diff --git a/rangy-textrange.js b/rangy-textrange.js index 215a6cc..58d7528 100644 --- a/rangy-textrange.js +++ b/rangy-textrange.js @@ -20,14 +20,14 @@ * http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html * * Part of Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ /** @@ -257,17 +257,14 @@ } } - function createCharacterOptions(options) { - return createOptions(options, defaultCharacterOptions); - } - - function createCaretCharacterOptions(options) { - return createOptions(options, defaultCaretCharacterOptions); - } - - function createFindOptions(optionsParam) { - var options = createOptions(optionsParam, defaultFindOptions); - options.characterOptions = createCharacterOptions(options.wordOptions); + function createNestedOptions(optionsParam, defaults) { + var options = createOptions(optionsParam, defaults); + if (defaults.hasOwnProperty("wordOptions")) { + options.wordOptions = createWordOptions(options.wordOptions); + } + if (defaults.hasOwnProperty("characterOptions")) { + options.characterOptions = createOptions(options.characterOptions, defaultCharacterOptions); + } return options; } @@ -1478,10 +1475,10 @@ if (isRegex) { result = searchTerm.exec(text); if (result) { + matchStartIndex = result.index; + matchEndIndex = matchStartIndex + result[0].length; if (insideRegexMatch) { // Check whether the match is now over - matchStartIndex = result.index; - matchEndIndex = matchStartIndex + result[0].length; if ((!backward && matchEndIndex < text.length) || (backward && matchStartIndex > 0)) { returnValue = handleMatch(matchStartIndex, matchEndIndex); break; @@ -1534,20 +1531,18 @@ */ return createEntryPointFunction( function(session, unit, count, moveOptions) { - if (typeof count == "undefined") { + if (typeof count == UNDEF) { count = unit; unit = CHARACTER; } - moveOptions = createOptions(moveOptions, defaultMoveOptions); - var characterOptions = createCharacterOptions(moveOptions.characterOptions); - var wordOptions = createWordOptions(moveOptions.wordOptions); + moveOptions = createNestedOptions(moveOptions, defaultMoveOptions); var boundaryIsStart = isStart; if (collapse) { boundaryIsStart = (count >= 0); this.collapse(!boundaryIsStart); } - var moveResult = movePositionBy(session.getRangeBoundaryPosition(this, boundaryIsStart), unit, count, characterOptions, wordOptions); + var moveResult = movePositionBy(session.getRangeBoundaryPosition(this, boundaryIsStart), unit, count, moveOptions.characterOptions, moveOptions.wordOptions); var newPos = moveResult.position; this[boundaryIsStart ? "setStart" : "setEnd"](newPos.node, newPos.offset); return moveResult.unitsMoved; @@ -1558,7 +1553,7 @@ function createRangeTrimmer(isStart) { return createEntryPointFunction( function(session, characterOptions) { - characterOptions = createCharacterOptions(characterOptions); + characterOptions = createOptions(characterOptions, defaultCharacterOptions); var pos; var it = createRangeCharacterIterator(session, this, characterOptions, !isStart); var trimCharCount = 0; @@ -1600,13 +1595,13 @@ expand: createEntryPointFunction( function(session, unit, expandOptions) { var moved = false; - expandOptions = createOptions(expandOptions, defaultExpandOptions); - var characterOptions = createCharacterOptions(expandOptions.characterOptions); + expandOptions = createNestedOptions(expandOptions, defaultExpandOptions); + var characterOptions = expandOptions.characterOptions; if (!unit) { unit = CHARACTER; } if (unit == WORD) { - var wordOptions = createWordOptions(expandOptions.wordOptions); + var wordOptions = expandOptions.wordOptions; var startPos = session.getRangeBoundaryPosition(this, true); var endPos = session.getRangeBoundaryPosition(this, false); @@ -1651,7 +1646,7 @@ text: createEntryPointFunction( function(session, characterOptions) { return this.collapsed ? - "" : getRangeCharacters(session, this, createCharacterOptions(characterOptions)).join(""); + "" : getRangeCharacters(session, this, createOptions(characterOptions, defaultCharacterOptions)).join(""); } ), @@ -1698,12 +1693,10 @@ findText: createEntryPointFunction( function(session, searchTermParam, findOptions) { // Set up options - findOptions = createFindOptions(findOptions); + findOptions = createNestedOptions(findOptions, defaultFindOptions); // Create word options if we're matching whole words only if (findOptions.wholeWordsOnly) { - findOptions.wordOptions = createWordOptions(findOptions.wordOptions); - // We don't ever want trailing spaces for search results findOptions.wordOptions.includeTrailingSpace = false; } @@ -1814,7 +1807,7 @@ if (!options) { options = {}; } - options.characterOptions = createCaretCharacterOptions(options.characterOptions); + options.characterOptions = createOptions(options.characterOptions, defaultCaretCharacterOptions); unitsMoved = range.move(unit, count, options); this.setSingleRange(range); } @@ -1890,11 +1883,9 @@ api.createWordIterator = function(startNode, startOffset, iteratorOptions) { var session = getSession(); - iteratorOptions = createOptions(iteratorOptions, defaultWordIteratorOptions); - var characterOptions = createCharacterOptions(iteratorOptions.characterOptions); - var wordOptions = createWordOptions(iteratorOptions.wordOptions); + iteratorOptions = createNestedOptions(iteratorOptions, defaultWordIteratorOptions); var startPos = session.getPosition(startNode, startOffset); - var tokenizedTextProvider = createTokenizedTextProvider(startPos, characterOptions, wordOptions); + var tokenizedTextProvider = createTokenizedTextProvider(startPos, iteratorOptions.characterOptions, iteratorOptions.wordOptions); var backward = isDirectionBackward(iteratorOptions.direction); return { diff --git a/rangy-textrange.min.js b/rangy-textrange.min.js index e32bde1..04c5a39 100644 --- a/rangy-textrange.min.js +++ b/rangy-textrange.min.js @@ -20,13 +20,13 @@ * http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html * * Part of Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ + * https://github.com/timdown/rangy * * Depends on Rangy core. * * Copyright 2014, Tim Down * Licensed under the MIT license. - * Version: 1.3.0-alpha.20140827 - * Build date: 27 August 2014 + * Version: 1.3.0-alpha.20140921 + * Build date: 21 September 2014 */ -!function(e,t){"function"==typeof define&&define.amd?define(["./rangy-core"],e):"undefined"!=typeof module&&"object"==typeof exports?module.exports=e(require("rangy")):e(t.rangy)}(function(e){e.createModule("TextRange",["WrappedSelection"],function(e,t){function n(e,t){function n(t,n,r){for(var i=e.slice(t,n),o={isWord:r,chars:i,toString:function(){return i.join("")}},a=0,c=i.length;c>a;++a)i[a].token=o;s.push(o)}for(var r,i,o,a=e.join(""),s=[],c=0;r=t.wordRegex.exec(a);){if(i=r.index,o=i+r[0].length,i>c&&n(c,i,!1),t.includeTrailingSpace)for(;Q.test(e[o]);)++o;n(i,o,!0),c=o}return cn;++n)if(1==t[n].nodeType&&"none"==c(t[n]))return!0;return!1}function d(e){var t;return 3==e.nodeType&&(t=e.parentNode)&&"hidden"==ht(t,"visibility")}function l(e){return e&&(1==e.nodeType&&!/^(inline(-block|-table)?|none)$/.test(c(e))||9==e.nodeType||11==e.nodeType)}function h(e){return j.isCharacterDataNode(e)||!/^(area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param)$/i.test(e.nodeName)}function p(e){for(var t=[];e.parentNode;)t.unshift(e.parentNode),e=e.parentNode;return t}function f(e){return p(e).concat([e])}function g(e){for(;e&&!e.nextSibling;)e=e.parentNode;return e?e.nextSibling:null}function v(e,t){return!t&&e.hasChildNodes()?e.firstChild:g(e)}function C(e){var t=e.previousSibling;if(t){for(e=t;e.hasChildNodes();)e=e.lastChild;return e}var n=e.parentNode;return n&&1==n.nodeType?n:null}function S(e){if(!e||3!=e.nodeType)return!1;var t=e.data;if(""===t)return!0;var n=e.parentNode;if(!n||1!=n.nodeType)return!1;var r=ht(e.parentNode,"whiteSpace");return/^[\t\n\r ]+$/.test(t)&&/^(normal|nowrap)$/.test(r)||/^[\t\r ]+$/.test(t)&&"pre-line"==r}function N(e){if(""===e.data)return!0;if(!S(e))return!1;var t=e.parentNode;return t?u(e)?!0:!1:!0}function y(e){var t=e.nodeType;return 7==t||8==t||u(e)||/^(script|style)$/i.test(e.nodeName)||d(e)||N(e)}function m(e,t){var n=e.nodeType;return 7==n||8==n||1==n&&"none"==c(e,t)}function x(){this.store={}}function T(e,t,n){return function(r){var i=this.cache;if(i.hasOwnProperty(e))return ft++,i[e];gt++;var o=t.call(this,n?this[n]:this,r);return i[e]=o,o}}function b(e,t){this.node=e,this.session=t,this.cache=new x,this.positions=new x}function P(e,t){this.offset=t,this.nodeWrapper=e,this.node=e.node,this.session=e.session,this.cache=new x}function w(){return"[Position("+j.inspectNode(this.node)+":"+this.offset+")]"}function R(){return E(),Rt=new Bt}function B(){return Rt||R()}function E(){Rt&&Rt.detach(),Rt=null}function k(e,n,r,i){function o(){var e=null;return n?(e=s,c||(s=s.previousVisible(),c=!s||r&&s.equals(r))):c||(e=s=s.nextVisible(),c=!s||r&&s.equals(r)),c&&(s=null),e}r&&(n?y(r.node)&&(r=e.previousVisible()):y(r.node)&&(r=r.nextVisible()));var a,s=e,c=!1,u=!1;return{next:function(){if(u)return u=!1,a;for(var e,t;e=o();)if(t=e.getCharacter(i))return a=e,e;return null},rewind:function(){if(!a)throw t.createError("createCharacterIterator: cannot rewind. Only one position can be rewound.");u=!0},dispose:function(){e=r=null}}}function O(e,t,n){function r(e){for(var t,n,r=[],a=e?i:o,s=!1,c=!1;t=a.next();){if(n=t.character,J.test(n))c&&(c=!1,s=!0);else{if(s){a.rewind();break}c=!0}r.push(t)}return r}var i=k(e,!1,null,t),o=k(e,!0,null,t),a=n.tokenizer,s=r(!0),c=r(!1).reverse(),u=a(c.concat(s),n),d=s.length?u.slice(Et(u,s[0].token)):[],l=c.length?u.slice(0,Et(u,c.pop().token)+1):[];return{nextEndToken:function(){for(var e,t;1==d.length&&!(e=d[0]).isWord&&(t=r(!0)).length>0;)d=a(e.chars.concat(t),n);return d.shift()},previousStartToken:function(){for(var e,t;1==l.length&&!(e=l[0]).isWord&&(t=r(!1)).length>0;)l=a(t.reverse().concat(e.chars),n);return l.pop()},dispose:function(){i.dispose(),o.dispose(),d=l=null}}}function L(e,t,n,r,i){var o,a,s,c,u=0,d=e,l=Math.abs(n);if(0!==n){var h=0>n;switch(t){case M:for(a=k(e,h,null,r);(o=a.next())&&l>u;)++u,d=o;s=o,a.dispose();break;case q:for(var p=O(e,r,i),f=h?p.previousStartToken:p.nextEndToken;(c=f())&&l>u;)c.isWord&&(++u,d=h?c.chars[0]:c.chars[c.chars.length-1]);break;default:throw new Error("movePositionBy: unit '"+t+"' not implemented")}h?(d=d.previousVisible(),u=-u):d&&d.isLeadingSpace&&(t==q&&(a=k(e,!1,null,r),s=a.next(),a.dispose()),s&&(d=s.previousVisible()))}return{position:d,unitsMoved:u}}function A(e,t,n,r){var i=e.getRangeBoundaryPosition(t,!0),o=e.getRangeBoundaryPosition(t,!1),a=r?o:i,s=r?i:o;return k(a,!!r,s,n)}function I(e,t,n){for(var r,i=[],o=A(e,t,n);r=o.next();)i.push(r);return o.dispose(),i}function W(t,n,r){var i=e.createRange(t.node);i.setStartAndEnd(t.node,t.offset,n.node,n.offset);var o=!i.expand("word",r);return o}function _(e,t,n,r,i){function o(e,t){var n=g[e].previousVisible(),r=g[t-1],o=!i.wholeWordsOnly||W(n,r,i.wordOptions);return{startPos:n,endPos:r,valid:o}}for(var a,s,c,u,d,l,h=Z(i.direction),p=k(e,h,e.session.getRangeBoundaryPosition(r,h),i.characterOptions),f="",g=[],v=null;a=p.next();)if(s=a.character,n||i.caseSensitive||(s=s.toLowerCase()),h?(g.unshift(a),f=s+f):(g.push(a),f+=s),n){if(d=t.exec(f))if(l){if(c=d.index,u=c+d[0].length,!h&&u0){v=o(c,u);break}}else l=!0}else if(-1!=(c=f.indexOf(t))){v=o(c,c+t.length);break}return l&&(v=o(c,u)),p.dispose(),v}function D(e){return function(){var t=!!Rt,n=B(),r=[n].concat(U.toArray(arguments)),i=e.apply(this,r);return t||E(),i}}function F(e,t){return D(function(n,r,a,s){"undefined"==typeof a&&(a=r,r=M),s=H(s,ut);var c=o(s.characterOptions),u=i(s.wordOptions),d=e;t&&(d=a>=0,this.collapse(!d));var l=L(n.getRangeBoundaryPosition(this,d),r,a,c,u),h=l.position;return this[d?"setStart":"setEnd"](h.node,h.offset),l.unitsMoved})}function V(e){return D(function(t,n){n=o(n);for(var r,i=A(t,this,n,!e),a=0;(r=i.next())&&J.test(r.character);)++a;i.dispose();var s=a>0;return s&&this[e?"moveStart":"moveEnd"]("character",e?a:-a,{characterOptions:n}),s})}function $(e){return D(function(t,n){var r=!1;return this.changeEachRange(function(t){r=t[e](n)||r}),r})}var M="character",q="word",j=e.dom,U=e.util,G=U.extend,H=U.createOptions,z=j.getBody,K=/^[ \t\f\r\n]+$/,Y=/^[ \t\f\r]+$/,J=/^[\t-\r \u0085\u00A0\u1680\u180E\u2000-\u200B\u2028\u2029\u202F\u205F\u3000]+$/,Q=/^[\t \u00A0\u1680\u180E\u2000-\u200B\u202F\u205F\u3000]+$/,X="en",Z=e.Selection.isDirectionBackward,et=!1,tt=!1,nt=!1,rt=!0;!function(){var t=document.createElement("div");t.contentEditable="true",t.innerHTML="

1

";var n=z(document),r=t.firstChild,i=e.getSelection();n.appendChild(t),i.collapse(r.lastChild,2),i.setStart(r.firstChild,0),et=1==(""+i).length,t.innerHTML="1
",i.collapse(t,2),i.setStart(t.firstChild,0),tt=1==(""+i).length,t.innerHTML="1

1

",i.collapse(t,2),i.setStart(t.firstChild,0),nt=1==(""+i).length,n.removeChild(t),i.removeAllRanges()}();var it,ot={includeBlockContentTrailingSpace:!0,includeSpaceBeforeBr:!0,includeSpaceBeforeBlock:!0,includePreLineTrailingSpace:!0,ignoreCharacters:""},at={includeBlockContentTrailingSpace:!rt,includeSpaceBeforeBr:!tt,includeSpaceBeforeBlock:!nt,includePreLineTrailingSpace:!0},st={en:{wordRegex:/[a-z0-9]+('[a-z0-9]+)*/gi,includeTrailingSpace:!1,tokenizer:n}},ct={caseSensitive:!1,withinRange:null,wholeWordsOnly:!1,wrap:!1,direction:"forward",wordOptions:null,characterOptions:null},ut={wordOptions:null,characterOptions:null},dt={wordOptions:null,characterOptions:null,trim:!1,trimStart:!0,trimEnd:!0},lt={wordOptions:null,characterOptions:null,direction:"forward"},ht=j.getComputedStyleProperty;!function(){var e=document.createElement("table"),t=z(document);t.appendChild(e),it="block"==ht(e,"display"),t.removeChild(e)}(),e.features.tableCssDisplayBlock=it;var pt={table:"table",caption:"table-caption",colgroup:"table-column-group",col:"table-column",thead:"table-header-group",tbody:"table-row-group",tfoot:"table-footer-group",tr:"table-row",td:"table-cell",th:"table-cell"};x.prototype={get:function(e){return this.store.hasOwnProperty(e)?this.store[e]:null},set:function(e,t){return this.store[e]=t}};var ft=0,gt=0,vt={getPosition:function(e){var t=this.positions;return t.get(e)||t.set(e,new P(this,e))},toString:function(){return"[NodeWrapper("+j.inspectNode(this.node)+")]"}};b.prototype=vt;var Ct="EMPTY",St="NON_SPACE",Nt="UNCOLLAPSIBLE_SPACE",yt="COLLAPSIBLE_SPACE",mt="TRAILING_SPACE_BEFORE_BLOCK",xt="TRAILING_SPACE_IN_BLOCK",Tt="TRAILING_SPACE_BEFORE_BR",bt="PRE_LINE_TRAILING_SPACE_BEFORE_LINE_BREAK",Pt="TRAILING_LINE_BREAK_AFTER_BR";G(vt,{isCharacterDataNode:T("isCharacterDataNode",j.isCharacterDataNode,"node"),getNodeIndex:T("nodeIndex",j.getNodeIndex,"node"),getLength:T("nodeLength",j.getNodeLength,"node"),containsPositions:T("containsPositions",h,"node"),isWhitespace:T("isWhitespace",S,"node"),isCollapsedWhitespace:T("isCollapsedWhitespace",N,"node"),getComputedDisplay:T("computedDisplay",c,"node"),isCollapsed:T("collapsed",y,"node"),isIgnored:T("ignored",m,"node"),next:T("nextPos",v,"node"),previous:T("previous",C,"node"),getTextNodeInfo:T("textNodeInfo",function(e){var t=null,n=!1,r=ht(e.parentNode,"whiteSpace"),i="pre-line"==r;return i?(t=Y,n=!0):("normal"==r||"nowrap"==r)&&(t=K,n=!0),{node:e,text:e.data,spaceRegex:t,collapseSpaces:n,preLine:i}},"node"),hasInnerText:T("hasInnerText",function(e,t){for(var n=this.session,r=n.getPosition(e.parentNode,this.getNodeIndex()+1),i=n.getPosition(e,0),o=t?r:i,a=t?i:r;o!==a;){if(o.prepopulateChar(),o.isDefinitelyNonEmpty())return!0;o=t?o.previousVisible():o.nextVisible()}return!1},"node"),isRenderedBlock:T("isRenderedBlock",function(e){for(var t=e.getElementsByTagName("br"),n=0,r=t.length;r>n;++n)if(!y(t[n]))return!0;return this.hasInnerText()},"node"),getTrailingSpace:T("trailingSpace",function(e){if("br"==e.tagName.toLowerCase())return"";switch(this.getComputedDisplay()){case"inline":for(var t=e.lastChild;t;){if(!m(t))return 1==t.nodeType?this.session.getNodeWrapper(t).getTrailingSpace():"";t=t.previousSibling}break;case"inline-block":case"inline-table":case"none":case"table-column":case"table-column-group":break;case"table-cell":return" ";default:return this.isRenderedBlock(!0)?"\n":""}return""},"node"),getLeadingSpace:T("leadingSpace",function(){switch(this.getComputedDisplay()){case"inline":case"inline-block":case"inline-table":case"none":case"table-column":case"table-column-group":case"table-cell":break;default:return this.isRenderedBlock(!1)?"\n":""}return""},"node")});var wt={character:"",characterType:Ct,isBr:!1,prepopulateChar:function(){var e=this;if(!e.prepopulatedChar){var t=e.node,n=e.offset,r="",i=Ct,o=!1;if(n>0)if(3==t.nodeType){var a=t.data,s=a.charAt(n-1),c=e.nodeWrapper.getTextNodeInfo(),u=c.spaceRegex;c.collapseSpaces?u.test(s)?n>1&&u.test(a.charAt(n-2))||(c.preLine&&"\n"===a.charAt(n)?(r=" ",i=bt):(r=" ",i=yt)):(r=s,i=St,o=!0):(r=s,i=Nt,o=!0)}else{var d=t.childNodes[n-1];if(d&&1==d.nodeType&&!y(d)&&("br"==d.tagName.toLowerCase()?(r="\n",e.isBr=!0,i=yt,o=!1):e.checkForTrailingSpace=!0),!r){var l=t.childNodes[n];l&&1==l.nodeType&&!y(l)&&(e.checkForLeadingSpace=!0)}}e.prepopulatedChar=!0,e.character=r,e.characterType=i,e.isCharInvariant=o}},isDefinitelyNonEmpty:function(){var e=this.characterType;return e==St||e==Nt},resolveLeadingAndTrailingSpaces:function(){if(this.prepopulatedChar||this.prepopulateChar(),this.checkForTrailingSpace){var e=this.session.getNodeWrapper(this.node.childNodes[this.offset-1]).getTrailingSpace();e&&(this.isTrailingSpace=!0,this.character=e,this.characterType=yt),this.checkForTrailingSpace=!1}if(this.checkForLeadingSpace){var t=this.session.getNodeWrapper(this.node.childNodes[this.offset]).getLeadingSpace();t&&(this.isLeadingSpace=!0,this.character=t,this.characterType=yt),this.checkForLeadingSpace=!1}},getPrecedingUncollapsedPosition:function(e){for(var t,n=this;n=n.previousVisible();)if(t=n.getCharacter(e),""!==t)return n;return null},getCharacter:function(e){function t(){return p||(d=f.getPrecedingUncollapsedPosition(e),p=!0),d}this.resolveLeadingAndTrailingSpaces();var n,i=this.character,o=r(e.ignoreCharacters),a=""!==i&&o.indexOf(i)>-1;if(this.isCharInvariant)return n=a?"":i;var s=["character",e.includeSpaceBeforeBr,e.includeBlockContentTrailingSpace,e.includePreLineTrailingSpace,o].join("_"),c=this.cache.get(s);if(null!==c)return c;var u,d,l="",h=this.characterType==yt,p=!1,f=this;return h?(" "!=i||t()&&!d.isTrailingSpace&&"\n"!=d.character)&&("\n"==i&&this.isLeadingSpace?t()&&"\n"!=d.character&&(l="\n"):(u=this.nextUncollapsed(),u&&(u.isBr?this.type=Tt:u.isTrailingSpace&&"\n"==u.character?this.type=xt:u.isLeadingSpace&&"\n"==u.character&&(this.type=mt),"\n"==u.character?(this.type!=Tt||e.includeSpaceBeforeBr)&&(this.type!=mt||e.includeSpaceBeforeBlock)&&(this.type==xt&&u.isTrailingSpace&&!e.includeBlockContentTrailingSpace||(this.type!=bt||u.type!=St||e.includePreLineTrailingSpace)&&("\n"==i?u.isTrailingSpace?this.isTrailingSpace||this.isBr&&(u.type=Pt,t()&&d.isLeadingSpace&&"\n"==d.character&&(u.character="")):l="\n":" "==i&&(l=" "))):l=i))):"\n"==i&&(!(u=this.nextUncollapsed())||u.isTrailingSpace),o.indexOf(l)>-1&&(l=""),this.cache.set(s,l),l},equals:function(e){return!!e&&this.node===e.node&&this.offset===e.offset},inspect:w,toString:function(){return this.character}};P.prototype=wt,G(wt,{next:T("nextPos",function(e){var t=e.nodeWrapper,n=e.node,r=e.offset,i=t.session;if(!n)return null;var o,a,s;return r==t.getLength()?(o=n.parentNode,a=o?t.getNodeIndex()+1:0):t.isCharacterDataNode()?(o=n,a=r+1):(s=n.childNodes[r],i.getNodeWrapper(s).containsPositions()?(o=s,a=0):(o=n,a=r+1)),o?i.getPosition(o,a):null}),previous:T("previous",function(e){var t,n,r,i=e.nodeWrapper,o=e.node,a=e.offset,s=i.session;return 0==a?(t=o.parentNode,n=t?i.getNodeIndex():0):i.isCharacterDataNode()?(t=o,n=a-1):(r=o.childNodes[a-1],s.getNodeWrapper(r).containsPositions()?(t=r,n=j.getNodeLength(r)):(t=o,n=a-1)),t?s.getPosition(t,n):null}),nextVisible:T("nextVisible",function(e){var t=e.next();if(!t)return null;var n=t.nodeWrapper,r=t.node,i=t;return n.isCollapsed()&&(i=n.session.getPosition(r.parentNode,n.getNodeIndex()+1)),i}),nextUncollapsed:T("nextUncollapsed",function(e){for(var t=e;t=t.nextVisible();)if(t.resolveLeadingAndTrailingSpaces(),""!==t.character)return t;return null}),previousVisible:T("previousVisible",function(e){var t=e.previous();if(!t)return null;var n=t.nodeWrapper,r=t.node,i=t;return n.isCollapsed()&&(i=n.session.getPosition(r.parentNode,n.getNodeIndex())),i})});var Rt=null,Bt=function(){function e(e){var t=new x;return{get:function(n){var r=t.get(n[e]);if(r)for(var i,o=0;i=r[o++];)if(i.node===n)return i;return null},set:function(n){var r=n.node[e],i=t.get(r)||t.set(r,[]);i.push(n)}}}function t(){this.initCaches()}var n=U.isHostProperty(document.documentElement,"uniqueID");return t.prototype={initCaches:function(){this.elementCache=n?function(){var e=new x;return{get:function(t){return e.get(t.uniqueID)},set:function(t){e.set(t.node.uniqueID,t)}}}():e("tagName"),this.textNodeCache=e("data"),this.otherNodeCache=e("nodeName")},getNodeWrapper:function(e){var t;switch(e.nodeType){case 1:t=this.elementCache;break;case 3:t=this.textNodeCache;break;default:t=this.otherNodeCache}var n=t.get(e);return n||(n=new b(e,this),t.set(n)),n},getPosition:function(e,t){return this.getNodeWrapper(e).getPosition(t)},getRangeBoundaryPosition:function(e,t){var n=t?"start":"end";return this.getPosition(e[n+"Container"],e[n+"Offset"])},detach:function(){this.elementCache=this.textNodeCache=this.otherNodeCache=null}},t}();G(j,{nextNode:v,previousNode:C});var Et=Array.prototype.indexOf?function(e,t){return e.indexOf(t)}:function(e,t){for(var n=0,r=e.length;r>n;++n)if(e[n]===t)return n;return-1};G(e.rangePrototype,{moveStart:F(!0,!1),moveEnd:F(!1,!1),move:F(!0,!0),trimStart:V(!0),trimEnd:V(!1),trim:D(function(e,t){var n=this.trimStart(t),r=this.trimEnd(t);return n||r}),expand:D(function(e,t,n){var r=!1;n=H(n,dt);var a=o(n.characterOptions);if(t||(t=M),t==q){var s,c,u=i(n.wordOptions),d=e.getRangeBoundaryPosition(this,!0),l=e.getRangeBoundaryPosition(this,!1),h=O(d,a,u),p=h.nextEndToken(),f=p.chars[0].previousVisible();if(this.collapsed)s=p;else{var g=O(l,a,u);s=g.previousStartToken()}return c=s.chars[s.chars.length-1],f.equals(d)||(this.setStart(f.node,f.offset),r=!0),c&&!c.equals(l)&&(this.setEnd(c.node,c.offset),r=!0),n.trim&&(n.trimStart&&(r=this.trimStart(a)||r),n.trimEnd&&(r=this.trimEnd(a)||r)),r}return this.moveEnd(M,1,n)}),text:D(function(e,t){return this.collapsed?"":I(e,this,o(t)).join("")}),selectCharacters:D(function(e,t,n,r,i){var o={characterOptions:i};t||(t=z(this.getDocument())),this.selectNodeContents(t),this.collapse(!0),this.moveStart("character",n,o),this.collapse(!0),this.moveEnd("character",r-n,o)}),toCharacterRange:D(function(e,t,n){t||(t=z(this.getDocument()));var r,i,o=t.parentNode,a=j.getNodeIndex(t),s=-1==j.comparePoints(this.startContainer,this.endContainer,o,a),c=this.cloneRange();return s?(c.setStartAndEnd(this.startContainer,this.startOffset,o,a),r=-c.text(n).length):(c.setStartAndEnd(o,a,this.startContainer,this.startOffset),r=c.text(n).length),i=r+this.text(n).length,{start:r,end:i}}),findText:D(function(t,n,r){r=s(r),r.wholeWordsOnly&&(r.wordOptions=i(r.wordOptions),r.wordOptions.includeTrailingSpace=!1);var o=Z(r.direction),a=r.withinRange;a||(a=e.createRange(),a.selectNodeContents(this.getDocument()));var c=n,u=!1;"string"==typeof c?r.caseSensitive||(c=c.toLowerCase()):u=!0;var d=t.getRangeBoundaryPosition(this,!o),l=a.comparePoint(d.node,d.offset);-1===l?d=t.getRangeBoundaryPosition(a,!0):1===l&&(d=t.getRangeBoundaryPosition(a,!1));for(var h,p=d,f=!1;;)if(h=_(p,c,u,a,r)){if(h.valid)return this.setStartAndEnd(h.startPos.node,h.startPos.offset,h.endPos.node,h.endPos.offset),!0;p=o?h.startPos:h.endPos}else{if(!r.wrap||f)return!1;a=a.cloneRange(),p=t.getRangeBoundaryPosition(a,!o),a.setBoundary(d.node,d.offset,o),f=!0}}),pasteHtml:function(e){if(this.deleteContents(),e){var t=this.createContextualFragment(e),n=t.lastChild;this.insertNode(t),this.collapseAfter(n)}}}),G(e.selectionPrototype,{expand:D(function(e,t,n){this.changeEachRange(function(e){e.expand(t,n)})}),move:D(function(e,t,n,r){var i=0;if(this.focusNode){this.collapse(this.focusNode,this.focusOffset);var o=this.getRangeAt(0);r||(r={}),r.characterOptions=a(r.characterOptions),i=o.move(t,n,r),this.setSingleRange(o)}return i}),trimStart:$("trimStart"),trimEnd:$("trimEnd"),trim:$("trim"),selectCharacters:D(function(t,n,r,i,o,a){var s=e.createRange(n);s.selectCharacters(n,r,i,a),this.setSingleRange(s,o)}),saveCharacterRanges:D(function(e,t,n){for(var r=this.getAllRanges(),i=r.length,o=[],a=1==i&&this.isBackward(),s=0,c=r.length;c>s;++s)o[s]={characterRange:r[s].toCharacterRange(t,n),backward:a,characterOptions:n};return o}),restoreCharacterRanges:D(function(t,n,r){this.removeAllRanges();for(var i,o,a,s=0,c=r.length;c>s;++s)o=r[s],a=o.characterRange,i=e.createRange(n),i.selectCharacters(n,a.start,a.end,o.characterOptions),this.addRange(i,o.backward)}),text:D(function(e,t){for(var n=[],r=0,i=this.rangeCount;i>r;++r)n[r]=this.getRangeAt(r).text(t);return n.join("")})}),e.innerText=function(t,n){var r=e.createRange(t);r.selectNodeContents(t);var i=r.text(n);return i},e.createWordIterator=function(e,t,n){var r=B();n=H(n,lt);var a=o(n.characterOptions),s=i(n.wordOptions),c=r.getPosition(e,t),u=O(c,a,s),d=Z(n.direction);return{next:function(){return d?u.previousStartToken():u.nextEndToken()},dispose:function(){u.dispose(),this.next=function(){}}}},e.noMutation=function(e){var t=B();e(t),E()},e.noMutation.createEntryPointFunction=D,e.textRange={isBlockNode:l,isCollapsedWhitespaceNode:N,createPosition:D(function(e,t,n){return e.getPosition(t,n)})}})},this); \ No newline at end of file +!function(e,t){"function"==typeof define&&define.amd?define(["./rangy-core"],e):"undefined"!=typeof module&&"object"==typeof exports?module.exports=e(require("rangy")):e(t.rangy)}(function(e){e.createModule("TextRange",["WrappedSelection"],function(e,t){function n(e,t){function n(t,n,r){for(var i=e.slice(t,n),o={isWord:r,chars:i,toString:function(){return i.join("")}},a=0,c=i.length;c>a;++a)i[a].token=o;s.push(o)}for(var r,i,o,a=e.join(""),s=[],c=0;r=t.wordRegex.exec(a);){if(i=r.index,o=i+r[0].length,i>c&&n(c,i,!1),t.includeTrailingSpace)for(;J.test(e[o]);)++o;n(i,o,!0),c=o}return cn;++n)if(1==t[n].nodeType&&"none"==a(t[n]))return!0;return!1}function c(e){var t;return 3==e.nodeType&&(t=e.parentNode)&&"hidden"==lt(t,"visibility")}function u(e){return e&&(1==e.nodeType&&!/^(inline(-block|-table)?|none)$/.test(a(e))||9==e.nodeType||11==e.nodeType)}function d(e){return q.isCharacterDataNode(e)||!/^(area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param)$/i.test(e.nodeName)}function l(e){for(var t=[];e.parentNode;)t.unshift(e.parentNode),e=e.parentNode;return t}function h(e){return l(e).concat([e])}function p(e){for(;e&&!e.nextSibling;)e=e.parentNode;return e?e.nextSibling:null}function f(e,t){return!t&&e.hasChildNodes()?e.firstChild:p(e)}function g(e){var t=e.previousSibling;if(t){for(e=t;e.hasChildNodes();)e=e.lastChild;return e}var n=e.parentNode;return n&&1==n.nodeType?n:null}function v(e){if(!e||3!=e.nodeType)return!1;var t=e.data;if(""===t)return!0;var n=e.parentNode;if(!n||1!=n.nodeType)return!1;var r=lt(e.parentNode,"whiteSpace");return/^[\t\n\r ]+$/.test(t)&&/^(normal|nowrap)$/.test(r)||/^[\t\r ]+$/.test(t)&&"pre-line"==r}function C(e){if(""===e.data)return!0;if(!v(e))return!1;var t=e.parentNode;return t?s(e)?!0:!1:!0}function S(e){var t=e.nodeType;return 7==t||8==t||s(e)||/^(script|style)$/i.test(e.nodeName)||c(e)||C(e)}function y(e,t){var n=e.nodeType;return 7==n||8==n||1==n&&"none"==a(e,t)}function N(){this.store={}}function m(e,t,n){return function(r){var i=this.cache;if(i.hasOwnProperty(e))return pt++,i[e];ft++;var o=t.call(this,n?this[n]:this,r);return i[e]=o,o}}function x(e,t){this.node=e,this.session=t,this.cache=new N,this.positions=new N}function T(e,t){this.offset=t,this.nodeWrapper=e,this.node=e.node,this.session=e.session,this.cache=new N}function b(){return"[Position("+q.inspectNode(this.node)+":"+this.offset+")]"}function P(){return R(),wt=new Rt}function w(){return wt||P()}function R(){wt&&wt.detach(),wt=null}function B(e,n,r,i){function o(){var e=null;return n?(e=s,c||(s=s.previousVisible(),c=!s||r&&s.equals(r))):c||(e=s=s.nextVisible(),c=!s||r&&s.equals(r)),c&&(s=null),e}r&&(n?S(r.node)&&(r=e.previousVisible()):S(r.node)&&(r=r.nextVisible()));var a,s=e,c=!1,u=!1;return{next:function(){if(u)return u=!1,a;for(var e,t;e=o();)if(t=e.getCharacter(i))return a=e,e;return null},rewind:function(){if(!a)throw t.createError("createCharacterIterator: cannot rewind. Only one position can be rewound.");u=!0},dispose:function(){e=r=null}}}function E(e,t,n){function r(e){for(var t,n,r=[],a=e?i:o,s=!1,c=!1;t=a.next();){if(n=t.character,Y.test(n))c&&(c=!1,s=!0);else{if(s){a.rewind();break}c=!0}r.push(t)}return r}var i=B(e,!1,null,t),o=B(e,!0,null,t),a=n.tokenizer,s=r(!0),c=r(!1).reverse(),u=a(c.concat(s),n),d=s.length?u.slice(Bt(u,s[0].token)):[],l=c.length?u.slice(0,Bt(u,c.pop().token)+1):[];return{nextEndToken:function(){for(var e,t;1==d.length&&!(e=d[0]).isWord&&(t=r(!0)).length>0;)d=a(e.chars.concat(t),n);return d.shift()},previousStartToken:function(){for(var e,t;1==l.length&&!(e=l[0]).isWord&&(t=r(!1)).length>0;)l=a(t.reverse().concat(e.chars),n);return l.pop()},dispose:function(){i.dispose(),o.dispose(),d=l=null}}}function O(e,t,n,r,i){var o,a,s,c,u=0,d=e,l=Math.abs(n);if(0!==n){var h=0>n;switch(t){case $:for(a=B(e,h,null,r);(o=a.next())&&l>u;)++u,d=o;s=o,a.dispose();break;case M:for(var p=E(e,r,i),f=h?p.previousStartToken:p.nextEndToken;(c=f())&&l>u;)c.isWord&&(++u,d=h?c.chars[0]:c.chars[c.chars.length-1]);break;default:throw new Error("movePositionBy: unit '"+t+"' not implemented")}h?(d=d.previousVisible(),u=-u):d&&d.isLeadingSpace&&(t==M&&(a=B(e,!1,null,r),s=a.next(),a.dispose()),s&&(d=s.previousVisible()))}return{position:d,unitsMoved:u}}function k(e,t,n,r){var i=e.getRangeBoundaryPosition(t,!0),o=e.getRangeBoundaryPosition(t,!1),a=r?o:i,s=r?i:o;return B(a,!!r,s,n)}function L(e,t,n){for(var r,i=[],o=k(e,t,n);r=o.next();)i.push(r);return o.dispose(),i}function A(t,n,r){var i=e.createRange(t.node);i.setStartAndEnd(t.node,t.offset,n.node,n.offset);var o=!i.expand("word",r);return o}function I(e,t,n,r,i){function o(e,t){var n=g[e].previousVisible(),r=g[t-1],o=!i.wholeWordsOnly||A(n,r,i.wordOptions);return{startPos:n,endPos:r,valid:o}}for(var a,s,c,u,d,l,h=X(i.direction),p=B(e,h,e.session.getRangeBoundaryPosition(r,h),i.characterOptions),f="",g=[],v=null;a=p.next();)if(s=a.character,n||i.caseSensitive||(s=s.toLowerCase()),h?(g.unshift(a),f=s+f):(g.push(a),f+=s),n){if(d=t.exec(f))if(c=d.index,u=c+d[0].length,l){if(!h&&u0){v=o(c,u);break}}else l=!0}else if(-1!=(c=f.indexOf(t))){v=o(c,c+t.length);break}return l&&(v=o(c,u)),p.dispose(),v}function W(e){return function(){var t=!!wt,n=w(),r=[n].concat(j.toArray(arguments)),i=e.apply(this,r);return t||R(),i}}function _(e,t){return W(function(n,r,i,a){typeof i==V&&(i=r,r=$),a=o(a,ct);var s=e;t&&(s=i>=0,this.collapse(!s));var c=O(n.getRangeBoundaryPosition(this,s),r,i,a.characterOptions,a.wordOptions),u=c.position;return this[s?"setStart":"setEnd"](u.node,u.offset),c.unitsMoved})}function D(e){return W(function(t,n){n=G(n,it);for(var r,i=k(t,this,n,!e),o=0;(r=i.next())&&Y.test(r.character);)++o;i.dispose();var a=o>0;return a&&this[e?"moveStart":"moveEnd"]("character",e?o:-o,{characterOptions:n}),a})}function F(e){return W(function(t,n){var r=!1;return this.changeEachRange(function(t){r=t[e](n)||r}),r})}var V="undefined",$="character",M="word",q=e.dom,j=e.util,U=j.extend,G=j.createOptions,H=q.getBody,z=/^[ \t\f\r\n]+$/,K=/^[ \t\f\r]+$/,Y=/^[\t-\r \u0085\u00A0\u1680\u180E\u2000-\u200B\u2028\u2029\u202F\u205F\u3000]+$/,J=/^[\t \u00A0\u1680\u180E\u2000-\u200B\u202F\u205F\u3000]+$/,Q="en",X=e.Selection.isDirectionBackward,Z=!1,et=!1,tt=!1,nt=!0;!function(){var t=document.createElement("div");t.contentEditable="true",t.innerHTML="

1

";var n=H(document),r=t.firstChild,i=e.getSelection();n.appendChild(t),i.collapse(r.lastChild,2),i.setStart(r.firstChild,0),Z=1==(""+i).length,t.innerHTML="1
",i.collapse(t,2),i.setStart(t.firstChild,0),et=1==(""+i).length,t.innerHTML="1

1

",i.collapse(t,2),i.setStart(t.firstChild,0),tt=1==(""+i).length,n.removeChild(t),i.removeAllRanges()}();var rt,it={includeBlockContentTrailingSpace:!0,includeSpaceBeforeBr:!0,includeSpaceBeforeBlock:!0,includePreLineTrailingSpace:!0,ignoreCharacters:""},ot={includeBlockContentTrailingSpace:!nt,includeSpaceBeforeBr:!et,includeSpaceBeforeBlock:!tt,includePreLineTrailingSpace:!0},at={en:{wordRegex:/[a-z0-9]+('[a-z0-9]+)*/gi,includeTrailingSpace:!1,tokenizer:n}},st={caseSensitive:!1,withinRange:null,wholeWordsOnly:!1,wrap:!1,direction:"forward",wordOptions:null,characterOptions:null},ct={wordOptions:null,characterOptions:null},ut={wordOptions:null,characterOptions:null,trim:!1,trimStart:!0,trimEnd:!0},dt={wordOptions:null,characterOptions:null,direction:"forward"},lt=q.getComputedStyleProperty;!function(){var e=document.createElement("table"),t=H(document);t.appendChild(e),rt="block"==lt(e,"display"),t.removeChild(e)}(),e.features.tableCssDisplayBlock=rt;var ht={table:"table",caption:"table-caption",colgroup:"table-column-group",col:"table-column",thead:"table-header-group",tbody:"table-row-group",tfoot:"table-footer-group",tr:"table-row",td:"table-cell",th:"table-cell"};N.prototype={get:function(e){return this.store.hasOwnProperty(e)?this.store[e]:null},set:function(e,t){return this.store[e]=t}};var pt=0,ft=0,gt={getPosition:function(e){var t=this.positions;return t.get(e)||t.set(e,new T(this,e))},toString:function(){return"[NodeWrapper("+q.inspectNode(this.node)+")]"}};x.prototype=gt;var vt="EMPTY",Ct="NON_SPACE",St="UNCOLLAPSIBLE_SPACE",yt="COLLAPSIBLE_SPACE",Nt="TRAILING_SPACE_BEFORE_BLOCK",mt="TRAILING_SPACE_IN_BLOCK",xt="TRAILING_SPACE_BEFORE_BR",Tt="PRE_LINE_TRAILING_SPACE_BEFORE_LINE_BREAK",bt="TRAILING_LINE_BREAK_AFTER_BR";U(gt,{isCharacterDataNode:m("isCharacterDataNode",q.isCharacterDataNode,"node"),getNodeIndex:m("nodeIndex",q.getNodeIndex,"node"),getLength:m("nodeLength",q.getNodeLength,"node"),containsPositions:m("containsPositions",d,"node"),isWhitespace:m("isWhitespace",v,"node"),isCollapsedWhitespace:m("isCollapsedWhitespace",C,"node"),getComputedDisplay:m("computedDisplay",a,"node"),isCollapsed:m("collapsed",S,"node"),isIgnored:m("ignored",y,"node"),next:m("nextPos",f,"node"),previous:m("previous",g,"node"),getTextNodeInfo:m("textNodeInfo",function(e){var t=null,n=!1,r=lt(e.parentNode,"whiteSpace"),i="pre-line"==r;return i?(t=K,n=!0):("normal"==r||"nowrap"==r)&&(t=z,n=!0),{node:e,text:e.data,spaceRegex:t,collapseSpaces:n,preLine:i}},"node"),hasInnerText:m("hasInnerText",function(e,t){for(var n=this.session,r=n.getPosition(e.parentNode,this.getNodeIndex()+1),i=n.getPosition(e,0),o=t?r:i,a=t?i:r;o!==a;){if(o.prepopulateChar(),o.isDefinitelyNonEmpty())return!0;o=t?o.previousVisible():o.nextVisible()}return!1},"node"),isRenderedBlock:m("isRenderedBlock",function(e){for(var t=e.getElementsByTagName("br"),n=0,r=t.length;r>n;++n)if(!S(t[n]))return!0;return this.hasInnerText()},"node"),getTrailingSpace:m("trailingSpace",function(e){if("br"==e.tagName.toLowerCase())return"";switch(this.getComputedDisplay()){case"inline":for(var t=e.lastChild;t;){if(!y(t))return 1==t.nodeType?this.session.getNodeWrapper(t).getTrailingSpace():"";t=t.previousSibling}break;case"inline-block":case"inline-table":case"none":case"table-column":case"table-column-group":break;case"table-cell":return" ";default:return this.isRenderedBlock(!0)?"\n":""}return""},"node"),getLeadingSpace:m("leadingSpace",function(){switch(this.getComputedDisplay()){case"inline":case"inline-block":case"inline-table":case"none":case"table-column":case"table-column-group":case"table-cell":break;default:return this.isRenderedBlock(!1)?"\n":""}return""},"node")});var Pt={character:"",characterType:vt,isBr:!1,prepopulateChar:function(){var e=this;if(!e.prepopulatedChar){var t=e.node,n=e.offset,r="",i=vt,o=!1;if(n>0)if(3==t.nodeType){var a=t.data,s=a.charAt(n-1),c=e.nodeWrapper.getTextNodeInfo(),u=c.spaceRegex;c.collapseSpaces?u.test(s)?n>1&&u.test(a.charAt(n-2))||(c.preLine&&"\n"===a.charAt(n)?(r=" ",i=Tt):(r=" ",i=yt)):(r=s,i=Ct,o=!0):(r=s,i=St,o=!0)}else{var d=t.childNodes[n-1];if(d&&1==d.nodeType&&!S(d)&&("br"==d.tagName.toLowerCase()?(r="\n",e.isBr=!0,i=yt,o=!1):e.checkForTrailingSpace=!0),!r){var l=t.childNodes[n];l&&1==l.nodeType&&!S(l)&&(e.checkForLeadingSpace=!0)}}e.prepopulatedChar=!0,e.character=r,e.characterType=i,e.isCharInvariant=o}},isDefinitelyNonEmpty:function(){var e=this.characterType;return e==Ct||e==St},resolveLeadingAndTrailingSpaces:function(){if(this.prepopulatedChar||this.prepopulateChar(),this.checkForTrailingSpace){var e=this.session.getNodeWrapper(this.node.childNodes[this.offset-1]).getTrailingSpace();e&&(this.isTrailingSpace=!0,this.character=e,this.characterType=yt),this.checkForTrailingSpace=!1}if(this.checkForLeadingSpace){var t=this.session.getNodeWrapper(this.node.childNodes[this.offset]).getLeadingSpace();t&&(this.isLeadingSpace=!0,this.character=t,this.characterType=yt),this.checkForLeadingSpace=!1}},getPrecedingUncollapsedPosition:function(e){for(var t,n=this;n=n.previousVisible();)if(t=n.getCharacter(e),""!==t)return n;return null},getCharacter:function(e){function t(){return p||(d=f.getPrecedingUncollapsedPosition(e),p=!0),d}this.resolveLeadingAndTrailingSpaces();var n,i=this.character,o=r(e.ignoreCharacters),a=""!==i&&o.indexOf(i)>-1;if(this.isCharInvariant)return n=a?"":i;var s=["character",e.includeSpaceBeforeBr,e.includeBlockContentTrailingSpace,e.includePreLineTrailingSpace,o].join("_"),c=this.cache.get(s);if(null!==c)return c;var u,d,l="",h=this.characterType==yt,p=!1,f=this;return h?(" "!=i||t()&&!d.isTrailingSpace&&"\n"!=d.character)&&("\n"==i&&this.isLeadingSpace?t()&&"\n"!=d.character&&(l="\n"):(u=this.nextUncollapsed(),u&&(u.isBr?this.type=xt:u.isTrailingSpace&&"\n"==u.character?this.type=mt:u.isLeadingSpace&&"\n"==u.character&&(this.type=Nt),"\n"==u.character?(this.type!=xt||e.includeSpaceBeforeBr)&&(this.type!=Nt||e.includeSpaceBeforeBlock)&&(this.type==mt&&u.isTrailingSpace&&!e.includeBlockContentTrailingSpace||(this.type!=Tt||u.type!=Ct||e.includePreLineTrailingSpace)&&("\n"==i?u.isTrailingSpace?this.isTrailingSpace||this.isBr&&(u.type=bt,t()&&d.isLeadingSpace&&"\n"==d.character&&(u.character="")):l="\n":" "==i&&(l=" "))):l=i))):"\n"==i&&(!(u=this.nextUncollapsed())||u.isTrailingSpace),o.indexOf(l)>-1&&(l=""),this.cache.set(s,l),l},equals:function(e){return!!e&&this.node===e.node&&this.offset===e.offset},inspect:b,toString:function(){return this.character}};T.prototype=Pt,U(Pt,{next:m("nextPos",function(e){var t=e.nodeWrapper,n=e.node,r=e.offset,i=t.session;if(!n)return null;var o,a,s;return r==t.getLength()?(o=n.parentNode,a=o?t.getNodeIndex()+1:0):t.isCharacterDataNode()?(o=n,a=r+1):(s=n.childNodes[r],i.getNodeWrapper(s).containsPositions()?(o=s,a=0):(o=n,a=r+1)),o?i.getPosition(o,a):null}),previous:m("previous",function(e){var t,n,r,i=e.nodeWrapper,o=e.node,a=e.offset,s=i.session;return 0==a?(t=o.parentNode,n=t?i.getNodeIndex():0):i.isCharacterDataNode()?(t=o,n=a-1):(r=o.childNodes[a-1],s.getNodeWrapper(r).containsPositions()?(t=r,n=q.getNodeLength(r)):(t=o,n=a-1)),t?s.getPosition(t,n):null}),nextVisible:m("nextVisible",function(e){var t=e.next();if(!t)return null;var n=t.nodeWrapper,r=t.node,i=t;return n.isCollapsed()&&(i=n.session.getPosition(r.parentNode,n.getNodeIndex()+1)),i}),nextUncollapsed:m("nextUncollapsed",function(e){for(var t=e;t=t.nextVisible();)if(t.resolveLeadingAndTrailingSpaces(),""!==t.character)return t;return null}),previousVisible:m("previousVisible",function(e){var t=e.previous();if(!t)return null;var n=t.nodeWrapper,r=t.node,i=t;return n.isCollapsed()&&(i=n.session.getPosition(r.parentNode,n.getNodeIndex())),i})});var wt=null,Rt=function(){function e(e){var t=new N;return{get:function(n){var r=t.get(n[e]);if(r)for(var i,o=0;i=r[o++];)if(i.node===n)return i;return null},set:function(n){var r=n.node[e],i=t.get(r)||t.set(r,[]);i.push(n)}}}function t(){this.initCaches()}var n=j.isHostProperty(document.documentElement,"uniqueID");return t.prototype={initCaches:function(){this.elementCache=n?function(){var e=new N;return{get:function(t){return e.get(t.uniqueID)},set:function(t){e.set(t.node.uniqueID,t)}}}():e("tagName"),this.textNodeCache=e("data"),this.otherNodeCache=e("nodeName")},getNodeWrapper:function(e){var t;switch(e.nodeType){case 1:t=this.elementCache;break;case 3:t=this.textNodeCache;break;default:t=this.otherNodeCache}var n=t.get(e);return n||(n=new x(e,this),t.set(n)),n},getPosition:function(e,t){return this.getNodeWrapper(e).getPosition(t)},getRangeBoundaryPosition:function(e,t){var n=t?"start":"end";return this.getPosition(e[n+"Container"],e[n+"Offset"])},detach:function(){this.elementCache=this.textNodeCache=this.otherNodeCache=null}},t}();U(q,{nextNode:f,previousNode:g});var Bt=Array.prototype.indexOf?function(e,t){return e.indexOf(t)}:function(e,t){for(var n=0,r=e.length;r>n;++n)if(e[n]===t)return n;return-1};U(e.rangePrototype,{moveStart:_(!0,!1),moveEnd:_(!1,!1),move:_(!0,!0),trimStart:D(!0),trimEnd:D(!1),trim:W(function(e,t){var n=this.trimStart(t),r=this.trimEnd(t);return n||r}),expand:W(function(e,t,n){var r=!1;n=o(n,ut);var i=n.characterOptions;if(t||(t=$),t==M){var a,s,c=n.wordOptions,u=e.getRangeBoundaryPosition(this,!0),d=e.getRangeBoundaryPosition(this,!1),l=E(u,i,c),h=l.nextEndToken(),p=h.chars[0].previousVisible();if(this.collapsed)a=h;else{var f=E(d,i,c);a=f.previousStartToken()}return s=a.chars[a.chars.length-1],p.equals(u)||(this.setStart(p.node,p.offset),r=!0),s&&!s.equals(d)&&(this.setEnd(s.node,s.offset),r=!0),n.trim&&(n.trimStart&&(r=this.trimStart(i)||r),n.trimEnd&&(r=this.trimEnd(i)||r)),r}return this.moveEnd($,1,n)}),text:W(function(e,t){return this.collapsed?"":L(e,this,G(t,it)).join("")}),selectCharacters:W(function(e,t,n,r,i){var o={characterOptions:i};t||(t=H(this.getDocument())),this.selectNodeContents(t),this.collapse(!0),this.moveStart("character",n,o),this.collapse(!0),this.moveEnd("character",r-n,o)}),toCharacterRange:W(function(e,t,n){t||(t=H(this.getDocument()));var r,i,o=t.parentNode,a=q.getNodeIndex(t),s=-1==q.comparePoints(this.startContainer,this.endContainer,o,a),c=this.cloneRange();return s?(c.setStartAndEnd(this.startContainer,this.startOffset,o,a),r=-c.text(n).length):(c.setStartAndEnd(o,a,this.startContainer,this.startOffset),r=c.text(n).length),i=r+this.text(n).length,{start:r,end:i}}),findText:W(function(t,n,r){r=o(r,st),r.wholeWordsOnly&&(r.wordOptions.includeTrailingSpace=!1);var i=X(r.direction),a=r.withinRange;a||(a=e.createRange(),a.selectNodeContents(this.getDocument()));var s=n,c=!1;"string"==typeof s?r.caseSensitive||(s=s.toLowerCase()):c=!0;var u=t.getRangeBoundaryPosition(this,!i),d=a.comparePoint(u.node,u.offset);-1===d?u=t.getRangeBoundaryPosition(a,!0):1===d&&(u=t.getRangeBoundaryPosition(a,!1));for(var l,h=u,p=!1;;)if(l=I(h,s,c,a,r)){if(l.valid)return this.setStartAndEnd(l.startPos.node,l.startPos.offset,l.endPos.node,l.endPos.offset),!0;h=i?l.startPos:l.endPos}else{if(!r.wrap||p)return!1;a=a.cloneRange(),h=t.getRangeBoundaryPosition(a,!i),a.setBoundary(u.node,u.offset,i),p=!0}}),pasteHtml:function(e){if(this.deleteContents(),e){var t=this.createContextualFragment(e),n=t.lastChild;this.insertNode(t),this.collapseAfter(n)}}}),U(e.selectionPrototype,{expand:W(function(e,t,n){this.changeEachRange(function(e){e.expand(t,n)})}),move:W(function(e,t,n,r){var i=0;if(this.focusNode){this.collapse(this.focusNode,this.focusOffset);var o=this.getRangeAt(0);r||(r={}),r.characterOptions=G(r.characterOptions,ot),i=o.move(t,n,r),this.setSingleRange(o)}return i}),trimStart:F("trimStart"),trimEnd:F("trimEnd"),trim:F("trim"),selectCharacters:W(function(t,n,r,i,o,a){var s=e.createRange(n);s.selectCharacters(n,r,i,a),this.setSingleRange(s,o)}),saveCharacterRanges:W(function(e,t,n){for(var r=this.getAllRanges(),i=r.length,o=[],a=1==i&&this.isBackward(),s=0,c=r.length;c>s;++s)o[s]={characterRange:r[s].toCharacterRange(t,n),backward:a,characterOptions:n};return o}),restoreCharacterRanges:W(function(t,n,r){this.removeAllRanges();for(var i,o,a,s=0,c=r.length;c>s;++s)o=r[s],a=o.characterRange,i=e.createRange(n),i.selectCharacters(n,a.start,a.end,o.characterOptions),this.addRange(i,o.backward)}),text:W(function(e,t){for(var n=[],r=0,i=this.rangeCount;i>r;++r)n[r]=this.getRangeAt(r).text(t);return n.join("")})}),e.innerText=function(t,n){var r=e.createRange(t);r.selectNodeContents(t);var i=r.text(n);return i},e.createWordIterator=function(e,t,n){var r=w();n=o(n,dt);var i=r.getPosition(e,t),a=E(i,n.characterOptions,n.wordOptions),s=X(n.direction);return{next:function(){return s?a.previousStartToken():a.nextEndToken()},dispose:function(){a.dispose(),this.next=function(){}}}},e.noMutation=function(e){var t=w();e(t),R()},e.noMutation.createEntryPointFunction=W,e.textRange={isBlockNode:u,isCollapsedWhitespaceNode:C,createPosition:W(function(e,t,n){return e.getPosition(t,n)})}})},this); \ No newline at end of file