-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathindex-sub.html
200 lines (188 loc) · 5.2 KB
/
index-sub.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello MUI</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.min.css">
<link rel="stylesheet" href="css/app.css" />
<style>
.addrec {
padding: 5px;
}
.name {
font-size: 14px;
line-height: 30px;
height: 30px;
overflow: hidden;
text-align: center;
}
</style>
</head>
<body>
<div class="mui-content mui-scroll-wrapper" id="pullrefresh">
<div class="mui-scroll">
<!--轮播图-->
<div id="carouselSlider" class="mui-slider">
<div class="mui-slider-group mui-slider-loop" id="loop">
</div>
<div class="mui-slider-indicator mui-text-right" id="indicator">
</div>
</div>
<div class="addrec">
<div class="mui-slider" id="addRecommendSlider">
</div>
</div>
</div>
</div>
<script type="text/template" id="loopTpl">
<div class="mui-slider-item mui-slider-item-duplicate">
<a href="javascript:;" data-url="<%=list[list.length-1].url%>">
<img src="<%=list[list.length-1].img%>">
<p class="mui-slider-title">
<%=list[list.length-1].title%>
</p>
</a>
</div>
<% _.each(list, function(v, i){ %>
<div class="mui-slider-item">
<a href="javascript:;" data-url="<%=v.url%>">
<img src="<%=v.img%>">
<p class="mui-slider-title">
<%=v.title%>
</p>
</a>
</div>
<% }) %>
<!-- 额外增加的一个节点(循环轮播:最后一个节点是第一张轮播) -->
<div class="mui-slider-item mui-slider-item-duplicate">
<a href="javascript:;" data-url="<%=list[0].url%>">
<img src="<%=list[0].img%>">
<p class="mui-slider-title">
<%=list[0].title%>
</p>
</a>
</div>
</script>
<script type="text/template" id="indicatorTpl">
<% _.each(list, function(v, i){ %>
<% if(i == 0){ %>
<div class="mui-indicator mui-active"></div>
<% } else { %>
<div class="mui-indicator"></div>
<% } %>
<% }) %>
</script>
<script type="text/template" id="sliderTpl">
<div id="sliderSegmentedControl" class="mui-segmented-control mui-segmented-control-inverted">
<% _.each(list, function(v, i){ %>
<a class="mui-control-item <%if(i == 0){%> mui-active <%}%>" href="#item<%=i+1%>">
<%=_.template.title(v.tab.title)%>
</a>
<% }) %>
</div>
<div id="list">
<% _.each(list, function(v, i){ %>
<div id="item<%=i+1%>" class="mui-control-content <%if(i==0){%> mui-active<%}%>">
<ul class="mui-table-view mui-grid-view mui-grid-9">
<% _.each(v.list, function(vv, ii){ %>
<li class="mui-table-view-cell mui-media mui-col-xs-6" style="padding: 5px;" data-url="<%=vv.url%>">
<a href="javascript:;">
<img src="<%=vv.img%>" width="100%" />
<p class="mui-slider-title" style="text-align:center;text-indent:0;opacity:.7;">
<%=vv.update%>
</p>
</a>
<p class="name">
<%=vv.name%>
</p>
</li>
<% }) %>
</ul>
</div>
<% }) %>
</div>
</script>
<script src="js/mui.min.js"></script>
<script src="js/zepto.min.js"></script>
<script src="js/underscore.js"></script>
<script src="js/common.js"></script>
<script>
var loopTplRender = _.template($("#loopTpl").html());
var indicatorTplRender = _.template($("#indicatorTpl").html());
var sliderTplRender = _.template($("#sliderTpl").html());
_.template.title = function(title) {
if(title) {
return title.replace("动漫", "");
} else {
return "-";
}
};
mui.init({
pullRefresh: {
container: '#pullrefresh',
down: {
callback: pulldownRefresh
}
}
});
mui.plusReady(function() {
pulldownRefresh();
$("#loop").on("tap", "a", function() {
var url = $(this).attr("data-url");
console.log(url);
Common.open("news-detail.html", "news-detail.html", {
url: encodeURIComponent(url)
});
});
$("#addRecommendSlider").on("tap", "li", function() {
var url = $(this).attr("data-url");
Common.open("animate-detail.html", "animate-detail.html", {
url: encodeURIComponent(url)
});
});
});
function carousel() {
$.ajax({
url: Common.api + '/carousel',
async: true,
cache: false,
method: 'get',
dataType: 'json',
success: function(data) {
var obj = {
list: data
};
$("#loop").html(loopTplRender(obj));
$("#indicator").html(indicatorTplRender(obj));
mui("#carouselSlider").slider({
interval: 5000
});
}
});
}
function addRecommend() {
$.ajax({
url: Common.api + '/addRecommend',
async: true,
cache: false,
method: 'get',
dataType: 'json',
success: function(data) {
var obj = {
list: data
};
$("#addRecommendSlider").html(sliderTplRender(obj));
mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
}
});
}
function pulldownRefresh() {
carousel();
addRecommend();
}
</script>
</body>
</html>