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.require("dojo.widget.*");
|
|
|
12 |
dojo.require("dojo.widget.HtmlWidget");
|
|
|
13 |
dojo.require("dojo.widget.RichText");
|
|
|
14 |
dojo.provide("dojo.widget.TreeEditor");
|
|
|
15 |
dojo.widget.defineWidget("dojo.widget.TreeEditor", dojo.widget.HtmlWidget, {singleLineMode:false, saveOnBlur:true, sync:false, selectOnOpen:true, controller:null, node:null, richTextParams:{styleSheets:"src/widget/templates/TreeEditor.css"}, getContents:function () {
|
|
|
16 |
return this.richText.getEditorContent();
|
|
|
17 |
}, open:function (node) {
|
|
|
18 |
if (!this.richText) {
|
|
|
19 |
this.richText = dojo.widget.createWidget("RichText", this.richTextParams, node.labelNode);
|
|
|
20 |
dojo.event.connect("around", this.richText, "onKeyDown", this, "richText_onKeyDown");
|
|
|
21 |
dojo.event.connect(this.richText, "onBlur", this, "richText_onBlur");
|
|
|
22 |
var self = this;
|
|
|
23 |
dojo.event.connect(this.richText, "onLoad", function () {
|
|
|
24 |
if (self.selectOnOpen) {
|
|
|
25 |
self.richText.execCommand("selectall");
|
|
|
26 |
}
|
|
|
27 |
});
|
|
|
28 |
} else {
|
|
|
29 |
this.richText.open(node.labelNode);
|
|
|
30 |
}
|
|
|
31 |
this.node = node;
|
|
|
32 |
}, close:function (save) {
|
|
|
33 |
this.richText.close(save);
|
|
|
34 |
this.node = null;
|
|
|
35 |
}, isClosed:function () {
|
|
|
36 |
return !this.richText || this.richText.isClosed;
|
|
|
37 |
}, execCommand:function () {
|
|
|
38 |
this.richText.execCommand.apply(this.richText, arguments);
|
|
|
39 |
}, richText_onKeyDown:function (invocation) {
|
|
|
40 |
var e = invocation.args[0];
|
|
|
41 |
if ((!e) && (this.object)) {
|
|
|
42 |
e = dojo.event.browser.fixEvent(this.editor.window.event);
|
|
|
43 |
}
|
|
|
44 |
switch (e.keyCode) {
|
|
|
45 |
case e.KEY_ESCAPE:
|
|
|
46 |
this.finish(false);
|
|
|
47 |
dojo.event.browser.stopEvent(e);
|
|
|
48 |
break;
|
|
|
49 |
case e.KEY_ENTER:
|
|
|
50 |
if (e.ctrlKey && !this.singleLineMode) {
|
|
|
51 |
this.execCommand("inserthtml", "<br/>");
|
|
|
52 |
} else {
|
|
|
53 |
this.finish(true);
|
|
|
54 |
}
|
|
|
55 |
dojo.event.browser.stopEvent(e);
|
|
|
56 |
break;
|
|
|
57 |
default:
|
|
|
58 |
return invocation.proceed();
|
|
|
59 |
}
|
|
|
60 |
}, richText_onBlur:function () {
|
|
|
61 |
this.finish(this.saveOnBlur);
|
|
|
62 |
}, finish:function (save) {
|
|
|
63 |
return this.controller.editLabelFinish(save, this.sync);
|
|
|
64 |
}});
|
|
|
65 |
|