{I" class:ETI"BundledAsset;FI"logical_path;TI"spina/wysihtml5.js;FI" pathname;TI"|/Users/bram/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spina-template-0.2.4/vendor/assets/javascripts/spina/wysihtml5.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+Ü¥UI" 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");b.close();var c=r.getIframeWindow(a).getSelection(), d=b.documentElement.lastChild.firstChild,b=b.createRange();b.setStart(d,1);b.collapse(!0);c.addRange(b);R=1==c.rangeCount;c.removeAllRanges();var e=b.cloneRange();b.setStart(d,0);e.setEnd(d,2);c.addRange(b);c.addRange(e);O=2==c.rangeCount;b.detach();e.detach();H.removeChild(a)}();a.features.selectionSupportsMultipleRanges=O;a.features.collapsedNonEditableSelectionsSupported=R;var C=!1,m;H&&s.isHostMethod(H,"createControlRange")&&(m=H.createControlRange(),s.areHostProperties(m,["item","add"])&&(C= !0));a.features.implementsControlRange=C;E=G?function(a){return a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset}:function(a){return a.rangeCount?a.getRangeAt(a.rangeCount-1).collapsed:!1};var I;s.isHostMethod(y,"getRangeAt")?I=function(a,b){try{return a.getRangeAt(b)}catch(c){return null}}:G&&(I=function(b){var c=r.getDocument(b.anchorNode),c=a.createRange(c);c.setStart(b.anchorNode,b.anchorOffset);c.setEnd(b.focusNode,b.focusOffset);c.collapsed!==this.isCollapsed&&(c.setStart(b.focusNode, b.focusOffset),c.setEnd(b.anchorNode,b.anchorOffset));return c});a.getSelection=function(a){a=a||window;var b=a._rangySelection,c=z(a),e=B?d(a):null;b?(b.nativeSelection=c,b.docSelection=e,b.refresh(a)):(b=new n(c,e,a),a._rangySelection=b);return b};a.getIframeSelection=function(b){return a.getSelection(r.getIframeWindow(b))};m=n.prototype;if(!x&&G&&s.areHostMethods(y,["removeAllRanges","addRange"])){m.removeAllRanges=function(){this.nativeSelection.removeAllRanges();f(this)};var F=function(b,c){var d= v.getRangeDocument(c),d=a.createRange(d);d.collapseToPoint(c.endContainer,c.endOffset);b.nativeSelection.addRange(g(d));b.nativeSelection.extend(c.startContainer,c.startOffset);b.refresh()};m.addRange=P?function(b,c){if(C&&B&&"Control"==this.docSelection.type)p(this,b);else if(c&&N)F(this,b);else{var d;O?d=this.rangeCount:(this.removeAllRanges(),d=0);this.nativeSelection.addRange(g(b));this.rangeCount=this.nativeSelection.rangeCount;this.rangeCount==d+1?(a.config.checkSelectionRanges&&(d=I(this.nativeSelection, this.rangeCount-1))&&!v.rangesEqual(d,b)&&(b=new t(d)),this._ranges[this.rangeCount-1]=b,e(this,b,K(this.nativeSelection)),this.isCollapsed=E(this)):this.refresh()}}:function(a,b){b&&N?F(this,a):(this.nativeSelection.addRange(g(a)),this.refresh())};m.setRanges=function(a){if(C&&1a||a>=this.rangeCount)throw new w("INDEX_SIZE_ERR");return this._ranges[a]};var J;if(x)J=function(b){var c;a.isSelectionValid(b.win)?c=b.docSelection.createRange():(c=r.getBody(b.win.document).createTextRange(),c.collapse(!0));"Control"==b.docSelection.type?l(b):c&&"undefined"!=typeof c.text? h(b,c):f(b)};else if(s.isHostMethod(y,"getRangeAt")&&"number"==typeof y.rangeCount)J=function(b){if(C&&B&&"Control"==b.docSelection.type)l(b);else if(b._ranges.length=b.rangeCount=b.nativeSelection.rangeCount,b.rangeCount){for(var c=0,d=b.rangeCount;c+(/ipad|iphone|ipod/.test(a)&&a.match(/ os (\d+).+? like mac os x/)||[,0])[1]||this.isAndroid()&&4>+(a.match(/android (\d+)/)||[,0])[1]||-1!==a.indexOf("opera mobi")||-1!==a.indexOf("hpwos/");return b&&d&&e&&!a},isTouchDevice:function(){return this.supportsEvent("touchmove")},isIos:function(){return/ipad|iphone|ipod/i.test(this.USER_AGENT)},isAndroid:function(){return-1!==this.USER_AGENT.indexOf("Android")},supportsSandboxedIframes:function(){return b},throwsMixedContentWarningWhenIframeSrcIsEmpty:function(){return!("querySelector"in document)},displaysCaretInEmptyContentEditableCorrectly:function(){return b},hasCurrentStyleProperty:function(){return"currentStyle"in c},hasHistoryIssue:function(){return d&&"Mac"===navigator.platform.substr(0,3)},insertsLineBreaksOnReturn:function(){return d},supportsPlaceholderAttributeOn:function(a){return"placeholder"in a},supportsEvent:function(a){var b;(b="on"+a in c)||(c.setAttribute("on"+a,"return;"),b="function"===typeof c["on"+a]);return b},supportsEventsInIframeCorrectly:function(){return!g}, supportsHTML5Tags:function(a){a=a.createElement("div");a.innerHTML="
foo
";return"
foo
"===a.innerHTML.toLowerCase()},supportsCommand:function(){var a={formatBlock:b,insertUnorderedList:b||e,insertOrderedList:b||e},c={insertHTML:d};return function(b,d){if(!a[d]){try{return b.queryCommandSupported(d)}catch(e){}try{return b.queryCommandEnabled(d)}catch(f){return!!c[d]}}return!1}}(),doesAutoLinkingInContentEditable:function(){return b},canDisableAutoLinking:function(){return this.supportsCommand(document, "AutoUrlDetect")},clearsContentEditableCorrectly:function(){return d||g||e},supportsGetAttributeCorrectly:function(){return"1"!=document.createElement("td").getAttribute("rowspan")},canSelectImagesInContentEditable:function(){return d||b||g},autoScrollsToCaret:function(){return!e},autoClosesUnclosedTags:function(){var a=c.cloneNode(!1),b;a.innerHTML="

";a=a.innerHTML.toLowerCase();b="

"===a||"

"===a;this.autoClosesUnclosedTags=function(){return b};return b}, supportsNativeGetElementsByClassName:function(){return-1!==String(document.getElementsByClassName).indexOf("[native code]")},supportsSelectionModify:function(){return"getSelection"in window&&"modify"in window.getSelection()},needsSpaceAfterLineBreak:function(){return g},supportsSpeechApiOn:function(b){return 11<=(a.match(/Chrome\/(\d+)/)||[,0])[1]&&("onwebkitspeechchange"in b||"speech"in b)},crashesWhenDefineProperty:function(a){return b&&("XMLHttpRequest"===a||"XDomainRequest"===a)},doesAsyncFocus:function(){return b}, hasProblemsSettingCaretAfterImg:function(){return b},hasUndoInContextMenu:function(){return d||f||g},hasInsertNodeIssue:function(){return g},hasIframeFocusIssue:function(){return b},createsNestedInvalidMarkupAfterPaste:function(){return e}}}(); wysihtml5.lang.array=function(a){return{contains:function(c){if(a.indexOf)return-1!==a.indexOf(c);for(var b=0,d=a.length;b"]/g,d={"&":"&","<":"<",">":">",'"':"""};wysihtml5.lang.string=function(e){e=String(e);return{trim:function(){return e.replace(a,"").replace(c,"")},interpolate:function(a){for(var b in a)e=this.replace("#{"+b+"}").by(a[b]);return e},replace:function(a){return{by:function(b){return e.split(a).join(b)}}},escapeHTML:function(){return e.replace(b,function(a){return d[a]})}}}})(); (function(a){function c(a){return a.replace(e,function(a,b){var c=(b.match(f)||[])[1]||"",d=k[c];b=b.replace(f,"");b.split(d).length>b.split(c).length&&(b+=c,c="");var e=d=b;b.length>g&&(e=e.substr(0,g)+"...");"www."===d.substr(0,4)&&(d="http://"+d);return''+e+""+c})}function b(h){if(!d.contains(h.nodeName))if(h.nodeType===a.TEXT_NODE&&h.data.match(e)){var l=h.parentNode,f=a.lang.string(h.data).escapeHTML(),g;g=l.ownerDocument;var k=g._wysihtml5_tempElement;k||(k=g._wysihtml5_tempElement= g.createElement("div"));g=k;g.innerHTML=""+c(f);for(g.removeChild(g.firstChild);g.firstChild;)l.insertBefore(g.firstChild,h);l.removeChild(h)}else{l=a.lang.array(h.childNodes).get();f=l.length;for(g=0;g"===a.outerHTML.slice(-4).toLowerCase())|| (h="div"));if(h in f){b=f[h];if(!b||b.remove)return null;b="string"===typeof b?{rename_tag:b}:b}else if(a.firstChild)b={rename_tag:d};else return null;h=a.ownerDocument.createElement(b.rename_tag||h);var f={},k=b.set_class,s=b.add_class,v=b.set_attributes,t=b.check_attributes,w=g.classes,A=0,z=[];b=[];var E=[],y=[],B;v&&(f=wysihtml5.lang.object(v).clone());if(t)for(B in t)if(v=l[t[B]])v=v(c(a,B)),"string"===typeof v&&(f[B]=v);k&&z.push(k);if(s)for(B in s)if(v=p[s[B]])k=v(c(a,B)),"string"===typeof k&& z.push(k);w["_wysihtml5-temp-placeholder"]=1;(y=a.getAttribute("class"))&&(z=z.concat(y.split(e)));for(s=z.length;A';b.stylesheets=d;return a.lang.string('#{stylesheets}').interpolate(b)},_unset:function(b,c,d,e){try{b[c]=d}catch(l){}try{b.__defineGetter__(c,function(){return d})}catch(p){}if(e)try{b.__defineSetter__(c, function(){})}catch(n){}if(!a.browser.crashesWhenDefineProperty(c))try{var u={get:function(){return d}};e&&(u.set=function(){});Object.defineProperty(b,c,u)}catch(D){}}})})(wysihtml5);(function(){var a={className:"class"};wysihtml5.dom.setAttributes=function(c){return{on:function(b){for(var d in c)b.setAttribute(a[d]||d,c[d])}}}})(); wysihtml5.dom.setStyles=function(a){return{on:function(c){c=c.style;if("string"===typeof a)c.cssText+=";"+a;else for(var b in a)"float"===b?(c.cssFloat=a[b],c.styleFloat=a[b]):c[b]=a[b]}}}; (function(a){a.simulatePlaceholder=function(c,b,d){var e=function(){b.hasPlaceholderSet()&&b.clear();b.placeholderSet=!1;a.removeClass(b.element,"placeholder")},f=function(){b.isEmpty()&&(b.placeholderSet=!0,b.setValue(d),a.addClass(b.element,"placeholder"))};c.on("set_placeholder",f).on("unset_placeholder",e).on("focus:composer",e).on("paste:composer",e).on("blur:composer",f);f()}})(wysihtml5.dom); (function(a){var c=document.documentElement;"textContent"in c?(a.setTextContent=function(a,c){a.textContent=c},a.getTextContent=function(a){return a.textContent}):"innerText"in c?(a.setTextContent=function(a,c){a.innerText=c},a.getTextContent=function(a){return a.innerText}):(a.setTextContent=function(a,c){a.nodeValue=c},a.getTextContent=function(a){return a.nodeValue})})(wysihtml5.dom); wysihtml5.quirks.cleanPastedHTML=function(){var a={"a u":wysihtml5.dom.replaceWithChildNodes};return function(c,b,d){b=b||a;d=d||c.ownerDocument||document;var e="string"===typeof c,f,g,k,h=0;c=e?wysihtml5.dom.getAsDom(c,d):c;for(k in b)for(f=c.querySelectorAll(k),d=b[k],g=f.length;h 

"==b||"

 

 

"==b)a.innerHTML=""},0)};return function(c){wysihtml5.dom.observe(c.element,["cut","keydown"],a)}}(); (function(a){a.quirks.getCorrectInnerHTML=function(c){var b=c.innerHTML;if(-1===b.indexOf("%7E"))return b;c=c.querySelectorAll("[href*='~'], [src*='~']");var d,e,f,g;g=0;for(f=c.length;g'+a.INVISIBLE_SPACE+"",h=this.getRange(this.doc),l;if(h){a.browser.hasInsertNodeIssue()?this.doc.execCommand("insertHTML", !1,k):(k=h.createContextualFragment(k),h.insertNode(k));try{b(h.startContainer,h.endContainer)}catch(p){setTimeout(function(){throw p;},0)}(h=this.doc.querySelector("._wysihtml5-temp-placeholder"))?(k=rangy.createRange(this.doc),l=h.nextSibling,a.browser.hasInsertNodeIssue()&&l&&"BR"===l.nodeName?(l=this.doc.createTextNode(a.INVISIBLE_SPACE),c.insert(l).after(h),k.setStartBefore(l),k.setEndBefore(l)):(k.selectNode(h),k.deleteContents()),this.setSelection(k)):e.focus();d&&(e.scrollTop=f,e.scrollLeft= g);try{h.parentNode.removeChild(h)}catch(n){}}else b(e,e)},executeAndRestoreSimple:function(a){var c,e,f=this.getRange(),g=this.doc.body,k;if(f){c=f.getNodes([3]);g=c[0]||f.startContainer;k=c[c.length-1]||f.endContainer;c=g===f.startContainer?f.startOffset:0;e=k===f.endContainer?f.endOffset:k.length;try{a(f.startContainer,f.endContainer)}catch(h){setTimeout(function(){throw h;},0)}a=rangy.createRange(this.doc);try{a.setStart(g,c)}catch(l){}try{a.setEnd(k,e)}catch(p){}try{this.setSelection(a)}catch(n){}}else a(g, g)},set:function(a,c){var e=rangy.createRange(this.doc);e.setStart(a,c||0);this.setSelection(e)},insertHTML:function(a){a=rangy.createRange(this.doc).createContextualFragment(a);var c=a.lastChild;this.insertNode(a);c&&this.setAfter(c)},insertNode:function(a){var c=this.getRange();c&&c.insertNode(a)},surround:function(a){var c=this.getRange();if(c)try{c.surroundContents(a),this.selectNode(a)}catch(e){a.appendChild(c.extractContents()),c.insertNode(a)}},scrollIntoView:function(){var b=this.doc,c=b.documentElement.scrollHeight> b.documentElement.offsetHeight,e;(e=b._wysihtml5ScrollIntoViewElement)||(e=b.createElement("span"),e.innerHTML=a.INVISIBLE_SPACE);e=b._wysihtml5ScrollIntoViewElement=e;if(c){this.insertNode(e);var c=e,f=0;if(c.parentNode){do f+=c.offsetTop||0,c=c.offsetParent;while(c)}c=f;e.parentNode.removeChild(e);c>=b.body.scrollTop+b.documentElement.offsetHeight-5&&(b.body.scrollTop=c)}},selectLine:function(){a.browser.supportsSelectionModify()?this._selectLine_W3C():this.doc.selection&&this._selectLine_MSIE()}, _selectLine_W3C:function(){var a=this.doc.defaultView.getSelection();a.modify("extend","left","lineboundary");a.modify("extend","right","lineboundary")},_selectLine_MSIE:function(){var a=this.doc.selection.createRange(),c=a.boundingTop,e=this.doc.body.scrollWidth,f;if(a.moveToPoint){0===c&&(f=this.doc.createElement("span"),this.insertNode(f),c=f.offsetTop,f.parentNode.removeChild(f));c+=1;for(f=-10;f"===g.innerHTML,a.selection.executeAndRestore(function(){e=wysihtml5.dom.convertToList(g,"ol")}),b&&a.selection.selectNode(e.querySelector("li"),!0)):b.execCommand(c,!1,null)},state:function(a){a=a.selection.getSelectedNode();return wysihtml5.dom.getParentElement(a,{nodeName:"OL"})}}; wysihtml5.commands.insertUnorderedList={exec:function(a,c){var b=a.doc,d=a.selection.getSelectedNode(),e=wysihtml5.dom.getParentElement(d,{nodeName:"UL"}),f=wysihtml5.dom.getParentElement(d,{nodeName:"OL"}),d="_wysihtml5-temp-"+(new Date).getTime(),g;e||f||!a.commands.support(c)?e?a.selection.executeAndRestore(function(){wysihtml5.dom.resolveList(e,a.config.useLineBreaks)}):f?a.selection.executeAndRestore(function(){wysihtml5.dom.renameElement(f,"ul")}):(a.commands.exec("formatBlock","div",d),g=b.querySelector("."+ d),b=""===g.innerHTML||g.innerHTML===wysihtml5.INVISIBLE_SPACE||"
"===g.innerHTML,a.selection.executeAndRestore(function(){e=wysihtml5.dom.convertToList(g,"ul")}),b&&a.selection.selectNode(e.querySelector("li"),!0)):b.execCommand(c,!1,null)},state:function(a){a=a.selection.getSelectedNode();return wysihtml5.dom.getParentElement(a,{nodeName:"UL"})}}; wysihtml5.commands.italic={exec:function(a,c){return wysihtml5.commands.formatInline.exec(a,c,"i")},state:function(a,c){return wysihtml5.commands.formatInline.state(a,c,"i")}};(function(a){var c=/wysiwyg-text-align-[0-9a-z]+/g;a.commands.justifyCenter={exec:function(b,d){return a.commands.formatBlock.exec(b,"formatBlock",null,"wysiwyg-text-align-center",c)},state:function(b,d){return a.commands.formatBlock.state(b,"formatBlock",null,"wysiwyg-text-align-center",c)}}})(wysihtml5); (function(a){var c=/wysiwyg-text-align-[0-9a-z]+/g;a.commands.justifyLeft={exec:function(b,d){return a.commands.formatBlock.exec(b,"formatBlock",null,"wysiwyg-text-align-left",c)},state:function(b,d){return a.commands.formatBlock.state(b,"formatBlock",null,"wysiwyg-text-align-left",c)}}})(wysihtml5); (function(a){var c=/wysiwyg-text-align-[0-9a-z]+/g;a.commands.justifyRight={exec:function(b,d){return a.commands.formatBlock.exec(b,"formatBlock",null,"wysiwyg-text-align-right",c)},state:function(b,d){return a.commands.formatBlock.state(b,"formatBlock",null,"wysiwyg-text-align-right",c)}}})(wysihtml5); (function(a){var c=/wysiwyg-text-align-[0-9a-z]+/g;a.commands.justifyFull={exec:function(b,d){return a.commands.formatBlock.exec(b,"formatBlock",null,"wysiwyg-text-align-justify",c)},state:function(b,d){return a.commands.formatBlock.state(b,"formatBlock",null,"wysiwyg-text-align-justify",c)}}})(wysihtml5);wysihtml5.commands.redo={exec:function(a){return a.undoManager.redo()},state:function(a){return!1}}; wysihtml5.commands.underline={exec:function(a,c){return wysihtml5.commands.formatInline.exec(a,c,"u")},state:function(a,c){return wysihtml5.commands.formatInline.state(a,c,"u")}};wysihtml5.commands.undo={exec:function(a){return a.undoManager.undo()},state:function(a){return!1}}; (function(a){var c=''+a.INVISIBLE_SPACE+"",b=''+a.INVISIBLE_SPACE+"",d=a.dom;a.UndoManager=a.lang.Dispatcher.extend({constructor:function(a){this.editor=a;this.composer=a.composer;this.element=this.composer.element;this.position=0;this.historyStr=[];this.historyDom=[];this.transact();this._observe()},_observe:function(){var e=this,f=this.composer.sandbox.getDocument(),g;d.observe(this.element, "keydown",function(a){if(!a.altKey&&(a.ctrlKey||a.metaKey)){var b=a.keyCode,c=90===b&&a.shiftKey||89===b;90!==b||a.shiftKey?c&&(e.redo(),a.preventDefault()):(e.undo(),a.preventDefault())}});d.observe(this.element,"keydown",function(a){a=a.keyCode;a!==g&&(g=a,8!==a&&46!==a||e.transact())});if(a.browser.hasUndoInContextMenu()){var k,h,l=function(){for(var a;a=f.querySelector("._wysihtml5-temp");)a.parentNode.removeChild(a);clearInterval(k)};d.observe(this.element,"contextmenu",function(){l();e.composer.selection.executeAndRestoreSimple(function(){e.element.lastChild&& e.composer.selection.setAfter(e.element.lastChild);f.execCommand("insertHTML",!1,c);f.execCommand("insertHTML",!1,b);f.execCommand("undo",!1,null)});k=setInterval(function(){f.getElementById("_wysihtml5-redo")?(l(),e.redo()):f.getElementById("_wysihtml5-undo")||(l(),e.undo())},400);h||(h=!0,d.observe(document,"mousedown",l),d.observe(f,["mousedown","paste","cut","copy"],l))})}this.editor.on("newword:composer",function(){e.transact()}).on("beforecommand:composer",function(){e.transact()})},transact:function(){var b= this.historyStr[this.position-1],c=this.composer.getValue();if(c!==b){25<(this.historyStr.length=this.historyDom.length=this.position)&&(this.historyStr.shift(),this.historyDom.shift(),this.position--);this.position++;var d=this.composer.selection.getRange(),b=d.startContainer||this.element,k=d.startOffset||0,h;b.nodeType===a.ELEMENT_NODE?d=b:(d=b.parentNode,h=this.getChildNodeIndex(d,b));d.setAttribute("data-wysihtml5-selection-offset",k);"undefined"!==typeof h&&d.setAttribute("data-wysihtml5-selection-node", h);h=this.element.cloneNode(!!c);this.historyDom.push(h);this.historyStr.push(c);d.removeAttribute("data-wysihtml5-selection-offset");d.removeAttribute("data-wysihtml5-selection-node")}},undo:function(){this.transact();this.undoPossible()&&(this.set(this.historyDom[--this.position-1]),this.editor.fire("undo:composer"))},redo:function(){this.redoPossible()&&(this.set(this.historyDom[++this.position-1]),this.editor.fire("redo:composer"))},undoPossible:function(){return 1",constructor:function(a,b,c){this.base(a,b,c);this.textarea=this.parent.textarea;this._initSandbox()},clear:function(){this.element.innerHTML=b.displaysCaretInEmptyContentEditableCorrectly()?"":this.CARET_HACK},getValue:function(b){var c=this.isEmpty()?"":a.quirks.getCorrectInnerHTML(this.element);b&&(c=this.parent.parse(c));return c},setValue:function(a,b){b&&(a=this.parent.parse(a));try{this.element.innerHTML= a}catch(c){this.element.innerText=a}},show:function(){this.iframe.style.display=this._displayStyle||"";this.textarea.element.disabled||(this.disable(),this.enable())},hide:function(){this._displayStyle=c.getStyle("display").from(this.iframe);"none"===this._displayStyle&&(this._displayStyle=null);this.iframe.style.display="none"},disable:function(){this.parent.fire("disable:composer");this.element.removeAttribute("contentEditable")},enable:function(){this.parent.fire("enable:composer");this.element.setAttribute("contentEditable", "true")},focus:function(b){a.browser.doesAsyncFocus()&&this.hasPlaceholderSet()&&this.clear();this.base();var c=this.element.lastChild;b&&c&&("BR"===c.nodeName?this.selection.setBefore(this.element.lastChild):this.selection.setAfter(this.element.lastChild))},getTextContent:function(){return c.getTextContent(this.element)},hasPlaceholderSet:function(){return this.getTextContent()==this.textarea.element.getAttribute("placeholder")&&this.placeholderSet},isEmpty:function(){var a=this.element.innerHTML.toLowerCase(); return""===a||"
"===a||"

"===a||"


"===a||this.hasPlaceholderSet()},_initSandbox:function(){var a=this;this.sandbox=new c.Sandbox(function(){a._create()},{stylesheets:this.config.stylesheets});this.iframe=this.sandbox.getIframe();var b=this.textarea.element;c.insert(this.iframe).after(b);if(b.form){var f=document.createElement("input");f.type="hidden";f.name="_wysihtml5_mode";f.value=1;c.insert(f).after(b)}},_create:function(){var d=this;this.doc=this.sandbox.getDocument();this.element= this.doc.body;this.textarea=this.parent.textarea;this.element.innerHTML=this.textarea.getValue(!0);this.selection=new a.Selection(this.parent);this.commands=new a.Commands(this.parent);c.copyAttributes("className spellcheck title lang dir accessKey".split(" ")).from(this.textarea.element).to(this.element);c.addClass(this.element,this.config.composerClassName);this.config.style&&this.style();this.observe();var e=this.config.name;e&&(c.addClass(this.element,e),c.addClass(this.iframe,e));this.enable(); this.textarea.element.disabled&&this.disable();(e="string"===typeof this.config.placeholder?this.config.placeholder:this.textarea.element.getAttribute("placeholder"))&&c.simulatePlaceholder(this.parent,this,e);this.commands.exec("styleWithCSS",!1);this._initAutoLinking();this._initObjectResizing();this._initUndoManager();this._initLineBreaking();!this.textarea.element.hasAttribute("autofocus")&&document.querySelector(":focus")!=this.textarea.element||b.isIos()||setTimeout(function(){d.focus(!0)}, 100);b.clearsContentEditableCorrectly()||a.quirks.ensureProperClearing(this);this.initSync&&this.config.sync&&this.initSync();this.textarea.hide();this.parent.fire("beforeload").fire("load")},_initAutoLinking:function(){var d=this,e=b.canDisableAutoLinking(),f=b.doesAutoLinkingInContentEditable();e&&this.commands.exec("autoUrlDetect",!1);if(this.config.autoLink){if(!f||f&&e)this.parent.on("newword:composer",function(){c.getTextContent(d.element).match(c.autoLink.URL_REG_EXP)&&d.selection.executeAndRestore(function(a, b){c.autoLink(b.parentNode)})}),c.observe(this.element,"blur",function(){c.autoLink(d.element)});var g=this.sandbox.getDocument().getElementsByTagName("a"),k=c.autoLink.URL_REG_EXP,h=function(b){b=a.lang.string(c.getTextContent(b)).trim();"www."===b.substr(0,4)&&(b="http://"+b);return b};c.observe(this.element,"keydown",function(a){if(g.length){a=d.selection.getSelectedNode(a.target.ownerDocument);var b=c.getParentElement(a,{nodeName:"A"},4),e;b&&(e=h(b),setTimeout(function(){var a=h(b);a!==e&&a.match(k)&& b.setAttribute("href",a)},0))}})}},_initObjectResizing:function(){this.commands.exec("enableObjectResizing",!0);if(b.supportsEvent("resizeend")){var d=["width","height"],e=d.length,f=this.element;c.observe(f,"resizeend",function(b){b=b.target||b.srcElement;var c=b.style,h=0,l;if("IMG"===b.nodeName){for(;h p:first-child { margin-top: 0; }","._wysihtml5-temp { display: none; }",a.browser.isGecko?"body.placeholder { color: graytext !important; }":"body.placeholder { color: #a9a9a9 !important; }","img:-moz-broken { -moz-force-broken-image-icon: 1; height: 24px; width: 24px; }"],h=function(a){if(a.setActive)try{a.setActive()}catch(e){}else{var f=a.style,h=b.documentElement.scrollTop|| b.body.scrollTop,g=b.documentElement.scrollLeft||b.body.scrollLeft,f={position:f.position,top:f.top,left:f.left,WebkitUserSelect:f.WebkitUserSelect};c.setStyles({position:"absolute",top:"-99999px",left:"-99999px",WebkitUserSelect:"none"}).on(a);a.focus();c.setStyles(f).on(a);d.scrollTo&&d.scrollTo(g,h)}};a.views.Composer.prototype.style=function(){var d=this,p=b.querySelector(":focus"),n=this.textarea.element,u=n.hasAttribute("placeholder"),D=u&&n.getAttribute("placeholder"),q=n.style.display,r=n.disabled, s;this.focusStylesHost=e.cloneNode(!1);this.blurStylesHost=e.cloneNode(!1);this.disabledStylesHost=e.cloneNode(!1);u&&n.removeAttribute("placeholder");n===p&&n.blur();n.disabled=!1;n.style.display=s="none";if(n.getAttribute("rows")&&"auto"===c.getStyle("height").from(n)||n.getAttribute("cols")&&"auto"===c.getStyle("width").from(n))n.style.display=s=q;c.copyStyles(g).from(n).to(this.iframe).andTo(this.blurStylesHost);c.copyStyles(f).from(n).to(this.element).andTo(this.blurStylesHost);c.insertCSS(k).into(this.element.ownerDocument); n.disabled=!0;c.copyStyles(g).from(n).to(this.disabledStylesHost);c.copyStyles(f).from(n).to(this.disabledStylesHost);n.disabled=r;n.style.display=q;h(n);n.style.display=s;c.copyStyles(g).from(n).to(this.focusStylesHost);c.copyStyles(f).from(n).to(this.focusStylesHost);n.style.display=q;c.copyStyles(["display"]).from(n).to(this.iframe);var v=a.lang.array(g).without(["display"]);p?p.focus():n.blur();u&&n.setAttribute("placeholder",D);this.parent.on("focus:composer",function(){c.copyStyles(v).from(d.focusStylesHost).to(d.iframe); c.copyStyles(f).from(d.focusStylesHost).to(d.element)});this.parent.on("blur:composer",function(){c.copyStyles(v).from(d.blurStylesHost).to(d.iframe);c.copyStyles(f).from(d.blurStylesHost).to(d.element)});this.parent.observe("disable:composer",function(){c.copyStyles(v).from(d.disabledStylesHost).to(d.iframe);c.copyStyles(f).from(d.disabledStylesHost).to(d.element)});this.parent.observe("enable:composer",function(){c.copyStyles(v).from(d.blurStylesHost).to(d.iframe);c.copyStyles(f).from(d.blurStylesHost).to(d.element)}); return this}})(wysihtml5); (function(a){var c=a.dom,b=a.browser,d={66:"bold",73:"italic",85:"underline"};a.views.Composer.prototype.observe=function(){var e=this,f=this.getValue(),g=this.sandbox.getIframe(),k=this.element,h=b.supportsEventsInIframeCorrectly()?k:this.sandbox.getWindow();c.observe(g,"DOMNodeRemoved",function(){clearInterval(l);e.parent.fire("destroy:composer")});var l=setInterval(function(){c.contains(document.documentElement,g)||(clearInterval(l),e.parent.fire("destroy:composer"))},250);c.observe(h,"focus", function(){e.parent.fire("focus").fire("focus:composer");setTimeout(function(){f=e.getValue()},0)});c.observe(h,"blur",function(){f!==e.getValue()&&e.parent.fire("change").fire("change:composer");e.parent.fire("blur").fire("blur:composer")});c.observe(k,"dragenter",function(){e.parent.fire("unset_placeholder")});c.observe(k,["drop","paste"],function(){setTimeout(function(){e.parent.fire("paste").fire("paste:composer")},0)});c.observe(k,"keyup",function(b){b=b.keyCode;b!==a.SPACE_KEY&&b!==a.ENTER_KEY|| e.parent.fire("newword:composer")});this.parent.on("paste:composer",function(){setTimeout(function(){e.parent.fire("newword:composer")},0)});b.canSelectImagesInContentEditable()||c.observe(k,"mousedown",function(a){var b=a.target;"IMG"===b.nodeName&&(e.selection.selectNode(b),a.preventDefault())});b.hasHistoryIssue()&&b.supportsSelectionModify()&&c.observe(k,"keydown",function(a){if(a.metaKey||a.ctrlKey){var b=a.keyCode,c=k.ownerDocument.defaultView.getSelection();if(37===b||39===b)37===b&&(c.modify("extend", "left","lineboundary"),a.shiftKey||c.collapseToStart()),39===b&&(c.modify("extend","right","lineboundary"),a.shiftKey||c.collapseToEnd()),a.preventDefault()}});c.observe(k,"keydown",function(a){var b=d[a.keyCode];(a.ctrlKey||a.metaKey)&&(!a.altKey&&b)&&(e.commands.exec(b),a.preventDefault())});c.observe(k,"keydown",function(b){var c=e.selection.getSelectedNode(!0),d=b.keyCode;!c||("IMG"!==c.nodeName||d!==a.BACKSPACE_KEY&&d!==a.DELETE_KEY)||(d=c.parentNode,d.removeChild(c),"A"!==d.nodeName||d.firstChild|| d.parentNode.removeChild(d),setTimeout(function(){a.quirks.redraw(k)},0),b.preventDefault())});b.hasIframeFocusIssue()&&(c.observe(this.iframe,"focus",function(){setTimeout(function(){e.doc.querySelector(":focus")!==e.element&&e.focus()},0)}),c.observe(this.element,"blur",function(){setTimeout(function(){e.selection.getSelection().removeAllRanges()},0)}));var p={IMG:"Image: ",A:"Link: "};c.observe(k,"mouseover",function(a){a=a.target;var b=a.nodeName;"A"!==b&&"IMG"!==b||a.hasAttribute("title")||(b= p[b]+(a.getAttribute("href")||a.getAttribute("src")),a.setAttribute("title",b))})}})(wysihtml5); (function(a){a.views.Synchronizer=Base.extend({constructor:function(a,b,d){this.editor=a;this.textarea=b;this.composer=d;this._observe()},fromComposerToTextarea:function(c){this.textarea.setValue(a.lang.string(this.composer.getValue()).trim(),c)},fromTextareaToComposer:function(a){var b=this.textarea.getValue();b?this.composer.setValue(b,a):(this.composer.clear(),this.editor.fire("set_placeholder"))},sync:function(a){"textarea"===this.editor.currentView.name?this.fromTextareaToComposer(a):this.fromComposerToTextarea(a)}, _observe:function(){var c,b=this,d=this.textarea.element.form,e=function(){c=setInterval(function(){b.fromComposerToTextarea()},400)},f=function(){clearInterval(c);c=null};e();d&&(a.dom.observe(d,"submit",function(){b.sync(!0)}),a.dom.observe(d,"reset",function(){setTimeout(function(){b.fromTextareaToComposer()},0)}));this.editor.on("change_view",function(a){"composer"!==a||c?"textarea"===a&&(b.fromComposerToTextarea(!0),f()):(b.fromTextareaToComposer(!0),e())});this.editor.on("destroy:composer", f)}})})(wysihtml5); wysihtml5.views.Textarea=wysihtml5.views.View.extend({name:"textarea",constructor:function(a,c,b){this.base(a,c,b);this._observe()},clear:function(){this.element.value=""},getValue:function(a){var c=this.isEmpty()?"":this.element.value;a&&(c=this.parent.parse(c));return c},setValue:function(a,c){c&&(a=this.parent.parse(a));this.element.value=a},hasPlaceholderSet:function(){var a=wysihtml5.browser.supportsPlaceholderAttributeOn(this.element),c=this.element.getAttribute("placeholder")||null,b=this.element.value; return a&&!b||b===c},isEmpty:function(){return!wysihtml5.lang.string(this.element.value).trim()||this.hasPlaceholderSet()},_observe:function(){var a=this.element,c=this.parent,b={focusin:"focus",focusout:"blur"},d=wysihtml5.browser.supportsEvent("focusin")?["focusin","focusout","change"]:["focus","blur","change"];c.on("beforeload",function(){wysihtml5.dom.observe(a,d,function(a){a=b[a.type]||a.type;c.fire(a).fire(a+":textarea")});wysihtml5.dom.observe(a,["paste","drop"],function(){setTimeout(function(){c.fire("paste").fire("paste:textarea")}, 0)})})}}); (function(a){var c=a.dom;a.toolbar.Dialog=a.lang.Dispatcher.extend({constructor:function(a,c){this.link=a;this.container=c},_observe:function(){if(!this._observed){var b=this,d=function(a){var c=b._serialize();c==b.elementToChange?b.fire("edit",c):b.fire("save",c);b.hide();a.preventDefault();a.stopPropagation()};c.observe(b.link,"click",function(){c.hasClass(b.link,"wysihtml5-command-dialog-opened")&&setTimeout(function(){b.hide()},0)});c.observe(this.container,"keydown",function(c){var e=c.keyCode; e===a.ENTER_KEY&&d(c);e===a.ESCAPE_KEY&&(b.fire("cancel"),b.hide())});c.delegate(this.container,"[data-wysihtml5-dialog-action=save]","click",d);c.delegate(this.container,"[data-wysihtml5-dialog-action=cancel]","click",function(a){b.fire("cancel");b.hide();a.preventDefault();a.stopPropagation()});for(var e=this.container.querySelectorAll("input, select, textarea"),f=0,g=e.length,k=function(){clearInterval(b.interval)};f