]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/tree/_dndSelector.js
2 Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo
._hasResource
["dijit.tree._dndSelector"]){
9 dojo
._hasResource
["dijit.tree._dndSelector"]=true;
10 dojo
.provide("dijit.tree._dndSelector");
11 dojo
.require("dojo.dnd.common");
12 dojo
.require("dijit.tree._dndContainer");
13 dojo
.declare("dijit.tree._dndSelector",dijit
.tree
._dndContainer
,{constructor:function(_1
,_2
){
16 this.simpleSelection
=false;
17 this.events
.push(dojo
.connect(this.tree
.domNode
,"onmousedown",this,"onMouseDown"),dojo
.connect(this.tree
.domNode
,"onmouseup",this,"onMouseUp"),dojo
.connect(this.tree
.domNode
,"onmousemove",this,"onMouseMove"));
18 },singular
:false,getSelectedNodes:function(){
19 return this.selection
;
20 },selectNone:function(){
21 return this._removeSelection()._removeAnchor();
23 this.inherited(arguments
);
24 this.selection
=this.anchor
=null;
25 },onMouseDown:function(e
){
29 if(e
.button
==dojo
.mouseButtons
.RIGHT
){
32 var _3
=dijit
.getEnclosingWidget(this.current
),id
=_3
.id
+"-dnd";
33 if(!dojo
.hasAttr(this.current
,"id")){
34 dojo
.attr(this.current
,"id",id
);
36 if(!this.singular
&&!dojo
.isCopyKey(e
)&&!e
.shiftKey
&&(this.current
.id
in this.selection
)){
37 this.simpleSelection
=true;
42 if(this.anchor
==this.current
){
43 if(dojo
.isCopyKey(e
)){
48 this.anchor
=this.current
;
49 this._addItemClass(this.anchor
,"Anchor");
50 this.selection
[this.current
.id
]=this.current
;
53 if(!this.singular
&&e
.shiftKey
){
54 if(dojo
.isCopyKey(e
)){
58 if(dojo
.isCopyKey(e
)){
59 if(this.anchor
==this.current
){
60 delete this.selection
[this.anchor
.id
];
63 if(this.current
.id
in this.selection
){
64 this._removeItemClass(this.current
,"Selected");
65 delete this.selection
[this.current
.id
];
68 this._removeItemClass(this.anchor
,"Anchor");
69 this._addItemClass(this.anchor
,"Selected");
71 this.anchor
=this.current
;
72 this._addItemClass(this.current
,"Anchor");
73 this.selection
[this.current
.id
]=this.current
;
77 if(!(id
in this.selection
)){
79 this.anchor
=this.current
;
80 this._addItemClass(this.current
,"Anchor");
81 this.selection
[id
]=this.current
;
87 },onMouseUp:function(e
){
88 if(!this.simpleSelection
){
91 this.simpleSelection
=false;
94 this.anchor
=this.current
;
95 this._addItemClass(this.anchor
,"Anchor");
96 this.selection
[this.current
.id
]=this.current
;
98 },onMouseMove:function(e
){
99 this.simpleSelection
=false;
100 },_removeSelection:function(){
101 var e
=dojo
.dnd
._empty
;
102 for(var i
in this.selection
){
108 this._removeItemClass(_4
,"Selected");
113 },_removeAnchor:function(){
115 this._removeItemClass(this.anchor
,"Anchor");
119 },forInSelectedItems:function(f
,o
){
121 for(var id
in this.selection
){
122 f
.call(o
,this.getItem(id
),id
,this);