Subversion Repositories Applications.papyrus

Rev

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