1 if(!dojo._hasResource["dijit._editor._Plugin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dijit._editor._Plugin"] = true;
3 dojo.provide("dijit._editor._Plugin");
4 dojo.require("dijit._Widget");
5 dojo.require("dijit.Editor");
6 dojo.require("dijit.form.Button");
8 dojo.declare("dijit._editor._Plugin", null, {
10 // This represents a "plugin" to the editor, which is basically
11 // a single button on the Toolbar and some associated code
12 constructor: function(/*Object?*/args, /*DomNode?*/node){
14 dojo.mixin(this, args);
20 iconClassPrefix: "dijitEditorIcon",
25 useDefaultCommand: true,
26 buttonClass: dijit.form.Button,
27 getLabel: function(key){
28 return this.editor.commands[key];
30 _initButton: function(props){
31 if(this.command.length){
32 var label = this.getLabel(this.command);
33 var className = this.iconClassPrefix+" "+this.iconClassPrefix + this.command.charAt(0).toUpperCase() + this.command.substr(1);
39 dropDown: this.dropDown,
42 this.button = new this.buttonClass(props);
47 dojo.forEach(this._connects, dojo.disconnect);
49 connect: function(o, f, tf){
50 this._connects.push(dojo.connect(o, f, this, tf));
52 updateState: function(){
54 var _c = this.command;
56 if(!_e.isLoaded){ return; }
57 if(!_c.length){ return; }
60 var enabled = _e.queryCommandEnabled(_c);
61 this.button.setAttribute('disabled', !enabled);
62 if(typeof this.button.checked == 'boolean'){
63 this.button.setAttribute('checked', _e.queryCommandState(_c));
70 setEditor: function(/*Widget*/editor){
71 // FIXME: detatch from previous editor!!
74 // FIXME: prevent creating this if we don't need to (i.e., editor can't handle our command)
77 // FIXME: wire up editor to button here!
78 if(this.command.length &&
79 !this.editor.queryCommandAvailable(this.command)
81 // console.debug("hiding:", this.command);
83 this.button.domNode.style.display = "none";
86 if(this.button && this.useDefaultCommand){
87 this.connect(this.button, "onClick",
88 dojo.hitch(this.editor, "execCommand", this.command, this.commandArg)
91 this.connect(this.editor, "onNormalizedDisplayChanged", "updateState");
93 setToolbar: function(/*Widget*/toolbar){
95 toolbar.addChild(this.button);
97 // console.debug("adding", this.button, "to:", toolbar);