forked from RubyLouvre/mass-Framework
/
index4.html
297 lines (277 loc) · 11.9 KB
/
index4.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>todos</title>
<style>
.ui-datepicker{
width:244px;
padding:2px;
border:1px solid #D3D3D3;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
min-height: 212px;
-moz-box-shadow: 3px 3px 4px #000;
-webkit-box-shadow: 3px 3px 4px #000;
box-shadow: 3px 3px 4px #000;
}
.ui-datepicker-header{
width:100%;
position: relative;
color: #222222;
font-weight: bold;
padding: .2em 0;
background: #d0d0d0;
background-image: linear-gradient(bottom, rgb(204,204,204) 10%, rgb(143,139,143) 53%, rgb(204,204,204) 91%);
background-image: -o-linear-gradient(bottom, rgb(204,204,204) 10%, rgb(143,139,143) 53%, rgb(204,204,204) 91%);
background-image: -moz-linear-gradient(bottom, rgb(204,204,204) 10%, rgb(143,139,143) 53%, rgb(204,204,204) 91%);
background-image: -webkit-linear-gradient(bottom, rgb(204,204,204) 10%, rgb(143,139,143) 53%, rgb(204,204,204) 91%);
background-image: -ms-linear-gradient(bottom, rgb(204,204,204) 10%, rgb(143,139,143) 53%, rgb(204,204,204) 91%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.1, rgb(204,204,204)),
color-stop(0.53, rgb(143,139,143)),
color-stop(0.91, rgb(204,204,204))
);
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
.ui-datepicker-month{
position: absolute;
top:4px;
color:black;
width: 20px;
height: 20px;
font-family: icomoon;
text-align: center;
vertical-align: middle;
line-height:20px;
padding:4px 2px 1px;
text-decoration: none;
}
.ui-datepicker-month:hover{
background: #e3e3e3;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}
.ui-datepicker-prev{
left:2px;
}
.ui-datepicker-next{
right:2px;
}
.ui-datepicker-title{
margin: 0px 20px;
line-height: 28px;
height: 28px;
text-align: center;
}
.ui-datepicker table {
width:100%;
border-collapse: collapse;
font-size: 13px;
font-family:Verdana,Arial,sans-serif
}
.ui-datepicker thead th {
border: 0 none;
font-weight: bold;
padding: 6px 4px;
text-align: center;
}
.ui-datepicker td {
border: 0 none;
font-size: 13px;
padding: 1px;
}
.ui-datepicker td span{
display: block;
padding: 3px;
text-align: right;
background: #DADADA;
text-decoration: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.ui-datepicker td .disabled{
opacity:0.5;
filter:alpha(opacity=50);
*zoom:1;
}
.ui-datepicker td span:hover{
background: #D4d4d4;
}
.ui-datepicker td .today{
background: #fbf9ef;
border:1px solid #fcefa1;
}
.ui-datepicker td .selected{
background: #fbf9ef;
}
@font-face {
font-family: icomoon;
src: url(more/icomoon.eot);
src: url(//:) format("no404"),
url("more/icomoon.woff") format("woff"),
url("more/icomoon.ttf") format("truetype"),
url("more/icomoon.svg#icomoon") format("svg");
}
</style>
<script src="avalon.js" type="text/javascript"></script>
<script type="text/javascript">
avalon.ready(function() {
var model = avalon.define("datepicker", function(vm) {
vm.changeYear = false
vm.changeMonth = false
vm.minDate = new Date(2013, 4, 25)
//当前时间
vm.current = new Date;
vm.currentMonth = vm.current.getMonth();
vm.currentYear = vm.current.getFullYear();
vm.selectedDate = new Date;
vm.title = {
get: function() {
var format = "";
if (!this.changeYear && this.changeMonth) {
format = "yyyy年";
} else if (this.changeYear && !this.changeMonth) {
format = "MMMM";
} else if (!this.changeYear && !this.changeMonth) {
format = "MMMM yyyy年";
}
return format && avalon.filters.date(this.current, format);
}
};
vm.$weeks = "日一二三四五六".split("");
vm.$months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
function getWeeks() {
var cur = vm.current;
var year = cur.getFullYear();
var month = cur.getMonth();
var date = cur.getDate()
cur.setMonth(month + 1);
cur.setDate(0);
var num = cur.getDate();
var dates = avalon.range(1, num + 1);
dates = dates.map(function(d) {
var timestamp = new Date(year, month + 1, d) - 0
var disabled = false;
if (vm.minDate) {
disabled = timestamp < vm.minDate - 0;
}
if (disabled && vm.maxDate) {
disabled = timestamp > vm.maxDate - 0;
}
return [year, month, d, disabled];
});
cur.setMonth(month);
cur.setDate(1);
var before = cur.getDay();
var shim = new Array(before);//在前面被上几个空白
dates = shim.concat(dates);
cur.setDate(date);//还原
var ret = [];
while (dates.length) {
ret.push(dates.splice(0, 7));
}
return ret;
}
vm.candidateWeeks = getWeeks();
function getYears() {
var y = vm.currentYear;
return avalon.range(y - 10, y + 10);
}
vm.candidateYears = getYears();
vm.nextMonth = function() {
var date = vm.current;
var m = date.getMonth();
vm.$fire("currentMonth", m + 1)
};
vm.prevMonth = function() {
var date = vm.current;
var m = date.getMonth();
vm.$fire("currentMonth", m - 1);
};
vm.$watch("currentMonth", function(val) {
var date = vm.current;
date.setMonth(val);
if (vm.currentMonth != val)
vm.currentMonth = val;
vm.candidateWeeks = getWeeks();
vm.title = date - 0;
});
vm.$watch("currentYear", function(val) {
var date = vm.current;
date.setFullYear(val);
if (vm.currentYear != val)
vm.currentYear = val;
vm.$fire("currentMonth", date.getMonth());
});
//高亮当前选中的事件
vm.select = function(e) {
var el = e.target;
if (el.tagName === "SPAN" && el.parentNode.tagName === "TD" && !/disabled/.test(el.className)) {
vm.selected = el.innerHTML;
var d = el.$scope.day.slice(0, 3);
vm.selectedDate = new Date(d[0], d[1], d[2]);
}
};
vm.selected = "";
vm.isSelected = function() {
return this.innerHTML === vm.selected;
};
var today = new Date;
today = [today.getFullYear(), today.getMonth(), today.getDate()].join();
vm.isToday = function() {
var day = this.$scope && this.$scope.day;
return day && day.slice(0, 3).join() === today;
};
});
avalon.scan();
});
</script>
</head>
<body ms-controller="datepicker">
<div class="ui-datepicker" >
<div class="ui-datepicker-header">
<a href="###" title="Prev" class="ui-datepicker-month ui-datepicker-prev" ms-click="prevMonth">
<
</a>
<a href="###"title="Next" class="ui-datepicker-month ui-datepicker-next" ms-click="nextMonth">
>
</a >
<div class="ui-datepicker-title" >
<select ms-each-month="$months" ms-if="changeMonth" ms-model="currentMonth" >
<option value="{{month}}" ms-selected="currentMonth === month">{{month+1}}月</option>
</select>
<select ms-each-year="candidateYears" ms-if="changeYear" ms-model="currentYear" >
<option value="{{year}}" ms-selected="currentYear === year">{{year}}年</option>
</select>
{{title}}
</div>
</div>
<table ms-click="select">
<thead>
<tr ms-each-date="$weeks">
<th>{{date}}</th>
</tr>
</thead>
<tbody ms-each-week="candidateWeeks">
<tr ms-each-day="week" >
<td><span ms-visible="day" ms-class-selected="isSelected" ms-class-disabled="day && day[3]" ms-class-today="isToday" >{{ day[2] }}</span></td>
</tr>
</tbody>
</table>
</div>
<p><input type="radio" ms-model="changeMonth" />可选择月份</br/>
<input type="radio" ms-model="changeYear" />可选择年份</p>
<div class="font">{{selectedDate | date("yyyy-MM-d")}}</div>
<div class="font">abcdefghijklmnopqrstuvwxyz</div>
<div class="font">ABCDFGHIJKLMNOPQRSTUVWXYZ</div>
</body>
</html>