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.TreeContextMenuV3");
12
dojo.require("dojo.event.*");
13
dojo.require("dojo.io.*");
14
dojo.require("dojo.widget.*");
15
dojo.require("dojo.widget.Menu2");
16
dojo.require("dojo.widget.TreeCommon");
17
dojo.widget.defineWidget("dojo.widget.TreeContextMenuV3", [dojo.widget.PopupMenu2, dojo.widget.TreeCommon], function () {
18
	this.listenedTrees = {};
19
}, {listenTreeEvents:["afterTreeCreate", "beforeTreeDestroy"], listenNodeFilter:function (elem) {
20
	return elem instanceof dojo.widget.Widget;
21
}, onAfterTreeCreate:function (message) {
22
	var tree = message.source;
23
	this.bindDomNode(tree.domNode);
24
}, onBeforeTreeDestroy:function (message) {
25
	this.unBindDomNode(message.source.domNode);
26
}, getTreeNode:function () {
27
	var source = this.getTopOpenEvent().target;
28
	var treeNode = this.domElement2TreeNode(source);
29
	return treeNode;
30
}, open:function () {
31
	var result = dojo.widget.PopupMenu2.prototype.open.apply(this, arguments);
32
	for (var i = 0; i < this.children.length; i++) {
33
		if (this.children[i].menuOpen) {
34
			this.children[i].menuOpen(this.getTreeNode());
35
		}
36
	}
37
	return result;
38
}, close:function () {
39
	for (var i = 0; i < this.children.length; i++) {
40
		if (this.children[i].menuClose) {
41
			this.children[i].menuClose(this.getTreeNode());
42
		}
43
	}
44
	var result = dojo.widget.PopupMenu2.prototype.close.apply(this, arguments);
45
	return result;
46
}});
47
dojo.widget.defineWidget("dojo.widget.TreeMenuItemV3", [dojo.widget.MenuItem2, dojo.widget.TreeCommon], function () {
48
	this.treeActions = [];
49
}, {treeActions:"", initialize:function (args, frag) {
50
	for (var i = 0; i < this.treeActions.length; i++) {
51
		this.treeActions[i] = this.treeActions[i].toUpperCase();
52
	}
53
}, getTreeNode:function () {
54
	var menu = this;
55
	while (!(menu instanceof dojo.widget.TreeContextMenuV3)) {
56
		menu = menu.parent;
57
	}
58
	var treeNode = menu.getTreeNode();
59
	return treeNode;
60
}, menuOpen:function (treeNode) {
61
	treeNode.viewEmphasize();
62
	this.setDisabled(false);
63
	var _this = this;
64
	dojo.lang.forEach(_this.treeActions, function (action) {
65
		_this.setDisabled(treeNode.actionIsDisabledNow(action));
66
	});
67
}, menuClose:function (treeNode) {
68
	treeNode.viewUnemphasize();
69
}, toString:function () {
70
	return "[" + this.widgetType + " node " + this.getTreeNode() + "]";
71
}});
72