coalescing_panda 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/bootstrap/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/bootstrap/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/bootstrap/bootstrap-datepicker.js +1247 -0
- data/app/assets/javascripts/bootstrap/bootstrap.js +6 -0
- data/app/assets/javascripts/coalescing_panda/application.js +0 -2
- data/app/assets/javascripts/coalescing_panda/oauth2.js.coffee +1 -1
- data/app/assets/stylesheets/bootstrap/bootstrap-datepicker.css +449 -0
- data/app/assets/stylesheets/bootstrap/bootstrap-overrides.css +40 -0
- data/app/assets/stylesheets/bootstrap/bootstrap-responsive.css +9 -0
- data/app/assets/stylesheets/bootstrap/bootstrap.css.scss +9 -0
- data/lib/coalescing_panda/version.rb +1 -1
- data/lib/coalescing_panda.rb +4 -1
- metadata +42 -4
- data/app/assets/javascripts/coalescing_panda/coalescing_panda/oauth2.js +0 -2
- data/app/assets/stylesheets/coalescing_panda/coalescing_panda/oauth2.css +0 -4
Binary file
|
Binary file
|
@@ -0,0 +1,1247 @@
|
|
1
|
+
/* =========================================================
|
2
|
+
* bootstrap-datepicker.js
|
3
|
+
* http://www.eyecon.ro/bootstrap-datepicker
|
4
|
+
* =========================================================
|
5
|
+
* Copyright 2012 Stefan Petre
|
6
|
+
* Improvements by Andrew Rowls
|
7
|
+
*
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
* you may not use this file except in compliance with the License.
|
10
|
+
* You may obtain a copy of the License at
|
11
|
+
*
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
*
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
* See the License for the specific language governing permissions and
|
18
|
+
* limitations under the License.
|
19
|
+
* ========================================================= */
|
20
|
+
|
21
|
+
!function( $ ) {
|
22
|
+
|
23
|
+
function UTCDate(){
|
24
|
+
return new Date(Date.UTC.apply(Date, arguments));
|
25
|
+
}
|
26
|
+
function UTCToday(){
|
27
|
+
var today = new Date();
|
28
|
+
return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
|
29
|
+
}
|
30
|
+
|
31
|
+
// Picker object
|
32
|
+
|
33
|
+
var Datepicker = function(element, options) {
|
34
|
+
var that = this;
|
35
|
+
|
36
|
+
this._process_options(options);
|
37
|
+
|
38
|
+
this.element = $(element);
|
39
|
+
this.format = DPGlobal.parseFormat(this.o.format);
|
40
|
+
this.isInline = false;
|
41
|
+
this.isInput = this.element.is('input');
|
42
|
+
this.component = this.element.is('.date') ? this.element.find('.add-on, .btn') : false;
|
43
|
+
this.hasInput = this.component && this.element.find('input').length;
|
44
|
+
if(this.component && this.component.length === 0)
|
45
|
+
this.component = false;
|
46
|
+
|
47
|
+
this.picker = $(DPGlobal.template);
|
48
|
+
this._buildEvents();
|
49
|
+
this._attachEvents();
|
50
|
+
|
51
|
+
if(this.isInline) {
|
52
|
+
this.picker.addClass('datepicker-inline').appendTo(this.element);
|
53
|
+
} else {
|
54
|
+
this.picker.addClass('datepicker-dropdown dropdown-menu');
|
55
|
+
}
|
56
|
+
|
57
|
+
if (this.o.rtl){
|
58
|
+
this.picker.addClass('datepicker-rtl');
|
59
|
+
this.picker.find('.prev i, .next i')
|
60
|
+
.toggleClass('icon-arrow-left icon-arrow-right');
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
this.viewMode = this.o.startView;
|
65
|
+
|
66
|
+
if (this.o.calendarWeeks)
|
67
|
+
this.picker.find('tfoot th.today')
|
68
|
+
.attr('colspan', function(i, val){
|
69
|
+
return parseInt(val) + 1;
|
70
|
+
});
|
71
|
+
|
72
|
+
this._allow_update = false;
|
73
|
+
|
74
|
+
this.setStartDate(this.o.startDate);
|
75
|
+
this.setEndDate(this.o.endDate);
|
76
|
+
this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
|
77
|
+
|
78
|
+
this.fillDow();
|
79
|
+
this.fillMonths();
|
80
|
+
|
81
|
+
this._allow_update = true;
|
82
|
+
|
83
|
+
this.update();
|
84
|
+
this.showMode();
|
85
|
+
|
86
|
+
if(this.isInline) {
|
87
|
+
this.show();
|
88
|
+
}
|
89
|
+
};
|
90
|
+
|
91
|
+
Datepicker.prototype = {
|
92
|
+
constructor: Datepicker,
|
93
|
+
|
94
|
+
_process_options: function(opts){
|
95
|
+
// Store raw options for reference
|
96
|
+
this._o = $.extend({}, this._o, opts);
|
97
|
+
// Processed options
|
98
|
+
var o = this.o = $.extend({}, this._o);
|
99
|
+
|
100
|
+
// Check if "de-DE" style date is available, if not language should
|
101
|
+
// fallback to 2 letter code eg "de"
|
102
|
+
var lang = o.language;
|
103
|
+
if (!dates[lang]) {
|
104
|
+
lang = lang.split('-')[0];
|
105
|
+
if (!dates[lang])
|
106
|
+
lang = $.fn.datepicker.defaults.language;
|
107
|
+
}
|
108
|
+
o.language = lang;
|
109
|
+
|
110
|
+
switch(o.startView){
|
111
|
+
case 2:
|
112
|
+
case 'decade':
|
113
|
+
o.startView = 2;
|
114
|
+
break;
|
115
|
+
case 1:
|
116
|
+
case 'year':
|
117
|
+
o.startView = 1;
|
118
|
+
break;
|
119
|
+
default:
|
120
|
+
o.startView = 0;
|
121
|
+
}
|
122
|
+
|
123
|
+
switch (o.minViewMode) {
|
124
|
+
case 1:
|
125
|
+
case 'months':
|
126
|
+
o.minViewMode = 1;
|
127
|
+
break;
|
128
|
+
case 2:
|
129
|
+
case 'years':
|
130
|
+
o.minViewMode = 2;
|
131
|
+
break;
|
132
|
+
default:
|
133
|
+
o.minViewMode = 0;
|
134
|
+
}
|
135
|
+
|
136
|
+
o.startView = Math.max(o.startView, o.minViewMode);
|
137
|
+
|
138
|
+
o.weekStart %= 7;
|
139
|
+
o.weekEnd = ((o.weekStart + 6) % 7);
|
140
|
+
|
141
|
+
var format = DPGlobal.parseFormat(o.format)
|
142
|
+
if (o.startDate !== -Infinity) {
|
143
|
+
o.startDate = DPGlobal.parseDate(o.startDate, format, o.language);
|
144
|
+
}
|
145
|
+
if (o.endDate !== Infinity) {
|
146
|
+
o.endDate = DPGlobal.parseDate(o.endDate, format, o.language);
|
147
|
+
}
|
148
|
+
|
149
|
+
o.daysOfWeekDisabled = o.daysOfWeekDisabled||[];
|
150
|
+
if (!$.isArray(o.daysOfWeekDisabled))
|
151
|
+
o.daysOfWeekDisabled = o.daysOfWeekDisabled.split(/[,\s]*/);
|
152
|
+
o.daysOfWeekDisabled = $.map(o.daysOfWeekDisabled, function (d) {
|
153
|
+
return parseInt(d, 10);
|
154
|
+
});
|
155
|
+
},
|
156
|
+
_events: [],
|
157
|
+
_secondaryEvents: [],
|
158
|
+
_applyEvents: function(evs){
|
159
|
+
for (var i=0, el, ev; i<evs.length; i++){
|
160
|
+
el = evs[i][0];
|
161
|
+
ev = evs[i][1];
|
162
|
+
el.on(ev);
|
163
|
+
}
|
164
|
+
},
|
165
|
+
_unapplyEvents: function(evs){
|
166
|
+
for (var i=0, el, ev; i<evs.length; i++){
|
167
|
+
el = evs[i][0];
|
168
|
+
ev = evs[i][1];
|
169
|
+
el.off(ev);
|
170
|
+
}
|
171
|
+
},
|
172
|
+
_buildEvents: function(){
|
173
|
+
if (this.isInput) { // single input
|
174
|
+
this._events = [
|
175
|
+
[this.element, {
|
176
|
+
focus: $.proxy(this.show, this),
|
177
|
+
keyup: $.proxy(this.update, this),
|
178
|
+
keydown: $.proxy(this.keydown, this)
|
179
|
+
}]
|
180
|
+
];
|
181
|
+
}
|
182
|
+
else if (this.component && this.hasInput){ // component: input + button
|
183
|
+
this._events = [
|
184
|
+
// For components that are not readonly, allow keyboard nav
|
185
|
+
[this.element.find('input'), {
|
186
|
+
focus: $.proxy(this.show, this),
|
187
|
+
keyup: $.proxy(this.update, this),
|
188
|
+
keydown: $.proxy(this.keydown, this)
|
189
|
+
}],
|
190
|
+
[this.component, {
|
191
|
+
click: $.proxy(this.show, this)
|
192
|
+
}]
|
193
|
+
];
|
194
|
+
}
|
195
|
+
else if (this.element.is('div')) { // inline datepicker
|
196
|
+
this.isInline = true;
|
197
|
+
}
|
198
|
+
else {
|
199
|
+
this._events = [
|
200
|
+
[this.element, {
|
201
|
+
click: $.proxy(this.show, this)
|
202
|
+
}]
|
203
|
+
];
|
204
|
+
}
|
205
|
+
|
206
|
+
this._secondaryEvents = [
|
207
|
+
[this.picker, {
|
208
|
+
click: $.proxy(this.click, this)
|
209
|
+
}],
|
210
|
+
[$(window), {
|
211
|
+
resize: $.proxy(this.place, this)
|
212
|
+
}],
|
213
|
+
[$(document), {
|
214
|
+
mousedown: $.proxy(function (e) {
|
215
|
+
// Clicked outside the datepicker, hide it
|
216
|
+
if (!(
|
217
|
+
this.element.is(e.target) ||
|
218
|
+
this.element.find(e.target).size() ||
|
219
|
+
this.picker.is(e.target) ||
|
220
|
+
this.picker.find(e.target).size()
|
221
|
+
)) {
|
222
|
+
this.hide();
|
223
|
+
}
|
224
|
+
}, this)
|
225
|
+
}]
|
226
|
+
];
|
227
|
+
},
|
228
|
+
_attachEvents: function(){
|
229
|
+
this._detachEvents();
|
230
|
+
this._applyEvents(this._events);
|
231
|
+
},
|
232
|
+
_detachEvents: function(){
|
233
|
+
this._unapplyEvents(this._events);
|
234
|
+
},
|
235
|
+
_attachSecondaryEvents: function(){
|
236
|
+
this._detachSecondaryEvents();
|
237
|
+
this._applyEvents(this._secondaryEvents);
|
238
|
+
},
|
239
|
+
_detachSecondaryEvents: function(){
|
240
|
+
this._unapplyEvents(this._secondaryEvents);
|
241
|
+
},
|
242
|
+
_trigger: function(event, altdate){
|
243
|
+
var date = altdate || this.date,
|
244
|
+
local_date = new Date(date.getTime() + (date.getTimezoneOffset()*60000));
|
245
|
+
|
246
|
+
this.element.trigger({
|
247
|
+
type: event,
|
248
|
+
date: local_date,
|
249
|
+
format: $.proxy(function(altformat){
|
250
|
+
var format = this.format;
|
251
|
+
if (altformat)
|
252
|
+
format = DPGlobal.parseFormat(altformat);
|
253
|
+
return DPGlobal.formatDate(date, format, this.language);
|
254
|
+
}, this)
|
255
|
+
});
|
256
|
+
},
|
257
|
+
|
258
|
+
show: function(e) {
|
259
|
+
if (!this.isInline)
|
260
|
+
this.picker.appendTo('body');
|
261
|
+
this.picker.show();
|
262
|
+
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
|
263
|
+
this.place();
|
264
|
+
this._attachSecondaryEvents();
|
265
|
+
if (e) {
|
266
|
+
e.preventDefault();
|
267
|
+
}
|
268
|
+
this._trigger('show');
|
269
|
+
},
|
270
|
+
|
271
|
+
hide: function(e){
|
272
|
+
if(this.isInline) return;
|
273
|
+
if (!this.picker.is(':visible')) return;
|
274
|
+
this.picker.hide().detach();
|
275
|
+
this._detachSecondaryEvents();
|
276
|
+
this.viewMode = this.o.startView;
|
277
|
+
this.showMode();
|
278
|
+
|
279
|
+
if (
|
280
|
+
this.o.forceParse &&
|
281
|
+
(
|
282
|
+
this.isInput && this.element.val() ||
|
283
|
+
this.hasInput && this.element.find('input').val()
|
284
|
+
)
|
285
|
+
)
|
286
|
+
this.setValue();
|
287
|
+
this._trigger('hide');
|
288
|
+
},
|
289
|
+
|
290
|
+
remove: function() {
|
291
|
+
this.hide();
|
292
|
+
this._detachEvents();
|
293
|
+
this._detachSecondaryEvents();
|
294
|
+
this.picker.remove();
|
295
|
+
delete this.element.data().datepicker;
|
296
|
+
if (!this.isInput) {
|
297
|
+
delete this.element.data().date;
|
298
|
+
}
|
299
|
+
},
|
300
|
+
|
301
|
+
getDate: function() {
|
302
|
+
var d = this.getUTCDate();
|
303
|
+
return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
|
304
|
+
},
|
305
|
+
|
306
|
+
getUTCDate: function() {
|
307
|
+
return this.date;
|
308
|
+
},
|
309
|
+
|
310
|
+
setDate: function(d) {
|
311
|
+
this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
|
312
|
+
},
|
313
|
+
|
314
|
+
setUTCDate: function(d) {
|
315
|
+
this.date = d;
|
316
|
+
this.setValue();
|
317
|
+
},
|
318
|
+
|
319
|
+
setValue: function() {
|
320
|
+
var formatted = this.getFormattedDate();
|
321
|
+
if (!this.isInput) {
|
322
|
+
if (this.component){
|
323
|
+
this.element.find('input').val(formatted);
|
324
|
+
}
|
325
|
+
} else {
|
326
|
+
this.element.val(formatted);
|
327
|
+
}
|
328
|
+
},
|
329
|
+
|
330
|
+
getFormattedDate: function(format) {
|
331
|
+
if (format === undefined)
|
332
|
+
format = this.format;
|
333
|
+
return DPGlobal.formatDate(this.date, format, this.o.language);
|
334
|
+
},
|
335
|
+
|
336
|
+
setStartDate: function(startDate){
|
337
|
+
this._process_options({startDate: startDate});
|
338
|
+
this.update();
|
339
|
+
this.updateNavArrows();
|
340
|
+
},
|
341
|
+
|
342
|
+
setEndDate: function(endDate){
|
343
|
+
this._process_options({endDate: endDate});
|
344
|
+
this.update();
|
345
|
+
this.updateNavArrows();
|
346
|
+
},
|
347
|
+
|
348
|
+
setDaysOfWeekDisabled: function(daysOfWeekDisabled){
|
349
|
+
this._process_options({daysOfWeekDisabled: daysOfWeekDisabled});
|
350
|
+
this.update();
|
351
|
+
this.updateNavArrows();
|
352
|
+
},
|
353
|
+
|
354
|
+
place: function(){
|
355
|
+
if(this.isInline) return;
|
356
|
+
var zIndex = parseInt(this.element.parents().filter(function() {
|
357
|
+
return $(this).css('z-index') != 'auto';
|
358
|
+
}).first().css('z-index'))+10;
|
359
|
+
var offset = this.component ? this.component.parent().offset() : this.element.offset();
|
360
|
+
var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(true);
|
361
|
+
this.picker.css({
|
362
|
+
top: offset.top + height,
|
363
|
+
left: offset.left,
|
364
|
+
zIndex: zIndex
|
365
|
+
});
|
366
|
+
},
|
367
|
+
|
368
|
+
_allow_update: true,
|
369
|
+
update: function(){
|
370
|
+
if (!this._allow_update) return;
|
371
|
+
|
372
|
+
var date, fromArgs = false;
|
373
|
+
if(arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
|
374
|
+
date = arguments[0];
|
375
|
+
fromArgs = true;
|
376
|
+
} else {
|
377
|
+
date = this.isInput ? this.element.val() : this.element.data('date') || this.element.find('input').val();
|
378
|
+
delete this.element.data().date;
|
379
|
+
}
|
380
|
+
|
381
|
+
this.date = DPGlobal.parseDate(date, this.format, this.o.language);
|
382
|
+
|
383
|
+
if(fromArgs) this.setValue();
|
384
|
+
|
385
|
+
if (this.date < this.o.startDate) {
|
386
|
+
this.viewDate = new Date(this.o.startDate);
|
387
|
+
} else if (this.date > this.o.endDate) {
|
388
|
+
this.viewDate = new Date(this.o.endDate);
|
389
|
+
} else {
|
390
|
+
this.viewDate = new Date(this.date);
|
391
|
+
}
|
392
|
+
this.fill();
|
393
|
+
},
|
394
|
+
|
395
|
+
fillDow: function(){
|
396
|
+
var dowCnt = this.o.weekStart,
|
397
|
+
html = '<tr>';
|
398
|
+
if(this.o.calendarWeeks){
|
399
|
+
var cell = '<th class="cw"> </th>';
|
400
|
+
html += cell;
|
401
|
+
this.picker.find('.datepicker-days thead tr:first-child').prepend(cell);
|
402
|
+
}
|
403
|
+
while (dowCnt < this.o.weekStart + 7) {
|
404
|
+
html += '<th class="dow">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
|
405
|
+
}
|
406
|
+
html += '</tr>';
|
407
|
+
this.picker.find('.datepicker-days thead').append(html);
|
408
|
+
},
|
409
|
+
|
410
|
+
fillMonths: function(){
|
411
|
+
var html = '',
|
412
|
+
i = 0;
|
413
|
+
while (i < 12) {
|
414
|
+
html += '<span class="month">'+dates[this.o.language].monthsShort[i++]+'</span>';
|
415
|
+
}
|
416
|
+
this.picker.find('.datepicker-months td').html(html);
|
417
|
+
},
|
418
|
+
|
419
|
+
setRange: function(range){
|
420
|
+
if (!range || !range.length)
|
421
|
+
delete this.range;
|
422
|
+
else
|
423
|
+
this.range = $.map(range, function(d){ return d.valueOf(); });
|
424
|
+
this.fill();
|
425
|
+
},
|
426
|
+
|
427
|
+
getClassNames: function(date){
|
428
|
+
var cls = [],
|
429
|
+
year = this.viewDate.getUTCFullYear(),
|
430
|
+
month = this.viewDate.getUTCMonth(),
|
431
|
+
currentDate = this.date.valueOf(),
|
432
|
+
today = new Date();
|
433
|
+
if (date.getUTCFullYear() < year || (date.getUTCFullYear() == year && date.getUTCMonth() < month)) {
|
434
|
+
cls.push('old');
|
435
|
+
} else if (date.getUTCFullYear() > year || (date.getUTCFullYear() == year && date.getUTCMonth() > month)) {
|
436
|
+
cls.push('new');
|
437
|
+
}
|
438
|
+
// Compare internal UTC date with local today, not UTC today
|
439
|
+
if (this.o.todayHighlight &&
|
440
|
+
date.getUTCFullYear() == today.getFullYear() &&
|
441
|
+
date.getUTCMonth() == today.getMonth() &&
|
442
|
+
date.getUTCDate() == today.getDate()) {
|
443
|
+
cls.push('today');
|
444
|
+
}
|
445
|
+
if (currentDate && date.valueOf() == currentDate) {
|
446
|
+
cls.push('active');
|
447
|
+
}
|
448
|
+
if (date.valueOf() < this.o.startDate || date.valueOf() > this.o.endDate ||
|
449
|
+
$.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1) {
|
450
|
+
cls.push('disabled');
|
451
|
+
}
|
452
|
+
if (this.range){
|
453
|
+
if (date > this.range[0] && date < this.range[this.range.length-1]){
|
454
|
+
cls.push('range');
|
455
|
+
}
|
456
|
+
if ($.inArray(date.valueOf(), this.range) != -1){
|
457
|
+
cls.push('selected');
|
458
|
+
}
|
459
|
+
}
|
460
|
+
return cls;
|
461
|
+
},
|
462
|
+
|
463
|
+
fill: function() {
|
464
|
+
var d = new Date(this.viewDate),
|
465
|
+
year = d.getUTCFullYear(),
|
466
|
+
month = d.getUTCMonth(),
|
467
|
+
startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
|
468
|
+
startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
|
469
|
+
endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
|
470
|
+
endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
|
471
|
+
currentDate = this.date && this.date.valueOf(),
|
472
|
+
tooltip;
|
473
|
+
this.picker.find('.datepicker-days thead th.datepicker-switch')
|
474
|
+
.text(dates[this.o.language].months[month]+' '+year);
|
475
|
+
this.picker.find('tfoot th.today')
|
476
|
+
.text(dates[this.o.language].today)
|
477
|
+
.toggle(this.o.todayBtn !== false);
|
478
|
+
this.picker.find('tfoot th.clear')
|
479
|
+
.text(dates[this.o.language].clear)
|
480
|
+
.toggle(this.o.clearBtn !== false);
|
481
|
+
this.updateNavArrows();
|
482
|
+
this.fillMonths();
|
483
|
+
var prevMonth = UTCDate(year, month-1, 28,0,0,0,0),
|
484
|
+
day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
|
485
|
+
prevMonth.setUTCDate(day);
|
486
|
+
prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7);
|
487
|
+
var nextMonth = new Date(prevMonth);
|
488
|
+
nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
|
489
|
+
nextMonth = nextMonth.valueOf();
|
490
|
+
var html = [];
|
491
|
+
var clsName;
|
492
|
+
while(prevMonth.valueOf() < nextMonth) {
|
493
|
+
if (prevMonth.getUTCDay() == this.o.weekStart) {
|
494
|
+
html.push('<tr>');
|
495
|
+
if(this.o.calendarWeeks){
|
496
|
+
// ISO 8601: First week contains first thursday.
|
497
|
+
// ISO also states week starts on Monday, but we can be more abstract here.
|
498
|
+
var
|
499
|
+
// Start of current week: based on weekstart/current date
|
500
|
+
ws = new Date(+prevMonth + (this.o.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
|
501
|
+
// Thursday of this week
|
502
|
+
th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
|
503
|
+
// First Thursday of year, year from thursday
|
504
|
+
yth = new Date(+(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
|
505
|
+
// Calendar week: ms between thursdays, div ms per day, div 7 days
|
506
|
+
calWeek = (th - yth) / 864e5 / 7 + 1;
|
507
|
+
html.push('<td class="cw">'+ calWeek +'</td>');
|
508
|
+
|
509
|
+
}
|
510
|
+
}
|
511
|
+
clsName = this.getClassNames(prevMonth);
|
512
|
+
clsName.push('day');
|
513
|
+
|
514
|
+
var before = this.o.beforeShowDay(prevMonth);
|
515
|
+
if (before === undefined)
|
516
|
+
before = {};
|
517
|
+
else if (typeof(before) === 'boolean')
|
518
|
+
before = {enabled: before};
|
519
|
+
else if (typeof(before) === 'string')
|
520
|
+
before = {classes: before};
|
521
|
+
if (before.enabled === false)
|
522
|
+
clsName.push('disabled');
|
523
|
+
if (before.classes)
|
524
|
+
clsName = clsName.concat(before.classes.split(/\s+/));
|
525
|
+
if (before.tooltip)
|
526
|
+
tooltip = before.tooltip;
|
527
|
+
|
528
|
+
clsName = $.unique(clsName);
|
529
|
+
html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + '>'+prevMonth.getUTCDate() + '</td>');
|
530
|
+
if (prevMonth.getUTCDay() == this.o.weekEnd) {
|
531
|
+
html.push('</tr>');
|
532
|
+
}
|
533
|
+
prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
|
534
|
+
}
|
535
|
+
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
|
536
|
+
var currentYear = this.date && this.date.getUTCFullYear();
|
537
|
+
|
538
|
+
var months = this.picker.find('.datepicker-months')
|
539
|
+
.find('th:eq(1)')
|
540
|
+
.text(year)
|
541
|
+
.end()
|
542
|
+
.find('span').removeClass('active');
|
543
|
+
if (currentYear && currentYear == year) {
|
544
|
+
months.eq(this.date.getUTCMonth()).addClass('active');
|
545
|
+
}
|
546
|
+
if (year < startYear || year > endYear) {
|
547
|
+
months.addClass('disabled');
|
548
|
+
}
|
549
|
+
if (year == startYear) {
|
550
|
+
months.slice(0, startMonth).addClass('disabled');
|
551
|
+
}
|
552
|
+
if (year == endYear) {
|
553
|
+
months.slice(endMonth+1).addClass('disabled');
|
554
|
+
}
|
555
|
+
|
556
|
+
html = '';
|
557
|
+
year = parseInt(year/10, 10) * 10;
|
558
|
+
var yearCont = this.picker.find('.datepicker-years')
|
559
|
+
.find('th:eq(1)')
|
560
|
+
.text(year + '-' + (year + 9))
|
561
|
+
.end()
|
562
|
+
.find('td');
|
563
|
+
year -= 1;
|
564
|
+
for (var i = -1; i < 11; i++) {
|
565
|
+
html += '<span class="year'+(i == -1 ? ' old' : i == 10 ? ' new' : '')+(currentYear == year ? ' active' : '')+(year < startYear || year > endYear ? ' disabled' : '')+'">'+year+'</span>';
|
566
|
+
year += 1;
|
567
|
+
}
|
568
|
+
yearCont.html(html);
|
569
|
+
},
|
570
|
+
|
571
|
+
updateNavArrows: function() {
|
572
|
+
if (!this._allow_update) return;
|
573
|
+
|
574
|
+
var d = new Date(this.viewDate),
|
575
|
+
year = d.getUTCFullYear(),
|
576
|
+
month = d.getUTCMonth();
|
577
|
+
switch (this.viewMode) {
|
578
|
+
case 0:
|
579
|
+
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() && month <= this.o.startDate.getUTCMonth()) {
|
580
|
+
this.picker.find('.prev').css({visibility: 'hidden'});
|
581
|
+
} else {
|
582
|
+
this.picker.find('.prev').css({visibility: 'visible'});
|
583
|
+
}
|
584
|
+
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() && month >= this.o.endDate.getUTCMonth()) {
|
585
|
+
this.picker.find('.next').css({visibility: 'hidden'});
|
586
|
+
} else {
|
587
|
+
this.picker.find('.next').css({visibility: 'visible'});
|
588
|
+
}
|
589
|
+
break;
|
590
|
+
case 1:
|
591
|
+
case 2:
|
592
|
+
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear()) {
|
593
|
+
this.picker.find('.prev').css({visibility: 'hidden'});
|
594
|
+
} else {
|
595
|
+
this.picker.find('.prev').css({visibility: 'visible'});
|
596
|
+
}
|
597
|
+
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear()) {
|
598
|
+
this.picker.find('.next').css({visibility: 'hidden'});
|
599
|
+
} else {
|
600
|
+
this.picker.find('.next').css({visibility: 'visible'});
|
601
|
+
}
|
602
|
+
break;
|
603
|
+
}
|
604
|
+
},
|
605
|
+
|
606
|
+
click: function(e) {
|
607
|
+
e.preventDefault();
|
608
|
+
var target = $(e.target).closest('span, td, th');
|
609
|
+
if (target.length == 1) {
|
610
|
+
switch(target[0].nodeName.toLowerCase()) {
|
611
|
+
case 'th':
|
612
|
+
switch(target[0].className) {
|
613
|
+
case 'datepicker-switch':
|
614
|
+
this.showMode(1);
|
615
|
+
break;
|
616
|
+
case 'prev':
|
617
|
+
case 'next':
|
618
|
+
var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
|
619
|
+
switch(this.viewMode){
|
620
|
+
case 0:
|
621
|
+
this.viewDate = this.moveMonth(this.viewDate, dir);
|
622
|
+
break;
|
623
|
+
case 1:
|
624
|
+
case 2:
|
625
|
+
this.viewDate = this.moveYear(this.viewDate, dir);
|
626
|
+
break;
|
627
|
+
}
|
628
|
+
this.fill();
|
629
|
+
break;
|
630
|
+
case 'today':
|
631
|
+
var date = new Date();
|
632
|
+
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
633
|
+
|
634
|
+
this.showMode(-2);
|
635
|
+
var which = this.o.todayBtn == 'linked' ? null : 'view';
|
636
|
+
this._setDate(date, which);
|
637
|
+
break;
|
638
|
+
case 'clear':
|
639
|
+
if (this.isInput)
|
640
|
+
this.element.val("");
|
641
|
+
else
|
642
|
+
this.element.find('input').val("");
|
643
|
+
this.update();
|
644
|
+
if (this.o.autoclose)
|
645
|
+
this.hide();
|
646
|
+
break;
|
647
|
+
}
|
648
|
+
break;
|
649
|
+
case 'span':
|
650
|
+
if (!target.is('.disabled')) {
|
651
|
+
this.viewDate.setUTCDate(1);
|
652
|
+
if (target.is('.month')) {
|
653
|
+
var day = 1;
|
654
|
+
var month = target.parent().find('span').index(target);
|
655
|
+
var year = this.viewDate.getUTCFullYear();
|
656
|
+
this.viewDate.setUTCMonth(month);
|
657
|
+
this._trigger('changeMonth', this.viewDate);
|
658
|
+
if (this.o.minViewMode === 1) {
|
659
|
+
this._setDate(UTCDate(year, month, day,0,0,0,0));
|
660
|
+
}
|
661
|
+
} else {
|
662
|
+
var year = parseInt(target.text(), 10)||0;
|
663
|
+
var day = 1;
|
664
|
+
var month = 0;
|
665
|
+
this.viewDate.setUTCFullYear(year);
|
666
|
+
this._trigger('changeYear', this.viewDate);
|
667
|
+
if (this.o.minViewMode === 2) {
|
668
|
+
this._setDate(UTCDate(year, month, day,0,0,0,0));
|
669
|
+
}
|
670
|
+
}
|
671
|
+
this.showMode(-1);
|
672
|
+
this.fill();
|
673
|
+
}
|
674
|
+
break;
|
675
|
+
case 'td':
|
676
|
+
if (target.is('.day') && !target.is('.disabled')){
|
677
|
+
var day = parseInt(target.text(), 10)||1;
|
678
|
+
var year = this.viewDate.getUTCFullYear(),
|
679
|
+
month = this.viewDate.getUTCMonth();
|
680
|
+
if (target.is('.old')) {
|
681
|
+
if (month === 0) {
|
682
|
+
month = 11;
|
683
|
+
year -= 1;
|
684
|
+
} else {
|
685
|
+
month -= 1;
|
686
|
+
}
|
687
|
+
} else if (target.is('.new')) {
|
688
|
+
if (month == 11) {
|
689
|
+
month = 0;
|
690
|
+
year += 1;
|
691
|
+
} else {
|
692
|
+
month += 1;
|
693
|
+
}
|
694
|
+
}
|
695
|
+
this._setDate(UTCDate(year, month, day,0,0,0,0));
|
696
|
+
}
|
697
|
+
break;
|
698
|
+
}
|
699
|
+
}
|
700
|
+
},
|
701
|
+
|
702
|
+
_setDate: function(date, which){
|
703
|
+
if (!which || which == 'date')
|
704
|
+
this.date = new Date(date);
|
705
|
+
if (!which || which == 'view')
|
706
|
+
this.viewDate = new Date(date);
|
707
|
+
this.fill();
|
708
|
+
this.setValue();
|
709
|
+
this._trigger('changeDate');
|
710
|
+
var element;
|
711
|
+
if (this.isInput) {
|
712
|
+
element = this.element;
|
713
|
+
} else if (this.component){
|
714
|
+
element = this.element.find('input');
|
715
|
+
}
|
716
|
+
if (element) {
|
717
|
+
element.change();
|
718
|
+
if (this.o.autoclose && (!which || which == 'date')) {
|
719
|
+
this.hide();
|
720
|
+
}
|
721
|
+
}
|
722
|
+
},
|
723
|
+
|
724
|
+
moveMonth: function(date, dir){
|
725
|
+
if (!dir) return date;
|
726
|
+
var new_date = new Date(date.valueOf()),
|
727
|
+
day = new_date.getUTCDate(),
|
728
|
+
month = new_date.getUTCMonth(),
|
729
|
+
mag = Math.abs(dir),
|
730
|
+
new_month, test;
|
731
|
+
dir = dir > 0 ? 1 : -1;
|
732
|
+
if (mag == 1){
|
733
|
+
test = dir == -1
|
734
|
+
// If going back one month, make sure month is not current month
|
735
|
+
// (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
|
736
|
+
? function(){ return new_date.getUTCMonth() == month; }
|
737
|
+
// If going forward one month, make sure month is as expected
|
738
|
+
// (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
|
739
|
+
: function(){ return new_date.getUTCMonth() != new_month; };
|
740
|
+
new_month = month + dir;
|
741
|
+
new_date.setUTCMonth(new_month);
|
742
|
+
// Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
|
743
|
+
if (new_month < 0 || new_month > 11)
|
744
|
+
new_month = (new_month + 12) % 12;
|
745
|
+
} else {
|
746
|
+
// For magnitudes >1, move one month at a time...
|
747
|
+
for (var i=0; i<mag; i++)
|
748
|
+
// ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
|
749
|
+
new_date = this.moveMonth(new_date, dir);
|
750
|
+
// ...then reset the day, keeping it in the new month
|
751
|
+
new_month = new_date.getUTCMonth();
|
752
|
+
new_date.setUTCDate(day);
|
753
|
+
test = function(){ return new_month != new_date.getUTCMonth(); };
|
754
|
+
}
|
755
|
+
// Common date-resetting loop -- if date is beyond end of month, make it
|
756
|
+
// end of month
|
757
|
+
while (test()){
|
758
|
+
new_date.setUTCDate(--day);
|
759
|
+
new_date.setUTCMonth(new_month);
|
760
|
+
}
|
761
|
+
return new_date;
|
762
|
+
},
|
763
|
+
|
764
|
+
moveYear: function(date, dir){
|
765
|
+
return this.moveMonth(date, dir*12);
|
766
|
+
},
|
767
|
+
|
768
|
+
dateWithinRange: function(date){
|
769
|
+
return date >= this.o.startDate && date <= this.o.endDate;
|
770
|
+
},
|
771
|
+
|
772
|
+
keydown: function(e){
|
773
|
+
if (this.picker.is(':not(:visible)')){
|
774
|
+
if (e.keyCode == 27) // allow escape to hide and re-show picker
|
775
|
+
this.show();
|
776
|
+
return;
|
777
|
+
}
|
778
|
+
var dateChanged = false,
|
779
|
+
dir, day, month,
|
780
|
+
newDate, newViewDate;
|
781
|
+
switch(e.keyCode){
|
782
|
+
case 27: // escape
|
783
|
+
this.hide();
|
784
|
+
e.preventDefault();
|
785
|
+
break;
|
786
|
+
case 37: // left
|
787
|
+
case 39: // right
|
788
|
+
if (!this.o.keyboardNavigation) break;
|
789
|
+
dir = e.keyCode == 37 ? -1 : 1;
|
790
|
+
if (e.ctrlKey){
|
791
|
+
newDate = this.moveYear(this.date, dir);
|
792
|
+
newViewDate = this.moveYear(this.viewDate, dir);
|
793
|
+
} else if (e.shiftKey){
|
794
|
+
newDate = this.moveMonth(this.date, dir);
|
795
|
+
newViewDate = this.moveMonth(this.viewDate, dir);
|
796
|
+
} else {
|
797
|
+
newDate = new Date(this.date);
|
798
|
+
newDate.setUTCDate(this.date.getUTCDate() + dir);
|
799
|
+
newViewDate = new Date(this.viewDate);
|
800
|
+
newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
|
801
|
+
}
|
802
|
+
if (this.dateWithinRange(newDate)){
|
803
|
+
this.date = newDate;
|
804
|
+
this.viewDate = newViewDate;
|
805
|
+
this.setValue();
|
806
|
+
this.update();
|
807
|
+
e.preventDefault();
|
808
|
+
dateChanged = true;
|
809
|
+
}
|
810
|
+
break;
|
811
|
+
case 38: // up
|
812
|
+
case 40: // down
|
813
|
+
if (!this.o.keyboardNavigation) break;
|
814
|
+
dir = e.keyCode == 38 ? -1 : 1;
|
815
|
+
if (e.ctrlKey){
|
816
|
+
newDate = this.moveYear(this.date, dir);
|
817
|
+
newViewDate = this.moveYear(this.viewDate, dir);
|
818
|
+
} else if (e.shiftKey){
|
819
|
+
newDate = this.moveMonth(this.date, dir);
|
820
|
+
newViewDate = this.moveMonth(this.viewDate, dir);
|
821
|
+
} else {
|
822
|
+
newDate = new Date(this.date);
|
823
|
+
newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
|
824
|
+
newViewDate = new Date(this.viewDate);
|
825
|
+
newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
|
826
|
+
}
|
827
|
+
if (this.dateWithinRange(newDate)){
|
828
|
+
this.date = newDate;
|
829
|
+
this.viewDate = newViewDate;
|
830
|
+
this.setValue();
|
831
|
+
this.update();
|
832
|
+
e.preventDefault();
|
833
|
+
dateChanged = true;
|
834
|
+
}
|
835
|
+
break;
|
836
|
+
case 13: // enter
|
837
|
+
this.hide();
|
838
|
+
e.preventDefault();
|
839
|
+
break;
|
840
|
+
case 9: // tab
|
841
|
+
this.hide();
|
842
|
+
break;
|
843
|
+
}
|
844
|
+
if (dateChanged){
|
845
|
+
this._trigger('changeDate');
|
846
|
+
var element;
|
847
|
+
if (this.isInput) {
|
848
|
+
element = this.element;
|
849
|
+
} else if (this.component){
|
850
|
+
element = this.element.find('input');
|
851
|
+
}
|
852
|
+
if (element) {
|
853
|
+
element.change();
|
854
|
+
}
|
855
|
+
}
|
856
|
+
},
|
857
|
+
|
858
|
+
showMode: function(dir) {
|
859
|
+
if (dir) {
|
860
|
+
this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir));
|
861
|
+
}
|
862
|
+
/*
|
863
|
+
vitalets: fixing bug of very special conditions:
|
864
|
+
jquery 1.7.1 + webkit + show inline datepicker in bootstrap popover.
|
865
|
+
Method show() does not set display css correctly and datepicker is not shown.
|
866
|
+
Changed to .css('display', 'block') solve the problem.
|
867
|
+
See https://github.com/vitalets/x-editable/issues/37
|
868
|
+
|
869
|
+
In jquery 1.7.2+ everything works fine.
|
870
|
+
*/
|
871
|
+
//this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
|
872
|
+
this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
|
873
|
+
this.updateNavArrows();
|
874
|
+
}
|
875
|
+
};
|
876
|
+
|
877
|
+
var DateRangePicker = function(element, options){
|
878
|
+
this.element = $(element);
|
879
|
+
this.inputs = $.map(options.inputs, function(i){ return i.jquery ? i[0] : i; });
|
880
|
+
delete options.inputs;
|
881
|
+
|
882
|
+
$(this.inputs)
|
883
|
+
.datepicker(options)
|
884
|
+
.bind('changeDate', $.proxy(this.dateUpdated, this));
|
885
|
+
|
886
|
+
this.pickers = $.map(this.inputs, function(i){ return $(i).data('datepicker'); });
|
887
|
+
this.updateDates();
|
888
|
+
};
|
889
|
+
DateRangePicker.prototype = {
|
890
|
+
updateDates: function(){
|
891
|
+
this.dates = $.map(this.pickers, function(i){ return i.date; });
|
892
|
+
this.updateRanges();
|
893
|
+
},
|
894
|
+
updateRanges: function(){
|
895
|
+
var range = $.map(this.dates, function(d){ return d.valueOf(); });
|
896
|
+
$.each(this.pickers, function(i, p){
|
897
|
+
p.setRange(range);
|
898
|
+
});
|
899
|
+
},
|
900
|
+
dateUpdated: function(e){
|
901
|
+
var dp = $(e.target).data('datepicker'),
|
902
|
+
new_date = dp.getUTCDate(),
|
903
|
+
i = $.inArray(e.target, this.inputs),
|
904
|
+
l = this.inputs.length;
|
905
|
+
if (i == -1) return;
|
906
|
+
|
907
|
+
if (new_date < this.dates[i]){
|
908
|
+
// Date being moved earlier/left
|
909
|
+
while (i>=0 && new_date < this.dates[i]){
|
910
|
+
this.pickers[i--].setUTCDate(new_date);
|
911
|
+
}
|
912
|
+
}
|
913
|
+
else if (new_date > this.dates[i]){
|
914
|
+
// Date being moved later/right
|
915
|
+
while (i<l && new_date > this.dates[i]){
|
916
|
+
this.pickers[i++].setUTCDate(new_date);
|
917
|
+
}
|
918
|
+
}
|
919
|
+
this.updateDates();
|
920
|
+
},
|
921
|
+
remove: function(){
|
922
|
+
$.map(this.pickers, function(p){ p.remove(); });
|
923
|
+
delete this.element.data().datepicker;
|
924
|
+
}
|
925
|
+
};
|
926
|
+
|
927
|
+
function opts_from_el(el, prefix){
|
928
|
+
// Derive options from element data-attrs
|
929
|
+
var data = $(el).data(),
|
930
|
+
out = {}, inkey,
|
931
|
+
replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])'),
|
932
|
+
prefix = new RegExp('^' + prefix.toLowerCase());
|
933
|
+
for (var key in data)
|
934
|
+
if (prefix.test(key)){
|
935
|
+
inkey = key.replace(replace, function(_,a){ return a.toLowerCase(); });
|
936
|
+
out[inkey] = data[key];
|
937
|
+
}
|
938
|
+
return out;
|
939
|
+
}
|
940
|
+
|
941
|
+
function opts_from_locale(lang){
|
942
|
+
// Derive options from locale plugins
|
943
|
+
var out = {};
|
944
|
+
// Check if "de-DE" style date is available, if not language should
|
945
|
+
// fallback to 2 letter code eg "de"
|
946
|
+
if (!dates[lang]) {
|
947
|
+
lang = lang.split('-')[0]
|
948
|
+
if (!dates[lang])
|
949
|
+
return;
|
950
|
+
}
|
951
|
+
var d = dates[lang];
|
952
|
+
$.each($.fn.datepicker.locale_opts, function(i,k){
|
953
|
+
if (k in d)
|
954
|
+
out[k] = d[k];
|
955
|
+
});
|
956
|
+
return out;
|
957
|
+
}
|
958
|
+
|
959
|
+
var old = $.fn.datepicker;
|
960
|
+
$.fn.datepicker = function ( option ) {
|
961
|
+
var args = Array.apply(null, arguments);
|
962
|
+
args.shift();
|
963
|
+
var internal_return,
|
964
|
+
this_return;
|
965
|
+
this.each(function () {
|
966
|
+
var $this = $(this),
|
967
|
+
data = $this.data('datepicker'),
|
968
|
+
options = typeof option == 'object' && option;
|
969
|
+
if (!data) {
|
970
|
+
var elopts = opts_from_el(this, 'date'),
|
971
|
+
// Preliminary otions
|
972
|
+
xopts = $.extend({}, $.fn.datepicker.defaults, elopts, options),
|
973
|
+
locopts = opts_from_locale(xopts.language),
|
974
|
+
// Options priority: js args, data-attrs, locales, defaults
|
975
|
+
opts = $.extend({}, $.fn.datepicker.defaults, locopts, elopts, options);
|
976
|
+
if ($this.is('.input-daterange') || opts.inputs){
|
977
|
+
var ropts = {
|
978
|
+
inputs: opts.inputs || $this.find('input').toArray()
|
979
|
+
};
|
980
|
+
$this.data('datepicker', (data = new DateRangePicker(this, $.extend(opts, ropts))));
|
981
|
+
}
|
982
|
+
else{
|
983
|
+
$this.data('datepicker', (data = new Datepicker(this, opts)));
|
984
|
+
}
|
985
|
+
}
|
986
|
+
if (typeof option == 'string' && typeof data[option] == 'function') {
|
987
|
+
internal_return = data[option].apply(data, args);
|
988
|
+
if (internal_return !== undefined)
|
989
|
+
return false;
|
990
|
+
}
|
991
|
+
});
|
992
|
+
if (internal_return !== undefined)
|
993
|
+
return internal_return;
|
994
|
+
else
|
995
|
+
return this;
|
996
|
+
};
|
997
|
+
|
998
|
+
$.fn.datepicker.defaults = {
|
999
|
+
autoclose: false,
|
1000
|
+
beforeShowDay: $.noop,
|
1001
|
+
calendarWeeks: false,
|
1002
|
+
clearBtn: false,
|
1003
|
+
daysOfWeekDisabled: [],
|
1004
|
+
endDate: Infinity,
|
1005
|
+
forceParse: true,
|
1006
|
+
format: 'mm/dd/yyyy',
|
1007
|
+
keyboardNavigation: true,
|
1008
|
+
language: 'en',
|
1009
|
+
minViewMode: 0,
|
1010
|
+
rtl: false,
|
1011
|
+
startDate: -Infinity,
|
1012
|
+
startView: 0,
|
1013
|
+
todayBtn: false,
|
1014
|
+
todayHighlight: false,
|
1015
|
+
weekStart: 0
|
1016
|
+
};
|
1017
|
+
$.fn.datepicker.locale_opts = [
|
1018
|
+
'format',
|
1019
|
+
'rtl',
|
1020
|
+
'weekStart'
|
1021
|
+
];
|
1022
|
+
$.fn.datepicker.Constructor = Datepicker;
|
1023
|
+
var dates = $.fn.datepicker.dates = {
|
1024
|
+
en: {
|
1025
|
+
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
1026
|
+
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
1027
|
+
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
1028
|
+
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
1029
|
+
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
1030
|
+
today: "Today",
|
1031
|
+
clear: "Clear"
|
1032
|
+
}
|
1033
|
+
};
|
1034
|
+
|
1035
|
+
var DPGlobal = {
|
1036
|
+
modes: [
|
1037
|
+
{
|
1038
|
+
clsName: 'days',
|
1039
|
+
navFnc: 'Month',
|
1040
|
+
navStep: 1
|
1041
|
+
},
|
1042
|
+
{
|
1043
|
+
clsName: 'months',
|
1044
|
+
navFnc: 'FullYear',
|
1045
|
+
navStep: 1
|
1046
|
+
},
|
1047
|
+
{
|
1048
|
+
clsName: 'years',
|
1049
|
+
navFnc: 'FullYear',
|
1050
|
+
navStep: 10
|
1051
|
+
}],
|
1052
|
+
isLeapYear: function (year) {
|
1053
|
+
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
|
1054
|
+
},
|
1055
|
+
getDaysInMonth: function (year, month) {
|
1056
|
+
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
|
1057
|
+
},
|
1058
|
+
validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
|
1059
|
+
nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,
|
1060
|
+
parseFormat: function(format){
|
1061
|
+
// IE treats \0 as a string end in inputs (truncating the value),
|
1062
|
+
// so it's a bad format delimiter, anyway
|
1063
|
+
var separators = format.replace(this.validParts, '\0').split('\0'),
|
1064
|
+
parts = format.match(this.validParts);
|
1065
|
+
if (!separators || !separators.length || !parts || parts.length === 0){
|
1066
|
+
throw new Error("Invalid date format.");
|
1067
|
+
}
|
1068
|
+
return {separators: separators, parts: parts};
|
1069
|
+
},
|
1070
|
+
parseDate: function(date, format, language) {
|
1071
|
+
if (date instanceof Date) return date;
|
1072
|
+
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)) {
|
1073
|
+
var part_re = /([\-+]\d+)([dmwy])/,
|
1074
|
+
parts = date.match(/([\-+]\d+)([dmwy])/g),
|
1075
|
+
part, dir;
|
1076
|
+
date = new Date();
|
1077
|
+
for (var i=0; i<parts.length; i++) {
|
1078
|
+
part = part_re.exec(parts[i]);
|
1079
|
+
dir = parseInt(part[1]);
|
1080
|
+
switch(part[2]){
|
1081
|
+
case 'd':
|
1082
|
+
date.setUTCDate(date.getUTCDate() + dir);
|
1083
|
+
break;
|
1084
|
+
case 'm':
|
1085
|
+
date = Datepicker.prototype.moveMonth.call(Datepicker.prototype, date, dir);
|
1086
|
+
break;
|
1087
|
+
case 'w':
|
1088
|
+
date.setUTCDate(date.getUTCDate() + dir * 7);
|
1089
|
+
break;
|
1090
|
+
case 'y':
|
1091
|
+
date = Datepicker.prototype.moveYear.call(Datepicker.prototype, date, dir);
|
1092
|
+
break;
|
1093
|
+
}
|
1094
|
+
}
|
1095
|
+
return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
|
1096
|
+
}
|
1097
|
+
var parts = date && date.match(this.nonpunctuation) || [],
|
1098
|
+
date = new Date(),
|
1099
|
+
parsed = {},
|
1100
|
+
setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
|
1101
|
+
setters_map = {
|
1102
|
+
yyyy: function(d,v){ return d.setUTCFullYear(v); },
|
1103
|
+
yy: function(d,v){ return d.setUTCFullYear(2000+v); },
|
1104
|
+
m: function(d,v){
|
1105
|
+
v -= 1;
|
1106
|
+
while (v<0) v += 12;
|
1107
|
+
v %= 12;
|
1108
|
+
d.setUTCMonth(v);
|
1109
|
+
while (d.getUTCMonth() != v)
|
1110
|
+
d.setUTCDate(d.getUTCDate()-1);
|
1111
|
+
return d;
|
1112
|
+
},
|
1113
|
+
d: function(d,v){ return d.setUTCDate(v); }
|
1114
|
+
},
|
1115
|
+
val, filtered, part;
|
1116
|
+
setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
|
1117
|
+
setters_map['dd'] = setters_map['d'];
|
1118
|
+
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
1119
|
+
var fparts = format.parts.slice();
|
1120
|
+
// Remove noop parts
|
1121
|
+
if (parts.length != fparts.length) {
|
1122
|
+
fparts = $(fparts).filter(function(i,p){
|
1123
|
+
return $.inArray(p, setters_order) !== -1;
|
1124
|
+
}).toArray();
|
1125
|
+
}
|
1126
|
+
// Process remainder
|
1127
|
+
if (parts.length == fparts.length) {
|
1128
|
+
for (var i=0, cnt = fparts.length; i < cnt; i++) {
|
1129
|
+
val = parseInt(parts[i], 10);
|
1130
|
+
part = fparts[i];
|
1131
|
+
if (isNaN(val)) {
|
1132
|
+
switch(part) {
|
1133
|
+
case 'MM':
|
1134
|
+
filtered = $(dates[language].months).filter(function(){
|
1135
|
+
var m = this.slice(0, parts[i].length),
|
1136
|
+
p = parts[i].slice(0, m.length);
|
1137
|
+
return m == p;
|
1138
|
+
});
|
1139
|
+
val = $.inArray(filtered[0], dates[language].months) + 1;
|
1140
|
+
break;
|
1141
|
+
case 'M':
|
1142
|
+
filtered = $(dates[language].monthsShort).filter(function(){
|
1143
|
+
var m = this.slice(0, parts[i].length),
|
1144
|
+
p = parts[i].slice(0, m.length);
|
1145
|
+
return m == p;
|
1146
|
+
});
|
1147
|
+
val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
|
1148
|
+
break;
|
1149
|
+
}
|
1150
|
+
}
|
1151
|
+
parsed[part] = val;
|
1152
|
+
}
|
1153
|
+
for (var i=0, s; i<setters_order.length; i++){
|
1154
|
+
s = setters_order[i];
|
1155
|
+
if (s in parsed && !isNaN(parsed[s]))
|
1156
|
+
setters_map[s](date, parsed[s]);
|
1157
|
+
}
|
1158
|
+
}
|
1159
|
+
return date;
|
1160
|
+
},
|
1161
|
+
formatDate: function(date, format, language){
|
1162
|
+
var val = {
|
1163
|
+
d: date.getUTCDate(),
|
1164
|
+
D: dates[language].daysShort[date.getUTCDay()],
|
1165
|
+
DD: dates[language].days[date.getUTCDay()],
|
1166
|
+
m: date.getUTCMonth() + 1,
|
1167
|
+
M: dates[language].monthsShort[date.getUTCMonth()],
|
1168
|
+
MM: dates[language].months[date.getUTCMonth()],
|
1169
|
+
yy: date.getUTCFullYear().toString().substring(2),
|
1170
|
+
yyyy: date.getUTCFullYear()
|
1171
|
+
};
|
1172
|
+
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
1173
|
+
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
1174
|
+
var date = [],
|
1175
|
+
seps = $.extend([], format.separators);
|
1176
|
+
for (var i=0, cnt = format.parts.length; i <= cnt; i++) {
|
1177
|
+
if (seps.length)
|
1178
|
+
date.push(seps.shift());
|
1179
|
+
date.push(val[format.parts[i]]);
|
1180
|
+
}
|
1181
|
+
return date.join('');
|
1182
|
+
},
|
1183
|
+
headTemplate: '<thead>'+
|
1184
|
+
'<tr>'+
|
1185
|
+
'<th class="prev"><i class="icon-arrow-left"/></th>'+
|
1186
|
+
'<th colspan="5" class="datepicker-switch"></th>'+
|
1187
|
+
'<th class="next"><i class="icon-arrow-right"/></th>'+
|
1188
|
+
'</tr>'+
|
1189
|
+
'</thead>',
|
1190
|
+
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
|
1191
|
+
footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr><tr><th colspan="7" class="clear"></th></tr></tfoot>'
|
1192
|
+
};
|
1193
|
+
DPGlobal.template = '<div class="datepicker">'+
|
1194
|
+
'<div class="datepicker-days">'+
|
1195
|
+
'<table class=" table-condensed">'+
|
1196
|
+
DPGlobal.headTemplate+
|
1197
|
+
'<tbody></tbody>'+
|
1198
|
+
DPGlobal.footTemplate+
|
1199
|
+
'</table>'+
|
1200
|
+
'</div>'+
|
1201
|
+
'<div class="datepicker-months">'+
|
1202
|
+
'<table class="table-condensed">'+
|
1203
|
+
DPGlobal.headTemplate+
|
1204
|
+
DPGlobal.contTemplate+
|
1205
|
+
DPGlobal.footTemplate+
|
1206
|
+
'</table>'+
|
1207
|
+
'</div>'+
|
1208
|
+
'<div class="datepicker-years">'+
|
1209
|
+
'<table class="table-condensed">'+
|
1210
|
+
DPGlobal.headTemplate+
|
1211
|
+
DPGlobal.contTemplate+
|
1212
|
+
DPGlobal.footTemplate+
|
1213
|
+
'</table>'+
|
1214
|
+
'</div>'+
|
1215
|
+
'</div>';
|
1216
|
+
|
1217
|
+
$.fn.datepicker.DPGlobal = DPGlobal;
|
1218
|
+
|
1219
|
+
|
1220
|
+
/* DATEPICKER NO CONFLICT
|
1221
|
+
* =================== */
|
1222
|
+
|
1223
|
+
$.fn.datepicker.noConflict = function(){
|
1224
|
+
$.fn.datepicker = old;
|
1225
|
+
return this;
|
1226
|
+
};
|
1227
|
+
|
1228
|
+
|
1229
|
+
/* DATEPICKER DATA-API
|
1230
|
+
* ================== */
|
1231
|
+
|
1232
|
+
$(document).on(
|
1233
|
+
'focus.datepicker.data-api click.datepicker.data-api',
|
1234
|
+
'[data-provide="datepicker"]',
|
1235
|
+
function(e){
|
1236
|
+
var $this = $(this);
|
1237
|
+
if ($this.data('datepicker')) return;
|
1238
|
+
e.preventDefault();
|
1239
|
+
// component click requires us to explicitly show it
|
1240
|
+
$this.datepicker('show');
|
1241
|
+
}
|
1242
|
+
);
|
1243
|
+
$(function(){
|
1244
|
+
$('[data-provide="datepicker-inline"]').datepicker();
|
1245
|
+
});
|
1246
|
+
|
1247
|
+
}( window.jQuery );
|