1318 |
alexandre_ |
1 |
/*
|
|
|
2 |
Copyright (c) 2004-2006, The Dojo Foundation
|
|
|
3 |
All Rights Reserved.
|
|
|
4 |
|
|
|
5 |
Licensed under the Academic Free License version 2.1 or above OR the
|
|
|
6 |
modified BSD license. For more information on Dojo licensing, see:
|
|
|
7 |
|
|
|
8 |
http://dojotoolkit.org/community/licensing.shtml
|
|
|
9 |
*/
|
|
|
10 |
|
1422 |
alexandre_ |
11 |
|
|
|
12 |
|
1318 |
alexandre_ |
13 |
dojo.provide("dojo.widget.Editor2Toolbar");
|
|
|
14 |
dojo.require("dojo.lang.*");
|
|
|
15 |
dojo.require("dojo.widget.*");
|
|
|
16 |
dojo.require("dojo.event.*");
|
|
|
17 |
dojo.require("dojo.html.layout");
|
|
|
18 |
dojo.require("dojo.html.display");
|
|
|
19 |
dojo.require("dojo.widget.RichText");
|
|
|
20 |
dojo.require("dojo.widget.PopupContainer");
|
|
|
21 |
dojo.require("dojo.widget.ColorPalette");
|
|
|
22 |
dojo.lang.declare("dojo.widget.HandlerManager", null, function () {
|
|
|
23 |
this._registeredHandlers = [];
|
|
|
24 |
}, {registerHandler:function (obj, func) {
|
|
|
25 |
if (arguments.length == 2) {
|
|
|
26 |
this._registeredHandlers.push(function () {
|
|
|
27 |
return obj[func].apply(obj, arguments);
|
|
|
28 |
});
|
|
|
29 |
} else {
|
|
|
30 |
this._registeredHandlers.push(obj);
|
|
|
31 |
}
|
|
|
32 |
}, removeHandler:function (func) {
|
|
|
33 |
for (var i = 0; i < this._registeredHandlers.length; i++) {
|
|
|
34 |
if (func === this._registeredHandlers[i]) {
|
|
|
35 |
delete this._registeredHandlers[i];
|
|
|
36 |
return;
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
dojo.debug("HandlerManager handler " + func + " is not registered, can not remove.");
|
|
|
40 |
}, destroy:function () {
|
|
|
41 |
for (var i = 0; i < this._registeredHandlers.length; i++) {
|
|
|
42 |
delete this._registeredHandlers[i];
|
|
|
43 |
}
|
|
|
44 |
}});
|
|
|
45 |
dojo.widget.Editor2ToolbarItemManager = new dojo.widget.HandlerManager;
|
|
|
46 |
dojo.lang.mixin(dojo.widget.Editor2ToolbarItemManager, {getToolbarItem:function (name) {
|
|
|
47 |
var item;
|
|
|
48 |
name = name.toLowerCase();
|
|
|
49 |
for (var i = 0; i < this._registeredHandlers.length; i++) {
|
|
|
50 |
item = this._registeredHandlers[i](name);
|
|
|
51 |
if (item) {
|
|
|
52 |
return item;
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
switch (name) {
|
|
|
56 |
case "bold":
|
|
|
57 |
case "copy":
|
|
|
58 |
case "cut":
|
|
|
59 |
case "delete":
|
|
|
60 |
case "indent":
|
|
|
61 |
case "inserthorizontalrule":
|
|
|
62 |
case "insertorderedlist":
|
|
|
63 |
case "insertunorderedlist":
|
|
|
64 |
case "italic":
|
|
|
65 |
case "justifycenter":
|
|
|
66 |
case "justifyfull":
|
|
|
67 |
case "justifyleft":
|
|
|
68 |
case "justifyright":
|
|
|
69 |
case "outdent":
|
|
|
70 |
case "paste":
|
|
|
71 |
case "redo":
|
|
|
72 |
case "removeformat":
|
|
|
73 |
case "selectall":
|
|
|
74 |
case "strikethrough":
|
|
|
75 |
case "subscript":
|
|
|
76 |
case "superscript":
|
|
|
77 |
case "underline":
|
|
|
78 |
case "undo":
|
|
|
79 |
case "unlink":
|
|
|
80 |
case "createlink":
|
|
|
81 |
case "insertimage":
|
|
|
82 |
case "htmltoggle":
|
|
|
83 |
item = new dojo.widget.Editor2ToolbarButton(name);
|
|
|
84 |
break;
|
|
|
85 |
case "forecolor":
|
|
|
86 |
case "hilitecolor":
|
|
|
87 |
item = new dojo.widget.Editor2ToolbarColorPaletteButton(name);
|
|
|
88 |
break;
|
|
|
89 |
case "plainformatblock":
|
|
|
90 |
item = new dojo.widget.Editor2ToolbarFormatBlockPlainSelect("formatblock");
|
|
|
91 |
break;
|
|
|
92 |
case "formatblock":
|
|
|
93 |
item = new dojo.widget.Editor2ToolbarFormatBlockSelect("formatblock");
|
|
|
94 |
break;
|
|
|
95 |
case "fontsize":
|
|
|
96 |
item = new dojo.widget.Editor2ToolbarFontSizeSelect("fontsize");
|
|
|
97 |
break;
|
|
|
98 |
case "fontname":
|
|
|
99 |
item = new dojo.widget.Editor2ToolbarFontNameSelect("fontname");
|
|
|
100 |
break;
|
|
|
101 |
case "inserttable":
|
|
|
102 |
case "insertcell":
|
|
|
103 |
case "insertcol":
|
|
|
104 |
case "insertrow":
|
|
|
105 |
case "deletecells":
|
|
|
106 |
case "deletecols":
|
|
|
107 |
case "deleterows":
|
|
|
108 |
case "mergecells":
|
|
|
109 |
case "splitcell":
|
|
|
110 |
dojo.debug(name + " is implemented in dojo.widget.Editor2Plugin.TableOperation, please require it first.");
|
|
|
111 |
break;
|
|
|
112 |
case "inserthtml":
|
|
|
113 |
case "blockdirltr":
|
|
|
114 |
case "blockdirrtl":
|
|
|
115 |
case "dirltr":
|
|
|
116 |
case "dirrtl":
|
|
|
117 |
case "inlinedirltr":
|
|
|
118 |
case "inlinedirrtl":
|
|
|
119 |
dojo.debug("Not yet implemented toolbar item: " + name);
|
|
|
120 |
break;
|
|
|
121 |
default:
|
|
|
122 |
dojo.debug("dojo.widget.Editor2ToolbarItemManager.getToolbarItem: Unknown toolbar item: " + name);
|
|
|
123 |
}
|
|
|
124 |
return item;
|
|
|
125 |
}});
|
|
|
126 |
dojo.addOnUnload(dojo.widget.Editor2ToolbarItemManager, "destroy");
|
|
|
127 |
dojo.declare("dojo.widget.Editor2ToolbarButton", null, function (name) {
|
|
|
128 |
this._name = name;
|
|
|
129 |
}, {create:function (node, toolbar, nohover) {
|
|
|
130 |
this._domNode = node;
|
|
|
131 |
var cmd = toolbar.parent.getCommand(this._name);
|
|
|
132 |
if (cmd) {
|
|
|
133 |
this._domNode.title = cmd.getText();
|
|
|
134 |
}
|
|
|
135 |
this.disableSelection(this._domNode);
|
|
|
136 |
this._parentToolbar = toolbar;
|
|
|
137 |
dojo.event.connect(this._domNode, "onclick", this, "onClick");
|
|
|
138 |
if (!nohover) {
|
|
|
139 |
dojo.event.connect(this._domNode, "onmouseover", this, "onMouseOver");
|
|
|
140 |
dojo.event.connect(this._domNode, "onmouseout", this, "onMouseOut");
|
|
|
141 |
}
|
|
|
142 |
}, disableSelection:function (rootnode) {
|
|
|
143 |
dojo.html.disableSelection(rootnode);
|
|
|
144 |
var nodes = rootnode.all || rootnode.getElementsByTagName("*");
|
|
|
145 |
for (var x = 0; x < nodes.length; x++) {
|
|
|
146 |
dojo.html.disableSelection(nodes[x]);
|
|
|
147 |
}
|
|
|
148 |
}, onMouseOver:function () {
|
|
|
149 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
150 |
if (curInst) {
|
|
|
151 |
var _command = curInst.getCommand(this._name);
|
|
|
152 |
if (_command && _command.getState() != dojo.widget.Editor2Manager.commandState.Disabled) {
|
|
|
153 |
this.highlightToolbarItem();
|
|
|
154 |
}
|
|
|
155 |
}
|
|
|
156 |
}, onMouseOut:function () {
|
|
|
157 |
this.unhighlightToolbarItem();
|
|
|
158 |
}, destroy:function () {
|
|
|
159 |
this._domNode = null;
|
|
|
160 |
this._parentToolbar = null;
|
|
|
161 |
}, onClick:function (e) {
|
|
|
162 |
if (this._domNode && !this._domNode.disabled && this._parentToolbar.checkAvailability()) {
|
|
|
163 |
e.preventDefault();
|
|
|
164 |
e.stopPropagation();
|
|
|
165 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
166 |
if (curInst) {
|
|
|
167 |
var _command = curInst.getCommand(this._name);
|
|
|
168 |
if (_command) {
|
|
|
169 |
_command.execute();
|
|
|
170 |
}
|
|
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
}, refreshState:function () {
|
|
|
174 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
175 |
var em = dojo.widget.Editor2Manager;
|
|
|
176 |
if (curInst) {
|
|
|
177 |
var _command = curInst.getCommand(this._name);
|
|
|
178 |
if (_command) {
|
|
|
179 |
var state = _command.getState();
|
|
|
180 |
if (state != this._lastState) {
|
|
|
181 |
switch (state) {
|
|
|
182 |
case em.commandState.Latched:
|
|
|
183 |
this.latchToolbarItem();
|
|
|
184 |
break;
|
|
|
185 |
case em.commandState.Enabled:
|
|
|
186 |
this.enableToolbarItem();
|
|
|
187 |
break;
|
|
|
188 |
case em.commandState.Disabled:
|
|
|
189 |
default:
|
|
|
190 |
this.disableToolbarItem();
|
|
|
191 |
}
|
|
|
192 |
this._lastState = state;
|
|
|
193 |
}
|
|
|
194 |
}
|
|
|
195 |
}
|
|
|
196 |
return em.commandState.Enabled;
|
|
|
197 |
}, latchToolbarItem:function () {
|
|
|
198 |
this._domNode.disabled = false;
|
|
|
199 |
this.removeToolbarItemStyle(this._domNode);
|
|
|
200 |
dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarLatchedItemStyle);
|
|
|
201 |
}, enableToolbarItem:function () {
|
|
|
202 |
this._domNode.disabled = false;
|
|
|
203 |
this.removeToolbarItemStyle(this._domNode);
|
|
|
204 |
dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarEnabledItemStyle);
|
|
|
205 |
}, disableToolbarItem:function () {
|
|
|
206 |
this._domNode.disabled = true;
|
|
|
207 |
this.removeToolbarItemStyle(this._domNode);
|
|
|
208 |
dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarDisabledItemStyle);
|
|
|
209 |
}, highlightToolbarItem:function () {
|
|
|
210 |
dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarHighlightedItemStyle);
|
|
|
211 |
}, unhighlightToolbarItem:function () {
|
|
|
212 |
dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarHighlightedItemStyle);
|
|
|
213 |
}, removeToolbarItemStyle:function () {
|
|
|
214 |
dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarEnabledItemStyle);
|
|
|
215 |
dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarLatchedItemStyle);
|
|
|
216 |
dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarDisabledItemStyle);
|
|
|
217 |
this.unhighlightToolbarItem();
|
|
|
218 |
}});
|
|
|
219 |
dojo.declare("dojo.widget.Editor2ToolbarDropDownButton", dojo.widget.Editor2ToolbarButton, {onClick:function () {
|
|
|
220 |
if (this._domNode && !this._domNode.disabled && this._parentToolbar.checkAvailability()) {
|
|
|
221 |
if (!this._dropdown) {
|
|
|
222 |
this._dropdown = dojo.widget.createWidget("PopupContainer", {});
|
|
|
223 |
this._domNode.appendChild(this._dropdown.domNode);
|
|
|
224 |
}
|
|
|
225 |
if (this._dropdown.isShowingNow) {
|
|
|
226 |
this._dropdown.close();
|
|
|
227 |
} else {
|
|
|
228 |
this.onDropDownShown();
|
|
|
229 |
this._dropdown.open(this._domNode, null, this._domNode);
|
|
|
230 |
}
|
|
|
231 |
}
|
|
|
232 |
}, destroy:function () {
|
|
|
233 |
this.onDropDownDestroy();
|
|
|
234 |
if (this._dropdown) {
|
|
|
235 |
this._dropdown.destroy();
|
|
|
236 |
}
|
|
|
237 |
dojo.widget.Editor2ToolbarDropDownButton.superclass.destroy.call(this);
|
|
|
238 |
}, onDropDownShown:function () {
|
|
|
239 |
}, onDropDownDestroy:function () {
|
|
|
240 |
}});
|
|
|
241 |
dojo.declare("dojo.widget.Editor2ToolbarColorPaletteButton", dojo.widget.Editor2ToolbarDropDownButton, {onDropDownShown:function () {
|
|
|
242 |
if (!this._colorpalette) {
|
|
|
243 |
this._colorpalette = dojo.widget.createWidget("ColorPalette", {});
|
|
|
244 |
this._dropdown.addChild(this._colorpalette);
|
|
|
245 |
this.disableSelection(this._dropdown.domNode);
|
|
|
246 |
this.disableSelection(this._colorpalette.domNode);
|
|
|
247 |
dojo.event.connect(this._colorpalette, "onColorSelect", this, "setColor");
|
|
|
248 |
dojo.event.connect(this._dropdown, "open", this, "latchToolbarItem");
|
|
|
249 |
dojo.event.connect(this._dropdown, "close", this, "enableToolbarItem");
|
|
|
250 |
}
|
|
|
251 |
}, setColor:function (color) {
|
|
|
252 |
this._dropdown.close();
|
|
|
253 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
254 |
if (curInst) {
|
|
|
255 |
var _command = curInst.getCommand(this._name);
|
|
|
256 |
if (_command) {
|
|
|
257 |
_command.execute(color);
|
|
|
258 |
}
|
|
|
259 |
}
|
|
|
260 |
}});
|
|
|
261 |
dojo.declare("dojo.widget.Editor2ToolbarFormatBlockPlainSelect", dojo.widget.Editor2ToolbarButton, {create:function (node, toolbar) {
|
|
|
262 |
this._domNode = node;
|
|
|
263 |
this._parentToolbar = toolbar;
|
|
|
264 |
this._domNode = node;
|
|
|
265 |
this.disableSelection(this._domNode);
|
|
|
266 |
dojo.event.connect(this._domNode, "onchange", this, "onChange");
|
|
|
267 |
}, destroy:function () {
|
|
|
268 |
this._domNode = null;
|
|
|
269 |
}, onChange:function () {
|
|
|
270 |
if (this._parentToolbar.checkAvailability()) {
|
|
|
271 |
var sv = this._domNode.value.toLowerCase();
|
|
|
272 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
273 |
if (curInst) {
|
|
|
274 |
var _command = curInst.getCommand(this._name);
|
|
|
275 |
if (_command) {
|
|
|
276 |
_command.execute(sv);
|
|
|
277 |
}
|
|
|
278 |
}
|
|
|
279 |
}
|
|
|
280 |
}, refreshState:function () {
|
|
|
281 |
if (this._domNode) {
|
|
|
282 |
dojo.widget.Editor2ToolbarFormatBlockPlainSelect.superclass.refreshState.call(this);
|
|
|
283 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
284 |
if (curInst) {
|
|
|
285 |
var _command = curInst.getCommand(this._name);
|
|
|
286 |
if (_command) {
|
|
|
287 |
var format = _command.getValue();
|
|
|
288 |
if (!format) {
|
|
|
289 |
format = "";
|
|
|
290 |
}
|
|
|
291 |
dojo.lang.forEach(this._domNode.options, function (item) {
|
|
|
292 |
if (item.value.toLowerCase() == format.toLowerCase()) {
|
|
|
293 |
item.selected = true;
|
|
|
294 |
}
|
|
|
295 |
});
|
|
|
296 |
}
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
}});
|
|
|
300 |
dojo.declare("dojo.widget.Editor2ToolbarComboItem", dojo.widget.Editor2ToolbarDropDownButton, {href:null, create:function (node, toolbar) {
|
|
|
301 |
dojo.widget.Editor2ToolbarComboItem.superclass.create.apply(this, arguments);
|
|
|
302 |
if (!this._contentPane) {
|
|
|
303 |
dojo.require("dojo.widget.ContentPane");
|
|
|
304 |
this._contentPane = dojo.widget.createWidget("ContentPane", {preload:"true"});
|
|
|
305 |
this._contentPane.addOnLoad(this, "setup");
|
|
|
306 |
this._contentPane.setUrl(this.href);
|
|
|
307 |
}
|
|
|
308 |
}, onMouseOver:function (e) {
|
|
|
309 |
if (this._lastState != dojo.widget.Editor2Manager.commandState.Disabled) {
|
|
|
310 |
dojo.html.addClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectStyle);
|
|
|
311 |
}
|
|
|
312 |
}, onMouseOut:function (e) {
|
|
|
313 |
dojo.html.removeClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectStyle);
|
|
|
314 |
}, onDropDownShown:function () {
|
|
|
315 |
if (!this._dropdown.__addedContentPage) {
|
|
|
316 |
this._dropdown.addChild(this._contentPane);
|
|
|
317 |
this._dropdown.__addedContentPage = true;
|
|
|
318 |
}
|
|
|
319 |
}, setup:function () {
|
|
|
320 |
}, onChange:function (e) {
|
|
|
321 |
if (this._parentToolbar.checkAvailability()) {
|
|
|
322 |
var name = e.currentTarget.getAttribute("dropDownItemName");
|
|
|
323 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
324 |
if (curInst) {
|
|
|
325 |
var _command = curInst.getCommand(this._name);
|
|
|
326 |
if (_command) {
|
|
|
327 |
_command.execute(name);
|
|
|
328 |
}
|
|
|
329 |
}
|
|
|
330 |
}
|
|
|
331 |
this._dropdown.close();
|
|
|
332 |
}, onMouseOverItem:function (e) {
|
|
|
333 |
dojo.html.addClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectItemStyle);
|
|
|
334 |
}, onMouseOutItem:function (e) {
|
|
|
335 |
dojo.html.removeClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectItemStyle);
|
|
|
336 |
}});
|
|
|
337 |
dojo.declare("dojo.widget.Editor2ToolbarFormatBlockSelect", dojo.widget.Editor2ToolbarComboItem, {href:dojo.uri.moduleUri("dojo.widget", "templates/Editor2/EditorToolbar_FormatBlock.html"), setup:function () {
|
|
|
338 |
dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.setup.call(this);
|
|
|
339 |
var nodes = this._contentPane.domNode.all || this._contentPane.domNode.getElementsByTagName("*");
|
|
|
340 |
this._blockNames = {};
|
|
|
341 |
this._blockDisplayNames = {};
|
|
|
342 |
for (var x = 0; x < nodes.length; x++) {
|
|
|
343 |
var node = nodes[x];
|
|
|
344 |
dojo.html.disableSelection(node);
|
|
|
345 |
var name = node.getAttribute("dropDownItemName");
|
|
|
346 |
if (name) {
|
|
|
347 |
this._blockNames[name] = node;
|
|
|
348 |
var childrennodes = node.getElementsByTagName(name);
|
|
|
349 |
this._blockDisplayNames[name] = childrennodes[childrennodes.length - 1].innerHTML;
|
|
|
350 |
}
|
|
|
351 |
}
|
|
|
352 |
for (var name in this._blockNames) {
|
|
|
353 |
dojo.event.connect(this._blockNames[name], "onclick", this, "onChange");
|
|
|
354 |
dojo.event.connect(this._blockNames[name], "onmouseover", this, "onMouseOverItem");
|
|
|
355 |
dojo.event.connect(this._blockNames[name], "onmouseout", this, "onMouseOutItem");
|
|
|
356 |
}
|
|
|
357 |
}, onDropDownDestroy:function () {
|
|
|
358 |
if (this._blockNames) {
|
|
|
359 |
for (var name in this._blockNames) {
|
|
|
360 |
delete this._blockNames[name];
|
|
|
361 |
delete this._blockDisplayNames[name];
|
|
|
362 |
}
|
|
|
363 |
}
|
|
|
364 |
}, refreshState:function () {
|
|
|
365 |
dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.refreshState.call(this);
|
|
|
366 |
if (this._lastState != dojo.widget.Editor2Manager.commandState.Disabled) {
|
|
|
367 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
368 |
if (curInst) {
|
|
|
369 |
var _command = curInst.getCommand(this._name);
|
|
|
370 |
if (_command) {
|
|
|
371 |
var format = _command.getValue();
|
|
|
372 |
if (format == this._lastSelectedFormat && this._blockDisplayNames) {
|
|
|
373 |
return this._lastState;
|
|
|
374 |
}
|
|
|
375 |
this._lastSelectedFormat = format;
|
|
|
376 |
var label = this._domNode.getElementsByTagName("label")[0];
|
|
|
377 |
var isSet = false;
|
|
|
378 |
if (this._blockDisplayNames) {
|
|
|
379 |
for (var name in this._blockDisplayNames) {
|
|
|
380 |
if (name == format) {
|
|
|
381 |
label.innerHTML = this._blockDisplayNames[name];
|
|
|
382 |
isSet = true;
|
|
|
383 |
break;
|
|
|
384 |
}
|
|
|
385 |
}
|
|
|
386 |
if (!isSet) {
|
|
|
387 |
label.innerHTML = " ";
|
|
|
388 |
}
|
|
|
389 |
}
|
|
|
390 |
}
|
|
|
391 |
}
|
|
|
392 |
}
|
|
|
393 |
return this._lastState;
|
|
|
394 |
}});
|
|
|
395 |
dojo.declare("dojo.widget.Editor2ToolbarFontSizeSelect", dojo.widget.Editor2ToolbarComboItem, {href:dojo.uri.moduleUri("dojo.widget", "templates/Editor2/EditorToolbar_FontSize.html"), setup:function () {
|
|
|
396 |
dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.setup.call(this);
|
|
|
397 |
var nodes = this._contentPane.domNode.all || this._contentPane.domNode.getElementsByTagName("*");
|
|
|
398 |
this._fontsizes = {};
|
|
|
399 |
this._fontSizeDisplayNames = {};
|
|
|
400 |
for (var x = 0; x < nodes.length; x++) {
|
|
|
401 |
var node = nodes[x];
|
|
|
402 |
dojo.html.disableSelection(node);
|
|
|
403 |
var name = node.getAttribute("dropDownItemName");
|
|
|
404 |
if (name) {
|
|
|
405 |
this._fontsizes[name] = node;
|
|
|
406 |
this._fontSizeDisplayNames[name] = node.getElementsByTagName("font")[0].innerHTML;
|
|
|
407 |
}
|
|
|
408 |
}
|
|
|
409 |
for (var name in this._fontsizes) {
|
|
|
410 |
dojo.event.connect(this._fontsizes[name], "onclick", this, "onChange");
|
|
|
411 |
dojo.event.connect(this._fontsizes[name], "onmouseover", this, "onMouseOverItem");
|
|
|
412 |
dojo.event.connect(this._fontsizes[name], "onmouseout", this, "onMouseOutItem");
|
|
|
413 |
}
|
|
|
414 |
}, onDropDownDestroy:function () {
|
|
|
415 |
if (this._fontsizes) {
|
|
|
416 |
for (var name in this._fontsizes) {
|
|
|
417 |
delete this._fontsizes[name];
|
|
|
418 |
delete this._fontSizeDisplayNames[name];
|
|
|
419 |
}
|
|
|
420 |
}
|
|
|
421 |
}, refreshState:function () {
|
|
|
422 |
dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.refreshState.call(this);
|
|
|
423 |
if (this._lastState != dojo.widget.Editor2Manager.commandState.Disabled) {
|
|
|
424 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
425 |
if (curInst) {
|
|
|
426 |
var _command = curInst.getCommand(this._name);
|
|
|
427 |
if (_command) {
|
|
|
428 |
var size = _command.getValue();
|
|
|
429 |
if (size == this._lastSelectedSize && this._fontSizeDisplayNames) {
|
|
|
430 |
return this._lastState;
|
|
|
431 |
}
|
|
|
432 |
this._lastSelectedSize = size;
|
|
|
433 |
var label = this._domNode.getElementsByTagName("label")[0];
|
|
|
434 |
var isSet = false;
|
|
|
435 |
if (this._fontSizeDisplayNames) {
|
|
|
436 |
for (var name in this._fontSizeDisplayNames) {
|
|
|
437 |
if (name == size) {
|
|
|
438 |
label.innerHTML = this._fontSizeDisplayNames[name];
|
|
|
439 |
isSet = true;
|
|
|
440 |
break;
|
|
|
441 |
}
|
|
|
442 |
}
|
|
|
443 |
if (!isSet) {
|
|
|
444 |
label.innerHTML = " ";
|
|
|
445 |
}
|
|
|
446 |
}
|
|
|
447 |
}
|
|
|
448 |
}
|
|
|
449 |
}
|
|
|
450 |
return this._lastState;
|
|
|
451 |
}});
|
|
|
452 |
dojo.declare("dojo.widget.Editor2ToolbarFontNameSelect", dojo.widget.Editor2ToolbarFontSizeSelect, {href:dojo.uri.moduleUri("dojo.widget", "templates/Editor2/EditorToolbar_FontName.html")});
|
|
|
453 |
dojo.widget.defineWidget("dojo.widget.Editor2Toolbar", dojo.widget.HtmlWidget, function () {
|
|
|
454 |
dojo.event.connect(this, "fillInTemplate", dojo.lang.hitch(this, function () {
|
|
|
455 |
if (dojo.render.html.ie) {
|
|
|
456 |
this.domNode.style.zoom = 1;
|
|
|
457 |
}
|
|
|
458 |
}));
|
|
|
459 |
}, {templateString:"<div dojoAttachPoint=\"domNode\" class=\"EditorToolbarDomNode\" unselectable=\"on\">\n\t<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\">\n\t\t<!--\n\t\t\tour toolbar should look something like:\n\n\t\t\t+=======+=======+=======+=============================================+\n\t\t\t| w w | style | copy | bo | it | un | le | ce | ri |\n\t\t\t| w w w | style |=======|==============|==============|\n\t\t\t| w w | style | paste | undo | redo | change style |\n\t\t\t+=======+=======+=======+=============================================+\n\t\t-->\n\t\t<tbody>\n\t\t\t<tr valign=\"top\">\n\t\t\t\t<td rowspan=\"2\">\n\t\t\t\t\t<div class=\"bigIcon\" dojoAttachPoint=\"wikiWordButton\"\n\t\t\t\t\t\tdojoOnClick=\"wikiWordClick; buttonClick;\">\n\t\t\t\t\t\t<span style=\"font-size: 30px; margin-left: 5px;\">\n\t\t\t\t\t\t\tW\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</td>\n\t\t\t\t<td rowspan=\"2\">\n\t\t\t\t\t<div class=\"bigIcon\" dojoAttachPoint=\"styleDropdownButton\"\n\t\t\t\t\t\tdojoOnClick=\"styleDropdownClick; buttonClick;\">\n\t\t\t\t\t\t<span unselectable=\"on\"\n\t\t\t\t\t\t\tstyle=\"font-size: 30px; margin-left: 5px;\">\n\t\t\t\t\t\t\tS\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"StyleDropdownContainer\" style=\"display: none;\"\n\t\t\t\t\t\tdojoAttachPoint=\"styleDropdownContainer\">\n\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"\n\t\t\t\t\t\t\theight=\"100%\" width=\"100%\">\n\t\t\t\t\t\t\t<tr valign=\"top\">\n\t\t\t\t\t\t\t\t<td rowspan=\"2\">\n\t\t\t\t\t\t\t\t\t<div style=\"height: 245px; overflow: auto;\">\n\t\t\t\t\t\t\t\t\t\t<div class=\"headingContainer\"\n\t\t\t\t\t\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\t\t\t\t\t\tdojoOnClick=\"normalTextClick\">normal</div>\n\t\t\t\t\t\t\t\t\t\t<h1 class=\"headingContainer\"\n\t\t\t\t\t\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\t\t\t\t\t\tdojoOnClick=\"h1TextClick\">Heading 1</h1>\n\t\t\t\t\t\t\t\t\t\t<h2 class=\"headingContainer\"\n\t\t\t\t\t\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\t\t\t\t\t\tdojoOnClick=\"h2TextClick\">Heading 2</h2>\n\t\t\t\t\t\t\t\t\t\t<h3 class=\"headingContainer\"\n\t\t\t\t\t\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\t\t\t\t\t\tdojoOnClick=\"h3TextClick\">Heading 3</h3>\n\t\t\t\t\t\t\t\t\t\t<h4 class=\"headingContainer\"\n\t\t\t\t\t\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\t\t\t\t\t\tdojoOnClick=\"h4TextClick\">Heading 4</h4>\n\t\t\t\t\t\t\t\t\t\t<div class=\"headingContainer\"\n\t\t\t\t\t\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\t\t\t\t\t\tdojoOnClick=\"blahTextClick\">blah</div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"headingContainer\"\n\t\t\t\t\t\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\t\t\t\t\t\tdojoOnClick=\"blahTextClick\">blah</div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"headingContainer\"\n\t\t\t\t\t\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\t\t\t\t\t\tdojoOnClick=\"blahTextClick\">blah</div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"headingContainer\">blah</div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"headingContainer\">blah</div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"headingContainer\">blah</div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"headingContainer\">blah</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<!--\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<span class=\"iconContainer\" dojoOnClick=\"buttonClick;\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"icon justifyleft\" \n\t\t\t\t\t\t\t\t\t\t\tstyle=\"float: left;\"> </span>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t<span class=\"iconContainer\" dojoOnClick=\"buttonClick;\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"icon justifycenter\" \n\t\t\t\t\t\t\t\t\t\t\tstyle=\"float: left;\"> </span>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t<span class=\"iconContainer\" dojoOnClick=\"buttonClick;\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"icon justifyright\" \n\t\t\t\t\t\t\t\t\t\t\tstyle=\"float: left;\"> </span>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t<span class=\"iconContainer\" dojoOnClick=\"buttonClick;\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"icon justifyfull\" \n\t\t\t\t\t\t\t\t\t\t\tstyle=\"float: left;\"> </span>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t-->\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr valign=\"top\">\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\tthud\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</div>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<!-- copy -->\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"copyButton\"\n\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\tdojoOnClick=\"copyClick; buttonClick;\">\n\t\t\t\t\t\t<span class=\"icon copy\" \n\t\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\t\tstyle=\"float: left;\"> </span> copy\n\t\t\t\t\t</span>\n\t\t\t\t\t<!-- \"droppable\" options -->\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"boldButton\"\n\t\t\t\t\t\tunselectable=\"on\"\n\t\t\t\t\t\tdojoOnClick=\"boldClick; buttonClick;\">\n\t\t\t\t\t\t<span class=\"icon bold\" unselectable=\"on\"> </span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"italicButton\"\n\t\t\t\t\t\tdojoOnClick=\"italicClick; buttonClick;\">\n\t\t\t\t\t\t<span class=\"icon italic\" unselectable=\"on\"> </span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"underlineButton\"\n\t\t\t\t\t\tdojoOnClick=\"underlineClick; buttonClick;\">\n\t\t\t\t\t\t<span class=\"icon underline\" unselectable=\"on\"> </span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"leftButton\"\n\t\t\t\t\t\tdojoOnClick=\"leftClick; buttonClick;\">\n\t\t\t\t\t\t<span class=\"icon justifyleft\" unselectable=\"on\"> </span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"fullButton\"\n\t\t\t\t\t\tdojoOnClick=\"fullClick; buttonClick;\">\n\t\t\t\t\t\t<span class=\"icon justifyfull\" unselectable=\"on\"> </span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"rightButton\"\n\t\t\t\t\t\tdojoOnClick=\"rightClick; buttonClick;\">\n\t\t\t\t\t\t<span class=\"icon justifyright\" unselectable=\"on\"> </span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<!-- paste -->\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"pasteButton\"\n\t\t\t\t\t\tdojoOnClick=\"pasteClick; buttonClick;\" unselectable=\"on\">\n\t\t\t\t\t\t<span class=\"icon paste\" style=\"float: left;\" unselectable=\"on\"> </span> paste\n\t\t\t\t\t</span>\n\t\t\t\t\t<!-- \"droppable\" options -->\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"undoButton\"\n\t\t\t\t\t\tdojoOnClick=\"undoClick; buttonClick;\" unselectable=\"on\">\n\t\t\t\t\t\t<span class=\"icon undo\" style=\"float: left;\" unselectable=\"on\"> </span> undo\n\t\t\t\t\t</span>\n\t\t\t\t\t<span class=\"iconContainer\" dojoAttachPoint=\"redoButton\"\n\t\t\t\t\t\tdojoOnClick=\"redoClick; buttonClick;\" unselectable=\"on\">\n\t\t\t\t\t\t<span class=\"icon redo\" style=\"float: left;\" unselectable=\"on\"> </span> redo\n\t\t\t\t\t</span>\n\t\t\t\t</td>\t\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n", templateCssString:".StyleDropdownContainer {\n\tposition: absolute;\n\tz-index: 1000;\n\toverflow: auto;\n\tcursor: default;\n\twidth: 250px;\n\theight: 250px;\n\tbackground-color: white;\n\tborder: 1px solid black;\n}\n\n.ColorDropdownContainer {\n\tposition: absolute;\n\tz-index: 1000;\n\toverflow: auto;\n\tcursor: default;\n\twidth: 250px;\n\theight: 150px;\n\tbackground-color: white;\n\tborder: 1px solid black;\n}\n\n.EditorToolbarDomNode {\n\tbackground-image: url(buttons/bg-fade.png);\n\tbackground-repeat: repeat-x;\n\tbackground-position: 0px -50px;\n}\n\n.EditorToolbarSmallBg {\n\tbackground-image: url(images/toolbar-bg.gif);\n\tbackground-repeat: repeat-x;\n\tbackground-position: 0px 0px;\n}\n\n/*\nbody {\n\tbackground:url(images/blank.gif) fixed;\n}*/\n\n.IEFixedToolbar {\n\tposition:absolute;\n\t/* top:0; */\n\ttop: expression(eval((document.documentElement||document.body).scrollTop));\n}\n\ndiv.bigIcon {\n\twidth: 40px;\n\theight: 40px; \n\t/* background-color: white; */\n\t/* border: 1px solid #a6a7a3; */\n\tfont-family: Verdana, Trebuchet, Tahoma, Arial;\n}\n\n.iconContainer {\n\tfont-family: Verdana, Trebuchet, Tahoma, Arial;\n\tfont-size: 13px;\n\tfloat: left;\n\theight: 18px;\n\tdisplay: block;\n\t/* background-color: white; */\n\tcursor: pointer;\n\tpadding: 1px 4px 1px 1px; /* almost the same as a transparent border */\n\tborder: 0px;\n}\n\n.dojoE2TBIcon {\n\tdisplay: block;\n\ttext-align: center;\n\tmin-width: 18px;\n\twidth: 18px;\n\theight: 18px;\n\t/* background-color: #a6a7a3; */\n\tbackground-repeat: no-repeat;\n\tbackground-image: url(buttons/aggregate.gif);\n}\n\n\n.dojoE2TBIcon[class~=dojoE2TBIcon] {\n}\n\n.ToolbarButtonLatched {\n border: #316ac5 1px solid; !important;\n padding: 0px 3px 0px 0px; !important; /* make room for border */\n background-color: #c1d2ee;\n}\n\n.ToolbarButtonHighlighted {\n border: #316ac5 1px solid; !important;\n padding: 0px 3px 0px 0px; !important; /* make room for border */\n background-color: #dff1ff;\n}\n\n.ToolbarButtonDisabled{\n filter: gray() alpha(opacity=30); /* IE */\n opacity: 0.30; /* Safari, Opera and Mozilla */\n}\n\n.headingContainer {\n\twidth: 150px;\n\theight: 30px;\n\tmargin: 0px;\n\t/* padding-left: 5px; */\n\toverflow: hidden;\n\tline-height: 25px;\n\tborder-bottom: 1px solid black;\n\tborder-top: 1px solid white;\n}\n\n.EditorToolbarDomNode select {\n\tfont-size: 14px;\n}\n \n.dojoE2TBIcon_Sep { width: 5px; min-width: 5px; max-width: 5px; background-position: 0px 0px}\n.dojoE2TBIcon_Backcolor { background-position: -18px 0px}\n.dojoE2TBIcon_Bold { background-position: -36px 0px}\n.dojoE2TBIcon_Cancel { background-position: -54px 0px}\n.dojoE2TBIcon_Copy { background-position: -72px 0px}\n.dojoE2TBIcon_Link { background-position: -90px 0px}\n.dojoE2TBIcon_Cut { background-position: -108px 0px}\n.dojoE2TBIcon_Delete { background-position: -126px 0px}\n.dojoE2TBIcon_TextColor { background-position: -144px 0px}\n.dojoE2TBIcon_BackgroundColor { background-position: -162px 0px}\n.dojoE2TBIcon_Indent { background-position: -180px 0px}\n.dojoE2TBIcon_HorizontalLine { background-position: -198px 0px}\n.dojoE2TBIcon_Image { background-position: -216px 0px}\n.dojoE2TBIcon_NumberedList { background-position: -234px 0px}\n.dojoE2TBIcon_Table { background-position: -252px 0px}\n.dojoE2TBIcon_BulletedList { background-position: -270px 0px}\n.dojoE2TBIcon_Italic { background-position: -288px 0px}\n.dojoE2TBIcon_CenterJustify { background-position: -306px 0px}\n.dojoE2TBIcon_BlockJustify { background-position: -324px 0px}\n.dojoE2TBIcon_LeftJustify { background-position: -342px 0px}\n.dojoE2TBIcon_RightJustify { background-position: -360px 0px}\n.dojoE2TBIcon_left_to_right { background-position: -378px 0px}\n.dojoE2TBIcon_list_bullet_indent { background-position: -396px 0px}\n.dojoE2TBIcon_list_bullet_outdent { background-position: -414px 0px}\n.dojoE2TBIcon_list_num_indent { background-position: -432px 0px}\n.dojoE2TBIcon_list_num_outdent { background-position: -450px 0px}\n.dojoE2TBIcon_Outdent { background-position: -468px 0px}\n.dojoE2TBIcon_Paste { background-position: -486px 0px}\n.dojoE2TBIcon_Redo { background-position: -504px 0px}\ndojoE2TBIcon_RemoveFormat { background-position: -522px 0px}\n.dojoE2TBIcon_right_to_left { background-position: -540px 0px}\n.dojoE2TBIcon_Save { background-position: -558px 0px}\n.dojoE2TBIcon_Space { background-position: -576px 0px}\n.dojoE2TBIcon_StrikeThrough { background-position: -594px 0px}\n.dojoE2TBIcon_Subscript { background-position: -612px 0px}\n.dojoE2TBIcon_Superscript { background-position: -630px 0px}\n.dojoE2TBIcon_Underline { background-position: -648px 0px}\n.dojoE2TBIcon_Undo { background-position: -666px 0px}\n.dojoE2TBIcon_WikiWord { background-position: -684px 0px}\n\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/EditorToolbar.css"), ToolbarLatchedItemStyle:"ToolbarButtonLatched", ToolbarEnabledItemStyle:"ToolbarButtonEnabled", ToolbarDisabledItemStyle:"ToolbarButtonDisabled", ToolbarHighlightedItemStyle:"ToolbarButtonHighlighted", ToolbarHighlightedSelectStyle:"ToolbarSelectHighlighted", ToolbarHighlightedSelectItemStyle:"ToolbarSelectHighlightedItem", postCreate:function () {
|
|
|
460 |
var nodes = dojo.html.getElementsByClass("dojoEditorToolbarItem", this.domNode);
|
|
|
461 |
this.items = {};
|
|
|
462 |
for (var x = 0; x < nodes.length; x++) {
|
|
|
463 |
var node = nodes[x];
|
|
|
464 |
var itemname = node.getAttribute("dojoETItemName");
|
|
|
465 |
if (itemname) {
|
|
|
466 |
var item = dojo.widget.Editor2ToolbarItemManager.getToolbarItem(itemname);
|
|
|
467 |
if (item) {
|
|
|
468 |
item.create(node, this);
|
|
|
469 |
this.items[itemname.toLowerCase()] = item;
|
|
|
470 |
} else {
|
|
|
471 |
node.style.display = "none";
|
|
|
472 |
}
|
|
|
473 |
}
|
|
|
474 |
}
|
|
|
475 |
}, update:function () {
|
|
|
476 |
for (var cmd in this.items) {
|
|
|
477 |
this.items[cmd].refreshState();
|
|
|
478 |
}
|
|
|
479 |
}, shareGroup:"", checkAvailability:function () {
|
|
|
480 |
if (!this.shareGroup) {
|
|
|
481 |
this.parent.focus();
|
|
|
482 |
return true;
|
|
|
483 |
}
|
|
|
484 |
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
|
|
485 |
if (this.shareGroup == curInst.toolbarGroup) {
|
|
|
486 |
return true;
|
|
|
487 |
}
|
|
|
488 |
return false;
|
|
|
489 |
}, destroy:function () {
|
|
|
490 |
for (var it in this.items) {
|
|
|
491 |
this.items[it].destroy();
|
|
|
492 |
delete this.items[it];
|
|
|
493 |
}
|
|
|
494 |
dojo.widget.Editor2Toolbar.superclass.destroy.call(this);
|
|
|
495 |
}});
|
|
|
496 |
|