Debian Codegraph @

dojox/widget/tests/test_RollingList.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 <title>Dojox Rolling List Test</title>
6
7 <style type="text/css">
8 @import "../../../dojo/resources/dojo.css";
9 @import "../../../dijit/tests/css/dijitTests.css";
10 </style>
11
12 <!-- required: a default dijit theme: -->
13 <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/tundra/tundra.css">
14
15 <!-- the additional styles for the widget -->
16 <link id="widgetStyle" rel="stylesheet" href="../RollingList/RollingList.css">
17
18 <!-- required: dojo.js -->
19 <script type="text/javascript" src="../../../dojo/dojo.js"
20 data-dojo-config="parseOnLoad: true, isDebug: true"></script>
21
22 <!-- not needed, for testing alternate themes -->
23 <script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
24
25 <script language="JavaScript" type="text/javascript">
26 dojo.require("dojo.data.ItemFileWriteStore");
27 dojo.require("dojox.widget.RollingList");
28 dojo.require("dijit.form.Button");
29 dojo.require("dijit.form.TextBox");
30 dojo.require("dojo.parser"); // scan page for widgets and instantiate them
31
32 dojo.declare("dojox.widget.RollingStore", dojo.data.ItemFileWriteStore, {
33 getLabel: function(item){
34 return this.inherited(arguments) + " (" + this.getValue(item, "type") + ")";
35 }
36 });
37
38 addedT = false;
39 addedD = false;
40 addedA = false;
41 removedC = false;
42 removedE = false;
43 changedD = false;
44 isBig = true;
45
46 addTijuana = function(){
47 if(addedT){
48 console.log("Tijuana is already added");
49 return;
50 }
51 addedT = true;
52 continentStore.fetchItemByIdentity({identity: "MX", onItem: function(i){
53 continentStore.newItem({id: "Tijuana", name: "Tijuana", type: "city"},
54 {parent: i, attribute: "children"});
55 continentStore.save();
56 }});
57 }
58 addDC = function(){
59 if(addedD){
60 console.log("Washington DC is already added");
61 return;
62 }
63 addedD = true;
64 continentStore.fetchItemByIdentity({identity: "US", onItem: function(i){
65 continentStore.newItem({id: "Washington DC", name: "Washington DC", type: "city"},
66 {parent: i, attribute: "children"});
67 continentStore.save();
68 }});
69 }
70 addAntarctica = function(){
71 if(addedA){
72 console.log("Antarctica is already added");
73 return;
74 }
75 continentStore.newItem({id: "Antarctica", name: "Antarctica", type: "continent"});
76 addedA = true;
77 }
78 removeTijuana = function(){
79 if(!addedT){
80 console.log("Tijuana is not yet added");
81 return;
82 }
83 addedT = false;
84 continentStore.fetchItemByIdentity({identity: "Tijuana", onItem: function(i){
85 continentStore.deleteItem(i);
86 continentStore.save();
87 }});
88 }
89 removeCanada = function(){
90 if(removedC){
91 console.log("Canada is already removed");
92 return;
93 }
94 removedC = true;
95 continentStore.fetchItemByIdentity({identity: "CA", onItem: function(i){
96 continentStore.deleteItem(i);
97 }});
98 }
99 removeEurope = function(){
100 if(removedE){
101 console.log("Europe is already removed");
102 return;
103 }
104 removedE = true;
105 continentStore.fetchItemByIdentity({identity: "EU", onItem: function(i){
106 continentStore.deleteItem(i);
107 }});
108 }
109 changeDC = function(){
110 if(!addedD){
111 console.log("Washington DC is not yet added");
112 return;
113 }
114 if(changedD){
115 console.log("Washington DC is already changed");
116 return;
117 }
118 changedD = true;
119 continentStore.fetchItemByIdentity({identity: "Washington DC", onItem: function(i){
120 continentStore.setValue(i, "type", "district");
121 }});
122 }
123 removeDC = function(){
124 if(!addedD){
125 console.log("Washington DC is not yet added");
126 return;
127 }
128 changedD = false;
129 addedD = false;
130 continentStore.fetchItemByIdentity({identity: "Washington DC", onItem: function(i){
131 continentStore.deleteItem(i);
132 continentStore.save();
133 }});
134
135 }
136 doResize = function(){
137 var newSize = isBig ? {w: 340, h: 100} : {w: 500, h: 300};
138 myList.resize(newSize);
139 isBig = !isBig;
140 }
141 setValue = function(id){
142 if(id){
143 continentStore.fetchItemByIdentity({identity: id, onItem: function(i){
144 myList.attr("value", i);
145 }});
146 }else{
147 myList.attr("value", null);
148 }
149 }
150 </script>
151
152 </head>
153 <body class="tundra">
154
155 <h1 class="testTitle">Dojox Rolling List Test</h1>
156
157 <div dojoType="dojox.widget.RollingStore" data-dojo-id="continentStore"
158 url="../../../dijit/tests/_data/countries.json">
159 </div>
160
161 <h3>Rolling List - <input dojoType="dijit.form.TextBox" type="text" id="clickWatch" disabled value="None Selected..."></h3>
162 <div dojoType="dojox.widget.RollingList" data-dojo-id="myList" id="myList" store="continentStore"
163 query="{type:'continent'}">
164 <script type="dojo/method" data-dojo-event="onChange" data-dojo-args="value">
165 console.log("Set Value:", value);
166 if(value){
167 dijit.byId("clickWatch").attr("value", this.store.getIdentity(value));
168 }else{
169 dijit.byId("clickWatch").attr("value", "None Selected...");
170 }
171 </script>
172 <script type="dojo/method" data-dojo-event="getPaneForItem" data-dojo-args="item,parentPane,children">
173 var ret = dojox.widget.RollingList.prototype.getPaneForItem.apply(this, arguments);
174
175 if(!ret){
176 ret = new dojox.widget._RollingListPane({
177 onItems: function(){
178 if(this.items.length){
179 this._setContentAndScroll("Details for " + this.store.getLabel(this.items[0]).replace(/</,"&lt;"));
180 }
181 }});
182 }
183 return ret;
184 </script>
185 </div>
186 <hr>
187 <button dojoType="dijit.form.Button" onClick="doResize()">Resize widget</button>
188 <hr>
189 <button dojoType="dijit.form.Button" onClick="setValue('Guadalajara')">Set Value to Guadalajara</button>
190 <button dojoType="dijit.form.Button" onClick="setValue('AF')">Set Value to Africa</button>
191 <button dojoType="dijit.form.Button" onClick="setValue('Toronto')">Set Value to Toronto</button>
192 <button dojoType="dijit.form.Button" onClick="setValue('')">Set No Value</button>
193 <hr>
194 <button dojoType="dijit.form.Button" onClick="addTijuana()">Add Item To Mexico (Tijuana)</button>
195 <button dojoType="dijit.form.Button" onClick="removeTijuana()">Remove Tijuana</button><br>
196 <button dojoType="dijit.form.Button" onClick="addDC()">Add Item To USA (Washington DC)</button>
197 <button dojoType="dijit.form.Button" onClick="changeDC()">Change Washington DC</button>
198 <button dojoType="dijit.form.Button" onClick="removeDC()">Remove Washington DC</button><br>
199 <button dojoType="dijit.form.Button" onClick="addAntarctica()">Add Item To Top-level (Antarctica)</button><br>
200 <button dojoType="dijit.form.Button" onClick="removeCanada()">Remove Canada</button>
201 <button dojoType="dijit.form.Button" onClick="removeEurope()">Remove Europe</button>
202 </body>
203 </html>