UNPKG

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.

162 lines (153 loc) 5.02 kB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <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>Globalized Model App Test</title> <link href="../../../../mobile/themes/iphone/base.css" rel="stylesheet"> <style> html,body { width: 100%; height: 100%; background: #eee; font-family: arial; color: #333; overflow: hidden; margin: 0; padding: 0; visibility: visible; } #splash { width: 90%; height: 90%; margin: auto; overflow: hidden; border: 2px solid green; color: #333; text-align: center; } </style> <script type="text/javascript"> dojoConfig = { parseOnLoad: false, mblHideAddressBar: false, mblAndroidWorkaround: false, mblAlwaysHideAddressBar: false, async:1, app: {debugApp: 0} // set debugApp to log app transitions and view activate/deactivate }; </script> <script type="text/javascript" src="../../../../../dojo/dojo.js"></script> <script> // the actual launcher require(["../../globalizedApp/globalizedApp.js"], function(){}); </script> <script type="text/javascript"> require([ "doh/runner", "dojo/topic", "dojo/_base/lang", "dojo/dom", "dojox/mobile/TransitionEvent", "dijit/registry" ], function(doh, topic, lang, dom, TransitionEvent, registry) { var events = []; var getLabelfromWid = function(wid, indx1, indx2){ var val = wid.labelNode.innerText || wid.labelNode.firstChild.nodeValue || ""; val = lang.trim(val); if(indx2){ val = val.substring(indx1,indx2) } return val; }; var getLabelfromDom = function(node, indx1, indx2){ var val = node.innerText || node.firstChild.nodeValue || ""; val = lang.trim(val); if(indx2){ val = val.substring(indx1,indx2) } return val; }; topic.subscribe("/app/status", lang.hitch(this, function(newStatus) { events.push(newStatus); if (newStatus == 2) { var listItem_0TestStr = "Label Zero"; var listItem_1TestStr = "Label One"; doh.register("Test-GlobalizedApp", [{ // Test initial listitem labels name : "initial-listItem-labels", runTest : function() { var dfd = new doh.Deferred(); setTimeout(function() { var ListItem_0Label = registry.byId("dojox_mobile_ListItem_0"); if(ListItem_0Label){ var lab = getLabelfromWid(ListItem_0Label,0,listItem_0TestStr.length); doh.is(lab, listItem_0TestStr); }else{ throw new Error("In initial-listItem-labels ListItem_0Label not found."); } var ListItem_1Label = registry.byId("dojox_mobile_ListItem_1"); if(ListItem_1Label){ doh.is(getLabelfromWid(ListItem_1Label,0,listItem_1TestStr.length), listItem_1TestStr); }else{ throw new Error("In initial-listItem-labels ListItem_1Label not found."); } return dfd.callback(true); }, 500); return dfd; } }, { // Test first transition name : "transition-test-1", runTest : function() { var dfd = new doh.Deferred(); setTimeout(function() { // transition to first li var liWidget = registry.byId("dojox_mobile_ListItem_2"); var ev = new TransitionEvent(liWidget.domNode, liWidget.params.transitionOptions); ev.dispatch(); return dfd.callback(true); }, 500); } }, { // Test global data 1 name : "global-data-test-1", timeout: 4000, runTest : function() { var dfd = new doh.Deferred(); setTimeout(function() { var d = dom.byId("label"); if(d){ var globalOutput = "Home-foo"; var lab = getLabelfromDom(d,0,globalOutput.length); doh.is(globalOutput, lab, "label should be of Home-foo"); }else{ throw new Error("In global-data-test-1 label should be of Home-foo."); } return dfd.callback(true); }, 2000); return dfd; } }, { // Test back transition name : "transition-back-1", runTest : function() { var dfd = new doh.Deferred(); if(history){ history.back(); setTimeout(function() { doh.t(globalizedApp.children["globalizedApp_home"], "globalizedApp_home viewShowing should be true"); return dfd.callback(true); }, 500); } } }]); doh.run(); } })); }); </script> </head> <body> </body> </html>