{I"
class:ETI"ProcessedAsset; FI"logical_path; TI"spina/wysihtml5.js; FI"
pathname; TI"Q/Users/bram/apps/Spina-template/vendor/assets/javascripts/spina/wysihtml5.js; FI"content_type; TI"application/javascript; TI"
mtime; Tl+ÏÔTI"length; TiVÃI"digest; TI"%5b01c87181da157f16a41e5042979fb1; FI"source; TI"VÃ/*
wysihtml5 v0.4.0pre
https://github.com/xing/wysihtml5
Author: Christopher Blum (https://github.com/tiff)
Copyright (C) 2012 XING AG
Licensed under the MIT license (MIT)
Rangy, a cross-browser JavaScript range and selection library
http://code.google.com/p/rangy/
Copyright 2011, Tim Down
Licensed under the MIT license.
Version: 1.2.2
Build date: 13 November 2011
*/
var wysihtml5={version:"0.4.0pre",commands:{},dom:{},quirks:{},toolbar:{},lang:{},selection:{},views:{},INVISIBLE_SPACE:"\ufeff",EMPTY_FUNCTION:function(){},ELEMENT_NODE:1,TEXT_NODE:3,BACKSPACE_KEY:8,ENTER_KEY:13,ESCAPE_KEY:27,SPACE_KEY:32,DELETE_KEY:46};
window.rangy=function(){function a(a,b){var c=typeof a[b];return c==l||!(c!=h||!a[b])||"unknown"==c}function c(a,b){return!(typeof a[b]!=h||!a[b])}function b(a,b){return typeof a[b]!=p}function d(a){return function(b,c){for(var d=c.length;d--;)if(!a(b,c[d]))return!1;return!0}}function e(a){return a&&r(a,q)&&v(a,D)}function f(a){window.alert("Rangy not supported in your browser. Reason: "+a);t.initialized=!0;t.supported=!1}function g(){if(!t.initialized){var b,d=!1,l=!1;a(document,"createRange")&&
(b=document.createRange(),r(b,u)&&v(b,n)&&(d=!0),b.detach());(b=c(document,"body")?document.body:document.getElementsByTagName("body")[0])&&a(b,"createTextRange")&&(b=b.createTextRange(),e(b)&&(l=!0));d||l||f("Neither Range nor TextRange are implemented");t.initialized=!0;t.features={implementsDomRange:d,implementsTextRange:l};d=A.concat(w);l=0;for(b=d.length;l["+a.childNodes.length+"]":a.nodeName:"[No node]"}function l(a){this._next=this.root=a}function p(a,b){this.node=a;this.offset=b}function n(a){this.code=this[a];this.codeName=a;this.message="DOMException: "+this.codeName}
var u="undefined",D=a.util;D.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||c.fail("document missing a Node creation method");D.isHostMethod(document,"getElementsByTagName")||c.fail("document missing getElementsByTagName method");var q=document.createElement("div");D.areHostMethods(q,["insertBefore","appendChild","cloneNode"])||c.fail("Incomplete Element implementation");D.isHostProperty(q,"innerHTML")||c.fail("Element is missing innerHTML property");q=document.createTextNode("test");
D.areHostMethods(q,["splitText","deleteData","insertData","appendData","cloneNode"])||c.fail("Incomplete Text Node implementation");var r=function(a,b){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1};l.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next,b;if(this._current){b=a.firstChild;if(!b)for(b=null;a!==this.root&&!(b=a.nextSibling);)a=a.parentNode;this._next=b}return this._current},detach:function(){this._current=this._next=this.root=
null}};p.prototype={equals:function(a){return this.node===a.node&this.offset==a.offset},inspect:function(){return"[DomPosition("+h(this.node)+":"+this.offset+")]"}};n.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};n.prototype.toString=function(){return this.message};a.dom={arrayContains:r,isHtmlNamespace:function(a){var b;return typeof a.namespaceURI==u||null===(b=a.namespaceURI)||"http://www.w3.org/1999/xhtml"==
b},parentElement:function(a){a=a.parentNode;return 1==a.nodeType?a:null},getNodeIndex:b,getNodeLength:function(a){var b;return f(a)?a.length:(b=a.childNodes)?b.length:0},getCommonAncestor:d,isAncestorOf:function(a,b,c){for(b=c?b:b.parentNode;b;){if(b===a)return!0;b=b.parentNode}return!1},getClosestAncestorIn:e,isCharacterDataNode:f,insertAfter:g,splitDataNode:function(a,b){var c=a.cloneNode(!1);c.deleteData(0,b);a.deleteData(b,a.length-b);g(c,a);return c},getDocument:k,getWindow:function(a){a=k(a);
if(typeof a.defaultView!=u)return a.defaultView;if(typeof a.parentWindow!=u)return a.parentWindow;throw Error("Cannot get a window object for node");},getIframeWindow:function(a){if(typeof a.contentWindow!=u)return a.contentWindow;if(typeof a.contentDocument!=u)return a.contentDocument.defaultView;throw Error("getIframeWindow: No Window object found for iframe element");},getIframeDocument:function(a){if(typeof a.contentDocument!=u)return a.contentDocument;if(typeof a.contentWindow!=u)return a.contentWindow.document;
throw Error("getIframeWindow: No Document object found for iframe element");},getBody:function(a){return D.isHostObject(a,"body")?a.body:a.getElementsByTagName("body")[0]},getRootContainer:function(a){for(var b;b=a.parentNode;)a=b;return a},comparePoints:function(a,c,l,h){var f;if(a==l)return c===h?0:c=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[c]);return d}function h(a){for(var b,c,e=d(a.range).createDocumentFragment();c=a.next();){b=a.isPartiallySelectedSubtree();c=c.cloneNode(!b);b&&(b=a.getSubtreeIterator(),c.appendChild(h(b)),b.detach(!0));if(10==c.nodeType)throw new F("HIERARCHY_REQUEST_ERR");e.appendChild(c)}return e}function l(a,b,c){var d,e;for(c=c||{stop:!1};d=a.next();)if(a.isPartiallySelectedSubtree())if(!1===
b(d)){c.stop=!0;break}else{if(d=a.getSubtreeIterator(),l(d,b,c),d.detach(!0),c.stop)break}else for(d=m.createIterator(d);e=d.next();)if(!1===b(e)){c.stop=!0;return}}function p(a){for(var b;a.next();)a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),p(b),b.detach(!0)):a.remove()}function n(a){for(var b,c=d(a.range).createDocumentFragment(),e;b=a.next();){a.isPartiallySelectedSubtree()?(b=b.cloneNode(!1),e=a.getSubtreeIterator(),b.appendChild(n(e)),e.detach(!0)):a.remove();if(10==b.nodeType)throw new F("HIERARCHY_REQUEST_ERR");
c.appendChild(b)}return c}function u(a,b,c){var d=!(!b||!b.length),e,h=!!c;d&&(e=RegExp("^("+b.join("|")+")$"));var f=[];l(new q(a,!1),function(a){d&&!e.test(a.nodeType)||h&&!c(a)||f.push(a)});return f}function D(a){return"["+("undefined"==typeof a.getName?"Range":a.getName())+"("+m.inspectNode(a.startContainer)+":"+a.startOffset+", "+m.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function q(a,b){this.range=a;this.clonePartiallySelectedTextNodes=b;if(!a.collapsed){this.sc=a.startContainer;this.so=
a.startOffset;this.ec=a.endContainer;this.eo=a.endOffset;var c=a.commonAncestorContainer;this.sc===this.ec&&m.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==c||m.isCharacterDataNode(this.sc)?m.getClosestAncestorIn(this.sc,c,!0):this.sc.childNodes[this.so],this._last=this.ec!==c||m.isCharacterDataNode(this.ec)?m.getClosestAncestorIn(this.ec,c,!0):this.ec.childNodes[this.eo-1])}}function r(a){this.code=this[a];
this.codeName=a;this.message="RangeException: "+this.codeName}function s(a,b,c){this.nodes=u(a,b,c);this._next=this.nodes[0];this._position=0}function v(a){return function(b,c){for(var d,e=c?b:b.parentNode;e;){d=e.nodeType;if(m.arrayContains(a,d))return e;e=e.parentNode}return null}}function t(a,b){if(da(a,b))throw new r("INVALID_NODE_TYPE_ERR");}function w(a){if(!a.startContainer)throw new F("INVALID_STATE_ERR");}function A(a,b){if(!m.arrayContains(b,a.nodeType))throw new r("INVALID_NODE_TYPE_ERR");
}function z(a,b){if(0>b||b>(m.isCharacterDataNode(a)?a.length:a.childNodes.length))throw new F("INDEX_SIZE_ERR");}function E(a,b){if(S(a,!0)!==S(b,!0))throw new F("WRONG_DOCUMENT_ERR");}function y(a){if(ea(a,!0))throw new F("NO_MODIFICATION_ALLOWED_ERR");}function B(a,b){if(!a)throw new F(b);}function x(a){w(a);if(!m.arrayContains(M,a.startContainer.nodeType)&&!S(a.startContainer,!0)||!m.arrayContains(M,a.endContainer.nodeType)&&!S(a.endContainer,!0)||!(a.startOffset<=(m.isCharacterDataNode(a.startContainer)?
a.startContainer.length:a.startContainer.childNodes.length)&&a.endOffset<=(m.isCharacterDataNode(a.endContainer)?a.endContainer.length:a.endContainer.childNodes.length)))throw Error("Range error: Range is no longer valid after DOM mutation ("+a.inspect()+")");}function L(){}function H(a){a.START_TO_START=U;a.START_TO_END=Y;a.END_TO_END=fa;a.END_TO_START=Z;a.NODE_BEFORE=$;a.NODE_AFTER=aa;a.NODE_BEFORE_AND_AFTER=ba;a.NODE_INSIDE=V}function G(a){H(a);H(a.prototype)}function N(a,b){return function(){x(this);
var c=this.startContainer,d=this.startOffset,e=this.commonAncestorContainer,h=new q(this,!0);c!==e&&(c=m.getClosestAncestorIn(c,e,!0),d=g(c),c=d.node,d=d.offset);l(h,y);h.reset();e=a(h);h.detach();b(this,c,d,c,d);return e}}function P(c,d,e){function l(a,b){return function(c){w(this);A(c,J);A(Q(c),M);c=(a?f:g)(c);(b?h:T)(this,c.node,c.offset)}}function h(a,b,c){var e=a.endContainer,l=a.endOffset;if(b!==a.startContainer||c!==a.startOffset){if(Q(b)!=Q(e)||1==m.comparePoints(b,c,e,l))e=b,l=c;d(a,b,c,
e,l)}}function T(a,b,c){var e=a.startContainer,l=a.startOffset;if(b!==a.endContainer||c!==a.endOffset){if(Q(b)!=Q(e)||-1==m.comparePoints(b,c,e,l))e=b,l=c;d(a,e,l,b,c)}}c.prototype=new L;a.util.extend(c.prototype,{setStart:function(a,b){w(this);t(a,!0);z(a,b);h(this,a,b)},setEnd:function(a,b){w(this);t(a,!0);z(a,b);T(this,a,b)},setStartBefore:l(!0,!0),setStartAfter:l(!1,!0),setEndBefore:l(!0,!1),setEndAfter:l(!1,!1),collapse:function(a){x(this);a?d(this,this.startContainer,this.startOffset,this.startContainer,
this.startOffset):d(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(a){w(this);t(a,!0);d(this,a,0,a,m.getNodeLength(a))},selectNode:function(a){w(this);t(a,!1);A(a,J);var b=f(a);a=g(a);d(this,b.node,b.offset,a.node,a.offset)},extractContents:N(n,d),deleteContents:N(p,d),canSurroundContents:function(){x(this);y(this.startContainer);y(this.endContainer);var a=new q(this,!0),c=a._first&&b(a._first,this)||a._last&&b(a._last,this);a.detach();return!c},
detach:function(){e(this)},splitBoundaries:function(){x(this);var a=this.startContainer,b=this.startOffset,c=this.endContainer,e=this.endOffset,l=a===c;m.isCharacterDataNode(c)&&(0=m.getNodeIndex(a)&&e++,b=0);d(this,a,b,c,e)},normalizeBoundaries:function(){x(this);var a=this.startContainer,b=this.startOffset,c=this.endContainer,e=this.endOffset,l=function(a){var b=
a.nextSibling;b&&b.nodeType==a.nodeType&&(c=a,e=a.length,a.appendData(b.data),b.parentNode.removeChild(b))},h=function(d){var l=d.previousSibling;if(l&&l.nodeType==d.nodeType){a=d;var h=d.length;b=l.length;d.insertData(0,l.data);l.parentNode.removeChild(l);a==c?(e+=b,c=a):c==d.parentNode&&(l=m.getNodeIndex(d),e==l?(c=d,e=h):e>l&&e--)}},f=!0;m.isCharacterDataNode(c)?c.length==e&&l(c):(0x",W=3==ca.firstChild.nodeType}catch(ga){}a.features.htmlParsingConforms=W;var X="startContainer startOffset endContainer endOffset collapsed commonAncestorContainer".split(" "),U=0,Y=1,fa=2,Z=3,$=0,aa=1,ba=2,V=3;L.prototype={attachListener:function(a,b){this._listeners[a].push(b)},compareBoundaryPoints:function(a,
b){x(this);E(this.startContainer,b.startContainer);var c=a==Z||a==U?"start":"end",d=a==Y||a==U?"start":"end";return m.comparePoints(this[c+"Container"],this[c+"Offset"],b[d+"Container"],b[d+"Offset"])},insertNode:function(a){x(this);A(a,K);y(this.startContainer);if(m.isAncestorOf(a,this.startContainer,!0))throw new F("HIERARCHY_REQUEST_ERR");a=k(a,this.startContainer,this.startOffset);this.setStartBefore(a)},cloneContents:function(){x(this);var a,b;if(this.collapsed)return d(this).createDocumentFragment();
if(this.startContainer===this.endContainer&&m.isCharacterDataNode(this.startContainer))return a=this.startContainer.cloneNode(!0),a.data=a.data.slice(this.startOffset,this.endOffset),b=d(this).createDocumentFragment(),b.appendChild(a),b;b=new q(this,!0);a=h(b);b.detach();return a},canSurroundContents:function(){x(this);y(this.startContainer);y(this.endContainer);var a=new q(this,!0),c=a._first&&b(a._first,this)||a._last&&b(a._last,this);a.detach();return!c},surroundContents:function(a){A(a,T);if(!this.canSurroundContents())throw new r("BAD_BOUNDARYPOINTS_ERR");
var b=this.extractContents();if(a.hasChildNodes())for(;a.lastChild;)a.removeChild(a.lastChild);k(a,this.startContainer,this.startOffset);a.appendChild(b);this.selectNode(a)},cloneRange:function(){x(this);for(var a=new C(d(this)),b=X.length,c;b--;)c=X[b],a[c]=this[c];return a},toString:function(){x(this);var a=this.startContainer;if(a===this.endContainer&&m.isCharacterDataNode(a))return 3==a.nodeType||4==a.nodeType?a.data.slice(this.startOffset,this.endOffset):"";var b=[],a=new q(this,!0);l(a,function(a){3!=
a.nodeType&&4!=a.nodeType||b.push(a.data)});a.detach();return b.join("")},compareNode:function(a){x(this);var b=a.parentNode,c=m.getNodeIndex(a);if(!b)throw new F("NOT_FOUND_ERR");a=this.comparePoint(b,c);b=this.comparePoint(b,c+1);return 0>a?0m.comparePoints(a,b,this.startContainer,this.startOffset)?-1:0=l&&0<=c:0>l&&0=m.comparePoints(a,b,this.endContainer,this.endOffset)},intersectsRange:function(a,b){x(this);if(d(a)!=d(this))throw new F("WRONG_DOCUMENT_ERR");var c=m.comparePoints(this.startContainer,this.startOffset,a.endContainer,a.endOffset),e=m.comparePoints(this.endContainer,this.endOffset,a.startContainer,a.startOffset);return b?0>=c&&0<=e:0>c&&0=this.comparePoint(a,m.getNodeLength(a))},containsRange:function(a){return this.intersection(a).equals(a)},containsNodeText:function(a){var b=this.cloneRange();b.selectNode(a);var c=b.getNodes([3]);return 012