]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/Avatar.js.uncompressed.js
modify dojo rebuild script to remove uncompressed files
[tt-rss.git] / lib / dojo / dnd / Avatar.js.uncompressed.js
1 define("dojo/dnd/Avatar", [
2 "../_base/declare",
3 "../_base/window",
4 "../dom",
5 "../dom-attr",
6 "../dom-class",
7 "../dom-construct",
8 "../hccss",
9 "../query"
10 ], function(declare, win, dom, domAttr, domClass, domConstruct, has, query){
11
12 // module:
13 // dojo/dnd/Avatar
14
15 return declare("dojo.dnd.Avatar", null, {
16 // summary:
17 // Object that represents transferred DnD items visually
18 // manager: Object
19 // a DnD manager object
20
21 constructor: function(manager){
22 this.manager = manager;
23 this.construct();
24 },
25
26 // methods
27 construct: function(){
28 // summary:
29 // constructor function;
30 // it is separate so it can be (dynamically) overwritten in case of need
31
32 var a = domConstruct.create("table", {
33 "class": "dojoDndAvatar",
34 style: {
35 position: "absolute",
36 zIndex: "1999",
37 margin: "0px"
38 }
39 }),
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;
45
46 if(has("highcontrast")){
47 domConstruct.create("span", {
48 id : "a11yIcon",
49 innerHTML : this.manager.copy ? '+' : "<"
50 }, td)
51 }
52 domConstruct.create("span", {
53 innerHTML: source.generateText ? this._generateText() : ""
54 }, td);
55
56 // we have to set the opacity on IE only after the node is live
57 domAttr.set(tr, {
58 "class": "dojoDndAvatarHeader",
59 style: {opacity: 0.9}
60 });
61 for(; i < k; ++i){
62 if(source.creator){
63 // create an avatar representation of the node
64 node = source._normalizedCreator(source.getItem(this.manager.nodes[i].id).data, "avatar").node;
65 }else{
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);
73 node = table;
74 }
75 }
76 node.id = "";
77 tr = domConstruct.create("tr", null, b);
78 td = domConstruct.create("td", null, tr);
79 td.appendChild(node);
80 domAttr.set(tr, {
81 "class": "dojoDndAvatarItem",
82 style: {opacity: (9 - i) / 10}
83 });
84 }
85 this.node = a;
86 },
87 destroy: function(){
88 // summary:
89 // destructor for the avatar; called to remove all references so it can be garbage-collected
90 domConstruct.destroy(this.node);
91 this.node = false;
92 },
93 update: function(){
94 // summary:
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
106 }
107 icon.innerHTML=text;
108 }
109 // replace text
110 query(("tr.dojoDndAvatarHeader td span" +(has("highcontrast") ? " span" : "")), this.node).forEach(
111 function(node){
112 node.innerHTML = this.manager.source.generateText ? this._generateText() : "";
113 }, this);
114 },
115 _generateText: function(){
116 // summary:
117 // generates a proper text to reflect copying or moving of items
118 return this.manager.nodes.length.toString();
119 }
120 });
121
122 });