dijit
Version:
Dijit provides a complete collection of user interface controls based on Dojo, giving you the power to create web applications that are highly optimized for usability, performance, internationalization, accessibility, but above all deliver an incredible u
118 lines (96 loc) • 3.46 kB
HTML
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>ContentPane Auto Require Tests</title>
<script src="../boilerplate.js"></script>
<script type="text/javascript">
require([
"doh",
"dojo/_base/declare",
"dojo/Deferred",
"dojo/dom",
"dojo/_base/lang",
"dojo/parser",
"dijit/registry",
"dojo/domReady!"
], function(doh, declare, Deferred, dom, lang, parser, registry){
// instances of AsyncWidget will finish initializing when this Deferred is resolved
var finishCreatingAsyncWidgets = new Deferred();
AsyncWidget = declare(null, {
declaredClass: "AsyncWidget",
markupFactory: function(params, node){
// the markup factory can return a promise, and the parser will wait
return finishCreatingAsyncWidgets.then(function(){return new AsyncWidget(params, node); });
},
constructor: function(args, node){
this.params = args;
lang.mixin(this, args);
},
startup: function(){
this._started = true;
}
});
doh.register("auto require", [
{
name: "auto-load parse",
timeout: 10000,
runTest: function(t){
var d = new doh.Deferred();
// This will test auto-loading but only if dijit/form/TextBox isn't in the cache
parser.parse(dom.byId("simple")).then(d.getTestCallback(function(){
t.is(typeof registry.byId("tb1"), "object", "objected created");
}));
return d;
}
},
{
name: "href",
timeout: 10000,
runTest: function(t){
var d = new doh.Deferred();
// This will test auto-loading but only if dijit/form/Button isn't in the cache
registry.byId("parsedPane1").set("href", "doc3.html").then(d.getTestCallback(function(){
t.is(typeof registry.byId("button1"), "object", "object created");
}));
return d;
}
},
function nested(){
var d = new doh.Deferred();
var parsePromise = parser.parse(dom.byId("nested"));
// Parser should wait for innerPane Contentpane,
// innerPane should wait for nested call to parser.parse(),
// and the nested parser.parse() call is waiting for AsyncWidget to initialize.
// This is to simulate when the nested parse() call is waiting for auto-load.
doh.f(parsePromise.isFulfilled(), "parse not completed yet");
doh.f(formWidget._started, "wrapper form widget not started yet");
finishCreatingAsyncWidgets.resolve(true);
return parsePromise.then(d.getTestCallback(function(){
doh.t(formWidget._started, "wrapper form widget started");
}));
return d;
}
]);
doh.run();
});
</script>
</head>
<body class="claro" role="main">
<h1 class="testTitle">Dijit layout.ContentPane Auto-Require Tests</h1>
<h2>ContentPane Loading Content that Requires Auto-Require</h2>
<div id="simple">
<div data-dojo-type="dijit/layout/ContentPane" id="parsedPane1">
<input type="text" aria-label="tb1" id="tb1" data-dojo-type="dijit/form/TextBox" data-dojo-props="value: 'testValue'" />
</div>
</div>
<div id="nested">
<div data-dojo-type="dijit/_WidgetBase" data-dojo-id="formWidget">
<div data-dojo-type="dijit/layout/ContentPane" id="innerPane">
<!-- for simulating an asynchronous nested parse due to waiting for module to load -->
<span data-dojo-id="asyncWidget" data-dojo-type="AsyncWidget">hi</span>
</div>
</div>
</div>
</body>
</html>