1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
dojo.provide("dojox.mvc.tests.mobile.demo.src");
//dojo.require("dojo.parser"); // no longer needed for repeat demo
dojo.require("dojox.mobile.parser");
dojo.require("dojox.mobile");
dojo.require("dojox.mobile.ScrollableView");
dojo.require("dojox.mobile.TextBox");
dojo.require("dojox.mvc");
dojo.require("dojox.mvc.Generate");
dojo.require("dojox.mvc.Group");
dojo.require("dojox.mvc.Repeat");
dojo.require("dojox.mobile.FlippableView");
dojo.require("dojox.mobile.ViewController");
dojo.require("dojox.mobile.TextArea");
dojo.require("dojox.mobile.Button");
dojo.require("dojox.mobile.FixedSplitter");
dojo.require("dojox.mobile.EdgeToEdgeList");
dojo.require("dojox.mobile.EdgeToEdgeCategory");
dojo.require("dojox.mobile.Heading");
dojo.require("dojox.mobile.FixedSplitterPane");
dojo.requireIf(!dojo.isWebKit, "dojox.mobile.compat");
dojo.requireIf(!dojo.isWebKit, "dojo.fx");
dojo.requireIf(!dojo.isWebKit, "dojo.fx.easing");
dojo.require("dojox.mobile.deviceTheme"); // used for device detection
// Initial data for Ship to - Bill demo
var names = {
"Serial" : "360324",
"First" : "John",
"Last" : "Doe",
"Email" : "jdoe@us.ibm.com",
"ShipTo" : {
"Street" : "123 Valley Rd",
"City" : "Katonah",
"State" : "NY",
"Zip" : "10536"
},
"BillTo" : {
"Street" : "17 Skyline Dr",
"City" : "Hawthorne",
"State" : "NY",
"Zip" : "10532"
}
};
// Initial repeat data used in the Repeat Data binding demo
var repeatData = [
{
"First" : "Chad",
"Last" : "Chapman",
"Location": "CA",
"Office" : "1278",
"Email" : "c.c@test.com",
"Tel" : "408-764-8237",
"Fax" : "408-764-8228"
},
{
"First" : "Irene",
"Last" : "Ira",
"Location": "NJ",
"Office" : "F09",
"Email" : "i.i@test.com",
"Tel" : "514-764-6532",
"Fax" : "514-764-7300"
},
{
"First" : "John",
"Last" : "Jacklin",
"Location": "CA",
"Office" : "6701",
"Email" : "j.j@test.com",
"Tel" : "408-764-1234",
"Fax" : "408-764-4321"
}
];
var selectedIndex = 0;
var model = dojox.mvc.newStatefulModel({ data : names });
var repeatmodel = dojox.mvc.newStatefulModel({ data : repeatData });
var nextIndexToAdd = repeatmodel.data.length;
// used in the Ship to - Bill to demo
function setRef(id, addrRef) {
var widget = dijit.byId(id);
widget.set("ref", addrRef);
}
// used in the Repeat Data binding demo
function setDetailsContext(index){
selectedIndex = index;
var groupRoot = dijit.byId("detailsGroup");
groupRoot.set("ref", index);
}
// used in the Repeat Data binding demo
function insertResult(index){
if (repeatmodel[index-1].First.value !== ""){ // TODO: figure out why we are getting called twice for each click
var insert = dojox.mvc.newStatefulModel({ "data" : {
"First" : "",
"Last" : "",
"Location": "CA",
"Office" : "",
"Email" : "",
"Tel" : "",
"Fax" : ""}
});
repeatmodel.add(index, insert);
setDetailsContext(index);
nextIndexToAdd++;
}else{
setDetailsContext(index-1);
}
};
// used in the Generate View demo
var genmodel;
function updateView() {
try {
var modeldata = dojo.fromJson(dojo.byId("modelArea").value);
genmodel = dojox.mvc.newStatefulModel({ data : modeldata });
dijit.byId("view").set("ref", genmodel);
dojo.byId("outerModelArea").style.display = "none";
dojo.byId("viewArea").style.display = "";
}catch(err){
console.error("Error parsing json from model: "+err);
}
};
// used in the Generate View demo
function updateModel() {
dojo.byId("outerModelArea").style.display = "";
try {
dojo.byId("modelArea").focus(); // hack: do this to force focus off of the textbox, bug on mobile?
dojo.byId("viewArea").style.display = "none";
dijit.byId("modelArea").set("value",(dojo.toJson(genmodel.toPlainObject(), true)));
} catch(e) {
console.log(e);
};
};
function setup() {
dojox.mobile.parser.parse();
};
dojo.ready(setup);
|