| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> |
| 5 | <meta name="apple-mobile-web-app-capable" content="yes" /> |
| 6 | <title>RoundRectDataList</title> |
| 7 | <script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="parseOnLoad: true"></script> |
| 8 | <script language="JavaScript" type="text/javascript"> |
| 9 | dojo.require("dojo.data.ItemFileWriteStore"); |
| 10 | //dojo.require("dojo.parser"); // Use the lightweight parser. |
| 11 | dojo.require("dojox.mobile.parser"); |
| 12 | dojo.require("dojox.mobile"); |
| 13 | dojo.require("dojox.mobile.deviceTheme"); |
| 14 | dojo.require("dojox.mobile.RoundRectDataList"); |
| 15 | |
| 16 | dojo.requireIf(!dojo.isWebKit, "dojox.mobile.compat"); |
| 17 | |
| 18 | var static_data = { |
| 19 | items: [ |
| 20 | {label: "Apple", moveTo: "dummy"}, |
| 21 | {label: "Banana", moveTo: "dummy"}, |
| 22 | {label: "Cherry", moveTo: "dummy"}, |
| 23 | {label: "Grape", moveTo: "dummy"}, |
| 24 | {label: "Kiwi", moveTo: "dummy"}, |
| 25 | {label: "Lemon", moveTo: "dummy"}, |
| 26 | {label: "Melon", moveTo: "dummy"}, |
| 27 | {label: "Orange", moveTo: "dummy"}, |
| 28 | {label: "Peach", moveTo: "dummy"} |
| 29 | ] |
| 30 | }; |
| 31 | var store1 = new dojo.data.ItemFileWriteStore({url: "settings.json", clearOnClose: true}); |
| 32 | var store2 = new dojo.data.ItemFileWriteStore({data: dojo.clone(static_data)}); |
| 33 | var store = store1; |
| 34 | var newItems = [[],[]]; |
| 35 | |
| 36 | // switch to the selected store |
| 37 | function switchTo(store){ |
| 38 | window.store = store; |
| 39 | dijit.byId("list").setStore(store); |
| 40 | } |
| 41 | // add a new item |
| 42 | function add1(){ |
| 43 | var item = store.newItem({label: "New Item", moveTo: "dummy"}); |
| 44 | this.newItems[(store == store1) ? 1 : 0].push(item); |
| 45 | } |
| 46 | // delete the added item |
| 47 | function delete1(){ |
| 48 | var item = this.newItems[(store == store1) ? 1 : 0].pop(); |
| 49 | if(item){ |
| 50 | store.deleteItem(item); |
| 51 | } |
| 52 | } |
| 53 | </script> |
| 54 | |
| 55 | <script type="text/javascript" src="../TestUtil.js"></script> |
| 56 | <script type="text/javascript" src="RoundRectDataList.js"></script> |
| 57 | </head> |
| 58 | <body> |
| 59 | <div id="foo" dojoType="dojox.mobile.View" selected="true"> |
| 60 | <h1 dojoType="dojox.mobile.Heading">RoundRectDataList</h1> |
| 61 | <ul dojoType="dojox.mobile.RoundRectDataList" id="list" store="store" query="{label: '*'}"></ul> |
| 62 | <p>show the different set:<br> |
| 63 | <input type="button" value="Set1" onclick="switchTo(store1)"> |
| 64 | <input type="button" value="Set2" onclick="switchTo(store2)"> |
| 65 | <p>alter the object store:<br> |
| 66 | <input type="button" value="Add" onclick="add1()"> |
| 67 | <input type="button" value="Delete" onclick="delete1()"> |
| 68 | </div> |
| 69 | </body> |
| 70 | </html> |