]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/Avatar.js.uncompressed.js
1 define("dojo/dnd/Avatar", [
10 ], function(declare
, win
, dom
, domAttr
, domClass
, domConstruct
, has
, query
){
15 return declare("dojo.dnd.Avatar", null, {
17 // Object that represents transferred DnD items visually
19 // a DnD manager object
21 constructor: function(manager
){
22 this.manager
= manager
;
27 construct: function(){
29 // constructor function;
30 // it is separate so it can be (dynamically) overwritten in case of need
32 var a
= domConstruct
.create("table", {
33 "class": "dojoDndAvatar",
40 source
= this.manager
.source
, node
,
41 b
= domConstruct
.create("tbody", null, a
),
42 tr
= domConstruct
.create("tr", null, b
),
43 td
= domConstruct
.create("td", null, tr
),
44 k
= Math
.min(5, this.manager
.nodes
.length
), i
= 0;
46 if(has("highcontrast")){
47 domConstruct
.create("span", {
49 innerHTML
: this.manager
.copy
? '+' : "<"
52 domConstruct
.create("span", {
53 innerHTML
: source
.generateText
? this._generateText() : ""
56 // we have to set the opacity on IE only after the node is live
58 "class": "dojoDndAvatarHeader",
63 // create an avatar representation of the node
64 node
= source
._normalizedCreator(source
.getItem(this.manager
.nodes
[i
].id
).data
, "avatar").node
;
66 // or just clone the node and hope it works
67 node
= this.manager
.nodes
[i
].cloneNode(true);
68 if(node
.tagName
.toLowerCase() == "tr"){
69 // insert extra table nodes
70 var table
= domConstruct
.create("table"),
71 tbody
= domConstruct
.create("tbody", null, table
);
72 tbody
.appendChild(node
);
77 tr
= domConstruct
.create("tr", null, b
);
78 td
= domConstruct
.create("td", null, tr
);
81 "class": "dojoDndAvatarItem",
82 style
: {opacity
: (9 - i
) / 10}
89 // destructor for the avatar; called to remove all references so it can be garbage-collected
90 domConstruct
.destroy(this.node
);
95 // updates the avatar to reflect the current DnD state
96 domClass
.toggle(this.node
, "dojoDndAvatarCanDrop", this.manager
.canDropFlag
);
97 if(has("highcontrast")){
98 var icon
= dom
.byId("a11yIcon");
99 var text
= '+'; // assume canDrop && copy
100 if (this.manager
.canDropFlag
&& !this.manager
.copy
){
101 text
= '< '; // canDrop && move
102 }else if (!this.manager
.canDropFlag
&& !this.manager
.copy
){
103 text
= "o"; //!canDrop && move
104 }else if(!this.manager
.canDropFlag
){
105 text
= 'x'; // !canDrop && copy
110 query(("tr.dojoDndAvatarHeader td span" +(has("highcontrast") ? " span" : "")), this.node
).forEach(
112 node
.innerHTML
= this.manager
.source
.generateText
? this._generateText() : "";
115 _generateText: function(){
117 // generates a proper text to reflect copying or moving of items
118 return this.manager
.nodes
.length
.toString();