Debian Codegraph @

dijit/tests/layout/test_ContentPane.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>ContentPane Test</title>
6
7 <script type="text/javascript" src="../boilerplate.js"></script>
8
9 <style>
10 .box {
11 position: relative;
12 background-color: white;
13 border: 2px solid black;
14 padding: 8px;
15 margin: 4px;
16 }
17 </style>
18
19 <script type="text/javascript">
20 require([
21 "doh/runner",
22 "dojo/_base/declare",
23 "dojo/dom",
24 "dojo/dom-construct",
25 "dojo/parser",
26 "dijit/registry",
27 "dijit/_WidgetBase",
28 "dijit/_TemplatedMixin",
29 "dijit/layout/ContentPane",
30 "dijit/Dialog",
31 "dojo/domReady!"
32 ], function(doh, declare, dom, domConstruct, parser,
33 registry, _WidgetBase, _TemplatedMixin){
34
35
36 // create a do nothing, only for test widget
37 declare("TestWidget", [_WidgetBase, _TemplatedMixin], {
38 templateString: "<span class='dojoxTestWidget'></span>"
39 });
40
41 doh.register("parse", function(){
42 parser.parse();
43
44 pane1 = registry.byId('parsedPane');
45 dialogCtrPane = registry.byId("dialogContainer");
46 });
47
48 doh.register("basicChecks", [
49 {
50 name: 'setContent',
51 runTest: function(t){
52 console.log("basicChecks: " + this.name);
53 var msg = "Simple Test";
54 pane1.set('content', msg);
55 t.is(msg, pane1.domNode.innerHTML);
56 }
57 },
58 {
59 name: 'parseInitialContent',
60 runTest: function(t){
61 console.log("basicChecks: " + this.name);
62 var parserTest = registry.byId("parserTest");
63 t.t(parserTest);
64 }
65 },
66 {
67 name: 'parseNewContent',
68 runTest: function(t){
69 console.log("basicChecks: " + this.name);
70 dialogCtrPane.set(
71 "content",
72 '<div data-dojo-type="dijit/Dialog" id="sacrificialDlg" title="Life is short for this fellow">'
73 +' <p>This dialog should be cleanly destroyed when the unit tests run</p>'
74 +'</div>'
75 );
76
77 t.t(registry.byId("sacrificialDlg"));
78 t.f(registry.byId("parserTest"));
79 }
80 },
81 {
82 name: 'empty',
83 runTest: function(t){
84 console.log("basicChecks: " + this.name);
85 t.t(registry.byId("sacrificialDlg"));
86
87 var dialog = registry.byId("sacrificialDlg");
88 // dialog is supposed to move its domNode to the body..
89 // we need to check it gets cleanly removed when we set content on the CP
90 t.t(dialog);
91 t.t(dialog.domNode.parentNode == document.body);
92
93 dialogCtrPane.set('content', "new content, no more dialog");
94 t.f(registry.byId("sacrificialDlg"));
95 t.f(dom.byId("sacrificialDlg"));
96 }
97 },
98 {
99 name: 'reuse',
100 runTest: function(t){
101 console.log("basicChecks: " + this.name);
102 // do the same thing over again - we should be error free
103 dialogCtrPane.set(
104 "content",
105 '<div data-dojo-type="dijit/Dialog" id="sacrificialDlg" title="Life is short for this fellow">'
106 +' <p>This dialog should be cleanly destroyed when the unit tests run</p>'
107 +'</div>'
108 );
109 var dialog = registry.byId("sacrificialDlg");
110 // dialog is supposed to move its domNode to the body..
111 // we need to check it gets cleanly removed when we set content on the CP
112 t.t(dialog);
113 t.t(dialog.domNode.parentNode == document.body);
114 }
115 },
116 {
117 name: 'destroy',
118 runTest: function(t){
119 console.log("basicChecks: " + this.name);
120
121 // manually stick a widget into the ContentPane
122 var manualWidget = new TestWidget({id: "destroyTestWidget"});
123 domConstruct.place(manualWidget.domNode, dialogCtrPane.domNode, "last");
124
125 // make sure widget created via get('content') and also the above widget are there
126 t.t(registry.byId("sacrificialDlg"), "dialog in dialogContainer still there");
127 t.t(registry.byId("destroyTestWidget"), "test widget in dialogContainer still there");
128
129 // when we kill the CP, it should also destroy any widgets created when we set content,
130 // and for backwards-compatibility reasons, any widgets that user stuck in there
131 // manually too
132 dialogCtrPane.destroyRecursive();
133
134 // make sure everything got deleted
135 t.f(registry.byId("dialogContainer"));
136 t.f(registry.byId("sacrificialDlg"), "dialog in dialogContainer was destroyed");
137 t.f(registry.byId("destroyTestWidget"), "test widget in dialogContainer was destroyed");
138 t.f(dom.byId("sacrificialDlg"));
139 }
140 }
141 ]);
142
143 doh.run();
144 });
145 </script>
146
147 </head>
148 <body class="claro" role="main">
149
150 <h1 class="testTitle">Dijit layout.ContentPane tests</h1>
151 <p>pre-container paragraph</p>
152
153 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='"class":"box"'>
154 some text (top-level container)
155
156 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='"class":"box"'>
157
158 text in the inner container (1)
159
160 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='"class":"box", href:"tab2.html"'>
161 hi
162 </div>
163
164 text in the inner container (2)
165
166 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='"class":"box"'>
167 inner-inner 2
168 </div>
169
170 text in the inner container (3)
171
172 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='"class":"box"'>
173 inner-inner 3
174 </div>
175
176 text in the inner container (4)
177
178 </div>
179
180 some more text (top-level container)
181 </div>
182
183 <p>mid-container paragraph</p>
184
185 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='"class":"box"'>
186 2nd top-level container
187 </div>
188
189 <p>post-container paragraph</p>
190
191 <div id="test" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='"class":"box", href:"combotab.html" '>
192 <p style='background-color:yellow;border:1px solid red;text-align:center;'>This text should automatically be replaced by downloaded content from combotab.html</p>
193 </div>
194
195 <hr/>
196 <p>ContentPanes used by the unit tests to verify functionality
197 <div id='parsedPane' data-dojo-type="dijit/layout/ContentPane" data-dojo-props='"class":"box" '>
198 Some Content Here
199 </div>
200 <div id='dialogContainer' data-dojo-type="dijit/layout/ContentPane" data-dojo-props='"class":"box" '>
201 <div id="parserTest" data-dojo-type="TestWidget" ></div>
202 </div>
203 </body>
204 </html>