-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalendar.html
More file actions
179 lines (172 loc) · 6.65 KB
/
calendar.html
File metadata and controls
179 lines (172 loc) · 6.65 KB
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
<div class="container theme-showcase">
<h1>Calendar</h1>
<div id="holder" class="row" ></div>
</div>
<script type="text/tmpl" id="tmpl">
{{
var date = date || new Date(),
month = date.getMonth(),
year = date.getFullYear(),
first = new Date(year, month, 1),
last = new Date(year, month + 1, 0),
startingDay = first.getDay(),
thedate = new Date(year, month, 1 - startingDay),
dayclass = lastmonthcss,
today = new Date(),
i, j;
if (mode === 'week') {
thedate = new Date(date);
thedate.setDate(date.getDate() - date.getDay());
first = new Date(thedate);
last = new Date(thedate);
last.setDate(last.getDate()+6);
} else if (mode === 'day') {
thedate = new Date(date);
first = new Date(thedate);
last = new Date(thedate);
last.setDate(thedate.getDate() + 1);
}
}}
<table class="calendar-table table table-condensed table-tight">
<thead>
<tr>
<td colspan="7" style="text-align: center">
<table style="white-space: nowrap; width: 100%">
<tr>
<td style="text-align: left;">
<span class="btn-group">
<button class="js-cal-prev btn btn-default"><</button>
<button class="js-cal-next btn btn-default">></button>
</span>
<button class="js-cal-option btn btn-default {{: first.toDateInt() <= today.toDateInt() && today.toDateInt() <= last.toDateInt() ? 'active':'' }}" data-date="{{: today.toISOString()}}" data-mode="month">{{: todayname }}</button>
</td>
<td>
<span class="btn-group btn-group-lg">
{{ if (mode !== 'day') { }}
{{ if (mode === 'month') { }}<button class="js-cal-option btn btn-link" data-mode="year">{{: months[month] }}</button>{{ } }}
{{ if (mode ==='week') { }}
<button class="btn btn-link disabled">{{: shortMonths[first.getMonth()] }} {{: first.getDate() }} - {{: shortMonths[last.getMonth()] }} {{: last.getDate() }}</button>
{{ } }}
<button class="js-cal-years btn btn-link">{{: year}}</button>
{{ } else { }}
<button class="btn btn-link disabled">{{: date.toDateString() }}</button>
{{ } }}
</span>
</td>
<td style="text-align: right">
<span class="btn-group">
<button class="js-cal-option btn btn-default {{: mode==='year'? 'active':'' }}" data-mode="year">Year</button>
<button class="js-cal-option btn btn-default {{: mode==='month'? 'active':'' }}" data-mode="month">Month</button>
<button class="js-cal-option btn btn-default {{: mode==='week'? 'active':'' }}" data-mode="week">Week</button>
<button class="js-cal-option btn btn-default {{: mode==='day'? 'active':'' }}" data-mode="day">Day</button>
</span>
</td>
</tr>
</table>
</td>
</tr>
</thead>
{{ if (mode ==='year') {
month = 0;
}}
<tbody>
{{ for (j = 0; j < 3; j++) { }}
<tr>
{{ for (i = 0; i < 4; i++) { }}
<td class="calendar-month month-{{:month}} js-cal-option" data-date="{{: new Date(year, month, 1).toISOString() }}" data-mode="month">
{{: months[month] }}
{{ month++;}}
</td>
{{ } }}
</tr>
{{ } }}
</tbody>
{{ } }}
{{ if (mode ==='month' || mode ==='week') { }}
<thead>
<tr class="c-weeks">
{{ for (i = 0; i < 7; i++) { }}
<th class="c-name">
{{: days[i] }}
</th>
{{ } }}
</tr>
</thead>
<tbody>
{{ for (j = 0; j < 6 && (j < 1 || mode === 'month'); j++) { }}
<tr>
{{ for (i = 0; i < 7; i++) { }}
{{ if (thedate > last) { dayclass = nextmonthcss; } else if (thedate >= first) { dayclass = thismonthcss; } }}
<td class="calendar-day {{: dayclass }} {{: thedate.toDateCssClass() }} {{: date.toDateCssClass() === thedate.toDateCssClass() ? 'selected':'' }} {{: daycss[i] }} js-cal-option" data-date="{{: thedate.toISOString() }}">
<div class="date">{{: thedate.getDate() }}</div>
{{ thedate.setDate(thedate.getDate() + 1);}}
</td>
{{ } }}
</tr>
{{ } }}
</tbody>
{{ } }}
{{ if (mode ==='day') { }}
<tbody>
<tr>
<td colspan="7">
<table class="table table-striped table-condensed table-tight-vert" >
<thead>
<tr>
<th> </th>
<th style="text-align: center; width: 100%">{{: days[date.getDay()] }}</th>
</tr>
</thead>
<tbody>
<tr>
<th class="timetitle" >All Day</th>
<td class="{{: date.toDateCssClass() }}"> </td>
</tr>
<tr>
<th class="timetitle" >Before 6 AM</th>
<td class="time-0-0"> </td>
</tr>
{{for (i = 6; i < 22; i++) { }}
<tr>
<th class="timetitle" >{{: i <= 12 ? i : i - 12 }} {{: i < 12 ? "AM" : "PM"}}</th>
<td class="time-{{: i}}-0"> </td>
</tr>
<tr>
<th class="timetitle" >{{: i <= 12 ? i : i - 12 }}:30 {{: i < 12 ? "AM" : "PM"}}</th>
<td class="time-{{: i}}-30"> </td>
</tr>
{{ } }}
<tr>
<th class="timetitle" >After 10 PM</th>
<td class="time-22-0"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
{{ } }}
</table>
</script>
<div class="container">
<hr>
<p>Resources</p>
<ul>
<li><a href="https://github.com/twbs/bootstrap">Bootstrap</a></li>
<li><a href="https://bootstrap-calendar.azurewebsites.net/index-bs3.html">another calendar</a></li>
<li><a href="http://www.bootply.com/rzNQTlDlFX">another calendar</a></li>
<li><a href="http://slipsum.com">lipsum generator</a></li>
</ul>
</div>
<div class="container">
<hr>
<p>Notes</p>
<ul>
<li>clicking on year to open and let you jump around 5ish years, don't care for current ui...</li>
<li>work needed on day mode (buggy, unfinished)</li>
<li>options missing still for classes</li>
<li>not sure about popover contents</li>
<li>? use of success state color and info state color ?</li>
<li><a href="http://www.reddit.com/r/css/comments/2gvw4n/i_refactored_my_less_to_follow_fats_guidelines/">can do better with css rules</a></li>
</ul>
</div>