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