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
|
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Calendar - Display month & year menus</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js">
$.widget( "ui.calendar", $.ui.calendar, {
_buildTitleMonth: function() {
var select = $( "<select>" ),
date = this._getDate().clone(),
i = 0,
option;
this._on( select, {
change: function() {
this._off( select );
this._getDate().setFullDate(
this._getDate().year(),
select.val(),
this._getDate().day()
);
this._updateView();
}
} );
for ( ; i < 12; i++ ) {
date.setFullDate( select.val(), i, this._getDate().day() );
option = $( "<option>", { val: i, text: date.monthName() } );
if ( this._getDate().month() === i ) {
option.prop( "selected", true );
}
select.append( option );
}
return select;
},
_buildTitleYear: function() {
var current = new Date(),
select = $( "<select>" ),
i = current.getFullYear(),
option;
this._on( select, {
change: function() {
this._off( select );
this._getDate().setFullDate(
select.val(),
this._getDate().month(),
this._getDate().day()
);
this._updateView();
}
} );
for ( ;i <= current.getFullYear() + 10; i++ ) {
option = $( "<option>", { val: i, text: i } );
if ( this._getDate().year() === i ) {
option.prop( "selected", true );
}
select.append( option );
}
return select;
}
});
$( "#calendar" ).calendar();
</script>
</head>
<body>
<div id="calendar"></div>
<div class="demo-description">
<p>Show month and year dropdowns in place of the static month/year header to facilitate navigation through large timeframes.</p>
</div>
</body>
</html>
|