Skip to content
This repository was archived by the owner on May 26, 2025. It is now read-only.

Commit 037e95b

Browse files
author
Pinhook
committed
history updated, this will break changes, but it's lighter and cleaner. List is the new store. Added cookie and local lists
1 parent 8bbdcc1 commit 037e95b

File tree

14 files changed

+473
-266
lines changed

14 files changed

+473
-266
lines changed

controller/history/history.html

Lines changed: 102 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
<!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">
33
<html lang="en">
44
<head>
55
<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>
1213
</head>
1314
<body>
1415
<div id="history_demo">
1516
<a href="#first&param=I">First</a>
1617
<a href="#second&param=love">Second</a>
1718
<a href="#third&param=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>
1822
</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+
{
2829
"history.first.index subscribe" : function(called, data) {
2930
alert("First[param] : " + data.param);
3031
},
@@ -35,10 +36,91 @@
3536

3637
"history.third.index subscribe" : function(called, data) {
3738
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();
42124
</script>
43125
</body>
44126
</html>

0 commit comments

Comments
 (0)