/* 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 b(a,b){var c=typeof a[b];return c==k||!!(c==g&&a[b])||"unknown"==c}function c(a,b){return!!(typeof a[b]==g&&a[b])}function a(a,b){return typeof a[b]!=l}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,w)&&v(a,s)}function f(a){window.alert("Rangy not supported in your browser. Reason: "+a);q.initialized=!0;q.supported=!1}function h(){if(!q.initialized){var a,d=!1,g=!1;b(document,"createRange")&& (a=document.createRange(),r(a,p)&&v(a,n)&&(d=!0),a.detach());if((a=c(document,"body")?document.body:document.getElementsByTagName("body")[0])&&b(a,"createTextRange"))a=a.createTextRange(),e(a)&&(g=!0);!d&&!g&&f("Neither Range nor TextRange are implemented");q.initialized=!0;q.features={implementsDomRange:d,implementsTextRange:g};d=B.concat(y);g=0;for(a=d.length;g["+a.childNodes.length+"]":a.nodeName}function k(a){this._next=this.root=a}function l(a,b){this.node=a;this.offset=b}function n(a){this.code=this[a];this.codeName=a;this.message="DOMException: "+this.codeName} var p="undefined",s=b.util;s.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||c.fail("document missing a Node creation method");s.isHostMethod(document,"getElementsByTagName")||c.fail("document missing getElementsByTagName method");var w=document.createElement("div");s.areHostMethods(w,["insertBefore","appendChild","cloneNode"])||c.fail("Incomplete Element implementation");s.isHostProperty(w,"innerHTML")||c.fail("Element is missing innerHTML property");w=document.createTextNode("test"); s.areHostMethods(w,["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};k.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}};l.prototype={equals:function(a){return this.node===a.node&this.offset==a.offset},inspect:function(){return"[DomPosition("+g(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};b.dom={arrayContains:r,isHtmlNamespace:function(a){var b;return typeof a.namespaceURI==p||null===(b=a.namespaceURI)||"http://www.w3.org/1999/xhtml"== b},parentElement:function(a){a=a.parentNode;return 1==a.nodeType?a:null},getNodeIndex:a,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:h,splitDataNode:function(a,b){var c=a.cloneNode(!1);c.deleteData(0,b);a.deleteData(b,a.length-b);h(c,a);return c},getDocument:j,getWindow:function(a){a=j(a); if(typeof a.defaultView!=p)return a.defaultView;if(typeof a.parentWindow!=p)return a.parentWindow;throw Error("Cannot get a window object for node");},getIframeWindow:function(a){if(typeof a.contentWindow!=p)return a.contentWindow;if(typeof a.contentDocument!=p)return a.contentDocument.defaultView;throw Error("getIframeWindow: No Window object found for iframe element");},getIframeDocument:function(a){if(typeof a.contentDocument!=p)return a.contentDocument;if(typeof a.contentWindow!=p)return a.contentWindow.document; throw Error("getIframeWindow: No Document object found for iframe element");},getBody:function(a){return s.isHostObject(a,"body")?a.body:a.getElementsByTagName("body")[0]},getRootContainer:function(a){for(var b;b=a.parentNode;)a=b;return a},comparePoints:function(b,c,g,k){var f;if(b==g)return c===k?0:c=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[c]);return d}function j(b){for(var c,d,e=a(b.range).createDocumentFragment();d=b.next();){c=b.isPartiallySelectedSubtree();d=d.cloneNode(!c);c&&(c=b.getSubtreeIterator(),d.appendChild(j(c)),c.detach(!0));if(10==d.nodeType)throw new D("HIERARCHY_REQUEST_ERR");e.appendChild(d)}return e}function g(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(),g(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 k(a){for(var b;a.next();)a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),k(b),b.detach(!0)):a.remove()}function l(b){for(var c,d=a(b.range).createDocumentFragment(),e;c=b.next();){b.isPartiallySelectedSubtree()?(c=c.cloneNode(!1),e=b.getSubtreeIterator(),c.appendChild(l(e)),e.detach(!0)):b.remove();if(10==c.nodeType)throw new D("HIERARCHY_REQUEST_ERR"); d.appendChild(c)}return d}function n(a,b,c){var d=!(!b||!b.length),e,k=!!c;d&&(e=RegExp("^("+b.join("|")+")$"));var f=[];g(new s(a,!1),function(a){(!d||e.test(a.nodeType))&&(!k||c(a))&&f.push(a)});return f}function p(a){return"["+("undefined"==typeof a.getName?"Range":a.getName())+"("+m.inspectNode(a.startContainer)+":"+a.startOffset+", "+m.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function s(a,b){this.range=a;this.clonePartiallySelectedTextNodes=b;if(!a.collapsed){this.sc=a.startContainer; this.so=a.startOffset;this.ec=a.endContainer;this.eo=a.endOffset;var c=a.commonAncestorContainer;this.sc===this.ec&&m.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc===c&&!m.isCharacterDataNode(this.sc)?this.sc.childNodes[this.so]:m.getClosestAncestorIn(this.sc,c,!0),this._last=this.ec===c&&!m.isCharacterDataNode(this.ec)?this.ec.childNodes[this.eo-1]:m.getClosestAncestorIn(this.ec,c,!0))}}function w(a){this.code= this[a];this.codeName=a;this.message="RangeException: "+this.codeName}function r(a,b,c){this.nodes=n(a,b,c);this._next=this.nodes[0];this._position=0}function t(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 v(a,b){if(M(a,b))throw new w("INVALID_NODE_TYPE_ERR");}function q(a){if(!a.startContainer)throw new D("INVALID_STATE_ERR");}function y(a,b){if(!m.arrayContains(b,a.nodeType))throw new w("INVALID_NODE_TYPE_ERR"); }function B(a,b){if(0>b||b>(m.isCharacterDataNode(a)?a.length:a.childNodes.length))throw new D("INDEX_SIZE_ERR");}function C(a,b){if(J(a,!0)!==J(b,!0))throw new D("WRONG_DOCUMENT_ERR");}function E(a){if(U(a,!0))throw new D("NO_MODIFICATION_ALLOWED_ERR");}function A(a,b){if(!a)throw new D(b);}function x(a){q(a);if(!m.arrayContains(N,a.startContainer.nodeType)&&!J(a.startContainer,!0)||!m.arrayContains(N,a.endContainer.nodeType)&&!J(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 H(){}function R(a){a.START_TO_START=V;a.START_TO_END=Z;a.END_TO_END=da;a.END_TO_START=$;a.NODE_BEFORE=aa;a.NODE_AFTER=ba;a.NODE_BEFORE_AND_AFTER=ca;a.NODE_INSIDE=W}function u(a){R(a);R(a.prototype)}function K(a,b){return function(){x(this); var c=this.startContainer,d=this.startOffset,e=this.commonAncestorContainer,k=new s(this,!0);c!==e&&(c=m.getClosestAncestorIn(c,e,!0),d=f(c),c=d.node,d=d.offset);g(k,E);k.reset();e=a(k);k.detach();b(this,c,d,c,d);return e}}function O(a,d,g){function h(a,b){return function(c){q(this);y(c,F);y(L(c),N);c=(a?e:f)(c);(b?T:j)(this,c.node,c.offset)}}function T(a,b,c){var e=a.endContainer,g=a.endOffset;if(b!==a.startContainer||c!==a.startOffset){if(L(b)!=L(e)||1==m.comparePoints(b,c,e,g))e=b,g=c;d(a,b,c, e,g)}}function j(a,b,c){var e=a.startContainer,g=a.startOffset;if(b!==a.endContainer||c!==a.endOffset){if(L(b)!=L(e)||-1==m.comparePoints(b,c,e,g))e=b,g=c;d(a,e,g,b,c)}}a.prototype=new H;b.util.extend(a.prototype,{setStart:function(a,b){q(this);v(a,!0);B(a,b);T(this,a,b)},setEnd:function(a,b){q(this);v(a,!0);B(a,b);j(this,a,b)},setStartBefore:h(!0,!0),setStartAfter:h(!1,!0),setEndBefore:h(!0,!1),setEndAfter:h(!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){q(this);v(a,!0);d(this,a,0,a,m.getNodeLength(a))},selectNode:function(a){q(this);v(a,!1);y(a,F);var b=e(a);a=f(a);d(this,b.node,b.offset,a.node,a.offset)},extractContents:K(l,d),deleteContents:K(k,d),canSurroundContents:function(){x(this);E(this.startContainer);E(this.endContainer);var a=new s(this,!0),b=a._first&&c(a._first,this)||a._last&&c(a._last,this);a.detach();return!b}, detach:function(){g(this)},splitBoundaries:function(){x(this);var a=this.startContainer,b=this.startOffset,c=this.endContainer,e=this.endOffset,g=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,g=function(a){var b= a.nextSibling;b&&b.nodeType==a.nodeType&&(c=a,e=a.length,a.appendData(b.data),b.parentNode.removeChild(b))},k=function(d){var g=d.previousSibling;if(g&&g.nodeType==d.nodeType){a=d;var k=d.length;b=g.length;d.insertData(0,g.data);g.parentNode.removeChild(g);a==c?(e+=b,c=a):c==d.parentNode&&(g=m.getNodeIndex(d),e==g?(c=d,e=k):e>g&&e--)}},f=!0;m.isCharacterDataNode(c)?c.length==e&&g(c):(0x",X=3==T.firstChild.nodeType}catch(ea){}b.features.htmlParsingConforms=X;var Y="startContainer startOffset endContainer endOffset collapsed commonAncestorContainer".split(" "),V=0,Z=1,da=2,$=3,aa=0,ba=1,ca=2,W=3;H.prototype={attachListener:function(a,b){this._listeners[a].push(b)},compareBoundaryPoints:function(a, b){x(this);C(this.startContainer,b.startContainer);var c=a==$||a==V?"start":"end",d=a==Z||a==V?"start":"end";return m.comparePoints(this[c+"Container"],this[c+"Offset"],b[d+"Container"],b[d+"Offset"])},insertNode:function(a){x(this);y(a,G);E(this.startContainer);if(m.isAncestorOf(a,this.startContainer,!0))throw new D("HIERARCHY_REQUEST_ERR");a=h(a,this.startContainer,this.startOffset);this.setStartBefore(a)},cloneContents:function(){x(this);var b,c;if(this.collapsed)return a(this).createDocumentFragment(); if(this.startContainer===this.endContainer&&m.isCharacterDataNode(this.startContainer))return b=this.startContainer.cloneNode(!0),b.data=b.data.slice(this.startOffset,this.endOffset),c=a(this).createDocumentFragment(),c.appendChild(b),c;c=new s(this,!0);b=j(c);c.detach();return b},canSurroundContents:function(){x(this);E(this.startContainer);E(this.endContainer);var a=new s(this,!0),b=a._first&&c(a._first,this)||a._last&&c(a._last,this);a.detach();return!b},surroundContents:function(a){y(a,Q);if(!this.canSurroundContents())throw new w("BAD_BOUNDARYPOINTS_ERR"); var b=this.extractContents();if(a.hasChildNodes())for(;a.lastChild;)a.removeChild(a.lastChild);h(a,this.startContainer,this.startOffset);a.appendChild(b);this.selectNode(a)},cloneRange:function(){x(this);for(var b=new z(a(this)),c=Y.length,d;c--;)d=Y[c],b[d]=this[d];return b},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 s(this,!0);g(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 D("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=g&&0<=d:0>g&&0=m.comparePoints(a,b,this.endContainer,this.endOffset)},intersectsRange:function(b,c){x(this);if(a(b)!=a(this))throw new D("WRONG_DOCUMENT_ERR");var d=m.comparePoints(this.startContainer,this.startOffset,b.endContainer,b.endOffset),e=m.comparePoints(this.endContainer,this.endOffset,b.startContainer,b.startOffset);return c?0>=d&&0<=e:0>d&&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");z.close();var I=r.getIframeWindow(m).getSelection(), D=z.documentElement.lastChild.firstChild,F=z.createRange();F.setStart(D,1);F.collapse(!0);I.addRange(F);z=1==I.rangeCount;I.removeAllRanges();var N=F.cloneRange();F.setStart(D,0);N.setEnd(D,2);I.addRange(F);I.addRange(N);P=2==I.rangeCount;F.detach();N.detach();u.removeChild(m)}b.features.selectionSupportsMultipleRanges=P;b.features.collapsedNonEditableSelectionsSupported=z;var G=!1;u&&t.isHostMethod(u,"createControlRange")&&(u=u.createControlRange(),t.areHostProperties(u,["item","add"])&&(G=!0)); b.features.implementsControlRange=G;E=K?function(a){return a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset}:function(a){return a.rangeCount?a.getRangeAt(a.rangeCount-1).collapsed:!1};var Q;t.isHostMethod(A,"getRangeAt")?Q=function(a,b){try{return a.getRangeAt(b)}catch(c){return null}}:K&&(Q=function(a){var c=r.getDocument(a.anchorNode),c=b.createRange(c);c.setStart(a.anchorNode,a.anchorOffset);c.setEnd(a.focusNode,a.focusOffset);c.collapsed!==this.isCollapsed&&(c.setStart(a.focusNode,a.focusOffset), c.setEnd(a.anchorNode,a.anchorOffset));return c});b.getSelection=function(a){a=a||window;var b=a._rangySelection,c=C(a),e=x?d(a):null;b?(b.nativeSelection=c,b.docSelection=e,b.refresh(a)):(b=new n(c,e,a),a._rangySelection=b);return b};b.getIframeSelection=function(a){return b.getSelection(r.getIframeWindow(a))};u=n.prototype;if(!H&&K&&t.areHostMethods(A,["removeAllRanges","addRange"])){u.removeAllRanges=function(){this.nativeSelection.removeAllRanges();f(this)};var L=function(a,c){var d=v.getRangeDocument(c), d=b.createRange(d);d.collapseToPoint(c.endContainer,c.endOffset);a.nativeSelection.addRange(h(d));a.nativeSelection.extend(c.startContainer,c.startOffset);a.refresh()};u.addRange=S?function(a,c){if(G&&x&&"Control"==this.docSelection.type)l(this,a);else if(c&&O)L(this,a);else{var d;P?d=this.rangeCount:(this.removeAllRanges(),d=0);this.nativeSelection.addRange(h(a));this.rangeCount=this.nativeSelection.rangeCount;this.rangeCount==d+1?(b.config.checkSelectionRanges&&(d=Q(this.nativeSelection,this.rangeCount- 1))&&!v.rangesEqual(d,a)&&(a=new q(d)),this._ranges[this.rangeCount-1]=a,e(this,a,M(this.nativeSelection)),this.isCollapsed=E(this)):this.refresh()}}:function(a,b){b&&O?L(this,a):(this.nativeSelection.addRange(h(a)),this.refresh())};u.setRanges=function(a){if(G&&1a||a>=this.rangeCount)throw new y("INDEX_SIZE_ERR");return this._ranges[a]};var J;if(H)J=function(a){var c;b.isSelectionValid(a.win)?c=a.docSelection.createRange():(c=r.getBody(a.win.document).createTextRange(),c.collapse(!0));"Control"==a.docSelection.type?k(a):c&&"undefined"!=typeof c.text? g(a,c):f(a)};else if(t.isHostMethod(A,"getRangeAt")&&"number"==typeof A.rangeCount)J=function(a){if(G&&x&&"Control"==a.docSelection.type)k(a);else if(a._ranges.length=a.rangeCount=a.nativeSelection.rangeCount,a.rangeCount){for(var c=0,d=a.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 a},throwsMixedContentWarningWhenIframeSrcIsEmpty:function(){return!("querySelector"in document)},displaysCaretInEmptyContentEditableCorrectly:function(){return a},hasCurrentStyleProperty:function(){return"currentStyle"in c},hasHistoryIssue:function(){return d},insertsLineBreaksOnReturn:function(){return d},supportsPlaceholderAttributeOn:function(a){return"placeholder"in a},supportsEvent:function(a){var b;if(!(b="on"+a in c))c.setAttribute("on"+a,"return;"), b="function"===typeof c["on"+a];return b},supportsEventsInIframeCorrectly:function(){return!h},supportsHTML5Tags:function(a){a=a.createElement("div");a.innerHTML="
foo
";return"
foo
"===a.innerHTML.toLowerCase()},supportsCommand:function(a,b){if(!j[b]){try{return a.queryCommandSupported(b)}catch(c){}try{return a.queryCommandEnabled(b)}catch(d){return!!g[b]}}return!1},doesAutoLinkingInContentEditable:function(){return a},canDisableAutoLinking:function(){return this.supportsCommand(document, "AutoUrlDetect")},clearsContentEditableCorrectly:function(){return d||h||e},supportsGetAttributeCorrectly:function(){return"1"!=document.createElement("td").getAttribute("rowspan")},canSelectImagesInContentEditable:function(){return d||a||h},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 h},supportsSpeechApiOn:function(a){return 11<=(b.match(/Chrome\/(\d+)/)||[,0])[1]&&("onwebkitspeechchange"in a||"speech"in a)},crashesWhenDefineProperty:function(b){return a&&("XMLHttpRequest"===b||"XDomainRequest"===b)},doesAsyncFocus:function(){return a}, hasProblemsSettingCaretAfterImg:function(){return a},hasUndoInContextMenu:function(){return d||f||h},hasInsertNodeIssue:function(){return h},hasIframeFocusIssue:function(){return a},createsNestedInvalidMarkupAfterPaste:function(){return e}}}(); wysihtml5.lang.array=function(b){return{contains:function(c){if(b.indexOf)return-1!==b.indexOf(c);for(var a=0,d=b.length;a"+j.data.replace(d,function(a,b){var c=(b.match(e)||[])[1]||"",d=h[c];b=b.replace(e,"");b.split(d).length>b.split(c).length&&(b+=c,c="");var g=d=b;b.length>f&&(g=g.substr(0,f)+"...");"www."===d.substr(0,4)&&(d="http://"+d);return''+ g+""+c});for(k.removeChild(k.firstChild);k.firstChild;)g.insertBefore(k.firstChild,j);g.removeChild(j)}else{g=b.lang.array(j.childNodes).get();k=g.length;for(l=0;l"!==a.outerHTML.slice(-4).toLowerCase())&& (g="div");if(g in f){b=f[g];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;g=a.ownerDocument.createElement(b.rename_tag||g);var f={},k=b.set_class,l=b.add_class,j=b.set_attributes,n=b.check_attributes,p=h.classes,s=0,q=[];b=[];var r=[],v=[],m;j&&(f=wysihtml5.lang.object(j).clone());if(n)for(m in n)if(j=w[n[m]])j=j(c(a,m)),"string"===typeof j&&(f[m]=j);k&&q.push(k);if(l)for(m in l)if(j=y[l[m]])k=j(c(a,m)),"string"===typeof k&& q.push(k);p["_wysihtml5-temp-placeholder"]=1;(v=a.getAttribute("class"))&&(q=q.concat(v.split(e)));for(l=q.length;s';a.stylesheets=d;return b.lang.string('#{stylesheets}').interpolate(a)},_unset:function(a,c,d,e){try{a[c]=d}catch(k){}try{a.__defineGetter__(c,function(){return d})}catch(l){}if(e)try{a.__defineSetter__(c, function(){})}catch(n){}if(!b.browser.crashesWhenDefineProperty(c))try{var p={get:function(){return d}};e&&(p.set=function(){});Object.defineProperty(a,c,p)}catch(s){}}})})(wysihtml5);(function(){var b={className:"class"};wysihtml5.dom.setAttributes=function(c){return{on:function(a){for(var d in c)a.setAttribute(b[d]||d,c[d])}}}})(); wysihtml5.dom.setStyles=function(b){return{on:function(c){c=c.style;if("string"===typeof b)c.cssText+=";"+b;else for(var a in b)"float"===a?(c.cssFloat=b[a],c.styleFloat=b[a]):c[a]=b[a]}}}; (function(b){b.simulatePlaceholder=function(c,a,d){var e=function(){a.hasPlaceholderSet()&&a.clear();a.placeholderSet=!1;b.removeClass(a.element,"placeholder")},f=function(){a.isEmpty()&&(a.placeholderSet=!0,a.setValue(d),b.addClass(a.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(b){var c=document.documentElement;"textContent"in c?(b.setTextContent=function(a,b){a.textContent=b},b.getTextContent=function(a){return a.textContent}):"innerText"in c?(b.setTextContent=function(a,b){a.innerText=b},b.getTextContent=function(a){return a.innerText}):(b.setTextContent=function(a,b){a.nodeValue=b},b.getTextContent=function(a){return a.nodeValue})})(wysihtml5.dom); wysihtml5.quirks.cleanPastedHTML=function(){var b={"a u":wysihtml5.dom.replaceWithChildNodes};return function(c,a,d){a=a||b;d=d||c.ownerDocument||document;var e="string"===typeof c,f,h,j,g=0;c=e?wysihtml5.dom.getAsDom(c,d):c;for(j in a){f=c.querySelectorAll(j);d=a[j];for(h=f.length;g"+b.innerHTML+"  ");var a=Math.max(b.firstElementChild.offsetHeight,b.firstElementChild.clientHeight);b.removeChild(b.firstElementChild);return c+a}}(); wysihtml5.quirks.ensureProperClearing=function(){var b=function(){var b=this;setTimeout(function(){var a=b.innerHTML.toLowerCase();if("

 

"==a||"

 

 

"==a)b.innerHTML=""},0)};return function(c){wysihtml5.dom.observe(c.element,["cut","keydown"],b)}}(); (function(b){b.quirks.getCorrectInnerHTML=function(c){var a=c.innerHTML;if(-1===a.indexOf("%7E"))return a;c=c.querySelectorAll("[href*='~'], [src*='~']");var d,e,f,h;h=0;for(f=c.length;h'+b.INVISIBLE_SPACE+"",g=this.getRange(this.doc),k;if(g){b.browser.hasInsertNodeIssue()?this.doc.execCommand("insertHTML", !1,j):(j=g.createContextualFragment(j),g.insertNode(j));try{a(g.startContainer,g.endContainer)}catch(l){setTimeout(function(){throw l;},0)}(g=this.doc.querySelector("._wysihtml5-temp-placeholder"))?(j=rangy.createRange(this.doc),k=g.nextSibling,b.browser.hasInsertNodeIssue()&&k&&"BR"===k.nodeName?(k=this.doc.createTextNode(b.INVISIBLE_SPACE),c.insert(k).after(g),j.setStartBefore(k),j.setEndBefore(k)):(j.selectNode(g),j.deleteContents()),this.setSelection(j)):e.focus();d&&(e.scrollTop=f,e.scrollLeft= h);try{g.parentNode.removeChild(g)}catch(n){}}else a(e,e)},executeAndRestoreSimple:function(a){var b,c,f=this.getRange(),h=this.doc.body,j;if(f){b=f.getNodes([3]);h=b[0]||f.startContainer;j=b[b.length-1]||f.endContainer;b=h===f.startContainer?f.startOffset:0;c=j===f.endContainer?f.endOffset:j.length;try{a(f.startContainer,f.endContainer)}catch(g){setTimeout(function(){throw g;},0)}a=rangy.createRange(this.doc);try{a.setStart(h,b)}catch(k){}try{a.setEnd(j,c)}catch(l){}try{this.setSelection(a)}catch(n){}}else a(h, h)},set:function(a,b){var c=rangy.createRange(this.doc);c.setStart(a,b||0);this.setSelection(c)},insertHTML:function(a){a=rangy.createRange(this.doc).createContextualFragment(a);var b=a.lastChild;this.insertNode(a);b&&this.setAfter(b)},insertNode:function(a){var b=this.getRange();b&&b.insertNode(a)},surround:function(a){var b=this.getRange();if(b)try{b.surroundContents(a),this.selectNode(a)}catch(c){a.appendChild(b.extractContents()),b.insertNode(a)}},scrollIntoView:function(){var a=this.doc,c=a.documentElement.scrollHeight> a.documentElement.offsetHeight,e;if(!(e=a._wysihtml5ScrollIntoViewElement))e=a.createElement("span"),e.innerHTML=b.INVISIBLE_SPACE;e=a._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>=a.body.scrollTop+a.documentElement.offsetHeight-5&&(a.body.scrollTop=c)}},selectLine:function(){b.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(),b=a.boundingTop,c=this.doc.body.scrollWidth,f;if(a.moveToPoint){0===b&&(f=this.doc.createElement("span"),this.insertNode(f),b=f.offsetTop,f.parentNode.removeChild(f));b+=1;for(f=-10;f"===h.innerHTML,b.selection.executeAndRestore(function(){e=wysihtml5.dom.convertToList(h,"ol")}),a&&b.selection.selectNode(e.querySelector("li"),!0))},state:function(b){b=b.selection.getSelectedNode();return wysihtml5.dom.getParentElement(b,{nodeName:"OL"})}}; wysihtml5.commands.insertUnorderedList={exec:function(b,c){var a=b.doc,d=b.selection.getSelectedNode(),e=wysihtml5.dom.getParentElement(d,{nodeName:"UL"}),f=wysihtml5.dom.getParentElement(d,{nodeName:"OL"}),d="_wysihtml5-temp-"+(new Date).getTime(),h;!e&&!f&&b.commands.support(c)?a.execCommand(c,!1,null):e?b.selection.executeAndRestore(function(){wysihtml5.dom.resolveList(e,b.config.useLineBreaks)}):f?b.selection.executeAndRestore(function(){wysihtml5.dom.renameElement(f,"ul")}):(b.commands.exec("formatBlock", "div",d),h=a.querySelector("."+d),a=""===h.innerHTML||h.innerHTML===wysihtml5.INVISIBLE_SPACE||"
"===h.innerHTML,b.selection.executeAndRestore(function(){e=wysihtml5.dom.convertToList(h,"ul")}),a&&b.selection.selectNode(e.querySelector("li"),!0))},state:function(b){b=b.selection.getSelectedNode();return wysihtml5.dom.getParentElement(b,{nodeName:"UL"})}}; wysihtml5.commands.italic={exec:function(b,c){return wysihtml5.commands.formatInline.exec(b,c,"i")},state:function(b,c){return wysihtml5.commands.formatInline.state(b,c,"i")}};(function(b){var c=/wysiwyg-text-align-[0-9a-z]+/g;b.commands.justifyCenter={exec:function(a){return b.commands.formatBlock.exec(a,"formatBlock",null,"wysiwyg-text-align-center",c)},state:function(a){return b.commands.formatBlock.state(a,"formatBlock",null,"wysiwyg-text-align-center",c)}}})(wysihtml5); (function(b){var c=/wysiwyg-text-align-[0-9a-z]+/g;b.commands.justifyLeft={exec:function(a){return b.commands.formatBlock.exec(a,"formatBlock",null,"wysiwyg-text-align-left",c)},state:function(a){return b.commands.formatBlock.state(a,"formatBlock",null,"wysiwyg-text-align-left",c)}}})(wysihtml5); (function(b){var c=/wysiwyg-text-align-[0-9a-z]+/g;b.commands.justifyRight={exec:function(a){return b.commands.formatBlock.exec(a,"formatBlock",null,"wysiwyg-text-align-right",c)},state:function(a){return b.commands.formatBlock.state(a,"formatBlock",null,"wysiwyg-text-align-right",c)}}})(wysihtml5); (function(b){var c=/wysiwyg-text-align-[0-9a-z]+/g;b.commands.justifyFull={exec:function(a){return b.commands.formatBlock.exec(a,"formatBlock",null,"wysiwyg-text-align-justify",c)},state:function(a){return b.commands.formatBlock.state(a,"formatBlock",null,"wysiwyg-text-align-justify",c)}}})(wysihtml5);wysihtml5.commands.redo={exec:function(b){return b.undoManager.redo()},state:function(){return!1}}; wysihtml5.commands.underline={exec:function(b,c){return wysihtml5.commands.formatInline.exec(b,c,"u")},state:function(b,c){return wysihtml5.commands.formatInline.state(b,c,"u")}};wysihtml5.commands.undo={exec:function(b){return b.undoManager.undo()},state:function(){return!1}}; (function(b){var c=''+b.INVISIBLE_SPACE+"",a=''+b.INVISIBLE_SPACE+"",d=b.dom;b.UndoManager=b.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(),h;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?(e.undo(),a.preventDefault()):c&&(e.redo(),a.preventDefault())}});d.observe(this.element,"keydown",function(a){a=a.keyCode;a!==h&&(h=a,(8===a||46===a)&&e.transact())});if(b.browser.hasUndoInContextMenu()){var j,g,k=function(){for(var a;a=f.querySelector("._wysihtml5-temp");)a.parentNode.removeChild(a);clearInterval(j)};d.observe(this.element,"contextmenu",function(){k();e.composer.selection.executeAndRestoreSimple(function(){e.element.lastChild&& e.composer.selection.setAfter(e.element.lastChild);f.execCommand("insertHTML",!1,c);f.execCommand("insertHTML",!1,a);f.execCommand("undo",!1,null)});j=setInterval(function(){f.getElementById("_wysihtml5-redo")?(k(),e.redo()):f.getElementById("_wysihtml5-undo")||(k(),e.undo())},400);g||(g=!0,d.observe(document,"mousedown",k),d.observe(f,["mousedown","paste","cut","copy"],k))})}this.editor.on("newword:composer",function(){e.transact()}).on("beforecommand:composer",function(){e.transact()})},transact:function(){var a= this.historyStr[this.position-1],c=this.composer.getValue();if(c!==a){if(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(),a=d.startContainer||this.element,j=d.startOffset||0,g;a.nodeType===b.ELEMENT_NODE?d=a:(d=a.parentNode,g=this.getChildNodeIndex(d,a));d.setAttribute("data-wysihtml5-selection-offset",j);"undefined"!==typeof g&&d.setAttribute("data-wysihtml5-selection-node", g);g=this.element.cloneNode(!!c);this.historyDom.push(g);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=a.displaysCaretInEmptyContentEditableCorrectly()?"":this.CARET_HACK},getValue:function(a){var c=this.isEmpty()?"":b.quirks.getCorrectInnerHTML(this.element);a&&(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(a){b.browser.doesAsyncFocus()&&this.hasPlaceholderSet()&&this.clear();this.base();var c=this.element.lastChild;a&&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 b.Selection(this.parent);this.commands=new b.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)&&!a.isIos()&&setTimeout(function(){d.focus(!0)}, 100);a.clearsContentEditableCorrectly()||b.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=a.canDisableAutoLinking(),f=a.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 h=this.sandbox.getDocument().getElementsByTagName("a"),j=c.autoLink.URL_REG_EXP,g=function(a){a=b.lang.string(c.getTextContent(a)).trim();"www."===a.substr(0,4)&&(a="http://"+a);return a};c.observe(this.element,"keydown",function(a){if(h.length){a=d.selection.getSelectedNode(a.target.ownerDocument);var b=c.getParentElement(a,{nodeName:"A"},4),e;b&&(e=g(b),setTimeout(function(){var a=g(b);a!==e&&a.match(j)&& b.setAttribute("href",a)},0))}})}},_initObjectResizing:function(){this.commands.exec("enableObjectResizing",!0);if(a.supportsEvent("resizeend")){var d=["width","height"],e=d.length,f=this.element;c.observe(f,"resizeend",function(a){a=a.target||a.srcElement;var c=a.style,g=0,k;if("IMG"===a.nodeName){for(;g p:first-child { margin-top: 0; }","._wysihtml5-temp { display: none; }",b.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; }"];b.views.Composer.prototype.style=function(){var g=this,k=a.querySelector(":focus"),l= this.textarea.element,n=l.hasAttribute("placeholder"),p=n&&l.getAttribute("placeholder"),s=l.style.display,w=l.disabled,r;this.focusStylesHost=e.cloneNode(!1);this.blurStylesHost=e.cloneNode(!1);this.disabledStylesHost=e.cloneNode(!1);n&&l.removeAttribute("placeholder");l===k&&l.blur();l.disabled=!1;l.style.display=r="none";if(l.getAttribute("rows")&&"auto"===c.getStyle("height").from(l)||l.getAttribute("cols")&&"auto"===c.getStyle("width").from(l))l.style.display=r=s;c.copyStyles(h).from(l).to(this.iframe).andTo(this.blurStylesHost); c.copyStyles(f).from(l).to(this.element).andTo(this.blurStylesHost);c.insertCSS(j).into(this.element.ownerDocument);l.disabled=!0;c.copyStyles(h).from(l).to(this.disabledStylesHost);c.copyStyles(f).from(l).to(this.disabledStylesHost);l.disabled=w;l.style.display=s;if(l.setActive)try{l.setActive()}catch(t){}else{var v=l.style,w=a.documentElement.scrollTop||a.body.scrollTop,q=a.documentElement.scrollLeft||a.body.scrollLeft,v={position:v.position,top:v.top,left:v.left,WebkitUserSelect:v.WebkitUserSelect}; c.setStyles({position:"absolute",top:"-99999px",left:"-99999px",WebkitUserSelect:"none"}).on(l);l.focus();c.setStyles(v).on(l);d.scrollTo&&d.scrollTo(q,w)}l.style.display=r;c.copyStyles(h).from(l).to(this.focusStylesHost);c.copyStyles(f).from(l).to(this.focusStylesHost);l.style.display=s;c.copyStyles(["display"]).from(l).to(this.iframe);var y=b.lang.array(h).without(["display","height"]);k?k.focus():l.blur();n&&l.setAttribute("placeholder",p);this.parent.on("focus:composer",function(){c.copyStyles(y).from(g.focusStylesHost).to(g.iframe); c.copyStyles(f).from(g.focusStylesHost).to(g.element)});this.parent.on("blur:composer",function(){c.copyStyles(y).from(g.blurStylesHost).to(g.iframe);c.copyStyles(f).from(g.blurStylesHost).to(g.element)});this.parent.observe("disable:composer",function(){c.copyStyles(y).from(g.disabledStylesHost).to(g.iframe);c.copyStyles(f).from(g.disabledStylesHost).to(g.element)});this.parent.observe("enable:composer",function(){c.copyStyles(y).from(g.blurStylesHost).to(g.iframe);c.copyStyles(f).from(g.blurStylesHost).to(g.element)}); return this}})(wysihtml5); (function(b){var c=b.dom,a=b.browser,d={66:"bold",73:"italic",85:"underline"};b.views.Composer.prototype.observe=function(){var e=this,f=this.getValue(),h=this.sandbox.getIframe(),j=this.element,g=a.supportsEventsInIframeCorrectly()?j:this.sandbox.getWindow();c.observe(h,"DOMNodeRemoved",function(){clearInterval(k);e.parent.fire("destroy:composer")});var k=setInterval(function(){c.contains(document.documentElement,h)||(clearInterval(k),e.parent.fire("destroy:composer"))},250);c.observe(g,"focus", function(){e.parent.fire("focus").fire("focus:composer");setTimeout(function(){f=e.getValue()},0)});c.observe(g,"blur",function(){f!==e.getValue()&&e.parent.fire("change").fire("change:composer");e.parent.fire("blur").fire("blur:composer")});c.observe(j,"dragenter",function(){e.parent.fire("unset_placeholder")});c.observe(j,["drop","paste"],function(){setTimeout(function(){e.parent.fire("paste").fire("paste:composer")},0)});c.observe(j,"keyup",function(a){a=a.keyCode;(a===b.SPACE_KEY||a===b.ENTER_KEY)&& e.parent.fire("newword:composer")});this.parent.on("paste:composer",function(){setTimeout(function(){e.parent.fire("newword:composer")},0)});a.canSelectImagesInContentEditable()||c.observe(j,"mousedown",function(a){var b=a.target;"IMG"===b.nodeName&&(e.selection.selectNode(b),a.preventDefault())});a.hasHistoryIssue()&&a.supportsSelectionModify()&&c.observe(j,"keydown",function(a){if(a.metaKey||a.ctrlKey){var b=a.keyCode,c=j.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(j,"keydown",function(a){var b=d[a.keyCode];if((a.ctrlKey||a.metaKey)&&!a.altKey&&b)e.commands.exec(b),a.preventDefault()});c.observe(j,"keydown",function(a){var c=e.selection.getSelectedNode(!0),d=a.keyCode;if(c&&"IMG"===c.nodeName&&(d===b.BACKSPACE_KEY||d===b.DELETE_KEY))d=c.parentNode,d.removeChild(c),"A"===d.nodeName&&!d.firstChild&& d.parentNode.removeChild(d),setTimeout(function(){b.quirks.redraw(j)},0),a.preventDefault()});a.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 l={IMG:"Image: ",A:"Link: "};c.observe(j,"mouseover",function(a){a=a.target;var b=a.nodeName;!("A"!==b&&"IMG"!==b)&&!a.hasAttribute("title")&& (b=l[b]+(a.getAttribute("href")||a.getAttribute("src")),a.setAttribute("title",b))})}})(wysihtml5); (function(b){b.views.Synchronizer=Base.extend({constructor:function(b,a,d){this.editor=b;this.textarea=a;this.composer=d;this._observe()},fromComposerToTextarea:function(c){this.textarea.setValue(b.lang.string(this.composer.getValue()).trim(),c)},fromTextareaToComposer:function(b){var a=this.textarea.getValue();a?this.composer.setValue(a,b):(this.composer.clear(),this.editor.fire("set_placeholder"))},sync:function(b){"textarea"===this.editor.currentView.name?this.fromTextareaToComposer(b):this.fromComposerToTextarea(b)}, _observe:function(){var c,a=this,d=this.textarea.element.form,e=function(){c=setInterval(function(){a.fromComposerToTextarea()},400)},f=function(){clearInterval(c);c=null};e();d&&(b.dom.observe(d,"submit",function(){a.sync(!0)}),b.dom.observe(d,"reset",function(){setTimeout(function(){a.fromTextareaToComposer()},0)}));this.editor.on("change_view",function(b){"composer"===b&&!c?(a.fromTextareaToComposer(!0),e()):"textarea"===b&&(a.fromComposerToTextarea(!0),f())});this.editor.on("destroy:composer", f)}})})(wysihtml5); wysihtml5.views.Textarea=wysihtml5.views.View.extend({name:"textarea",constructor:function(b,c,a){this.base(b,c,a);this._observe()},clear:function(){this.element.value=""},getValue:function(b){var c=this.isEmpty()?"":this.element.value;b&&(c=this.parent.parse(c));return c},setValue:function(b,c){c&&(b=this.parent.parse(b));this.element.value=b},hasPlaceholderSet:function(){var b=wysihtml5.browser.supportsPlaceholderAttributeOn(this.element),c=this.element.getAttribute("placeholder")||null,a=this.element.value; return b&&!a||a===c},isEmpty:function(){return!wysihtml5.lang.string(this.element.value).trim()||this.hasPlaceholderSet()},_observe:function(){var b=this.element,c=this.parent,a={focusin:"focus",focusout:"blur"},d=wysihtml5.browser.supportsEvent("focusin")?["focusin","focusout","change"]:["focus","blur","change"];c.on("beforeload",function(){wysihtml5.dom.observe(b,d,function(b){b=a[b.type]||b.type;c.fire(b).fire(b+":textarea")});wysihtml5.dom.observe(b,["paste","drop"],function(){setTimeout(function(){c.fire("paste").fire("paste:textarea")}, 0)})})}}); (function(b){var c=b.dom;b.toolbar.Dialog=b.lang.Dispatcher.extend({constructor:function(a,b){this.link=a;this.container=b},_observe:function(){if(!this._observed){var a=this,d=function(b){var c=a._serialize();c==a.elementToChange?a.fire("edit",c):a.fire("save",c);a.hide();b.preventDefault();b.stopPropagation()};c.observe(a.link,"click",function(){c.hasClass(a.link,"wysihtml5-command-dialog-opened")&&setTimeout(function(){a.hide()},0)});c.observe(this.container,"keydown",function(c){var e=c.keyCode; e===b.ENTER_KEY&&d(c);e===b.ESCAPE_KEY&&a.hide()});c.delegate(this.container,"[data-wysihtml5-dialog-action=save]","click",d);c.delegate(this.container,"[data-wysihtml5-dialog-action=cancel]","click",function(b){a.fire("cancel");a.hide();b.preventDefault();b.stopPropagation()});for(var e=this.container.querySelectorAll("input, select, textarea"),f=0,h=e.length,j=function(){clearInterval(a.interval)};f