Debian Codegraph @

dojox/mvc/tests/test_mvc_repeat_select_cancel.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html style="width:100%;height:100%;overflow:hidden;">
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>Dojo Repeat Selection Test</title>
6
7 <style type="text/css">
8 @import "../../../dijit/themes/dijit.css";
9 @import "../../../dijit/themes/claro/document.css";
10 @import "../../../dijit/tests/css/dijitTests.css";
11 </style>
12
13 <!-- required: a default dijit theme: -->
14 <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
15
16 <style>
17 .bordercontainer-nopadding .dijitContentPane, .bordercontainer-nopadding .dijitSplitContainer-dijitContentPane, .bordercontainer-nopadding .dijitBorderContainer-dijitContentPane {
18 padding: 0;
19 }
20
21 .bordercontainer-nopadding .dijitMenuBar {
22 border-width: 0 0 1px 0;
23 }
24
25 .view .dijitMenu {
26 border-width: 0;
27 }
28
29 .view .dijitMenuItemHover {
30 background-color: inherit;
31 background-image: none;
32 }
33
34 .view .dijitMenuItemSelected {
35 background-color: #abd6ff;
36 background-image: url("images/standardGradient.png");
37 background-repeat: repeat-x;
38 background-image: -moz-linear-gradient(rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 100%);
39 background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 100%);
40 background-image: -o-linear-gradient(rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 100%);
41 background-image: -ms-linear-gradient(rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 100%);
42 _background-image: none;
43 }
44
45 .view td.dijitMenuItemLabel {
46 width: 100%;
47 padding: 6px;
48 }
49
50 .view td.dijitMenuItemIconCell {
51 padding: 6px;
52 }
53
54 .dijitBorderContainerNoGutter > .form {
55 padding: 6px;
56 }
57
58 .row {
59 width: 100%;
60 display: inline-block;
61 padding: 6px;
62 -box-sizing: border-box;
63 -moz-box-sizing: border-box;
64 -webkit-box-sizing: border-box;
65 }
66
67 .cell {
68 width: 100%;
69 display:inline-block;
70 -box-sizing: border-box;
71 -moz-box-sizing: border-box;
72 -webkit-box-sizing: border-box;
73 }
74
75 .complete {
76 text-decoration: line-through;
77 }
78 </style>
79
80 <!-- required: dojo.js -->
81 <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true, async: true, mvc: {debugBindings: true}"></script>
82
83 <script type="text/javascript">
84 var ViewMenuBarData, DetailMenuBarData, initialRows;
85 var selectionStatusConverter = {
86 format: function(value){
87 return this.target.uniqueId == (value || {}).uniqueId;
88 },
89 parse: function(value){
90 if(!value){ throw new Error(); } // Stop copying the new value for unchecked case
91 for(var a = this.source.inModel, i = 0; i < a.length; i++){
92 if(a[i].uniqueId == this.target.uniqueId){
93 return a[i];
94 }
95 }
96 }
97 }, priorityConverter = {
98 format: function(value){
99 return "dijitIcon dijitMenuItemIconCell " + (value <= 1 ? "dijitIconError" : "");
100 }
101 }, completeConverter = {
102 format: function(value){
103 return "dijitMenuItemLabel" + (value ? " complete" : "");
104 }
105 },subjectConverter = {
106 format: function(value){
107 return value || "(No subject)";
108 }
109 };
110
111 require([
112 "dojox",
113 "dojo/_base/declare",
114 "dojo/_base/lang",
115 "dojo/dom",
116 "dojo/dom-class",
117 "dojo/parser",
118 "dojo/Stateful",
119 "dijit/registry",
120 "dijit/Menu",
121 "dojox/mvc/at",
122 "dojox/mvc/getStateful",
123 "dijit/form/CheckBox",
124 "dijit/form/DateTextBox",
125 "dijit/form/Select",
126 "dijit/form/TextBox",
127 "dijit/layout/BorderContainer",
128 "dijit/layout/ContentPane",
129 "dijit/Editor",
130 "dijit/MenuBar",
131 "dijit/MenuBarItem",
132 "dijit/MenuItem",
133 "dojox/mvc/_atBindingExtension",
134 "dojox/mvc/EditModelRefController",
135 "dojox/mvc/ListController",
136 "dojox/mvc/StatefulArray",
137 "dojox/mvc/Group",
138 "dojox/mvc/Repeat"
139 ], function(dojox, declare, lang, ddom, domClass, parser, Stateful, registry, Menu, at, getStateful){
140
141 var uniqueIdSeq = 3;
142
143 initialRows = getStateful([
144 {
145 uniqueId: 0,
146 Completed: false,
147 Subject: "Pick up my kids",
148 Due: new Date((new Date()).getTime() + 48 * 3600000),
149 Priority: 1,
150 Description: "At the kindergarden"
151 },
152 {
153 uniqueId: 1,
154 Completed: true,
155 Subject: "Take dojox.mvc learning course",
156 Due: new Date((new Date()).getTime() + 72 * 3600000),
157 Priority: 2,
158 Description: "Need to find course material at http://dojotoolkit.org/"
159 },
160 {
161 uniqueId: 2,
162 Completed: false,
163 Subject: "Wash my car",
164 Due: new Date((new Date()).getTime() + 120 * 3600000),
165 Priority: 3,
166 Description: "Need to buy a cleaner before that"
167 }
168 ]);
169
170 ViewMenuBarData = getStateful([
171 {
172 label: "New",
173 onClick: function(){
174 var ctl = registry.byId("listCtl");
175 var payload = getStateful({
176 uniqueId: uniqueIdSeq++,
177 Completed: false,
178 Subject: "",
179 Due: new Date(""),
180 Priority: 2,
181 Description: ""
182 });
183 ctl.inModel.unshift(payload);
184 ctl.set("cursor", payload);
185 }
186 },
187 {
188 label: "Delete",
189 onClick: function(){
190 var ctl = registry.byId("listCtl");
191 if(!confirm("Are you sure you want to delete \"" + ctl.get("Subject") + "\"?")){ return; }
192
193 var idx = ctl.get("cursorIndex");
194 if(idx >= 0){
195 ctl.inModel.splice(idx, 1);
196 }
197 if(idx < ctl.inModel.get("length")){
198 ctl.set("cursorIndex", idx);
199 }
200 }
201 }
202 ]);
203
204 DetailMenuBarData = getStateful([
205 {
206 label: "Cancel",
207 onClick: function(){
208 var ctl = registry.byId("listCtl");
209 if(!confirm("Are you sure you want to cancel editing \"" + ctl.get("Subject") + "\"?")){ return; }
210 ctl.reset();
211 }
212 }
213 ]);
214
215 domClass.add(ddom.byId("loading"), "dijitDisplayNone");
216 domClass.remove(ddom.byId("main"), "dijitDisplayNone");
217 parser.parse();
218 });
219 </script>
220 </head>
221 <body class="claro" style="width:100%;height:100%;margin:0;padding:0;overflow:hidden;">
222 <script type="dojo/require">at: "dojox/mvc/at"</script>
223 <table id="loading" style="width:100%;height:100%;" border="0" cellpadding="0" cellspacing="0">
224 <tbody>
225 <tr>
226 <td align="center">Loading...</td>
227 </tr>
228 </tbody>
229 </table>
230 <div id="main" class="dijitDisplayNone" style="width:100%;height:100%;">
231 <span id="listCtl" data-dojo-type="dojox.mvc.ListController" data-dojo-mixins="dojox.mvc.EditModelRefController"
232 data-dojo-props="_refInModelProp: 'inModel', _refSourceModelProp: 'cursor', _refModelProp: 'model', inModel: initialRows, cursorIndex: 0"></span>
233 <div class="bordercontainer-nopadding" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="persist: false, gutters: true, style: 'height: 100%; width: 100%;'">
234 <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'left', style: 'background-color: white; width: 48ex', splitter: true">
235 <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="persist: false, gutters: false">
236 <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'top'">
237 <div data-dojo-type="dojox.mvc.Repeat" data-dojo-mixins="dijit.MenuBar" data-dojo-props="children: ViewMenuBarData">
238 <div data-dojo-type="dijit.MenuBarItem" data-dojo-props="'*': at('rel:${index}', '*')"></div>
239 </div>
240 </div>
241 <div class="view" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'">
242 <table border="0" cellspacing="0" cellpadding="0">
243 <tbody data-dojo-type="dojox.mvc.Repeat" data-dojo-props="children: at('widget:listCtl', 'inModel')">
244 <tr data-dojo-type="dijit._WidgetBase" data-dojo-props="target: at('rel:', '${index}')">
245 <td class="dijitMenuItemIconCell">
246 <input data-dojo-type="dijit.form.CheckBox"
247 data-dojo-props="uniqueId: at('rel:', 'uniqueId'),
248 checked: at('widget:listCtl', 'cursor').transform(selectionStatusConverter)">
249 </td>
250 <td class="dijitMenuItemIconCell">
251 <img src="../../../dojo/resources/blank.gif" data-dojo-type="dijit._WidgetBase"
252 data-dojo-props="_setDomClassAttr: {node: 'domNode', type: 'class'}, domClass: at('rel:', 'Priority').direction(at.from).transform(priorityConverter)">
253 </td>
254 <td data-dojo-type="dijit._WidgetBase"
255 data-dojo-props="Subject: at('rel:', 'Subject').direction(at.from).transform(subjectConverter),
256 _setDomClassAttr: {node: 'domNode', type: 'class'}, domClass: at('rel:', 'Completed').direction(at.from).transform(completeConverter),
257 _setSubjectAttr: {node: 'domNode', type: 'innerText'}">
258 </td>
259 </tr>
260 </tbody>
261 </table>
262 </div>
263 </div>
264 </div>
265 <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center', style: 'background-color: white;'">
266 <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="persist: false, gutters: false">
267 <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'top'">
268 <div data-dojo-type="dojox.mvc.Repeat" data-dojo-mixins="dijit.MenuBar" data-dojo-props="children: DetailMenuBarData">
269 <div data-dojo-type="dijit.MenuBarItem" data-dojo-props="'*': at('rel:${index}', '*')"></div>
270 </div>
271 </div>
272 <div class="form" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center', target: at('widget:listCtl', 'model')">
273 <div class="row">
274 <span class="cell">
275 <label for="completed">Completed:</label>
276 <input id="completed" data-dojo-type="dijit.form.CheckBox" data-dojo-props="checked: at('rel:', 'Completed')">
277 </span>
278 </div>
279 <div class="row">
280 <label class="cell" for="subject">Subject:</label>
281 <input class="cell" id="subject" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Subject')">
282 </div>
283 <div class="row">
284 <label class="cell" for="priority">Priority:</label>
285 <span class="cell">
286 <select id="priority" data-dojo-type="dijit.form.Select" data-dojo-props="value: at('rel:', 'Priority')">
287 <option value="1">1</option>
288 <option value="2">2</option>
289 <option value="3">3</option>
290 </select>
291 </span>
292 </div>
293 <div class="row">
294 <label class="cell" for="due">Due:</label>
295 <span class="cell">
296 <input id="due" data-dojo-type="dijit.form.DateTextBox"
297 data-dojo-props="required: false, constraints: {datePattern: 'MMMM dd yyyy'}, value: at('rel:', 'Due')">
298 </span>
299 </div>
300 <div class="row">
301 <span class="cell">Description:</span>
302 <div class="cell" data-dojo-type="dijit.Editor"
303 data-dojo-props="plugins: ['bold', 'italic', 'underline'], height: '200', value: at('rel:', 'Description')"></div>
304 </div>
305 </div>
306 </div>
307 </div>
308 </div>
309 </div>
310 </body>
311 </html>