dojo.provide("dijit._editor.plugins.SpellCheck"); dojo.experimental("dijit._editor.plugins.SpellCheck"); dojo.require("dijit._editor._Plugin"); dojo.require("dojox.widget.SpellCheck"); dojo.requireLocalization("dojox.widget", "SpellCheck"); dojo.declare("dijit._editor.plugins.SpellCheck", dijit._editor._Plugin, { //summary: This plugin is used to allow the use of the dojox spellchecker //i18nModule: String //Module for i18n i18nModule:"dojox.widget", //i18nBundle: String //Bundle for i18n i18nBundle:"SpellCheck", useDefaultCommand: false, buttonClass: dijit.form.ToggleButton, command: "spellCheck", _spell: null, _nls:null, getLabel: function(key){ if(this._nls===null) this._nls = dojo.i18n.getLocalization(this.i18nModule, this.i18nBundle, this.lang); return this._nls.label; }, _initButton: function(){ this.inherited("_initButton", arguments); this.connect(this.button, "onClick", this._spellCheck); }, updateState: function(){ var _e = this.editor; var _c = this.command; if(!_e){ return; } if(!_e.isLoaded){ return; } if(!_c.length){ return; } if(this.button){ try{ var enabled = _e.isSpellCheck; if(typeof this.button.checked == 'boolean'){ this.button.attr('checked', enabled); } }catch(e){ console.debug(e); } } }, setEditor: function(/*Widget*/editor){ this.inherited("setEditor", arguments); if(this.button){ this.button.domNode.style.display = ""; } }, _spellCheck: function(){ // toggle the value for isSpellCheck if(this._spell === null){ var tbSize=dojo.marginBox(this.editor.toolbar.domNode); this._spell = new dojox.widget.SpellCheck({ editor: this.editor, innerDocument: this.editor.document, setContent: dojo.hitch(this.editor, this.editor.setValue), getContent: dojo.hitch(this.editor, this.editor.getValue), aspell: dojo.config.aspell, textarea: null, contextualMenuCoordsCorrection: { l: 0, t: tbSize.h//editor toolbar height } }); } if (!this._spell.isInProgress) { if (this._spell.start()) this.editor.isSpellCheck=true; } else { if(this._spell.stop()) this.editor.isSpellCheck=false; } } } ); dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",null,function(o){ if(o.plugin){ return; } switch(o.args.name){ case "spellCheck": o.plugin = new dijit._editor.plugins.SpellCheck({command: o.args.name}); } });