Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Details | Compare with Previous | 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
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.widget.Editor2");
14
dojo.require("dojo.io.*");
15
dojo.require("dojo.widget.RichText");
16
dojo.require("dojo.widget.Editor2Toolbar");
17
dojo.require("dojo.uri.cache");
18
dojo.widget.Editor2Manager = new dojo.widget.HandlerManager;
19
dojo.lang.mixin(dojo.widget.Editor2Manager, {_currentInstance:null, commandState:{Disabled:0, Latched:1, Enabled:2}, getCurrentInstance:function () {
20
	return this._currentInstance;
21
}, setCurrentInstance:function (inst) {
22
	this._currentInstance = inst;
23
}, getCommand:function (editor, name) {
24
	var oCommand;
25
	name = name.toLowerCase();
26
	for (var i = 0; i < this._registeredHandlers.length; i++) {
27
		oCommand = this._registeredHandlers[i](editor, name);
28
		if (oCommand) {
29
			return oCommand;
30
		}
31
	}
32
	switch (name) {
33
	  case "htmltoggle":
34
		oCommand = new dojo.widget.Editor2BrowserCommand(editor, name);
35
		break;
36
	  case "formatblock":
37
		oCommand = new dojo.widget.Editor2FormatBlockCommand(editor, name);
38
		break;
39
	  case "anchor":
40
		oCommand = new dojo.widget.Editor2Command(editor, name);
41
		break;
42
	  case "createlink":
43
		oCommand = new dojo.widget.Editor2DialogCommand(editor, name, {contentFile:"dojo.widget.Editor2Plugin.CreateLinkDialog", contentClass:"Editor2CreateLinkDialog", title:"Insert/Edit Link", width:"300px", height:"200px"});
44
		break;
45
	  case "insertimage":
46
		oCommand = new dojo.widget.Editor2DialogCommand(editor, name, {contentFile:"dojo.widget.Editor2Plugin.InsertImageDialog", contentClass:"Editor2InsertImageDialog", title:"Insert/Edit Image", width:"400px", height:"270px"});
47
		break;
48
	  default:
49
		var curtInst = this.getCurrentInstance();
50
		if ((curtInst && curtInst.queryCommandAvailable(name)) || (!curtInst && dojo.widget.Editor2.prototype.queryCommandAvailable(name))) {
51
			oCommand = new dojo.widget.Editor2BrowserCommand(editor, name);
52
		} else {
53
			dojo.debug("dojo.widget.Editor2Manager.getCommand: Unknown command " + name);
54
			return;
55
		}
56
	}
57
	return oCommand;
58
}, destroy:function () {
59
	this._currentInstance = null;
60
	dojo.widget.HandlerManager.prototype.destroy.call(this);
61
}});
62
dojo.addOnUnload(dojo.widget.Editor2Manager, "destroy");
63
dojo.lang.declare("dojo.widget.Editor2Command", null, function (editor, name) {
64
	this._editor = editor;
65
	this._updateTime = 0;
66
	this._name = name;
67
}, {_text:"Unknown", execute:function (para) {
68
	dojo.unimplemented("dojo.widget.Editor2Command.execute");
69
}, getText:function () {
70
	return this._text;
71
}, getState:function () {
72
	return dojo.widget.Editor2Manager.commandState.Enabled;
73
}, destroy:function () {
74
}});
75
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"};
76
dojo.lang.declare("dojo.widget.Editor2BrowserCommand", dojo.widget.Editor2Command, function (editor, name) {
77
	var text = dojo.widget.Editor2BrowserCommandNames[name.toLowerCase()];
78
	if (text) {
79
		this._text = text;
80
	}
81
}, {execute:function (para) {
82
	this._editor.execCommand(this._name, para);
83
}, getState:function () {
84
	if (this._editor._lastStateTimestamp > this._updateTime || this._state == undefined) {
85
		this._updateTime = this._editor._lastStateTimestamp;
86
		try {
87
			if (this._editor.queryCommandEnabled(this._name)) {
88
				if (this._editor.queryCommandState(this._name)) {
89
					this._state = dojo.widget.Editor2Manager.commandState.Latched;
90
				} else {
91
					this._state = dojo.widget.Editor2Manager.commandState.Enabled;
92
				}
93
			} else {
94
				this._state = dojo.widget.Editor2Manager.commandState.Disabled;
95
			}
96
		}
97
		catch (e) {
98
			this._state = dojo.widget.Editor2Manager.commandState.Enabled;
99
		}
100
	}
101
	return this._state;
102
}, getValue:function () {
103
	try {
104
		return this._editor.queryCommandValue(this._name);
105
	}
106
	catch (e) {
107
	}
108
}});
109
dojo.lang.declare("dojo.widget.Editor2FormatBlockCommand", dojo.widget.Editor2BrowserCommand, {});
110
dojo.require("dojo.widget.FloatingPane");
111
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) {
112
	this.fillInFloatingPaneTemplate(args, frag);
113
	dojo.widget.Editor2Dialog.superclass.fillInTemplate.call(this, args, frag);
114
}, postCreate:function () {
115
	if (this.contentFile) {
116
		dojo.require(this.contentFile);
117
	}
118
	if (this.modal) {
119
		dojo.widget.ModalDialogBase.prototype.postCreate.call(this);
120
	} else {
121
		with (this.domNode.style) {
122
			zIndex = 999;
123
			display = "none";
124
		}
125
	}
126
	dojo.widget.FloatingPaneBase.prototype.postCreate.apply(this, arguments);
127
	dojo.widget.Editor2Dialog.superclass.postCreate.call(this);
128
	if (this.width && this.height) {
129
		with (this.domNode.style) {
130
			width = this.width;
131
			height = this.height;
132
		}
133
	}
134
}, createContent:function () {
135
	if (!this.contentWidget && this.contentClass) {
136
		this.contentWidget = dojo.widget.createWidget(this.contentClass);
137
		this.addChild(this.contentWidget);
138
	}
139
}, show:function () {
140
	if (!this.contentWidget) {
141
		dojo.widget.Editor2Dialog.superclass.show.apply(this, arguments);
142
		this.createContent();
143
		dojo.widget.Editor2Dialog.superclass.hide.call(this);
144
	}
145
	if (!this.contentWidget || !this.contentWidget.loadContent()) {
146
		return;
147
	}
148
	this.showFloatingPane();
149
	dojo.widget.Editor2Dialog.superclass.show.apply(this, arguments);
150
	if (this.modal) {
151
		this.showModalDialog();
152
	}
153
	if (this.modal) {
154
		this.bg.style.zIndex = this.domNode.style.zIndex - 1;
155
	}
156
}, onShow:function () {
157
	dojo.widget.Editor2Dialog.superclass.onShow.call(this);
158
	this.onFloatingPaneShow();
159
}, closeWindow:function () {
160
	this.hide();
161
	dojo.widget.Editor2Dialog.superclass.closeWindow.apply(this, arguments);
162
}, hide:function () {
163
	if (this.modal) {
164
		this.hideModalDialog();
165
	}
166
	dojo.widget.Editor2Dialog.superclass.hide.call(this);
167
}, checkSize:function () {
168
	if (this.isShowing()) {
169
		if (this.modal) {
170
			this._sizeBackground();
171
		}
172
		this.placeModalDialog();
173
		this.onResized();
174
	}
175
}});
176
dojo.widget.defineWidget("dojo.widget.Editor2DialogContent", dojo.widget.HtmlWidget, {widgetsInTemplate:true, loadContent:function () {
177
	return true;
178
}, cancel:function () {
179
	this.parent.hide();
180
}});
181
dojo.lang.declare("dojo.widget.Editor2DialogCommand", dojo.widget.Editor2BrowserCommand, function (editor, name, dialogParas) {
182
	this.dialogParas = dialogParas;
183
}, {execute:function () {
184
	if (!this.dialog) {
185
		if (!this.dialogParas.contentFile || !this.dialogParas.contentClass) {
186
			alert("contentFile and contentClass should be set for dojo.widget.Editor2DialogCommand.dialogParas!");
187
			return;
188
		}
189
		this.dialog = dojo.widget.createWidget("Editor2Dialog", this.dialogParas);
190
		dojo.body().appendChild(this.dialog.domNode);
191
		dojo.event.connect(this, "destroy", this.dialog, "destroy");
192
	}
193
	this.dialog.show();
194
}, getText:function () {
195
	return this.dialogParas.title || dojo.widget.Editor2DialogCommand.superclass.getText.call(this);
196
}});
197
dojo.widget.Editor2ToolbarGroups = {};
198
dojo.widget.defineWidget("dojo.widget.Editor2", dojo.widget.RichText, function () {
199
	this._loadedCommands = {};
200
}, {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 () {
201
	dojo.event.topic.publish("dojo.widget.Editor2::preLoadingToolbar", this);
202
	if (this.toolbarAlwaysVisible) {
203
		dojo.require("dojo.widget.Editor2Plugin.AlwaysShowToolbar");
204
	}
205
	if (this.toolbarWidget) {
206
		this.toolbarWidget.show();
207
		dojo.html.insertBefore(this.toolbarWidget.domNode, this.domNode.firstChild);
208
	} else {
209
		if (this.shareToolbar) {
210
			dojo.deprecated("Editor2:shareToolbar is deprecated in favor of toolbarGroup", "0.5");
211
			this.toolbarGroup = "defaultDojoToolbarGroup";
212
		}
213
		if (this.toolbarGroup) {
214
			if (dojo.widget.Editor2ToolbarGroups[this.toolbarGroup]) {
215
				this.toolbarWidget = dojo.widget.Editor2ToolbarGroups[this.toolbarGroup];
216
			}
217
		}
218
		if (!this.toolbarWidget) {
219
			var tbOpts = {shareGroup:this.toolbarGroup, parent:this};
220
			tbOpts.templateString = dojo.uri.cache.get(this.toolbarTemplatePath);
221
			if (this.toolbarTemplateCssPath) {
222
				tbOpts.templateCssPath = this.toolbarTemplateCssPath;
223
				tbOpts.templateCssString = dojo.uri.cache.get(this.toolbarTemplateCssPath);
224
			}
225
			if (this.toolbarPlaceHolder) {
226
				this.toolbarWidget = dojo.widget.createWidget("Editor2Toolbar", tbOpts, dojo.byId(this.toolbarPlaceHolder), "after");
227
			} else {
228
				this.toolbarWidget = dojo.widget.createWidget("Editor2Toolbar", tbOpts, this.domNode.firstChild, "before");
229
			}
230
			if (this.toolbarGroup) {
231
				dojo.widget.Editor2ToolbarGroups[this.toolbarGroup] = this.toolbarWidget;
232
			}
233
			dojo.event.connect(this, "close", this.toolbarWidget, "hide");
234
			this.toolbarLoaded();
235
		}
236
	}
237
	dojo.event.topic.registerPublisher("Editor2.clobberFocus", this, "clobberFocus");
238
	dojo.event.topic.subscribe("Editor2.clobberFocus", this, "setBlur");
239
	dojo.event.topic.publish("dojo.widget.Editor2::onLoad", this);
240
}, toolbarLoaded:function () {
241
}, registerLoadedPlugin:function (obj) {
242
	if (!this.loadedPlugins) {
243
		this.loadedPlugins = [];
244
	}
245
	this.loadedPlugins.push(obj);
246
}, unregisterLoadedPlugin:function (obj) {
247
	for (var i in this.loadedPlugins) {
248
		if (this.loadedPlugins[i] === obj) {
249
			delete this.loadedPlugins[i];
250
			return;
251
		}
252
	}
253
	dojo.debug("dojo.widget.Editor2.unregisterLoadedPlugin: unknow plugin object: " + obj);
254
}, execCommand:function (command, argument) {
255
	switch (command.toLowerCase()) {
256
	  case "htmltoggle":
257
		this.toggleHtmlEditing();
258
		break;
259
	  default:
260
		dojo.widget.Editor2.superclass.execCommand.apply(this, arguments);
261
	}
262
}, queryCommandEnabled:function (command, argument) {
263
	switch (command.toLowerCase()) {
264
	  case "htmltoggle":
265
		return true;
266
	  default:
267
		if (this._inSourceMode) {
268
			return false;
269
		}
270
		return dojo.widget.Editor2.superclass.queryCommandEnabled.apply(this, arguments);
271
	}
272
}, queryCommandState:function (command, argument) {
273
	switch (command.toLowerCase()) {
274
	  case "htmltoggle":
275
		return this._inSourceMode;
276
	  default:
277
		return dojo.widget.Editor2.superclass.queryCommandState.apply(this, arguments);
278
	}
279
}, onClick:function (e) {
280
	dojo.widget.Editor2.superclass.onClick.call(this, e);
281
	if (dojo.widget.PopupManager) {
282
		if (!e) {
283
			e = this.window.event;
284
		}
285
		dojo.widget.PopupManager.onClick(e);
286
	}
287
}, clobberFocus:function () {
288
}, toggleHtmlEditing:function () {
289
	if (this === dojo.widget.Editor2Manager.getCurrentInstance()) {
290
		if (!this._inSourceMode) {
291
			var html = this.getEditorContent();
292
			this._inSourceMode = true;
293
			if (!this._htmlEditNode) {
294
				this._htmlEditNode = dojo.doc().createElement("textarea");
295
				dojo.html.insertAfter(this._htmlEditNode, this.editorObject);
296
			}
297
			this._htmlEditNode.style.display = "";
298
			this._htmlEditNode.style.width = "100%";
299
			this._htmlEditNode.style.height = dojo.html.getBorderBox(this.editNode).height + "px";
300
			this._htmlEditNode.value = html;
301
			with (this.editorObject.style) {
302
				position = "absolute";
303
				left = "-2000px";
304
				top = "-2000px";
305
			}
306
		} else {
307
			this._inSourceMode = false;
308
			this._htmlEditNode.blur();
309
			with (this.editorObject.style) {
310
				position = "";
311
				left = "";
312
				top = "";
313
			}
314
			var html = this._htmlEditNode.value;
315
			dojo.lang.setTimeout(this, "replaceEditorContent", 1, html);
316
			this._htmlEditNode.style.display = "none";
317
			this.focus();
318
		}
319
		this.onDisplayChanged(null, true);
320
	}
321
}, setFocus:function () {
322
	if (dojo.widget.Editor2Manager.getCurrentInstance() === this) {
323
		return;
324
	}
325
	this.clobberFocus();
326
	dojo.widget.Editor2Manager.setCurrentInstance(this);
327
}, setBlur:function () {
328
}, saveSelection:function () {
329
	this._bookmark = null;
330
	this._bookmark = dojo.withGlobal(this.window, dojo.html.selection.getBookmark);
331
}, restoreSelection:function () {
332
	if (this._bookmark) {
333
		this.focus();
334
		dojo.withGlobal(this.window, "moveToBookmark", dojo.html.selection, [this._bookmark]);
335
		this._bookmark = null;
336
	} else {
337
		dojo.debug("restoreSelection: no saved selection is found!");
338
	}
339
}, _updateToolbarLastRan:null, _updateToolbarTimer:null, _updateToolbarFrequency:500, updateToolbar:function (force) {
340
	if ((!this.isLoaded) || (!this.toolbarWidget)) {
341
		return;
342
	}
343
	var diff = new Date() - this._updateToolbarLastRan;
344
	if ((!force) && (this._updateToolbarLastRan) && ((diff < this._updateToolbarFrequency))) {
345
		clearTimeout(this._updateToolbarTimer);
346
		var _this = this;
347
		this._updateToolbarTimer = setTimeout(function () {
348
			_this.updateToolbar();
349
		}, this._updateToolbarFrequency / 2);
350
		return;
351
	} else {
352
		this._updateToolbarLastRan = new Date();
353
	}
354
	if (dojo.widget.Editor2Manager.getCurrentInstance() !== this) {
355
		return;
356
	}
357
	this.toolbarWidget.update();
358
}, destroy:function (finalize) {
359
	this._htmlEditNode = null;
360
	dojo.event.disconnect(this, "close", this.toolbarWidget, "hide");
361
	if (!finalize) {
362
		this.toolbarWidget.destroy();
363
	}
364
	dojo.widget.Editor2.superclass.destroy.call(this);
365
}, _lastStateTimestamp:0, onDisplayChanged:function (e, forceUpdate) {
366
	this._lastStateTimestamp = (new Date()).getTime();
367
	dojo.widget.Editor2.superclass.onDisplayChanged.call(this, e);
368
	this.updateToolbar(forceUpdate);
369
}, onLoad:function () {
370
	try {
371
		dojo.widget.Editor2.superclass.onLoad.call(this);
372
	}
373
	catch (e) {
374
		dojo.debug(e);
375
	}
376
	this.editorOnLoad();
377
}, onFocus:function () {
378
	dojo.widget.Editor2.superclass.onFocus.call(this);
379
	this.setFocus();
380
}, getEditorContent:function () {
381
	if (this._inSourceMode) {
382
		return this._htmlEditNode.value;
383
	}
384
	return dojo.widget.Editor2.superclass.getEditorContent.call(this);
385
}, replaceEditorContent:function (html) {
386
	if (this._inSourceMode) {
387
		this._htmlEditNode.value = html;
388
		return;
389
	}
390
	dojo.widget.Editor2.superclass.replaceEditorContent.apply(this, arguments);
391
}, getCommand:function (name) {
392
	if (this._loadedCommands[name]) {
393
		return this._loadedCommands[name];
394
	}
395
	var cmd = dojo.widget.Editor2Manager.getCommand(this, name);
396
	this._loadedCommands[name] = cmd;
397
	return cmd;
398
}, shortcuts:[["bold"], ["italic"], ["underline"], ["selectall", "a"], ["insertunorderedlist", "\\"]], setupDefaultShortcuts:function () {
399
	var exec = function (cmd) {
400
		return function () {
401
			cmd.execute();
402
		};
403
	};
404
	var self = this;
405
	dojo.lang.forEach(this.shortcuts, function (item) {
406
		var cmd = self.getCommand(item[0]);
407
		if (cmd) {
408
			self.addKeyHandler(item[1] ? item[1] : item[0].charAt(0), item[2] == undefined ? self.KEY_CTRL : item[2], exec(cmd));
409
		}
410
	});
411
}});
412