src/myams/resources/js/ext/tinymce/dev/plugins/spellchecker/plugin.min.js
changeset 0 f05d7aea098a
child 5 c9c69b13d884
equal deleted inserted replaced
-1:000000000000 0:f05d7aea098a
       
     1 (function(b,g){var d={};function c(m,n){var l,j=[];for(var k=0;k<m.length;++k){l=d[m[k]]||e(m[k]);if(!l){throw"module definition dependecy not found: "+m[k]}j.push(l)}n.apply(null,j)}function h(k,j,i){if(typeof k!=="string"){throw"invalid module definition, module id must be defined and be a string"}if(j===g){throw"invalid module definition, dependencies must be specified"}if(i===g){throw"invalid module definition, definition function must be specified"}c(j,function(){d[k]=i.apply(null,arguments)})}function f(i){return !!d[i]}function e(l){var j=b;var i=l.split(/[.\/]/);for(var k=0;k<i.length;++k){if(!j[i[k]]){return}j=j[i[k]]}return j}function a(l){for(var k=0;k<l.length;k++){var m=b;var o=l[k];var j=o.split(/[.\/]/);for(var n=0;n<j.length-1;++n){if(m[j[n]]===g){m[j[n]]={}}m=m[j[n]]}m[j[j.length-1]]=d[o]}}h("tinymce/spellcheckerplugin/DomTextMatcher",[],function(){return function(C,n){var B,k=[],s,G=n.dom;var y,t,E;y=n.schema.getBlockElements();t=n.schema.getWhiteSpaceElements();E=n.schema.getShortEndedElements();function F(K,L){if(!K[0]){throw"findAndReplaceDOMText cannot handle zero-length matches"}return{start:K.index,end:K.index+K[0].length,text:K[0],data:L}}function i(K){var m;if(K.nodeType===3){return K.data}if(t[K.nodeName]&&!y[K.nodeName]){return""}m="";if(y[K.nodeName]||E[K.nodeName]){m+="\n"}if((K=K.firstChild)){do{m+=i(K)}while((K=K.nextSibling))}return m}function H(M,O,S){var K,R,P,L,T=[],Q=0,N=M,m,U=0;O=O.slice(0);O.sort(function(W,V){return W.start-V.start});m=O.shift();out:while(true){if(y[N.nodeName]||E[N.nodeName]){Q++}if(N.nodeType===3){if(!R&&N.length+Q>=m.end){R=N;L=m.end-Q}else{if(K){T.push(N)}}if(!K&&N.length+Q>m.start){K=N;P=m.start-Q}Q+=N.length}if(K&&R){N=S({startNode:K,startNodeIndex:P,endNode:R,endNodeIndex:L,innerNodes:T,match:m.text,matchIndex:U});Q-=(R.length-L);K=null;R=null;T=[];m=O.shift();U++;if(!m){break}}else{if((!t[N.nodeName]||y[N.nodeName])&&N.firstChild){N=N.firstChild;continue}else{if(N.nextSibling){N=N.nextSibling;continue}}}while(true){if(N.nextSibling){N=N.nextSibling;break}else{if(N.parentNode!==M){N=N.parentNode}else{break out}}}}}function v(K){function m(N,L){var M=k[L];if(!M.stencil){M.stencil=K(M)}var O=M.stencil.cloneNode(false);O.setAttribute("data-mce-index",L);if(N){O.appendChild(G.doc.createTextNode(N))}return O}return function(R){var Y,L,S,N=R.startNode,U=R.endNode,Z=R.matchIndex,aa=G.doc;if(N===U){var O=N;S=O.parentNode;if(R.startNodeIndex>0){Y=aa.createTextNode(O.data.substring(0,R.startNodeIndex));S.insertBefore(Y,O)}var M=m(R.match,Z);S.insertBefore(M,O);if(R.endNodeIndex<O.length){L=aa.createTextNode(O.data.substring(R.endNodeIndex));S.insertBefore(L,O)}O.parentNode.removeChild(O);return M}else{Y=aa.createTextNode(N.data.substring(0,R.startNodeIndex));L=aa.createTextNode(U.data.substring(R.endNodeIndex));var W=m(N.data.substring(R.startNodeIndex),Z);var V=[];for(var Q=0,P=R.innerNodes.length;Q<P;++Q){var ab=R.innerNodes[Q];var X=m(ab.data,Z);ab.parentNode.replaceChild(X,ab);V.push(X)}var T=m(U.data.substring(0,R.endNodeIndex),Z);S=N.parentNode;S.insertBefore(Y,N);S.insertBefore(W,N);S.removeChild(N);S=U.parentNode;S.insertBefore(T,U);S.insertBefore(L,U);S.removeChild(U);return T}}}function o(K){var m=K.parentNode;m.insertBefore(K.firstChild,K);K.parentNode.removeChild(K)}function D(m){var O=C.getElementsByTagName("*"),N=[];m=typeof m=="number"?""+m:null;for(var M=0;M<O.length;M++){var L=O[M],K=L.getAttribute("data-mce-index");if(K!==null&&K.length){if(K===m||m===null){N.push(L)}}}return N}function j(m){var K=k.length;while(K--){if(k[K]===m){return K}}return -1}function r(K){var m=[];l(function(L,M){if(K(L,M)){m.push(L)}});k=m;return this}function l(L){for(var K=0,m=k.length;K<m;K++){if(L(k[K],K)===false){break}}return this}function q(m){if(k.length){H(C,k,v(m))}return this}function x(m,K){if(s&&m.global){while((B=m.exec(s))){k.push(F(B,K))}}return this}function A(m){var K,L=D(m?j(m):null);K=L.length;while(K--){o(L[K])}return this}function z(m){return k[m.getAttribute("data-mce-index")]}function u(m){return D(j(m))[0]}function w(L,m,K){k.push({start:L,end:L+m,text:s.substr(L,m),data:K});return this}function p(K){var L=D(j(K));var m=n.dom.createRng();m.setStartBefore(L[0]);m.setEndAfter(L[L.length-1]);return m}function I(K,L){var m=p(K);m.deleteContents();if(L.length>0){m.insertNode(n.dom.doc.createTextNode(L))}return m}function J(){k.splice(0,k.length);A();return this}s=i(C);return{text:s,matches:k,each:l,filter:r,reset:J,matchFromElement:z,elementFromMatch:u,find:x,add:w,wrap:q,unwrap:A,replace:I,rangeFromMatch:p,indexOf:j}}});h("tinymce/spellcheckerplugin/Plugin",["tinymce/spellcheckerplugin/DomTextMatcher","tinymce/PluginManager","tinymce/util/Tools","tinymce/ui/Menu","tinymce/dom/DOMUtils","tinymce/util/XHR","tinymce/util/URI","tinymce/util/JSON"],function(p,k,j,m,n,l,i,o){k.add("spellchecker",function(r,u){var z,A=this,Q,q,H,M=r.settings;var N;function P(){if(!A.textMatcher){A.textMatcher=new p(r.getBody(),r)}return A.textMatcher}function I(T,R){var S=[];j.each(R,function(U){S.push({selectable:true,text:U.name,data:U.value})});return S}var J=M.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";z=I("Language",j.map(J.split(","),function(R){R=R.split("=");return{name:R[0],value:R[1]}}));function y(S){for(var R in S){return false}return true}function s(W,U){var T=[],R=Q[W];j.each(R,function(Y){T.push({text:Y,onclick:function(){r.insertContent(r.dom.encode(Y));r.dom.remove(U);K()}})});T.push({text:"-"});if(N){T.push({text:"Add to Dictionary",onclick:function(){v(W,U)}})}T.push.apply(T,[{text:"Ignore",onclick:function(){C(W,U)}},{text:"Ignore all",onclick:function(){C(W,U,true)}}]);H=new m({items:T,context:"contextmenu",onautohide:function(Y){if(Y.target.className.indexOf("spellchecker")!=-1){Y.preventDefault()}},onhide:function(){H.remove();H=null}});H.renderTo(document.body);var X=n.DOM.getPos(r.getContentAreaContainer());var V=r.dom.getPos(U[0]);var S=r.dom.getRoot();if(S.nodeName=="BODY"){V.x-=S.ownerDocument.documentElement.scrollLeft||S.scrollLeft;V.y-=S.ownerDocument.documentElement.scrollTop||S.scrollTop}else{V.x-=S.scrollLeft;V.y-=S.scrollTop}X.x+=V.x;X.y+=V.y;H.moveTo(X.x,X.y+U[0].offsetHeight)}function G(){return r.getParam("spellchecker_wordchar_pattern")||new RegExp('[^\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`\u00a7\u00a9\u00ab\u00ae\u00b1\u00b6\u00b7\u00b8\u00bb\u00bc\u00bd\u00be\u00bf\u00d7\u00f7\u00a4\u201d\u201c\u201e\u00a0\u2002\u2003\u2009]+',"g")}function t(W,V,S,T){var U={method:W},R="";if(W=="spellcheck"){U.text=V;U.lang=M.spellchecker_language}if(W=="addToDictionary"){U.word=V}j.each(U,function(Y,X){if(R){R+="&"}R+=X+"="+encodeURIComponent(Y)});l.send({url:new i(u).toAbsolute(M.spellchecker_rpc_url),type:"post",content_type:"application/x-www-form-urlencoded",data:R,success:function(X){X=o.parse(X);if(!X){T("Sever response wasn't proper JSON.")}else{if(X.error){T(X.error)}else{S(X)}}},error:function(X,Y){T("Spellchecker request error: "+Y.status)}})}function L(U,V,R,T){var S=M.spellchecker_callback||t;S.call(A,U,V,R,T)}function O(){if(q){F();return}else{F()}function R(S){r.windowManager.alert(S);r.setProgressState(false);F()}r.setProgressState(true);L("spellcheck",P().text,B,R);r.focus()}function K(){if(!r.dom.select("span.mce-spellchecker-word").length){F()}}function v(S,R){r.setProgressState(true);L("addToDictionary",S,function(){r.setProgressState(false);r.dom.remove(R,true);K()},function(T){r.windowManager.alert(T);r.setProgressState(false)})}function C(T,R,S){r.selection.collapse();if(S){j.each(r.dom.select("span.mce-spellchecker-word"),function(U){if(U.getAttribute("data-mce-word")==T){r.dom.remove(U,true)}})}else{r.dom.remove(R,true)}K()}function F(){P().reset();A.textMatcher=null;if(q){q=false;r.fire("SpellcheckEnd")}}function x(S){var R=S.getAttribute("data-mce-index");if(typeof R=="number"){return""+R}return R}function w(S){var R,U=[];R=j.toArray(r.getBody().getElementsByTagName("span"));if(R.length){for(var T=0;T<R.length;T++){var V=x(R[T]);if(V===null||!V.length){continue}if(V===S.toString()){U.push(R[T])}}}return U}r.on("click",function(U){var T=U.target;if(T.className=="mce-spellchecker-word"){U.preventDefault();var S=w(x(T));if(S.length>0){var R=r.dom.createRng();R.setStartBefore(S[0]);R.setEndAfter(S[S.length-1]);r.selection.setRng(R);s(T.getAttribute("data-mce-word"),S)}}});r.addMenuItem("spellchecker",{text:"Spellcheck",context:"tools",onclick:O,selectable:true,onPostRender:function(){var R=this;R.active(q);r.on("SpellcheckStart SpellcheckEnd",function(){R.active(q)})}});function E(S){var R=M.spellchecker_language;S.control.items().each(function(T){T.active(T.settings.data===R)})}function B(S){var R;if(S.words){N=!!S.dictionary;R=S.words}else{R=S}r.setProgressState(false);if(y(R)){r.windowManager.alert("No misspellings found");q=false;return}Q=R;P().find(G()).filter(function(T){return !!R[T.text]}).wrap(function(T){return r.dom.create("span",{"class":"mce-spellchecker-word","data-mce-bogus":1,"data-mce-word":T.text})});q=true;r.fire("SpellcheckStart")}var D={tooltip:"Spellcheck",onclick:O,onPostRender:function(){var R=this;r.on("SpellcheckStart SpellcheckEnd",function(){R.active(q)})}};if(z.length>1){D.type="splitbutton";D.menu=z;D.onshow=E;D.onselect=function(R){M.spellchecker_language=R.control.settings.data}}r.addButton("spellchecker",D);r.addCommand("mceSpellCheck",O);r.on("remove",function(){if(H){H.remove();H=null}});r.on("change",K);this.getTextMatcher=P;this.getWordCharPattern=G;this.markErrors=B;this.getLanguage=function(){return M.spellchecker_language};M.spellchecker_language=M.spellchecker_language||M.language||"en"})});a(["tinymce/spellcheckerplugin/DomTextMatcher"])})(this);