Debian Codegraph @

dojox/mdnd/tests/unitTests/dropIndicator/DropIndicatorTest.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5
6 <title>Drop Indicator place test</title>
7
8 <script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script>
9
10 <script type="text/javascript">
11
12 dojo.require("doh.runner");
13 dojo.require("dojo.parser");
14 dojo.require("dojox.mdnd.AreaManager");
15 dojo.require("dojox.mdnd.DropIndicator");
16 dojo.require("dojox.mdnd.dropMode.VerticalDropMode");
17
18 dojo.addOnLoad(function(){
19 var size = {'w':100,'h':100};
20
21 var mgr = dojox.mdnd.AreaManager.areaManager();
22 var dropIndicator = mgr._dropIndicator;
23
24 mgr.areaClass = "dndArea";
25 mgr.dragHandleClass="dragHandle";
26 mgr.registerByClass();
27
28 var area1, area2, area3,item;
29 area1 = dojo.byId("area1");
30 area2 = dojo.byId("area2");
31 item = dojo.byId("item1");
32
33
34 doh.register("DropIndicatorPlace",
35 [
36 {
37 // Test to place drop indicator into area 1
38 // with no node references. In this case the drop
39 // indicator is displayed at the end of the area
40 name:"TestPlaceDropIndicatorNoPlace",
41 runTest: function(t){
42 var diNode = dropIndicator.place(area1,null,size);
43 // retrieve drop indicator which must be at the end
44 var node = area1.getElementsByTagName("div")[4];
45
46 //check that DropIndicator is at good position
47 doh.assertEqual(diNode,node);
48 doh.assertEqual("dropIndicator",node.className);
49 //check content node size
50 doh.assertEqual(100,dojo.contentBox(node).h);
51 }
52 },
53 { /**
54 * Test to place drop indicator into area 1
55 * with place0 node reference. In this case the drop
56 * indicator is displayed at the begenning
57 *
58 */
59 name:"TestPlaceDropIndicatorPlace0",
60 runTest: function(t){
61 var place0 = dojo.byId("place0");
62 var diNode = dropIndicator.place(area1,place0,size);
63 // retrieve drop indicator which must be at the first position
64 var node = area1.getElementsByTagName("div")[0];
65 //check that DropIndicator is present
66 doh.assertEqual(diNode,node);
67 doh.assertEqual("dropIndicator",node.className);
68 //check node size
69 doh.assertEqual(100,dojo.contentBox(node).h);
70 }
71 },
72 { /**
73 * Test to place drop indicator into area 1
74 * with place2 node reference. In this case the drop
75 * indicator is displayed at the begenning
76 *
77 */
78 name:"TestPlaceDropIndicatorPlace2",
79 runTest: function(t){
80 var place0 = dojo.byId("place2");
81 var diNode = dropIndicator.place(area1,place0,size);
82 // retrieve drop indicator which must be at the first position
83 var node = area1.getElementsByTagName("div")[2];
84 //check that DropIndicator is present
85 doh.assertEqual(diNode,node);
86 doh.assertEqual("dropIndicator",node.className);
87 //check node size
88 doh.assertEqual(100,dojo.contentBox(node).h);
89 }
90 },
91 { /**
92 * Test to place drop indicator into area 1
93 * with bad node reference (using item). In this case the drop
94 * indicator is displayed at the begenning
95 *
96 */
97 name:"TestPlaceDropIndicatorNoPlace",
98 runTest: function(t){
99 var a1BeginSize = area1.getElementsByTagName("div").length;
100 var a2BeginSize = area2.getElementsByTagName("div").length;
101
102 var diNode = dropIndicator.place(area1,item,size);
103 // get elements number after placement
104
105 var a1EndSize = area1.getElementsByTagName("div").length;
106 var a2EndSize = area2.getElementsByTagName("div").length;
107 //check that none child added to the 2 areas and diNode is null
108 doh.assertEqual(null,diNode);
109 doh.assertEqual(a1BeginSize, a1EndSize);
110 doh.assertEqual(a2BeginSize, a2EndSize);
111 }
112 },
113 { /**
114 * Test removing dropIndicator
115 */
116 name:"TestRemoveDropIndicator",
117 runTest: function(t){
118 var listDropIndicator = dojo.query(".dropIndicator");
119 // check that there's only one dromIndicator
120 doh.assertEqual(1,listDropIndicator.length);
121 // remove the drop indicator
122 dropIndicator.remove();
123 // check that there's none drop indicator
124 listDropIndicator = dojo.query(".dropIndicator");
125 doh.assertEqual(0,listDropIndicator.length);
126 }
127 },
128 { /**
129 * Test removing dropIndicator that is not present in the document
130 */
131 name:"TestRemoveDropIndicatorNonExisting",
132 runTest: function(t){
133 var listDropIndicator = dojo.query(".dropIndicator");
134 // check that there's no drop indicator present
135 doh.assertEqual(0,listDropIndicator.length);
136 // remove the drop indicator
137 dropIndicator.remove();
138 // check that there's none drop indicator present
139 listDropIndicator = dojo.query(".dropIndicator");
140 doh.assertEqual(0,listDropIndicator.length);
141 }
142 }
143 ]
144 );
145 doh.run();
146 });
147
148
149 //--------------------------------------
150 </script>
151 <style type="text/css">
152 .area{
153 position:absolute;
154 top:10px;
155 border:5px solid #AAA;
156 background-color:#DDD;
157 margin:0;
158 padding:0;
159 }
160 #area1{
161 left:10px;
162 width : 300px;
163 }
164 #area2{
165 left:330px;
166 width : 100px;
167 height:300px;
168 }
169 .placeNode{
170 width:100%;
171 height:75px;
172
173 }
174 </style>
175 </head>
176 <body class="orange">
177 <div id="area2" class="dndArea area">
178 <div style="background-color:white" id="item1">tested item</div>
179 </div>
180 <div id="area1" class="dndArea area">
181 <div id="place0" class="placeNode"></div>
182 <div id="place1" class="placeNode"></div>
183 <div id="place2" class="placeNode"></div>
184 <div id="place3" class="placeNode"></div>
185 </div>
186 </body>
187 </html>