text: !function(){"use strict";var U=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return U(n())}}},H=tinymce.util.Tools.resolve("tinymce.PluginManager"),u=function(e){return e.getParam("spellchecker_rpc_url")},J=function(e){var t=new RegExp('[^\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`§©«®±¶·¸»¼½¾¿×÷¤”“„    ]+',"g");return e.getParam("spellchecker_wordchar_pattern",t)},W=tinymce.util.Tools.resolve("tinymce.util.Tools"),d=tinymce.util.Tools.resolve("tinymce.util.URI"),f=tinymce.util.Tools.resolve("tinymce.util.XHR");function m(e){return e&&1===e.nodeType&&"false"===e.contentEditable}var $,s=function(e,t){if(!t.get()){var n=function(i,r){var n,o,f,g,h,a=[],v=r.dom;function c(e,t){if(!e[0])throw new Error("findAndReplaceDOMText cannot handle zero-length matches");return{start:e.index,end:e.index+e[0].length,text:e[0],data:t}}function l(e){var t=i.getElementsByTagName("*"),n=[];e="number"==typeof e?""+e:null;for(var r=0;r<t.length;r++){var o=t[r],a=o.getAttribute("data-mce-index");null!==a&&a.length&&-1!==o.className.indexOf("mce-spellchecker-word")&&(a!==e&&null!==e||n.push(o))}return n}function s(e){for(var t=a.length;t--;)if(a[t]===e)return t;return-1}function e(e){for(var t=0,n=a.length;t<n&&!1!==e(a[t],t);t++);return this}function t(e){var t,n,r=l(e?s(e):null);for(t=r.length;t--;)(n=r[t]).parentNode.insertBefore(n.firstChild,n),n.parentNode.removeChild(n);return this}function u(e){var t=l(s(e)),n=r.dom.createRng();return n.setStartBefore(t[0]),n.setEndAfter(t[t.length-1]),n}return f=r.schema.getBlockElements(),g=r.schema.getWhiteSpaceElements(),h=r.schema.getShortEndedElements(),{text:o=function e(t){var n;if(3===t.nodeType)return t.data;if(g[t.nodeName]&&!f[t.nodeName])return"";if(m(t))return"\n";if(n="",(f[t.nodeName]||h[t.nodeName])&&(n+="\n"),t=t.firstChild)for(;n+=e(t),t=t.nextSibling;);return n}(i),matches:a,each:e,filter:function(n){var r=[];return e(function(e,t){n(e,t)&&r.push(e)}),a=r,this},reset:function(){return a.splice(0,a.length),t(),this},matchFromElement:function(e){return a[e.getAttribute("data-mce-index")]},elementFromMatch:function(e){return l(s(e))[0]},find:function(e,t){if(o&&e.global)for(;n=e.exec(o);)a.push(c(n,t));return this},add:function(e,t,n){return a.push({start:e,end:e+t,text:o.substr(e,t),data:n}),this},wrap:function(e){return a.length&&function(e,t,n){var r,o,a,i,c,l=[],s=0,u=e,d=0;(t=t.slice(0)).sort(function(e,t){return e.start-t.start}),c=t.shift();e:for(;;){if((f[u.nodeName]||h[u.nodeName]||m(u))&&s++,3===u.nodeType&&(!o&&u.length+s>=c.end?(o=u,i=c.end-s):r&&l.push(u),!r&&u.length+s>c.start&&(r=u,a=c.start-s),s+=u.length),r&&o){if(u=n({startNode:r,startNodeIndex:a,endNode:o,endNodeIndex:i,innerNodes:l,match:c.text,matchIndex:d}),s-=o.length-i,o=r=null,l=[],d++,!(c=t.shift()))break}else if(g[u.nodeName]&&!f[u.nodeName]||!u.firstChild){if(u.nextSibling){u=u.nextSibling;continue}}else if(!m(u)){u=u.firstChild;continue}for(;;){if(u.nextSibling){u=u.nextSibling;break}if(u.parentNode===e)break e;u=u.parentNode}}}(i,a,function(o){function p(e,t){var n=a[t];n.stencil||(n.stencil=o(n));var r=n.stencil.cloneNode(!1);return r.setAttribute("data-mce-index",t),e&&r.appendChild(v.doc.createTextNode(e)),r}return function(e){var t,n,r,o=e.startNode,a=e.endNode,i=e.matchIndex,c=v.doc;if(o===a){var l=o;r=l.parentNode,0<e.startNodeIndex&&(t=c.createTextNode(l.data.substring(0,e.startNodeIndex)),r.insertBefore(t,l));var s=p(e.match,i);return r.insertBefore(s,l),e.endNodeIndex<l.length&&(n=c.createTextNode(l.data.substring(e.endNodeIndex)),r.insertBefore(n,l)),l.parentNode.removeChild(l),s}t=c.createTextNode(o.data.substring(0,e.startNodeIndex)),n=c.createTextNode(a.data.substring(e.endNodeIndex));for(var u=p(o.data.substring(e.startNodeIndex),i),d=0,f=e.innerNodes.length;d<f;++d){var g=e.innerNodes[d],h=p(g.data,i);g.parentNode.replaceChild(h,g)}var m=p(a.data.substring(0,e.endNodeIndex),i);return(r=o.parentNode).insertBefore(t,o),r.insertBefore(u,o),r.removeChild(o),(r=a.parentNode).insertBefore(m,a),r.insertBefore(n,a),r.removeChild(a),m}}(e)),this},unwrap:t,replace:function(e,t){var n=u(e);return n.deleteContents(),0<t.length&&n.insertNode(r.dom.doc.createTextNode(t)),n},rangeFromMatch:u,indexOf:s}}(e.getBody(),e);t.set(n)}return t.get()},c=function(e,t,n,r,o,a,i){var c,l,s;(e.getParam("spellchecker_callback")||(c=e,l=t,s=n,function(e,t,n,r){var o={method:e,lang:s.get()},a="";o["addToDictionary"===e?"word":"text"]=t,W.each(o,function(e,t){a&&(a+="&"),a+=t+"="+encodeURIComponent(e)}),f.send({url:new d(l).toAbsolute(u(c)),type:"post",content_type:"application/x-www-form-urlencoded",data:a,success:function(e){if(e=JSON.parse(e))e.error?r(e.error):n(e);else{var t=c.translate("Server response wasn't proper JSON.");r(t)}},error:function(){var e=c.translate("The spelling service was not found: (")+u(c)+c.translate(")");r(e)}})})).call(e.plugins.spellchecker,r,o,a,i)},l=function(e,t,n){e.dom.select("span.mce-spellchecker-word").length||i(e,t,n)},i=function(e,t,n){var r=e.selection.getBookmark();if(s(e,n).reset(),e.selection.moveToBookmark(r),n.set(null),t.get())return t.set(!1),e.fire("SpellcheckEnd"),!0},g=function(e){var t=e.getAttribute("data-mce-index");return"number"==typeof t?""+t:t},h=function(t,e,n,r,o){var a,i;if(a="string"!=typeof o&&o.words?(i=!!o.dictionary,o.words):o,t.setProgressState(!1),function(e){for(var t in e)return!1;return!0}(a)){var c=t.translate("No misspellings found.");return t.notificationManager.open({text:c,type:"info"}),void e.set(!1)}r.set({suggestions:a,hasDictionarySupport:i});var l=t.selection.getBookmark();s(t,n).find(J(t)).filter(function(e){return!!a[e.text]}).wrap(function(e){return t.dom.create("span",{class:"mce-spellchecker-word","data-mce-bogus":1,"data-mce-word":e.text})}),t.selection.moveToBookmark(l),e.set(!0),t.fire("SpellcheckStart")},z=function(t,e,n,r,o,a){i(t,n,r)||(t.setProgressState(!0),c(t,e,a,"spellcheck",s(t,r).text,function(e){h(t,n,r,o,e)},function(e){t.notificationManager.open({text:e,type:"error"}),t.setProgressState(!1),i(t,n,r)}),t.focus())},G=l,X=function(t,e,n,r,o,a,i){t.setProgressState(!0),c(t,e,o,"addToDictionary",a,function(){t.setProgressState(!1),t.dom.remove(i,!0),l(t,n,r)},function(e){t.notificationManager.open({text:e,type:"error"}),t.setProgressState(!1)})},Y=function(t,e,n,r,o,a){t.selection.collapse(),a?W.each(t.dom.select("span.mce-spellchecker-word"),function(e){e.getAttribute("data-mce-word")===r&&t.dom.remove(e,!0)}):t.dom.remove(o,!0),l(t,e,n)},j=function(e,t){var n,r=[];if((n=W.toArray(e.getBody().getElementsByTagName("span"))).length)for(var o=0;o<n.length;o++){var a=g(n[o]);null!==a&&a.length&&a===t.toString()&&r.push(n[o])}return r},q=g,K=h,Q=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),V=tinymce.util.Tools.resolve("tinymce.ui.Factory");H.add("spellchecker",function(e,t){if(!1==!(!/(^|[ ,])tinymcespellchecker([, ]|$)/.test(e.settings.plugins)||!H.get("tinymcespellchecker")||(void 0!==window.console&&window.console.log&&window.console.log("Spell Checker Pro is incompatible with Spell Checker plugin! Remove 'spellchecker' from the 'plugins' option."),0))){var n=U(!1),r=U((L=(F=e).getParam("language","en"),F.getParam("spellchecker_language",L))),o=U(null),a=U(null);return b=t,T=n,B=o,P=r,C=a,D=w=e,E=W.map((A=D,A.getParam("spellchecker_languages","English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,German=de,Italian=it,Polish=pl,Portuguese=pt_BR,Spanish=es,Swedish=sv")).split(","),function(e){return{name:(e=e.split("="))[0],value:e[1]}}),I=[],W.each(E,function(e){I.push({selectable:!0,text:e.name,data:e.value})}),O={tooltip:"Spellcheck",onclick:_=function(){z(w,b,T,B,C,P)},onPostRender:function(e){var t=e.control;w.on("SpellcheckStart SpellcheckEnd",function(){t.active(T.get())})}},1<(M=I).length&&(O.type="splitbutton",O.menu=M,O.onshow=(R=P,function(e){var t=R.get();e.control.items().each(function(e){e.active(e.settings.data===t)})}),O.onselect=function(e){P.set(e.control.settings.data)}),w.addButton("spellchecker",O),w.addMenuItem("spellchecker",{text:"Spellcheck",context:"tools",onclick:_,selectable:!0,onPostRender:function(){var e=this;e.active(T.get()),w.on("SpellcheckStart SpellcheckEnd",function(){e.active(T.get())})}}),x=t,k=a,N=n,y=o,S=r,(v=e).on("click",function(e){var t=e.target;if("mce-spellchecker-word"===t.className){e.preventDefault();var n=j(v,q(t));if(0<n.length){var r=v.dom.createRng();r.setStartBefore(n[0]),r.setEndAfter(n[n.length-1]),v.selection.setRng(r),function(t,e,n,r,o,a,i,c){var l=[],s=n.get().suggestions[i];W.each(s,function(e){l.push({text:e,onclick:function(){t.insertContent(t.dom.encode(e)),t.dom.remove(c),G(t,r,o)}})}),l.push({text:"-"}),n.get().hasDictionarySupport&&l.push({text:"Add to Dictionary",onclick:function(){X(t,e,r,o,a,i,c)}}),l.push.apply(l,[{text:"Ignore",onclick:function(){Y(t,r,o,i,c)}},{text:"Ignore all",onclick:function(){Y(t,r,o,i,c,!0)}}]),($=V.create("menu",{items:l,context:"contextmenu",onautohide:function(e){-1!==e.target.className.indexOf("spellchecker")&&e.preventDefault()},onhide:function(){$.remove(),$=null}})).renderTo(document.body);var u=Q.DOM.getPos(t.getContentAreaContainer()),d=t.dom.getPos(c[0]),f=t.dom.getRoot();"BODY"===f.nodeName?(d.x-=f.ownerDocument.documentElement.scrollLeft||f.scrollLeft,d.y-=f.ownerDocument.documentElement.scrollTop||f.scrollTop):(d.x-=f.scrollLeft,d.y-=f.scrollTop),u.x+=d.x,u.y+=d.y,$.moveTo(u.x,u.y+c[0].offsetHeight)}(v,x,k,N,y,S,t.getAttribute("data-mce-word"),n)}}}),f=t,g=n,h=o,m=a,p=r,(d=e).addCommand("mceSpellCheck",function(){z(d,f,g,h,m,p)}),i=e,c=n,l=a,s=o,u=r,{getTextMatcher:function(){return s.get()},getWordCharPattern:function(){return J(i)},markErrors:function(e){K(i,c,s,l,e)},getLanguage:function(){return u.get()}}}var i,c,l,s,u,d,f,g,h,m,p,v,x,k,N,y,S,w,b,T,B,P,C,E,I,D,R,A,M,_,O,F,L})}();