|
1 | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
2 | | - "http://www.w3.org/TR/html4/strict.dtd"> |
| 2 | + "http://www.w3.org/TR/html4/strict.dtd"> |
3 | 3 | <html lang="en"> |
4 | 4 | <head> |
5 | 5 | <title>hover</title> |
6 | | - <style type='text/css'> |
7 | | - body {font-family: verdana} |
8 | | - .error {border: solid 1px red;} |
9 | | - .error_text { color: red; font-size: 10px;} |
10 | | - td {padding: 3px;} |
11 | | - </style> |
| 6 | + <style type='text/css'> |
| 7 | + body {font-family: verdana} |
| 8 | + .error {border: solid 1px red;} |
| 9 | + .error_text { color: red; font-size: 10px;} |
| 10 | + td {padding: 3px;} |
| 11 | + .list-test, .object-list-test, .nested-object-test {color: blue; cursor: pointer; text-decoration: underline;} |
| 12 | + </style> |
12 | 13 | </head> |
13 | 14 | <body> |
14 | 15 | <div id="history_demo"> |
15 | 16 | <a href="#first¶m=I">First</a> |
16 | 17 | <a href="#second¶m=love">Second</a> |
17 | 18 | <a href="#third¶m=jmvc!">Third</a> |
| 19 | + <a class="list-test">Fourth</a> |
| 20 | + <a class="object-list-test">Fifth</a> |
| 21 | + <a class="nested-object-test">Sixth</a> |
18 | 22 | </div> |
19 | | - <script type='text/javascript' |
20 | | - src='../../../steal/steal.js?steal[app]=jquery/controller/history&steal[env]=development' |
21 | | - package='main.js' |
22 | | - compress='false'> |
23 | | - </script> |
24 | | - <script type='text/javascript'> |
25 | | - $.Controller.extend('HistoryDemoController',{ |
26 | | - }, |
27 | | - { |
| 23 | + <script type='text/javascript' src='../../../steal/steal.js?steal[app]=jquery/controller/history&steal[env]=development'> |
| 24 | + </script> |
| 25 | + <script type='text/javascript'> |
| 26 | + $.Controller.extend('HistoryDemoController',{ |
| 27 | + }, |
| 28 | + { |
28 | 29 | "history.first.index subscribe" : function(called, data) { |
29 | 30 | alert("First[param] : " + data.param); |
30 | 31 | }, |
|
35 | 36 |
|
36 | 37 | "history.third.index subscribe" : function(called, data) { |
37 | 38 | alert("Third[param] : " + data.param); |
38 | | - } |
39 | | - }); |
40 | | - |
41 | | - $("#history_demo").history_demo(); |
| 39 | + }, |
| 40 | + |
| 41 | + "history.fourth.index subscribe" : function(called, data) { |
| 42 | + alert("Fourth[myList] : [" + data.myList.join(', ') + "]"); |
| 43 | + }, |
| 44 | + |
| 45 | + "history.fifth.index subscribe" : function(called, data) { |
| 46 | + var obj_list = []; |
| 47 | + $.each(data.myObjectList, function(i, obj) { |
| 48 | + var params = []; |
| 49 | + $.each(obj, function(key, val) {params.push(key + ": " + val);}); |
| 50 | + obj_list.push("{" + params.join(", ") + "}"); |
| 51 | + }); |
| 52 | + alert("Fourth[myObjectList] : [" + obj_list.join(", ") + "]"); |
| 53 | + }, |
| 54 | + |
| 55 | + "history.sixth.index subscribe" : function(called, data) { |
| 56 | + var params = []; |
| 57 | + |
| 58 | + // myObject.a (object) |
| 59 | + var vars_a = []; |
| 60 | + $.each(data.myObject.a, function(key, val) {vars_a.push(key + ": "+val)}); |
| 61 | + params.push("a: {" + vars_a.join(", ") + "}"); |
| 62 | + |
| 63 | + // myObject.b (array) |
| 64 | + params.push("b: [" + data.myObject.b.join(", ") + "]"); |
| 65 | + |
| 66 | + // myObject.c (array of objects) |
| 67 | + var obj_list = []; |
| 68 | + $.each(data.myObject.c, function(i, obj) { |
| 69 | + var obj_params = []; |
| 70 | + $.each(obj, function(key, val) {obj_params.push(key + ": " + val);}); |
| 71 | + obj_list.push("\t{" + obj_params.join(", ") + "}"); |
| 72 | + }); |
| 73 | + params.push("c: [\n" + obj_list.join(",\n ") + "\t\n]"); |
| 74 | + |
| 75 | + alert("Fourth[myObject] : {\n" + params.join(",\n") + "\n}"); |
| 76 | + }, |
| 77 | + |
| 78 | + ".list-test click" : function(el, ev){ |
| 79 | + this.history_add({controller:'fourth', myList:[1,2,3]}); |
| 80 | + }, |
| 81 | + |
| 82 | + ".object-list-test click" : function(el, ev){ |
| 83 | + var myObjectList = [ |
| 84 | + { |
| 85 | + one: 1, |
| 86 | + two: 2, |
| 87 | + three: 3 |
| 88 | + }, |
| 89 | + { |
| 90 | + four: 4, |
| 91 | + five: 5, |
| 92 | + six: 6 |
| 93 | + } |
| 94 | + ]; |
| 95 | + this.history_add({controller:'fifth', myObjectList:myObjectList}); |
| 96 | + }, |
| 97 | + |
| 98 | + ".nested-object-test click" : function(el, ev) { |
| 99 | + var myObject = { |
| 100 | + a: { |
| 101 | + one: 1, |
| 102 | + two: 2, |
| 103 | + three: 3 |
| 104 | + }, |
| 105 | + b: [1, 2, 3], |
| 106 | + c: [ |
| 107 | + { |
| 108 | + one: 1, |
| 109 | + two: 2, |
| 110 | + three: 3 |
| 111 | + }, |
| 112 | + { |
| 113 | + four: 4, |
| 114 | + five: 5, |
| 115 | + six: 6 |
| 116 | + } |
| 117 | + ] |
| 118 | + }; |
| 119 | + this.history_add({controller:'sixth', myObject:myObject}); |
| 120 | + } |
| 121 | + }); |
| 122 | + |
| 123 | + $("#history_demo").history_demo(); |
42 | 124 | </script> |
43 | 125 | </body> |
44 | 126 | </html> |
0 commit comments