1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/* Do not modify this file directly. It is compiled from other files. */
/*
* TinyMCE Writing Improvement Tool Plugin
* Author: Raphael Mudge (raffi@automattic.com)
*
* http://www.afterthedeadline.com
*
* Distributed under the LGPL
*
* Derived from:
* $Id: editor_plugin_src.js 425 2007-11-21 15:17:39Z spocke $
*
* @author Moxiecode
* @copyright Copyright (C) 2004-2008, Moxiecode Systems AB, All rights reserved.
*
* Moxiecode Spell Checker plugin released under the LGPL with TinyMCE
*/
!function(){var e,t=tinymce.each,n=tinymce.DOM;function o(e,t){return window.AtD_l10n_r0ar&&window.AtD_l10n_r0ar[e]||t}tinymce.create("tinymce.plugins.AfterTheDeadlinePlugin",{getInfo:function(){return{longname:"After The Deadline",author:"Raphael Mudge",authorurl:"http://blog.afterthedeadline.com",infourl:"http://www.afterthedeadline.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}},initAtDCore:function(e){var n=new AtDCore;return n.map=t,n.getAttrib=function(t,n){return e.dom.getAttrib(t,n)},n.findSpans=function(t){return t?e.dom.select("span",t):e.dom.select("span")},n.hasClass=function(t,n){return e.dom.hasClass(t,n)},n.contents=function(e){return e.childNodes},n.replaceWith=function(t,n){return e.dom.replace(n,t)},n.create=function(t){return e.dom.create("span",{class:"mceItemHidden"},t)},n.removeParent=function(t){return e.dom.remove(t,1),t},n.remove=function(t){e.dom.remove(t)},n.setIgnoreStrings(e.getParam("atd_ignore_strings",[]).join(",")),n.showTypes(e.getParam("atd_show_types","")),n},init:function(n,r){if("undefined"!=typeof AtDCore){var i=this,s=n;this.url=r,this.editor=n,e=n.core=this.initAtDCore(s,i);var a=tinymce.util.Cookie.getHash("atd_ignore");a||(a={}),s.addCommand("mceWritingImprovementTool",function(t){"undefined"!=typeof AtD_proofread_click_count&&AtD_proofread_click_count++,i.editor.setProgressState(1),i._removeWords(),i.sendRequest("checkDocument",n.getContent({format:"raw"}),function(r,s){if(i.editor.setProgressState(0),200===s.status&&"html"!==s.responseText.substr(1,4)&&s.responseXML)if(null==s.responseXML.getElementsByTagName("message").item(0)){var a=e.processXML(s.responseXML),d=0;a.count>0&&(d=i.markMyWords(a.errors),n.suggestions=a.suggestions),0!==d||t&&void 0!==t?t&&t(d):n.windowManager.alert(o("message_no_errors_found","No writing errors were found."))}else n.windowManager.alert(s.responseXML.getElementsByTagName("message").item(0).firstChild.data,t?function(){t(0)}:function(){});else n.windowManager.alert(o("message_server_error","There was a problem communicating with the Proofreading service. Try again in one minute."),t?function(){t(0)}:function(){})})}),s.onInit.add(function(){!1!==s.settings.content_css&&s.dom.loadCSS(s.getParam("atd_css_url",r+"/css/content.css"))}),s.onClick.add(i._showMenu,i),s.onContextMenu.add(i._showMenu,i),s.onPreProcess.add(function(e,n){var o=e.dom;t(o.select("span",n.node).reverse(),function(e){!e||!(o.hasClass(e,"hiddenGrammarError")||o.hasClass(e,"hiddenSpellError")||o.hasClass(e,"hiddenSuggestion")||o.hasClass(e,"mceItemHidden"))&&(o.getAttrib(e,"class")||o.getAttrib(e,"style")||o.getAttrib(e,"id")||o.hasClass(e,"Apple-style-span")||o.getAttrib(e,"mce_name"))||o.remove(e,1)})}),s.onBeforeExecCommand.add(function(e,t){"mceCodeEditor"===t?i._removeWords():"mceFullScreen"===t&&i._done()}),n.addButton("AtD",{title:o("button_proofread_tooltip","Proofread Writing"),image:n.getParam("atd_button_url",r+"/atdbuttontr.gif"),cmd:"mceWritingImprovementTool"})}},_removeWords:function(e){var t=this.editor,n=t.dom,o=t.selection,r=o.getBookmark();t.core.removeWords(void 0,e),n.setHTML(n.getRoot(),n.getRoot().innerHTML),o.moveToBookmark(r)},markMyWords:function(e){var t=this.editor,n=t.selection,o=n.getBookmark(),r=t.core.markMyWords(t.core.contents(this.editor.getBody()),e);return n.moveToBookmark(o),r},_showMenu:function(e,t){var r=this;e=r.editor;var i,s,a=r._menu,d=e.dom,c=d.getViewPort(e.getWin());if(a||(i=n.getPos(e.getContentAreaContainer()),a=e.controlManager.createDropMenu("spellcheckermenu",{offset_x:i.x,offset_y:i.y,class:"mceNoIcons"}),r._menu=a),e.core.isMarkedNode(t.target)){a.removeAll();var l=e.core.findSuggestion(t.target);if(l)if(0===l.suggestions.length)a.add({title:l.description,class:"mceMenuItemTitle"}).setDisabled(1);else{a.add({title:l.description,class:"mceMenuItemTitle"}).setDisabled(1);for(var u=0;u<l.suggestions.length;u++)!function(n){a.add({title:n,onclick:function(){e.core.applySuggestion(t.target,n),r._checkDone()}})}(l.suggestions[u]);a.addSeparator()}else a.add({title:o("menu_title_no_suggestions","No suggestions"),class:"mceMenuItemTitle"}).setDisabled(1);return l&&l.moreinfo&&(s=l.moreinfo,a.add({title:o("menu_option_explain","Explain..."),onclick:function(){e.windowManager.open({url:s,width:480,height:380,inline:!0},{theme_url:this.url})}}),a.addSeparator()),a.add({title:o("menu_option_ignore_once","Ignore suggestion"),onclick:function(){d.remove(t.target,1),r._checkDone()}}),"true"===String(this.editor.getParam("atd_ignore_enable","false"))?a.add({title:o("menu_option_ignore_always","Ignore always"),onclick:function(){var e=r.editor.getParam("atd_ignore_rpc_url","{backend}");if("{backend}"===e){var n=tinymce.util.Cookie.getHash("atd_ignore");n||(n={}),n[t.target.innerHTML]=1,tinymce.util.Cookie.setHash("atd_ignore",n,new Date((new Date).getTime()+15768e7))}else{var o=r.editor.getParam("atd_rpc_id","12345678");tinymce.util.XHR.send({url:e+encodeURI(t.target.innerHTML).replace(/&/g,"%26")+"&key="+o,content_type:"text/xml",async:!0,type:"GET",success:function(){},error:function(e,t,n){alert("Ignore preference save failed\n"+e+"\n"+t.status+"\nAt: "+n.url)}}),r.editor.core.setIgnoreStrings(t.target.innerHTML)}r._removeWords(t.target.innerHTML),r._checkDone()}}):a.add({title:o("menu_option_ignore_all","Ignore all"),onclick:function(){r._removeWords(t.target.innerHTML),r._checkDone()}}),e.selection.select(t.target),i=d.getPos(t.target),a.showMenu(i.x,i.y+t.target.offsetHeight-c.y),tinymce.dom.Event.cancel(t)}a.hideMenu()},_checkDone:function(){var e,n=this.editor.dom;t(n.select("span"),function(t){if(t&&n.hasClass(t,"mceItemHidden"))return e=!0,!1}),e||this._done()},_done:function(){this._removeWords(),this._menu&&this._menu.hideMenu(),this.editor.nodeChanged()},sendRequest:function(e,t,n){var o=this.editor.getParam("atd_rpc_id","12345678"),r=this.editor.getParam("atd_rpc_url","{backend}"),i=this;if("{backend}"===r||"12345678"===o)return this.editor.setProgressState(0),void alert("Please specify: atd_rpc_url and atd_rpc_id");tinymce.util.XHR.send({url:r+"/"+e,content_type:"text/xml",type:"POST",data:"data="+encodeURI(t).replace(/&/g,"%26")+"&key="+o,async:!0,success:n,error:function(e,t,n){i.editor.setProgressState(0),alert(e+"\n"+t.status+"\nAt: "+n.url)}})}}),tinymce.PluginManager.add("AtD",tinymce.plugins.AfterTheDeadlinePlugin)}();
|