Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
11
dojo.provide("dojo.widget.Editor2");
12
dojo.require("dojo.io.*");
13
dojo.require("dojo.widget.RichText");
14
dojo.require("dojo.widget.Editor2Toolbar");
15
dojo.require("dojo.uri.cache");
16
dojo.widget.Editor2Manager = new dojo.widget.HandlerManager;
17
dojo.lang.mixin(dojo.widget.Editor2Manager, {_currentInstance:null, commandState:{Disabled:0, Latched:1, Enabled:2}, getCurrentInstance:function () {
18
	return this._currentInstance;
19
}, setCurrentInstance:function (inst) {
20
	this._currentInstance = inst;
21
}, getCommand:function (editor, name) {
22
	var oCommand;
23
	name = name.toLowerCase();
24
	for (var i = 0; i < this._registeredHandlers.length; i++) {
25
		oCommand = this._registeredHandlers[i](editor, name);
26
		if (oCommand) {
27
			return oCommand;
28
		}
29
	}
30
	switch (name) {
31
	  case "htmltoggle":
32
		oCommand = new dojo.widget.Editor2BrowserCommand(editor, name);
33
		break;
34
	  case "formatblock":
35
		oCommand = new dojo.widget.Editor2FormatBlockCommand(editor, name);
36
		break;
37
	  case "anchor":
38
		oCommand = new dojo.widget.Editor2Command(editor, name);
39
		break;
40
	  case "createlink":
41
		oCommand = new dojo.widget.Editor2DialogCommand(editor, name, {contentFile:"dojo.widget.Editor2Plugin.CreateLinkDialog", contentClass:"Editor2CreateLinkDialog", title:"Insert/Edit Link", width:"300px", height:"200px"});
42
		break;
43
	  case "insertimage":
44
		oCommand = new dojo.widget.Editor2DialogCommand(editor, name, {contentFile:"dojo.widget.Editor2Plugin.InsertImageDialog", contentClass:"Editor2InsertImageDialog", title:"Insert/Edit Image", width:"400px", height:"270px"});
45
		break;
46
	  default:
47
		var curtInst = this.getCurrentInstance();
48
		if ((curtInst && curtInst.queryCommandAvailable(name)) || (!curtInst && dojo.widget.Editor2.prototype.queryCommandAvailable(name))) {
49
			oCommand = new dojo.widget.Editor2BrowserCommand(editor, name);
50
		} else {
51
			dojo.debug("dojo.widget.Editor2Manager.getCommand: Unknown command " + name);
52
			return;
53
		}
54
	}
55
	return oCommand;
56
}, destroy:function () {
57
	this._currentInstance = null;
58
	dojo.widget.HandlerManager.prototype.destroy.call(this);
59
}});
60
dojo.addOnUnload(dojo.widget.Editor2Manager, "destroy");
61
dojo.lang.declare("dojo.widget.Editor2Command", null, function (editor, name) {
62
	this._editor = editor;
63
	this._updateTime = 0;
64
	this._name = name;
65
}, {_text:"Unknown", execute:function (para) {
66
	dojo.unimplemented("dojo.widget.Editor2Command.execute");
67
}, getText:function () {
68
	return this._text;
69
}, getState:function () {
70
	return dojo.widget.Editor2Manager.commandState.Enabled;
71
}, destroy:function () {
72
}});
73
dojo.widget.Editor2BrowserCommandNames = {"bold":"Bold", "copy":"Copy", "cut":"Cut", "Delete":"Delete", "indent":"Indent", "inserthorizontalrule":"Horizental Rule", "insertorderedlist":"Numbered List", "insertunorderedlist":"Bullet List", "italic":"Italic", "justifycenter":"Align Center", "justifyfull":"Justify", "justifyleft":"Align Left", "justifyright":"Align Right", "outdent":"Outdent", "paste":"Paste", "redo":"Redo", "removeformat":"Remove Format", "selectall":"Select All", "strikethrough":"Strikethrough", "subscript":"Subscript", "superscript":"Superscript", "underline":"Underline", "undo":"Undo", "unlink":"Remove Link", "createlink":"Create Link", "insertimage":"Insert Image", "htmltoggle":"HTML Source", "forecolor":"Foreground Color", "hilitecolor":"Background Color", "plainformatblock":"Paragraph Style", "formatblock":"Paragraph Style", "fontsize":"Font Size", "fontname":"Font Name"};
74
dojo.lang.declare("dojo.widget.Editor2BrowserCommand", dojo.widget.Editor2Command, function (editor, name) {
75
	var text = dojo.widget.Editor2BrowserCommandNames[name.toLowerCase()];
76
	if (text) {
77
		this._text = text;
78
	}
79
}, {execute:function (para) {
80
	this._editor.execCommand(this._name, para);
81
}, getState:function () {
82
	if (this._editor._lastStateTimestamp > this._updateTime || this._state == undefined) {
83
		this._updateTime = this._editor._lastStateTimestamp;
84
		try {
85
			if (this._editor.queryCommandEnabled(this._name)) {
86
				if (this._editor.queryCommandState(this._name)) {
87
					this._state = dojo.widget.Editor2Manager.commandState.Latched;
88
				} else {
89
					this._state = dojo.widget.Editor2Manager.commandState.Enabled;
90
				}
91
			} else {
92
				this._state = dojo.widget.Editor2Manager.commandState.Disabled;
93
			}
94
		}
95
		catch (e) {
96
			this._state = dojo.widget.Editor2Manager.commandState.Enabled;
97
		}
98
	}
99
	return this._state;
100
}, getValue:function () {
101
	try {
102
		return this._editor.queryCommandValue(this._name);
103
	}
104
	catch (e) {
105
	}
106
}});
107
dojo.lang.declare("dojo.widget.Editor2FormatBlockCommand", dojo.widget.Editor2BrowserCommand, {});
108
dojo.require("dojo.widget.FloatingPane");
109
dojo.widget.defineWidget("dojo.widget.Editor2Dialog", [dojo.widget.HtmlWidget, dojo.widget.FloatingPaneBase, dojo.widget.ModalDialogBase], {templateString:"<div id=\"${this.widgetId}\" class=\"dojoFloatingPane\">\n\t<span dojoattachpoint=\"tabStartOuter\" dojoonfocus=\"trapTabs\" dojoonblur=\"clearTrap\"\ttabindex=\"0\"></span>\n\t<span dojoattachpoint=\"tabStart\" dojoonfocus=\"trapTabs\" dojoonblur=\"clearTrap\" tabindex=\"0\"></span>\n\t<div dojoAttachPoint=\"titleBar\" class=\"dojoFloatingPaneTitleBar\"  style=\"display:none\">\n\t  \t<img dojoAttachPoint=\"titleBarIcon\"  class=\"dojoFloatingPaneTitleBarIcon\">\n\t\t<div dojoAttachPoint=\"closeAction\" dojoAttachEvent=\"onClick:hide\"\n   \t  \t\tclass=\"dojoFloatingPaneCloseIcon\"></div>\n\t\t<div dojoAttachPoint=\"restoreAction\" dojoAttachEvent=\"onClick:restoreWindow\"\n   \t  \t\tclass=\"dojoFloatingPaneRestoreIcon\"></div>\n\t\t<div dojoAttachPoint=\"maximizeAction\" dojoAttachEvent=\"onClick:maximizeWindow\"\n   \t  \t\tclass=\"dojoFloatingPaneMaximizeIcon\"></div>\n\t\t<div dojoAttachPoint=\"minimizeAction\" dojoAttachEvent=\"onClick:minimizeWindow\"\n   \t  \t\tclass=\"dojoFloatingPaneMinimizeIcon\"></div>\n\t  \t<div dojoAttachPoint=\"titleBarText\" class=\"dojoFloatingPaneTitleText\">${this.title}</div>\n\t</div>\n\n\t<div id=\"${this.widgetId}_container\" dojoAttachPoint=\"containerNode\" class=\"dojoFloatingPaneClient\"></div>\n\t<span dojoattachpoint=\"tabEnd\" dojoonfocus=\"trapTabs\" dojoonblur=\"clearTrap\" tabindex=\"0\"></span>\n\t<span dojoattachpoint=\"tabEndOuter\" dojoonfocus=\"trapTabs\" dojoonblur=\"clearTrap\" tabindex=\"0\"></span>\n\t<div dojoAttachPoint=\"resizeBar\" class=\"dojoFloatingPaneResizebar\" style=\"display:none\"></div>\n</div>\n", modal:true, width:"", height:"", windowState:"minimized", displayCloseAction:true, contentFile:"", contentClass:"", fillInTemplate:function (args, frag) {
110
	this.fillInFloatingPaneTemplate(args, frag);
111
	dojo.widget.Editor2Dialog.superclass.fillInTemplate.call(this, args, frag);
112
}, postCreate:function () {
113
	if (this.contentFile) {
114
		dojo.require(this.contentFile);
115
	}
116
	if (this.modal) {
117
		dojo.widget.ModalDialogBase.prototype.postCreate.call(this);
118
	} else {
119
		with (this.domNode.style) {
120
			zIndex = 999;
121
			display = "none";
122
		}
123
	}
124
	dojo.widget.FloatingPaneBase.prototype.postCreate.apply(this, arguments);
125
	dojo.widget.Editor2Dialog.superclass.postCreate.call(this);
126
	if (this.width && this.height) {
127
		with (this.domNode.style) {
128
			width = this.width;
129
			height = this.height;
130
		}
131
	}
132
}, createContent:function () {
133
	if (!this.contentWidget && this.contentClass) {
134
		this.contentWidget = dojo.widget.createWidget(this.contentClass);
135
		this.addChild(this.contentWidget);
136
	}
137
}, show:function () {
138
	if (!this.contentWidget) {
139
		dojo.widget.Editor2Dialog.superclass.show.apply(this, arguments);
140
		this.createContent();
141
		dojo.widget.Editor2Dialog.superclass.hide.call(this);
142
	}
143
	if (!this.contentWidget || !this.contentWidget.loadContent()) {
144
		return;
145
	}
146
	this.showFloatingPane();
147
	dojo.widget.Editor2Dialog.superclass.show.apply(this, arguments);
148
	if (this.modal) {
149
		this.showModalDialog();
150
	}
151
	if (this.modal) {
152
		this.bg.style.zIndex = this.domNode.style.zIndex - 1;
153
	}
154
}, onShow:function () {
155
	dojo.widget.Editor2Dialog.superclass.onShow.call(this);
156
	this.onFloatingPaneShow();
157
}, closeWindow:function () {
158
	this.hide();
159
	dojo.widget.Editor2Dialog.superclass.closeWindow.apply(this, arguments);
160
}, hide:function () {
161
	if (this.modal) {
162
		this.hideModalDialog();
163
	}
164
	dojo.widget.Editor2Dialog.superclass.hide.call(this);
165
}, checkSize:function () {
166
	if (this.isShowing()) {
167
		if (this.modal) {
168
			this._sizeBackground();
169
		}
170
		this.placeModalDialog();
171
		this.onResized();
172
	}
173
}});
174
dojo.widget.defineWidget("dojo.widget.Editor2DialogContent", dojo.widget.HtmlWidget, {widgetsInTemplate:true, loadContent:function () {
175
	return true;
176
}, cancel:function () {
177
	this.parent.hide();
178
}});
179
dojo.lang.declare("dojo.widget.Editor2DialogCommand", dojo.widget.Editor2BrowserCommand, function (editor, name, dialogParas) {
180
	this.dialogParas = dialogParas;
181
}, {execute:function () {
182
	if (!this.dialog) {
183
		if (!this.dialogParas.contentFile || !this.dialogParas.contentClass) {
184
			alert("contentFile and contentClass should be set for dojo.widget.Editor2DialogCommand.dialogParas!");
185
			return;
186
		}
187
		this.dialog = dojo.widget.createWidget("Editor2Dialog", this.dialogParas);
188
		dojo.body().appendChild(this.dialog.domNode);
189
		dojo.event.connect(this, "destroy", this.dialog, "destroy");
190
	}
191
	this.dialog.show();
192
}, getText:function () {
193
	return this.dialogParas.title || dojo.widget.Editor2DialogCommand.superclass.getText.call(this);
194
}});
195
dojo.widget.Editor2ToolbarGroups = {};
196
dojo.widget.defineWidget("dojo.widget.Editor2", dojo.widget.RichText, function () {
197
	this._loadedCommands = {};
198
}, {toolbarAlwaysVisible:false, toolbarWidget:null, scrollInterval:null, toolbarTemplatePath:dojo.uri.cache.set(dojo.uri.moduleUri("dojo.widget", "templates/EditorToolbarOneline.html"), "<div class=\"EditorToolbarDomNode EditorToolbarSmallBg\">\n\t<table cellpadding=\"1\" cellspacing=\"0\" border=\"0\">\n\t\t<tbody>\n\t\t\t<tr valign=\"top\" align=\"left\">\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"htmltoggle\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon\" \n\t\t\t\t\t\tstyle=\"background-image: none; width: 30px;\" >&lt;h&gt;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"copy\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Copy\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"paste\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Paste\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"undo\">\n\t\t\t\t\t\t<!-- FIXME: should we have the text \"undo\" here? -->\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Undo\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"redo\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Redo\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td isSpacer=\"true\">\n\t\t\t\t\t<span class=\"iconContainer\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Sep\"\tstyle=\"width: 5px; min-width: 5px;\"></span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"createlink\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Link\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"insertimage\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Image\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"inserthorizontalrule\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_HorizontalLine \">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"bold\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Bold\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"italic\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Italic\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"underline\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Underline\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"strikethrough\">\n\t\t\t\t\t\t<span \n\t\t\t\t\t\t\tclass=\"dojoE2TBIcon dojoE2TBIcon_StrikeThrough\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td isSpacer=\"true\">\n\t\t\t\t\t<span class=\"iconContainer\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Sep\" \n\t\t\t\t\t\t\tstyle=\"width: 5px; min-width: 5px;\"></span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"insertunorderedlist\">\n\t\t\t\t\t\t<span \n\t\t\t\t\t\t\tclass=\"dojoE2TBIcon dojoE2TBIcon_BulletedList\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"insertorderedlist\">\n\t\t\t\t\t\t<span \n\t\t\t\t\t\t\tclass=\"dojoE2TBIcon dojoE2TBIcon_NumberedList\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td isSpacer=\"true\">\n\t\t\t\t\t<span class=\"iconContainer\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Sep\" style=\"width: 5px; min-width: 5px;\"></span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"indent\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Indent\" \n\t\t\t\t\t\t\tunselectable=\"on\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"outdent\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Outdent\" \n\t\t\t\t\t\t\tunselectable=\"on\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td isSpacer=\"true\">\n\t\t\t\t\t<span class=\"iconContainer\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Sep\" style=\"width: 5px; min-width: 5px;\"></span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"forecolor\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_TextColor\" \n\t\t\t\t\t\t\tunselectable=\"on\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"hilitecolor\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_BackgroundColor\" \n\t\t\t\t\t\t\tunselectable=\"on\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td isSpacer=\"true\">\n\t\t\t\t\t<span class=\"iconContainer\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Sep\" style=\"width: 5px; min-width: 5px;\"></span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"justifyleft\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_LeftJustify\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"justifycenter\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_CenterJustify\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"justifyright\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_RightJustify\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"justifyfull\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_BlockJustify\">&nbsp;</span>\n\t\t\t\t\t</span>\n\t\t\t\t</td>\t\n\t\t\t\t<td>\n\t\t\t\t\t<select class=\"dojoEditorToolbarItem\" dojoETItemName=\"plainformatblock\">\n\t\t\t\t\t\t<!-- FIXME: using \"p\" here inserts a paragraph in most cases! -->\n\t\t\t\t\t\t<option value=\"\">-- format --</option>\n\t\t\t\t\t\t<option value=\"p\">Normal</option>\n\t\t\t\t\t\t<option value=\"pre\">Fixed Font</option>\n\t\t\t\t\t\t<option value=\"h1\">Main Heading</option>\n\t\t\t\t\t\t<option value=\"h2\">Section Heading</option>\n\t\t\t\t\t\t<option value=\"h3\">Sub-Heading</option>\n\t\t\t\t\t\t<!-- <option value=\"blockquote\">Block Quote</option> -->\n\t\t\t\t\t</select>\n\t\t\t\t</td>\n\t\t\t\t<td><!-- uncomment to enable save button -->\n\t\t\t\t\t<!-- save -->\n\t\t\t\t\t<!--span class=\"iconContainer dojoEditorToolbarItem\" dojoETItemName=\"save\">\n\t\t\t\t\t\t<span class=\"dojoE2TBIcon dojoE2TBIcon_Save\">&nbsp;</span>\n\t\t\t\t\t</span-->\n\t\t\t\t</td>\n\t\t\t\t<td width=\"*\">&nbsp;</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n"), toolbarTemplateCssPath:null, toolbarPlaceHolder:"", _inSourceMode:false, _htmlEditNode:null, toolbarGroup:"", shareToolbar:false, contextMenuGroupSet:"", editorOnLoad:function () {
199
	dojo.event.topic.publish("dojo.widget.Editor2::preLoadingToolbar", this);
200
	if (this.toolbarAlwaysVisible) {
201
		dojo.require("dojo.widget.Editor2Plugin.AlwaysShowToolbar");
202
	}
203
	if (this.toolbarWidget) {
204
		this.toolbarWidget.show();
205
		dojo.html.insertBefore(this.toolbarWidget.domNode, this.domNode.firstChild);
206
	} else {
207
		if (this.shareToolbar) {
208
			dojo.deprecated("Editor2:shareToolbar is deprecated in favor of toolbarGroup", "0.5");
209
			this.toolbarGroup = "defaultDojoToolbarGroup";
210
		}
211
		if (this.toolbarGroup) {
212
			if (dojo.widget.Editor2ToolbarGroups[this.toolbarGroup]) {
213
				this.toolbarWidget = dojo.widget.Editor2ToolbarGroups[this.toolbarGroup];
214
			}
215
		}
216
		if (!this.toolbarWidget) {
217
			var tbOpts = {shareGroup:this.toolbarGroup, parent:this};
218
			tbOpts.templateString = dojo.uri.cache.get(this.toolbarTemplatePath);
219
			if (this.toolbarTemplateCssPath) {
220
				tbOpts.templateCssPath = this.toolbarTemplateCssPath;
221
				tbOpts.templateCssString = dojo.uri.cache.get(this.toolbarTemplateCssPath);
222
			}
223
			if (this.toolbarPlaceHolder) {
224
				this.toolbarWidget = dojo.widget.createWidget("Editor2Toolbar", tbOpts, dojo.byId(this.toolbarPlaceHolder), "after");
225
			} else {
226
				this.toolbarWidget = dojo.widget.createWidget("Editor2Toolbar", tbOpts, this.domNode.firstChild, "before");
227
			}
228
			if (this.toolbarGroup) {
229
				dojo.widget.Editor2ToolbarGroups[this.toolbarGroup] = this.toolbarWidget;
230
			}
231
			dojo.event.connect(this, "close", this.toolbarWidget, "hide");
232
			this.toolbarLoaded();
233
		}
234
	}
235
	dojo.event.topic.registerPublisher("Editor2.clobberFocus", this, "clobberFocus");
236
	dojo.event.topic.subscribe("Editor2.clobberFocus", this, "setBlur");
237
	dojo.event.topic.publish("dojo.widget.Editor2::onLoad", this);
238
}, toolbarLoaded:function () {
239
}, registerLoadedPlugin:function (obj) {
240
	if (!this.loadedPlugins) {
241
		this.loadedPlugins = [];
242
	}
243
	this.loadedPlugins.push(obj);
244
}, unregisterLoadedPlugin:function (obj) {
245
	for (var i in this.loadedPlugins) {
246
		if (this.loadedPlugins[i] === obj) {
247
			delete this.loadedPlugins[i];
248
			return;
249
		}
250
	}
251
	dojo.debug("dojo.widget.Editor2.unregisterLoadedPlugin: unknow plugin object: " + obj);
252
}, execCommand:function (command, argument) {
253
	switch (command.toLowerCase()) {
254
	  case "htmltoggle":
255
		this.toggleHtmlEditing();
256
		break;
257
	  default:
258
		dojo.widget.Editor2.superclass.execCommand.apply(this, arguments);
259
	}
260
}, queryCommandEnabled:function (command, argument) {
261
	switch (command.toLowerCase()) {
262
	  case "htmltoggle":
263
		return true;
264
	  default:
265
		if (this._inSourceMode) {
266
			return false;
267
		}
268
		return dojo.widget.Editor2.superclass.queryCommandEnabled.apply(this, arguments);
269
	}
270
}, queryCommandState:function (command, argument) {
271
	switch (command.toLowerCase()) {
272
	  case "htmltoggle":
273
		return this._inSourceMode;
274
	  default:
275
		return dojo.widget.Editor2.superclass.queryCommandState.apply(this, arguments);
276
	}
277
}, onClick:function (e) {
278
	dojo.widget.Editor2.superclass.onClick.call(this, e);
279
	if (dojo.widget.PopupManager) {
280
		if (!e) {
281
			e = this.window.event;
282
		}
283
		dojo.widget.PopupManager.onClick(e);
284
	}
285
}, clobberFocus:function () {
286
}, toggleHtmlEditing:function () {
287
	if (this === dojo.widget.Editor2Manager.getCurrentInstance()) {
288
		if (!this._inSourceMode) {
289
			var html = this.getEditorContent();
290
			this._inSourceMode = true;
291
			if (!this._htmlEditNode) {
292
				this._htmlEditNode = dojo.doc().createElement("textarea");
293
				dojo.html.insertAfter(this._htmlEditNode, this.editorObject);
294
			}
295
			this._htmlEditNode.style.display = "";
296
			this._htmlEditNode.style.width = "100%";
297
			this._htmlEditNode.style.height = dojo.html.getBorderBox(this.editNode).height + "px";
298
			this._htmlEditNode.value = html;
299
			with (this.editorObject.style) {
300
				position = "absolute";
301
				left = "-2000px";
302
				top = "-2000px";
303
			}
304
		} else {
305
			this._inSourceMode = false;
306
			this._htmlEditNode.blur();
307
			with (this.editorObject.style) {
308
				position = "";
309
				left = "";
310
				top = "";
311
			}
312
			var html = this._htmlEditNode.value;
313
			dojo.lang.setTimeout(this, "replaceEditorContent", 1, html);
314
			this._htmlEditNode.style.display = "none";
315
			this.focus();
316
		}
317
		this.onDisplayChanged(null, true);
318
	}
319
}, setFocus:function () {
320
	if (dojo.widget.Editor2Manager.getCurrentInstance() === this) {
321
		return;
322
	}
323
	this.clobberFocus();
324
	dojo.widget.Editor2Manager.setCurrentInstance(this);
325
}, setBlur:function () {
326
}, saveSelection:function () {
327
	this._bookmark = null;
328
	this._bookmark = dojo.withGlobal(this.window, dojo.html.selection.getBookmark);
329
}, restoreSelection:function () {
330
	if (this._bookmark) {
331
		this.focus();
332
		dojo.withGlobal(this.window, "moveToBookmark", dojo.html.selection, [this._bookmark]);
333
		this._bookmark = null;
334
	} else {
335
		dojo.debug("restoreSelection: no saved selection is found!");
336
	}
337
}, _updateToolbarLastRan:null, _updateToolbarTimer:null, _updateToolbarFrequency:500, updateToolbar:function (force) {
338
	if ((!this.isLoaded) || (!this.toolbarWidget)) {
339
		return;
340
	}
341
	var diff = new Date() - this._updateToolbarLastRan;
342
	if ((!force) && (this._updateToolbarLastRan) && ((diff < this._updateToolbarFrequency))) {
343
		clearTimeout(this._updateToolbarTimer);
344
		var _this = this;
345
		this._updateToolbarTimer = setTimeout(function () {
346
			_this.updateToolbar();
347
		}, this._updateToolbarFrequency / 2);
348
		return;
349
	} else {
350
		this._updateToolbarLastRan = new Date();
351
	}
352
	if (dojo.widget.Editor2Manager.getCurrentInstance() !== this) {
353
		return;
354
	}
355
	this.toolbarWidget.update();
356
}, destroy:function (finalize) {
357
	this._htmlEditNode = null;
358
	dojo.event.disconnect(this, "close", this.toolbarWidget, "hide");
359
	if (!finalize) {
360
		this.toolbarWidget.destroy();
361
	}
362
	dojo.widget.Editor2.superclass.destroy.call(this);
363
}, _lastStateTimestamp:0, onDisplayChanged:function (e, forceUpdate) {
364
	this._lastStateTimestamp = (new Date()).getTime();
365
	dojo.widget.Editor2.superclass.onDisplayChanged.call(this, e);
366
	this.updateToolbar(forceUpdate);
367
}, onLoad:function () {
368
	try {
369
		dojo.widget.Editor2.superclass.onLoad.call(this);
370
	}
371
	catch (e) {
372
		dojo.debug(e);
373
	}
374
	this.editorOnLoad();
375
}, onFocus:function () {
376
	dojo.widget.Editor2.superclass.onFocus.call(this);
377
	this.setFocus();
378
}, getEditorContent:function () {
379
	if (this._inSourceMode) {
380
		return this._htmlEditNode.value;
381
	}
382
	return dojo.widget.Editor2.superclass.getEditorContent.call(this);
383
}, replaceEditorContent:function (html) {
384
	if (this._inSourceMode) {
385
		this._htmlEditNode.value = html;
386
		return;
387
	}
388
	dojo.widget.Editor2.superclass.replaceEditorContent.apply(this, arguments);
389
}, getCommand:function (name) {
390
	if (this._loadedCommands[name]) {
391
		return this._loadedCommands[name];
392
	}
393
	var cmd = dojo.widget.Editor2Manager.getCommand(this, name);
394
	this._loadedCommands[name] = cmd;
395
	return cmd;
396
}, shortcuts:[["bold"], ["italic"], ["underline"], ["selectall", "a"], ["insertunorderedlist", "\\"]], setupDefaultShortcuts:function () {
397
	var exec = function (cmd) {
398
		return function () {
399
			cmd.execute();
400
		};
401
	};
402
	var self = this;
403
	dojo.lang.forEach(this.shortcuts, function (item) {
404
		var cmd = self.getCommand(item[0]);
405
		if (cmd) {
406
			self.addKeyHandler(item[1] ? item[1] : item[0].charAt(0), item[2] == undefined ? self.KEY_CTRL : item[2], exec(cmd));
407
		}
408
	});
409
}});
410