| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> |
| 5 | <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> |
| 6 | <meta name="apple-mobile-web-app-capable" content="yes"/> |
| 7 | <title>Data Lists</title> |
| 8 | |
| 9 | <script type="text/javascript" src="../../../deviceTheme.js" data-dojo-config="mblThemeFiles: ['base']"></script> |
| 10 | <script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true, has: {'dojo-bidi': true }"></script> |
| 11 | |
| 12 | <script type="text/javascript"> |
| 13 | require([ |
| 14 | "dojo/data/ItemFileWriteStore", |
| 15 | "dijit/registry", |
| 16 | "doh/runner", |
| 17 | "dojo/dom", |
| 18 | "dojo/ready", |
| 19 | "dojo/query", |
| 20 | "dojo/_base/lang", |
| 21 | "dojox/mobile/parser", |
| 22 | "dojox/mobile", |
| 23 | "dojox/mobile/compat", |
| 24 | "dojox/mobile/RoundRectDataList", |
| 25 | "dojox/mobile/EdgeToEdgeDataList" |
| 26 | ], function(ItemFileWriteStore, registry, runner, dom, ready, query, lang){ |
| 27 | var static_data1 = { |
| 28 | items: [ |
| 29 | { label: "Wi-Fi!", icon: "../../images/i-icon-1.png", moveTo: "wifi" }, |
| 30 | { label: "Brightness & Wallpaper!", icon: "../../images/i-icon-2.png", moveTo: "bright" }, |
| 31 | { label: "Picture Frame!", icon: "../../images/i-icon-3.png", moveTo: "picture" }, |
| 32 | { label: "Mail, Contacts, Calendars!", icon: "../../images/i-icon-5.png", moveTo: "wifi" } |
| 33 | ] |
| 34 | }; |
| 35 | |
| 36 | var static_data2 = { |
| 37 | items: [ |
| 38 | {label: "Apple!", moveTo: "dummy"}, |
| 39 | {label: "Banana!", moveTo: "dummy"}, |
| 40 | {label: "Cherry!", moveTo: "dummy"} |
| 41 | ] |
| 42 | }; |
| 43 | store1 = new ItemFileWriteStore({data: lang.clone(static_data1), clearOnClose: true}); |
| 44 | store2 = new ItemFileWriteStore({data: lang.clone(static_data2), clearOnClose: true}); |
| 45 | store = store1; |
| 46 | var newItems = [[],[]]; |
| 47 | |
| 48 | // switch to the selected store |
| 49 | switchTo = function(store){ |
| 50 | window.store = store; |
| 51 | registry.byId("roundrect_list").setStore(store); |
| 52 | registry.byId("edgetoedge_list").setStore(store); |
| 53 | }; |
| 54 | // add a new item |
| 55 | add = function(){ |
| 56 | var item = store.newItem({label: "New Item!", moveTo: "dummy"}); |
| 57 | newItems[(store == store1) ? 1 : 0].push(item); |
| 58 | }; |
| 59 | toggleTextDir = function(){ |
| 60 | w1 = registry.byId("roundrect_list"); |
| 61 | w1.set("textDir", (w1.get("textDir") !== "rtl") ? "rtl" : "ltr"); |
| 62 | |
| 63 | w2 = registry.byId("edgetoedge_list"); |
| 64 | w2.set("textDir", (w2.get("textDir") !== "rtl") ? "rtl" : "ltr"); |
| 65 | }; |
| 66 | ready(function(){ |
| 67 | runner.register("Bidi Store Lists", [ |
| 68 | { |
| 69 | name: "mobile", |
| 70 | runTest: function(){ |
| 71 | query(".mblListItemLabel").forEach(function(node, index, arr){ |
| 72 | if(node.innerHTML) |
| 73 | runner.is(String.fromCharCode(8235), node.innerHTML.charAt(0), "ListItem's label node should have direction correspondent to list's 'textDir'"); |
| 74 | }); |
| 75 | } |
| 76 | } |
| 77 | ]); |
| 78 | |
| 79 | runner.register("log", function(){ |
| 80 | dom.byId('failures').innerHTML = runner._failureCount; |
| 81 | dom.byId('errors').innerHTML = runner._errorCount; |
| 82 | }); |
| 83 | runner.run(); |
| 84 | }); |
| 85 | }); |
| 86 | </script> |
| 87 | </head> |
| 88 | <body style="visibility:hidden;"> |
| 89 | <div data-dojo-type="dojox.mobile.View"> |
| 90 | <h1 data-dojo-type="dojox.mobile.Heading">RoundRectDataList</h1> |
| 91 | <ul data-dojo-type="dojox.mobile.RoundRectDataList" id="roundrect_list" data-dojo-props='textDir:"rtl", store:store, query:{label: "*"}'></ul> |
| 92 | <h1 data-dojo-type="dojox.mobile.Heading">EdgeToEdgeDataList</h1> |
| 93 | <ul data-dojo-type="dojox.mobile.EdgeToEdgeDataList" id="edgetoedge_list" data-dojo-props='textDir:"rtl", store:store, query:{label: "*"}'></ul> |
| 94 | <table border="1"> |
| 95 | <tr><th>Show the different set</th><th>Alter the object store</th></tr> |
| 96 | <tr><td> |
| 97 | <input type="button" value="Set1" onclick="switchTo(store1)"> |
| 98 | <input type="button" value="Set2" onclick="switchTo(store2)"> |
| 99 | </td><td> |
| 100 | <input type="button" value="Add" onclick="add()"> |
| 101 | <input type="button" value="Toggle textDir" onclick="toggleTextDir()"> |
| 102 | </td></tr></table> |
| 103 | </div> |
| 104 | <br>Errors: <span id="errors">?</span> |
| 105 | <br>Failures: <span id="failures">?</span> |
| 106 | </body> |
| 107 | </html> |