-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
178 lines (163 loc) · 5.24 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<title>Test MVC</title>
<style>
.menu {
position: absolute;
width: 200px;
top: 0;
bottom: 0;
left: -200px;
background: #EEE;
transition: left .3s linear;
}
.menu.show {
left: 0;
}
.menu-switch {
position: absolute;
width: 20px;
height: 40px;
top: 40px;
right: -20px;
background: #424782;
}
</style>
</head>
<body>
<div id="jsTest" style="display: none;">
<div><span>姓名:</span><span n-bind="userinfo.name"></span><span>年龄:</span><span n-bind="userinfo.age"></span></div>
<h1 n-bind="title"></h1>
<h1 n-bind-once="title"></h1>
<input n-bind="username" type="radio" name="name" value="liu1">liu1
<input n-bind="username" type="radio" name="name" value="liu2">liu2
<input n-bind="username" type="radio" name="name" value="liu3">liu3
<p>我的姓名是: <span n-bind="username"></span></p>
<input n-bind="jobs" type="checkbox" name="jobs" value="teacher">老师<br>
<input n-bind="jobs" type="checkbox" name="jobs" value="student">学生<br>
<input n-bind="jobs" type="checkbox" name="jobs" value="programer">程序员<br>
<select n-bind="secondJob" name="type" id="">
<option value="">请选择</option>
<option value="teacher">老师</option>
<option value="student">学生</option>
<option value="programer">程序员</option>
</select>
<p>你的第二职业是:<span n-bind="secondJob"></span></p>
<h2 n-bind="info.subTitle.title"></h2>
<ul n-repeat="items" n-template="user-tmpl"></ul>
<div n-delegate="jsClick,click,sayHello"><button class="jsClick">click me</button></div>
<button n-on="click,sayHello">点击我</button>
<div n-show="isShow" style="width: 100px; height: 100px; background: #DDD;"></div>
<span n-show="isShow">我是行内,也会消失</span>
<button n-on="click,showBlock">显示</button>
<input type="text" name="myname" n-bind="myname">
<p>我的名字是:<span n-bind="myname" n-filter="parseName"></span></p>
</div>
<div id="jsScroll" n-scroll="handleScroll" style="height: 300px; overflow: scroll;">
<ul n-repeat="items" n-template="user-tmpl" style="background: #EEE;"></ul>
<div n-show="loading" style="text-align: center;">加载中...</div>
<div n-hide="loading" style="text-align: center;">已经加载完成</div>
<div class="menu" n-class="isOpen:show light">
<div class="menu-switch" n-on="click,switchMenu"></div>
</div>
</div>
</body>
<script type="text/html" id="user-tmpl">
<li><span>姓名:</span><span>{name}</span><span>年龄:</span><span>{age}</span></li>
</script>
<script type="text/javascript" src="js/ze.js"></script>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript">
var isShow = true;
var $userinfo = new Ze.VM({
view: 'jsTest',
methods: {
sayHello: function () {
alert('hello world');
},
showBlock: function () {
$userinfo.model.set('isShow', isShow = !isShow);
},
parseName: function(value) {
return '我是加工了的名字:' + value;
}
}
});
setTimeout(function() {
$userinfo.model.set({
userinfo: {
name: 'liuzesen',
age: 18
},
title: 'hello world',
username: 'liu1',
jobs: ['programer', 'student'],
secondJob: 'programer',
//info: {subTitle: {title: 'sub to you'} }
isShow: true,
items: [
{name: 'liuzesen', age: 1},
{name: 'zesonliu', age: 2},
{name: 'zesonliu', age: 3},
{name: 'zesonliu', age: 4},
{name: 'zesonliu', age: 5},
{name: 'zesonliu', age: 6},
{name: 'zesonliu', age: 7},
{name: 'zesonliu', age: 8}
]
});
}, 1000);
setTimeout(function () {
$userinfo.model.set('title', 'hello world11111111111111111');
$userinfo.model.splice('items', 2, 2, {name: 'liuzesen', age: 100});
$userinfo.model.splice('items', 0, 0, {name: 'liuzesen11111', age: 1001111});
}, 2000);
setTimeout(function () {
$userinfo.model.push('items', [{name: 'liuzesen1111', age: 100}, {name: 'liuzesen2222', age: 100}, {name: 'liuzesen3333', age: 100}]);
}, 4000);
/*setTimeout(function() {
$userinfo.model.set('info.subTitle', 'again sub to you');
$userinfo.model.push('items', [{name: 'zesonliu', age: 30}, {name: 'zesonliu', age: 30}]);
}, 1000);*/
/*var baseUrl = 'http://test.apps.gzh.qq.com/smvc/?r='
ajax.get(baseUrl + 'test/test', function(data) {
console.log(data);
});*/
var $scroller = new Ze.VM({
view: 'jsScroll',
model: {
loading: true,
isOpen: false,
items: [
{name: 'liuzesen', age: 1},
{name: 'zesonliu', age: 2},
{name: 'zesonliu', age: 3},
{name: 'zesonliu', age: 4},
{name: 'zesonliu', age: 5},
{name: 'zesonliu', age: 6},
{name: 'zesonliu', age: 7}
]
},
methods: {
handleScroll: function (handle) {
var me = this;
handle.atBottom(10, function () {
me.model.set('loading', true);
handle.stopListen();
setTimeout(function () {
me.model.push('items', [{name: 'liuzesen1111', age: 100}, {name: 'liuzesen2222', age: 100}, {name: 'liuzesen3333', age: 100}]);
me.model.set('loading', false);
handle.beginListen();
}, 3000);
});
},
switchMenu: function () {
$scroller.model.set('isOpen', !$scroller.model.get('isOpen'));
}
}
});
</script>
</html>