]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/Avatar.js.uncompressed.js
1 define("dojo/dnd/Avatar", ["../main", "./common"], function(dojo
) {
8 dojo
.declare("dojo.dnd.Avatar", null, {
10 // Object that represents transferred DnD items visually
12 // a DnD manager object
14 constructor: function(manager
){
15 this.manager
= manager
;
20 construct: function(){
22 // constructor function;
23 // it is separate so it can be (dynamically) overwritten in case of need
24 this.isA11y
= dojo
.hasClass(dojo
.body(),"dijit_a11y");
25 var a
= dojo
.create("table", {
26 "class": "dojoDndAvatar",
33 source
= this.manager
.source
, node
,
34 b
= dojo
.create("tbody", null, a
),
35 tr
= dojo
.create("tr", null, b
),
36 td
= dojo
.create("td", null, tr
),
37 icon
= this.isA11y
? dojo
.create("span", {
39 innerHTML
: this.manager
.copy
? '+' : "<"
41 span
= dojo
.create("span", {
42 innerHTML
: source
.generateText
? this._generateText() : ""
44 k
= Math
.min(5, this.manager
.nodes
.length
), i
= 0;
45 // we have to set the opacity on IE only after the node is live
47 "class": "dojoDndAvatarHeader",
52 // create an avatar representation of the node
53 node
= source
._normalizedCreator(source
.getItem(this.manager
.nodes
[i
].id
).data
, "avatar").node
;
55 // or just clone the node and hope it works
56 node
= this.manager
.nodes
[i
].cloneNode(true);
57 if(node
.tagName
.toLowerCase() == "tr"){
58 // insert extra table nodes
59 var table
= dojo
.create("table"),
60 tbody
= dojo
.create("tbody", null, table
);
61 tbody
.appendChild(node
);
66 tr
= dojo
.create("tr", null, b
);
67 td
= dojo
.create("td", null, tr
);
70 "class": "dojoDndAvatarItem",
71 style
: {opacity
: (9 - i
) / 10}
78 // destructor for the avatar; called to remove all references so it can be garbage-collected
79 dojo
.destroy(this.node
);
84 // updates the avatar to reflect the current DnD state
85 dojo
[(this.manager
.canDropFlag
? "add" : "remove") + "Class"](this.node
, "dojoDndAvatarCanDrop");
87 var icon
= dojo
.byId("a11yIcon");
88 var text
= '+'; // assume canDrop && copy
89 if (this.manager
.canDropFlag
&& !this.manager
.copy
) {
90 text
= '< '; // canDrop && move
91 }else if (!this.manager
.canDropFlag
&& !this.manager
.copy
) {
92 text
= "o"; //!canDrop && move
93 }else if(!this.manager
.canDropFlag
){
94 text
= 'x'; // !canDrop && copy
99 dojo
.query(("tr.dojoDndAvatarHeader td span" +(this.isA11y
? " span" : "")), this.node
).forEach(
101 node
.innerHTML
= this._generateText();
104 _generateText: function(){
105 // summary: generates a proper text to reflect copying or moving of items
106 return this.manager
.nodes
.length
.toString();
110 return dojo
.dnd
.Avatar
;