/* 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