Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dijit._editor.plugins.FontChoice"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dijit._editor.plugins.FontChoice"] = true;
3
dojo.provide("dijit._editor.plugins.FontChoice");
4
 
5
dojo.require("dijit._editor._Plugin");
6
dojo.require("dijit.form.FilteringSelect");
7
dojo.require("dojo.data.ItemFileReadStore");
8
dojo.require("dojo.i18n");
9
 
10
dojo.requireLocalization("dijit._editor", "FontChoice", null, "ROOT");
11
 
12
dojo.declare("dijit._editor.plugins.FontChoice",
13
	dijit._editor._Plugin,
14
	{
15
		_uniqueId: 0,
16
 
17
		buttonClass: dijit.form.FilteringSelect,
18
 
19
		_initButton: function(){
20
			this.inherited("_initButton", arguments);
21
 
22
			//TODO: do we need nls for font names?  provide css font lists? or otherwise make this more configurable?
23
			var names = {
24
				fontName: ["serif", "sans-serif", "monospaced", "cursive", "fantasy"],
25
				fontSize: [1,2,3,4,5,6,7],
26
				formatBlock: ["p", "h1", "h2", "h3", "pre"] }[this.command];
27
			var strings = dojo.i18n.getLocalization("dijit._editor", "FontChoice");
28
			var items = dojo.map(names, function(x){ return { name: strings[x], value: x }; });
29
			items.push({name:"", value:""}); // FilteringSelect doesn't like unmatched blank strings
30
			this.button.store = new dojo.data.ItemFileReadStore(
31
				{ data: { identifier: "value",
32
					items: items }
33
				});
34
			this.button.setValue("");
35
 
36
			dojo.connect(this.button, "onChange", this, function(choice){
37
				this.editor.execCommand(this.command, choice);
38
			});
39
		},
40
 
41
		updateState: function(){
42
			this.inherited("updateState", arguments);
43
			var _e = this.editor;
44
			var _c = this.command;
45
			if(!_e || !_e.isLoaded || !_c.length){ return; }
46
			if(this.button){
47
				var value = _e.queryCommandValue(_c);
48
				this.button.setValue(value);
49
			}
50
		},
51
 
52
		setToolbar: function(){
53
			this.inherited("setToolbar", arguments);
54
 
55
			var forRef = this.button;
56
			if(!forRef.id){ forRef.id = "dijitEditorButton-"+this.command+(this._uniqueId++); } //TODO: is this necessary?  FilteringSelects always seem to have an id?
57
			var label = dojo.doc.createElement("label");
58
			label.setAttribute("for", forRef.id);
59
			var strings = dojo.i18n.getLocalization("dijit._editor", "FontChoice");
60
			label.appendChild(dojo.doc.createTextNode(strings[this.command]));
61
			dojo.place(label, this.button.domNode, "before");
62
		}
63
	}
64
);
65
 
66
}