dojox
Version:
Dojo eXtensions, a rollup of many useful sub-projects and varying states of maturity – from very stable and robust, to alpha and experimental. See individual projects contain README files for details.
108 lines (101 loc) • 4.15 kB
HTML
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<title>Data Lists</title>
<script type="text/javascript" src="../../../deviceTheme.js" data-dojo-config="mblThemeFiles: ['base']"></script>
<script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true, has: {'dojo-bidi': true }"></script>
<script type="text/javascript">
require([
"dojo/data/ItemFileWriteStore",
"dijit/registry",
"doh/runner",
"dojo/dom",
"dojo/ready",
"dojo/query",
"dojo/_base/lang",
"dojox/mobile/parser",
"dojox/mobile",
"dojox/mobile/compat",
"dojox/mobile/RoundRectDataList",
"dojox/mobile/EdgeToEdgeDataList"
], function(ItemFileWriteStore, registry, runner, dom, ready, query, lang){
var static_data1 = {
items: [
{ label: "Wi-Fi!", icon: "../../images/i-icon-1.png", moveTo: "wifi" },
{ label: "Brightness & Wallpaper!", icon: "../../images/i-icon-2.png", moveTo: "bright" },
{ label: "Picture Frame!", icon: "../../images/i-icon-3.png", moveTo: "picture" },
{ label: "Mail, Contacts, Calendars!", icon: "../../images/i-icon-5.png", moveTo: "wifi" }
]
};
var static_data2 = {
items: [
{label: "Apple!", moveTo: "dummy"},
{label: "Banana!", moveTo: "dummy"},
{label: "Cherry!", moveTo: "dummy"}
]
};
store1 = new ItemFileWriteStore({data: lang.clone(static_data1), clearOnClose: true});
store2 = new ItemFileWriteStore({data: lang.clone(static_data2), clearOnClose: true});
store = store1;
var newItems = [[],[]];
// switch to the selected store
switchTo = function(store){
window.store = store;
registry.byId("roundrect_list").setStore(store);
registry.byId("edgetoedge_list").setStore(store);
};
// add a new item
add = function(){
var item = store.newItem({label: "New Item!", moveTo: "dummy"});
newItems[(store == store1) ? 1 : 0].push(item);
};
toggleTextDir = function(){
w1 = registry.byId("roundrect_list");
w1.set("textDir", (w1.get("textDir") !== "rtl") ? "rtl" : "ltr");
w2 = registry.byId("edgetoedge_list");
w2.set("textDir", (w2.get("textDir") !== "rtl") ? "rtl" : "ltr");
};
ready(function(){
runner.register("Bidi Store Lists", [
{
name: "mobile",
runTest: function(){
query(".mblListItemLabel").forEach(function(node, index, arr){
if(node.innerHTML)
runner.is(String.fromCharCode(8235), node.innerHTML.charAt(0), "ListItem's label node should have direction correspondent to list's 'textDir'");
});
}
}
]);
runner.register("log", function(){
dom.byId('failures').innerHTML = runner._failureCount;
dom.byId('errors').innerHTML = runner._errorCount;
});
runner.run();
});
});
</script>
</head>
<body style="visibility:hidden;">
<div data-dojo-type="dojox.mobile.View">
<h1 data-dojo-type="dojox.mobile.Heading">RoundRectDataList</h1>
<ul data-dojo-type="dojox.mobile.RoundRectDataList" id="roundrect_list" data-dojo-props='textDir:"rtl", store:store, query:{label: "*"}'></ul>
<h1 data-dojo-type="dojox.mobile.Heading">EdgeToEdgeDataList</h1>
<ul data-dojo-type="dojox.mobile.EdgeToEdgeDataList" id="edgetoedge_list" data-dojo-props='textDir:"rtl", store:store, query:{label: "*"}'></ul>
<table border="1">
<tr><th>Show the different set</th><th>Alter the object store</th></tr>
<tr><td>
<input type="button" value="Set1" onclick="switchTo(store1)">
<input type="button" value="Set2" onclick="switchTo(store2)">
</td><td>
<input type="button" value="Add" onclick="add()">
<input type="button" value="Toggle textDir" onclick="toggleTextDir()">
</td></tr></table>
</div>
<br>Errors: <span id="errors">?</span>
<br>Failures: <span id="failures">?</span>
</body>
</html>