dijit._editor.plugins.FontChoice._initButton
dojo.require("dijit._editor.plugins.FontChoice");
defined in dijit/_editor/plugins/FontChoice.js
Usage
function () (view source)
var cmd = this.command; var names = this.custom || { fontName: this.generic ? ["serif", "sans-serif", "monospace", "cursive", "fantasy"] : // CSS font-family generics ["Arial", "Times New Roman", "Comic Sans MS", "Courier New"], fontSize: [1,2,3,4,5,6,7], // sizes according to the old HTML FONT SIZE formatBlock: ["p", "h1", "h2", "h3", "pre"] }[cmd]; var strings = dojo.i18n.getLocalization("dijit._editor", "FontChoice"); var items = dojo.map(names, function(value){ var name = strings[value] || value; var label = name; switch(cmd){ case "fontName": label = "<div style='font-family: "+value+"'>" + name + "</div>"; break; case "fontSize": // we're stuck using the deprecated FONT tag to correspond with the size measurements used by the editor label = "<font size="+value+"'>"+name+"</font>"; break; case "formatBlock": label = "<" + value + ">" + name + "</" + value + ">"; } return { label: label, name: name, value: value }; }); items.push({label: "", name:"", value:""}); // FilteringSelect doesn't like unmatched blank strings dijit._editor.plugins.FontChoice.superclass._initButton.apply(this, [{ labelType: "html", labelAttr: "label", searchAttr: "name", store: new dojo.data.ItemFileReadStore( { data: { identifier: "value", items: items } })}]); this.button.setValue(""); this.connect(this.button, "onChange", function(choice){ if(this.updating){ return; } // FIXME: IE is really messed up here!! if(dojo.isIE && "_savedSelection" in this){ var b = this._savedSelection; delete this._savedSelection; this.editor.focus(); this.editor._moveToBookmark(b); }else{ // this.editor.focus(); dijit.focus(this._focusHandle); } if(this.command == "fontName" && choice.indexOf(" ") != -1){ choice = "'" + choice + "'"; } this.editor.execCommand(this.editor._normalizeCommand(this.command), choice); });