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(){function e(e,t){return window.AtD_l10n_r0ar&&window.AtD_l10n_r0ar[e]||t}var t,n=tinymce.each,o=tinymce.DOM;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 t=new AtDCore;return t.map=n,t.getAttrib=function(t,n){return e.dom.getAttrib(t,n)},t.findSpans=function(t){return t?e.dom.select("span",t):e.dom.select("span")},t.hasClass=function(t,n){return e.dom.hasClass(t,n)},t.contents=function(e){return e.childNodes},t.replaceWith=function(t,n){return e.dom.replace(n,t)},t.create=function(t){return e.dom.create("span",{class:"mceItemHidden"},t)},t.removeParent=function(t){return e.dom.remove(t,1),t},t.remove=function(t){e.dom.remove(t)},t.setIgnoreStrings(e.getParam("atd_ignore_strings",[]).join(",")),t.showTypes(e.getParam("atd_show_types","")),t},init:function(o,r){if("undefined"!=typeof AtDCore){var i=this,a=o;this.url=r,this.editor=o,t=o.core=this.initAtDCore(a,i);var s=tinymce.util.Cookie.getHash("atd_ignore");s||(s={}),a.addCommand("mceWritingImprovementTool",function(n){"undefined"!=typeof AtD_proofread_click_count&&AtD_proofread_click_count++,i.editor.setProgressState(1),i._removeWords(),i.sendRequest("checkDocument",o.getContent({format:"raw"}),function(r,a){if(i.editor.setProgressState(0),200!==a.status||"html"===a.responseText.substr(1,4)||!a.responseXML)return void o.windowManager.alert(e("message_server_error","There was a problem communicating with the Proofreading service. Try again in one minute."),n?function(){n(0)}:function(){});if(null!=a.responseXML.getElementsByTagName("message").item(0))return void o.windowManager.alert(a.responseXML.getElementsByTagName("message").item(0).firstChild.data,n?function(){n(0)}:function(){});var s=t.processXML(a.responseXML),d=0;s.count>0&&(d=i.markMyWords(s.errors),o.suggestions=s.suggestions),0!==d||n&&void 0!==n?n&&n(d):o.windowManager.alert(e("message_no_errors_found","No writing errors were found."))})}),a.onInit.add(function(){!1!==a.settings.content_css&&a.dom.loadCSS(a.getParam("atd_css_url",r+"/css/content.css"))}),a.onClick.add(i._showMenu,i),a.onContextMenu.add(i._showMenu,i),a.onPreProcess.add(function(e,t){var o=e.dom;n(o.select("span",t.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)})}),a.onBeforeExecCommand.add(function(e,t){"mceCodeEditor"===t?i._removeWords():"mceFullScreen"===t&&i._done()}),o.addButton("AtD",{title:e("button_proofread_tooltip","Proofread Writing"),image:o.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(t,n){var r=this;t=r.editor;var i,a=r._menu,s=t.dom,d=s.getViewPort(t.getWin());if(a||(i=o.getPos(t.getContentAreaContainer()),a=t.controlManager.createDropMenu("spellcheckermenu",{offset_x:i.x,offset_y:i.y,class:"mceNoIcons"}),r._menu=a),t.core.isMarkedNode(n.target)){a.removeAll();var c=t.core.findSuggestion(n.target);if(c)if(0===c.suggestions.length)a.add({title:c.description,class:"mceMenuItemTitle"}).setDisabled(1);else{a.add({title:c.description,class:"mceMenuItemTitle"}).setDisabled(1);for(var u=0;u<c.suggestions.length;u++)!function(e){a.add({title:e,onclick:function(){t.core.applySuggestion(n.target,e),r._checkDone()}})}(c.suggestions[u]);a.addSeparator()}else a.add({title:e("menu_title_no_suggestions","No suggestions"),class:"mceMenuItemTitle"}).setDisabled(1);return c&&c.moreinfo&&(!function(n){a.add({title:e("menu_option_explain","Explain..."),onclick:function(){t.windowManager.open({url:n,width:480,height:380,inline:!0},{theme_url:this.url})}})}(c.moreinfo),a.addSeparator()),a.add({title:e("menu_option_ignore_once","Ignore suggestion"),onclick:function(){s.remove(n.target,1),r._checkDone()}}),"true"===String(this.editor.getParam("atd_ignore_enable","false"))?a.add({title:e("menu_option_ignore_always","Ignore always"),onclick:function(){var e=r.editor.getParam("atd_ignore_rpc_url","{backend}");if("{backend}"===e){var t=tinymce.util.Cookie.getHash("atd_ignore");t||(t={}),t[n.target.innerHTML]=1,tinymce.util.Cookie.setHash("atd_ignore",t,new Date((new Date).getTime()+15768e7))}else{var o=r.editor.getParam("atd_rpc_id","12345678");tinymce.util.XHR.send({url:e+encodeURI(n.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(n.target.innerHTML)}r._removeWords(n.target.innerHTML),r._checkDone()}}):a.add({title:e("menu_option_ignore_all","Ignore all"),onclick:function(){r._removeWords(n.target.innerHTML),r._checkDone()}}),t.selection.select(n.target),i=s.getPos(n.target),a.showMenu(i.x,i.y+n.target.offsetHeight-d.y),tinymce.dom.Event.cancel(n)}a.hideMenu()},_checkDone:function(){var e,t=this,o=t.editor,r=o.dom;n(r.select("span"),function(t){if(t&&r.hasClass(t,"mceItemHidden"))return e=!0,!1}),e||t._done()},_done:function(){var e=this;e._removeWords(),e._menu&&e._menu.hideMenu(),e.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)}();
|