1 | <html> |
---|
2 | <head> |
---|
3 | <script language="JavaScript" type="text/javascript"> |
---|
4 | // Dojo configuration |
---|
5 | djConfig = { |
---|
6 | isDebug: true, |
---|
7 | dojoIframeHistoryUrl: "../../resources/iframe_history.html" //for xdomain |
---|
8 | }; |
---|
9 | </script> |
---|
10 | <script type="text/javascript" |
---|
11 | src="../dojo.js" |
---|
12 | data-dojo-config="isDebug:true, dojoIframeHistoryUrl: '../resources/iframe_history.html'"></script> |
---|
13 | <!--script type="text/javascript" src="../back.js"></script--> |
---|
14 | <script type="text/javascript"> |
---|
15 | require(["dojo/_base/lang", "dojo/_base/kernel", "dojo/back", "dojo/dom", "dojo/domReady!"], function(lang, kernel, back, dom){ |
---|
16 | ApplicationState = function(stateData, outputDivId, backForwardOutputDivId, bookmarkValue){ |
---|
17 | this.stateData = stateData; |
---|
18 | this.outputDivId = outputDivId; |
---|
19 | this.backForwardOutputDivId = backForwardOutputDivId; |
---|
20 | this.changeUrl = bookmarkValue || false; |
---|
21 | }; |
---|
22 | |
---|
23 | lang.extend(ApplicationState, { |
---|
24 | back: function(){ |
---|
25 | this.showBackForwardMessage("BACK for State Data: " + this.stateData); |
---|
26 | this.showStateData(); |
---|
27 | }, |
---|
28 | forward: function(){ |
---|
29 | this.showBackForwardMessage("FORWARD for State Data: " + this.stateData); |
---|
30 | this.showStateData(); |
---|
31 | }, |
---|
32 | showStateData: function(){ |
---|
33 | dom.byId(this.outputDivId).innerHTML += this.stateData + '<br />'; |
---|
34 | }, |
---|
35 | showBackForwardMessage: function(message){ |
---|
36 | dom.byId(this.backForwardOutputDivId).innerHTML += message + '<br />'; |
---|
37 | } |
---|
38 | }); |
---|
39 | |
---|
40 | var data = { |
---|
41 | link0: "This is the initial state (page first loaded)", |
---|
42 | "link with spaces": "This is data for a state with spaces", |
---|
43 | "link%20with%20encoded": "This is data for a state with encoded bits", |
---|
44 | "link+with+pluses": "This is data for a state with pluses", |
---|
45 | link1: "This is data for link 1", |
---|
46 | link2: "This is data for link 2", |
---|
47 | link3: "This is data for link 3", |
---|
48 | link4: "This is data for link 4", |
---|
49 | link5: "This is data for link 5", |
---|
50 | link6: "This is data for link 6", |
---|
51 | link7: "This is data for link 7" |
---|
52 | }; |
---|
53 | |
---|
54 | kernel.global.goNav = function goNav(id){ |
---|
55 | var appState = new ApplicationState(data[id], "output", "dataOutput", id); |
---|
56 | appState.showStateData(); |
---|
57 | back.addToHistory(appState); |
---|
58 | }; |
---|
59 | |
---|
60 | var appState = new ApplicationState(data["link0"], "output", "dataOutput"); |
---|
61 | appState.showStateData(); |
---|
62 | back.setInitialState(appState); |
---|
63 | }); |
---|
64 | </script> |
---|
65 | </head> |
---|
66 | <body> |
---|
67 | <script type="text/javascript"> |
---|
68 | require(["dojo/back"], function(back){back.init();}); |
---|
69 | </script> |
---|
70 | <div style="padding-bottom: 20px; width: 100%; border-bottom: 1px solid gray"> |
---|
71 | <h3>dojo.back test</h3> |
---|
72 | |
---|
73 | |
---|
74 | <p>This page tests the dojo.back back/forward code.</p> |
---|
75 | |
---|
76 | <p>The buttons that start with "Link" on them don't use any dojo.xhr* calls, |
---|
77 | just JS data already in the page.</p> |
---|
78 | |
---|
79 | <ul> |
---|
80 | <li>Don't test this page using local disk for MSIE. MSIE will not |
---|
81 | create a history list for iframe_history.html if served from a file: |
---|
82 | URL. Serve the test pages from a web server to test in that browser.</li> |
---|
83 | <li>Safari 2.0.3+ (and probably 1.3.2+): Only the back button works OK |
---|
84 | (not the forward button).</li> |
---|
85 | <li>Opera 8.5.3: Does not work.</li> |
---|
86 | <li>Konqueror: Unknown. The latest may have Safari's behavior.</li> |
---|
87 | </ul> |
---|
88 | </div> |
---|
89 | <div style="float:left; padding: 20px"> |
---|
90 | <button onclick="goNav('link1')">Link 1</button><br /> |
---|
91 | <button onclick="goNav('link with spaces')">Link with Spaces</button><br /> |
---|
92 | <button onclick="goNav('link%20with%20encoded')">Link with Encoded</button><br /> |
---|
93 | <button onclick="goNav('link+with+pluses')">Link with Pluses</button><br /> |
---|
94 | <button onclick="goNav('link3')">Link 3</button><br /> |
---|
95 | <button onclick="goNav('link4')">Link 4</button><br /> |
---|
96 | <button onclick="goNav('link5')">Link 5</button><br /> |
---|
97 | <button onclick="goNav('link6')">Link 6</button><br /> |
---|
98 | <button onclick="goNav('link7')">Link 7</button><br /> |
---|
99 | </div> |
---|
100 | <div style="float: left; padding: 20px"> |
---|
101 | <b>Data Output:</b><br /> |
---|
102 | <div id="output"></div> |
---|
103 | <hr /> |
---|
104 | <i>Back/Forward Info:</i><br /> |
---|
105 | <div id="dataOutput"></div> |
---|
106 | </div> |
---|
107 | </body> |
---|
108 | </html> |
---|