foundation-datetimepicker-rails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,11 +4,9 @@
|
|
4
4
|
* project website http://foundation-datepicker.peterbeno.com
|
5
5
|
*
|
6
6
|
* original project:
|
7
|
-
* bootstrap-datepicker.js
|
8
|
-
* http://www.eyecon.ro/bootstrap-datepicker
|
9
|
-
* =========================================================
|
10
7
|
* Copyright 2012 Stefan Petre
|
11
8
|
* Improvements by Andrew Rowls
|
9
|
+
* Improvements by Sébastien Malot
|
12
10
|
*
|
13
11
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
14
12
|
* you may not use this file except in compliance with the License.
|
@@ -30,33 +28,60 @@
|
|
30
28
|
}
|
31
29
|
function UTCToday(){
|
32
30
|
var today = new Date();
|
33
|
-
return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
|
31
|
+
return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate(), today.getUTCHours(), today.getUTCMinutes(), today.getUTCSeconds());
|
34
32
|
}
|
35
33
|
|
36
34
|
// Picker object
|
37
35
|
|
38
|
-
var
|
36
|
+
var Datetimepicker = function(element, options) {
|
39
37
|
var that = this;
|
40
38
|
|
41
39
|
this.element = $(element);
|
42
40
|
this.closeButton = options.closeButton;
|
43
|
-
this.language = options.language||this.element.data('date-language')||"en";
|
44
|
-
this.language = this.language in dates ? this.language : this.language.split('-')[0]; //Check if "de-DE" style date is available, if not language should fallback to 2 letter code eg "de"
|
41
|
+
this.language = options.language || this.element.data('date-language') || "en";
|
45
42
|
this.language = this.language in dates ? this.language : "en";
|
46
|
-
this.isRTL = dates[this.language].rtl||false;
|
47
|
-
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||
|
43
|
+
this.isRTL = dates[this.language].rtl || false;
|
44
|
+
this.format = DPGlobal.parseFormat(options.format || this.element.data('date-format') || 'yyyy-mm-dd hh:ii');
|
48
45
|
this.isInline = false;
|
49
46
|
this.isInput = this.element.is('input');
|
50
|
-
this.component = this.element.is('.date') ? this.element.find('.prefix') : false;
|
47
|
+
this.component = this.element.is('.date') ? this.element.find('.prefix').parent() : false;
|
48
|
+
this.componentReset = this.element.is('.date') ? this.element.find('.prefix').parent() : false;
|
51
49
|
this.hasInput = this.component && this.element.find('input').length;
|
52
|
-
|
53
|
-
|
54
|
-
this.onRender = options.onRender || function () {};
|
55
|
-
if(this.component && this.component.length === 0)
|
50
|
+
if (this.component && this.component.length === 0) {
|
56
51
|
this.component = false;
|
52
|
+
}
|
53
|
+
this.linkField = options.linkField || this.element.data('link-field') || false;
|
54
|
+
this.linkFormat = DPGlobal.parseFormat(options.linkFormat || this.element.data('link-format') || 'yyyy-mm-dd hh:ii:ss');
|
55
|
+
this.minuteStep = options.minuteStep || this.element.data('minute-step') || 5;
|
56
|
+
this.pickerPosition = options.pickerPosition || this.element.data('picker-position') || 'bottom-right';
|
57
57
|
|
58
58
|
this._attachEvents();
|
59
59
|
|
60
|
+
this.minView = 0;
|
61
|
+
if ('minView' in options) {
|
62
|
+
this.minView = options.minView;
|
63
|
+
} else if ('minView' in this.element.data()) {
|
64
|
+
this.minView = this.element.data('min-view');
|
65
|
+
}
|
66
|
+
this.minView = DPGlobal.convertViewMode(this.minView);
|
67
|
+
|
68
|
+
this.maxView = DPGlobal.modes.length-1;
|
69
|
+
if ('maxView' in options) {
|
70
|
+
this.maxView = options.maxView;
|
71
|
+
} else if ('maxView' in this.element.data()) {
|
72
|
+
this.maxView = this.element.data('max-view');
|
73
|
+
}
|
74
|
+
this.maxView = DPGlobal.convertViewMode(this.maxView);
|
75
|
+
|
76
|
+
this.startViewMode = 2;
|
77
|
+
if ('startView' in options) {
|
78
|
+
this.startViewMode = options.startView;
|
79
|
+
} else if ('startView' in this.element.data()) {
|
80
|
+
this.startViewMode = this.element.data('start-view');
|
81
|
+
}
|
82
|
+
this.startViewMode = DPGlobal.convertViewMode(this.startViewMode);
|
83
|
+
this.viewMode = this.startViewMode;
|
84
|
+
|
60
85
|
this.forceParse = true;
|
61
86
|
if ('forceParse' in options) {
|
62
87
|
this.forceParse = options.forceParse;
|
@@ -64,7 +89,6 @@
|
|
64
89
|
this.forceParse = this.element.data('date-force-parse');
|
65
90
|
}
|
66
91
|
|
67
|
-
|
68
92
|
this.picker = $(DPGlobal.template)
|
69
93
|
.appendTo(this.isInline ? this.element : 'body')
|
70
94
|
.on({
|
@@ -72,22 +96,27 @@
|
|
72
96
|
mousedown: $.proxy(this.mousedown, this)
|
73
97
|
});
|
74
98
|
if (this.closeButton){
|
75
|
-
this.picker.find('a.
|
99
|
+
this.picker.find('a.datetimepicker-close').show();
|
76
100
|
}
|
77
|
-
|
78
|
-
if(this.isInline) {
|
79
|
-
this.picker.addClass('
|
101
|
+
|
102
|
+
if (this.isInline) {
|
103
|
+
this.picker.addClass('datetimepicker-inline');
|
104
|
+
|
80
105
|
} else {
|
81
|
-
this.
|
106
|
+
if (this.component && this.pickerPosition == 'bottom-left') {
|
107
|
+
this.picker.addClass('datetimepicker-dropdown-left dropdown-menu');
|
108
|
+
} else {
|
109
|
+
this.picker.addClass('datetimepicker-dropdown dropdown-menu');
|
110
|
+
}
|
82
111
|
}
|
83
112
|
if (this.isRTL){
|
84
|
-
this.picker.addClass('
|
113
|
+
this.picker.addClass('datetimepicker-rtl');
|
85
114
|
this.picker.find('.prev i, .next i')
|
86
|
-
.toggleClass('icon-
|
115
|
+
.toggleClass('icon-chevron-left icon-chevron-right');
|
87
116
|
}
|
88
117
|
$(document).on('mousedown', function (e) {
|
89
|
-
// Clicked outside the
|
90
|
-
if ($(e.target).closest('.
|
118
|
+
// Clicked outside the datetimepicker, hide it
|
119
|
+
if ($(e.target).closest('.datetimepicker').length === 0) {
|
91
120
|
that.hide();
|
92
121
|
}
|
93
122
|
});
|
@@ -106,54 +135,29 @@
|
|
106
135
|
this.keyboardNavigation = this.element.data('date-keyboard-navigation');
|
107
136
|
}
|
108
137
|
|
109
|
-
this.
|
110
|
-
|
111
|
-
case 2:
|
112
|
-
case 'decade':
|
113
|
-
this.viewMode = this.startViewMode = 2;
|
114
|
-
break;
|
115
|
-
case 1:
|
116
|
-
case 'year':
|
117
|
-
this.viewMode = this.startViewMode = 1;
|
118
|
-
break;
|
119
|
-
}
|
120
|
-
|
121
|
-
this.todayBtn = (options.todayBtn||this.element.data('date-today-btn')||false);
|
122
|
-
this.todayHighlight = (options.todayHighlight||this.element.data('date-today-highlight')||false);
|
138
|
+
this.todayBtn = (options.todayBtn || this.element.data('date-today-btn') || false);
|
139
|
+
this.todayHighlight = (options.todayHighlight || this.element.data('date-today-highlight') || false);
|
123
140
|
|
124
|
-
this.
|
125
|
-
if ('calendarWeeks' in options) {
|
126
|
-
this.calendarWeeks = options.calendarWeeks;
|
127
|
-
} else if ('dateCalendarWeeks' in this.element.data()) {
|
128
|
-
this.calendarWeeks = this.element.data('date-calendar-weeks');
|
129
|
-
}
|
130
|
-
if (this.calendarWeeks)
|
131
|
-
this.picker.find('tfoot th.today')
|
132
|
-
.attr('colspan', function(i, val){
|
133
|
-
return parseInt(val) + 1;
|
134
|
-
});
|
135
|
-
|
136
|
-
this.weekStart = ((options.weekStart||this.element.data('date-weekstart')||dates[this.language].weekStart||0) % 7);
|
141
|
+
this.weekStart = ((options.weekStart || this.element.data('date-weekstart') || dates[this.language].weekStart || 0) % 7);
|
137
142
|
this.weekEnd = ((this.weekStart + 6) % 7);
|
138
143
|
this.startDate = -Infinity;
|
139
144
|
this.endDate = Infinity;
|
140
145
|
this.daysOfWeekDisabled = [];
|
141
|
-
this.setStartDate(options.startDate||this.element.data('date-startdate'));
|
142
|
-
this.setEndDate(options.endDate||this.element.data('date-enddate'));
|
143
|
-
this.setDaysOfWeekDisabled(options.daysOfWeekDisabled||this.element.data('date-days-of-week-disabled'));
|
144
|
-
|
146
|
+
this.setStartDate(options.startDate || this.element.data('date-startdate'));
|
147
|
+
this.setEndDate(options.endDate || this.element.data('date-enddate'));
|
148
|
+
this.setDaysOfWeekDisabled(options.daysOfWeekDisabled || this.element.data('date-days-of-week-disabled'));
|
145
149
|
this.fillDow();
|
146
150
|
this.fillMonths();
|
147
151
|
this.update();
|
148
152
|
this.showMode();
|
149
153
|
|
150
154
|
if(this.isInline) {
|
151
|
-
this.show();
|
155
|
+
this.picker.show();
|
152
156
|
}
|
153
157
|
};
|
154
158
|
|
155
|
-
|
156
|
-
constructor:
|
159
|
+
Datetimepicker.prototype = {
|
160
|
+
constructor: Datetimepicker,
|
157
161
|
|
158
162
|
_events: [],
|
159
163
|
_attachEvents: function(){
|
@@ -179,10 +183,16 @@
|
|
179
183
|
click: $.proxy(this.show, this)
|
180
184
|
}]
|
181
185
|
];
|
186
|
+
if (this.componentReset) {
|
187
|
+
this._events.push([
|
188
|
+
this.componentReset,
|
189
|
+
{click: $.proxy(this.reset, this)}
|
190
|
+
]);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
else if (this.element.is('div')) { // inline datetimepicker
|
194
|
+
this.isInline = true;
|
182
195
|
}
|
183
|
-
else if (this.element.is('div')) { // inline datepicker
|
184
|
-
this.isInline = true;
|
185
|
-
}
|
186
196
|
else {
|
187
197
|
this._events = [
|
188
198
|
[this.element, {
|
@@ -196,6 +206,7 @@
|
|
196
206
|
el.on(ev);
|
197
207
|
}
|
198
208
|
},
|
209
|
+
|
199
210
|
_detachEvents: function(){
|
200
211
|
for (var i=0, el, ev; i<this._events.length; i++){
|
201
212
|
el = this._events[i][0];
|
@@ -208,10 +219,12 @@
|
|
208
219
|
show: function(e) {
|
209
220
|
this.picker.show();
|
210
221
|
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
|
211
|
-
this.
|
222
|
+
if (this.forceParse) {
|
223
|
+
this.update();
|
224
|
+
}
|
212
225
|
this.place();
|
213
226
|
$(window).on('resize', $.proxy(this.place, this));
|
214
|
-
if (e
|
227
|
+
if (e) {
|
215
228
|
e.stopPropagation();
|
216
229
|
e.preventDefault();
|
217
230
|
}
|
@@ -223,7 +236,6 @@
|
|
223
236
|
|
224
237
|
hide: function(e){
|
225
238
|
if(this.isInline) return;
|
226
|
-
if (!this.picker.is(':visible')) return;
|
227
239
|
this.picker.hide();
|
228
240
|
$(window).off('resize', this.place);
|
229
241
|
this.viewMode = this.startViewMode;
|
@@ -235,7 +247,7 @@
|
|
235
247
|
if (
|
236
248
|
this.forceParse &&
|
237
249
|
(
|
238
|
-
this.isInput && this.element.val()
|
250
|
+
this.isInput && this.element.val() ||
|
239
251
|
this.hasInput && this.element.find('input').val()
|
240
252
|
)
|
241
253
|
)
|
@@ -249,7 +261,7 @@
|
|
249
261
|
remove: function() {
|
250
262
|
this._detachEvents();
|
251
263
|
this.picker.remove();
|
252
|
-
delete this.element.data().
|
264
|
+
delete this.element.data().datetimepicker;
|
253
265
|
},
|
254
266
|
|
255
267
|
getDate: function() {
|
@@ -266,30 +278,43 @@
|
|
266
278
|
},
|
267
279
|
|
268
280
|
setUTCDate: function(d) {
|
269
|
-
this.
|
270
|
-
|
281
|
+
if (d >= this.startDate && d <= this.endDate) {
|
282
|
+
this.date = d;
|
283
|
+
this.setValue();
|
284
|
+
this.viewDate = this.date;
|
285
|
+
this.fill();
|
286
|
+
} else {
|
287
|
+
this.element.trigger({
|
288
|
+
type: 'outOfRange',
|
289
|
+
date: d,
|
290
|
+
startDate: this.startDate,
|
291
|
+
endDate: this.endDate
|
292
|
+
});
|
293
|
+
}
|
271
294
|
},
|
272
295
|
|
273
296
|
setValue: function() {
|
274
297
|
var formatted = this.getFormattedDate();
|
275
298
|
if (!this.isInput) {
|
276
299
|
if (this.component){
|
277
|
-
this.element.find('input').
|
300
|
+
this.element.find('input').prop('value', formatted);
|
278
301
|
}
|
279
302
|
this.element.data('date', formatted);
|
280
303
|
} else {
|
281
|
-
this.element.
|
304
|
+
this.element.prop('value', formatted);
|
305
|
+
}
|
306
|
+
if (this.linkField) {
|
307
|
+
$('#' + this.linkField).val(this.getFormattedDate(this.linkFormat));
|
282
308
|
}
|
283
309
|
},
|
284
310
|
|
285
311
|
getFormattedDate: function(format) {
|
286
|
-
if
|
287
|
-
format = this.format;
|
312
|
+
if(format == undefined) format = this.format;
|
288
313
|
return DPGlobal.formatDate(this.date, format, this.language);
|
289
314
|
},
|
290
315
|
|
291
316
|
setStartDate: function(startDate){
|
292
|
-
this.startDate = startDate
|
317
|
+
this.startDate = startDate || -Infinity;
|
293
318
|
if (this.startDate !== -Infinity) {
|
294
319
|
this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language);
|
295
320
|
}
|
@@ -298,7 +323,7 @@
|
|
298
323
|
},
|
299
324
|
|
300
325
|
setEndDate: function(endDate){
|
301
|
-
this.endDate = endDate||Infinity;
|
326
|
+
this.endDate = endDate || Infinity;
|
302
327
|
if (this.endDate !== Infinity) {
|
303
328
|
this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language);
|
304
329
|
}
|
@@ -307,7 +332,7 @@
|
|
307
332
|
},
|
308
333
|
|
309
334
|
setDaysOfWeekDisabled: function(daysOfWeekDisabled){
|
310
|
-
this.daysOfWeekDisabled = daysOfWeekDisabled||[];
|
335
|
+
this.daysOfWeekDisabled = daysOfWeekDisabled || [];
|
311
336
|
if (!$.isArray(this.daysOfWeekDisabled)) {
|
312
337
|
this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
|
313
338
|
}
|
@@ -317,20 +342,28 @@
|
|
317
342
|
this.update();
|
318
343
|
this.updateNavArrows();
|
319
344
|
},
|
320
|
-
|
345
|
+
|
321
346
|
place: function(){
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
347
|
+
if(this.isInline) return;
|
348
|
+
var zIndex = parseInt(this.element.parents().filter(function() {
|
349
|
+
return $(this).css('z-index') != 'auto';
|
350
|
+
}).first().css('z-index'))+10;
|
351
|
+
var offset, left;
|
352
|
+
if (this.component) {
|
353
|
+
offset = this.component.offset();
|
354
|
+
left = offset.left;
|
355
|
+
if (this.pickerPosition == 'bottom-left') {
|
356
|
+
left += this.component.outerWidth() - this.picker.outerWidth();
|
357
|
+
}
|
358
|
+
} else {
|
359
|
+
offset = this.element.offset();
|
360
|
+
left = offset.left;
|
361
|
+
}
|
362
|
+
this.picker.css({
|
363
|
+
top: offset.top + this.height,
|
364
|
+
left: left,
|
365
|
+
zIndex: zIndex
|
366
|
+
});
|
334
367
|
},
|
335
368
|
|
336
369
|
update: function(){
|
@@ -339,9 +372,9 @@
|
|
339
372
|
date = arguments[0];
|
340
373
|
fromArgs = true;
|
341
374
|
} else {
|
342
|
-
date = this.isInput ? this.element.
|
375
|
+
date = this.isInput ? this.element.prop('value') : this.element.data('date') || this.element.find('input').prop('value');
|
343
376
|
}
|
344
|
-
|
377
|
+
|
345
378
|
this.date = DPGlobal.parseDate(date, this.format, this.language);
|
346
379
|
|
347
380
|
if(fromArgs) this.setValue();
|
@@ -359,16 +392,11 @@
|
|
359
392
|
fillDow: function(){
|
360
393
|
var dowCnt = this.weekStart,
|
361
394
|
html = '<tr>';
|
362
|
-
if(this.calendarWeeks){
|
363
|
-
var cell = '<th class="cw"> </th>';
|
364
|
-
html += cell;
|
365
|
-
this.picker.find('.datepicker-days thead tr:first-child').prepend(cell);
|
366
|
-
}
|
367
395
|
while (dowCnt < this.weekStart + 7) {
|
368
396
|
html += '<th class="dow">'+dates[this.language].daysMin[(dowCnt++)%7]+'</th>';
|
369
397
|
}
|
370
398
|
html += '</tr>';
|
371
|
-
this.picker.find('.
|
399
|
+
this.picker.find('.datetimepicker-days thead').append(html);
|
372
400
|
},
|
373
401
|
|
374
402
|
fillMonths: function(){
|
@@ -377,30 +405,39 @@
|
|
377
405
|
while (i < 12) {
|
378
406
|
html += '<span class="month">'+dates[this.language].monthsShort[i++]+'</span>';
|
379
407
|
}
|
380
|
-
this.picker.find('.
|
408
|
+
this.picker.find('.datetimepicker-months td').html(html);
|
381
409
|
},
|
382
410
|
|
383
411
|
fill: function() {
|
412
|
+
if (this.date == null || this.viewDate == null) {
|
413
|
+
return;
|
414
|
+
}
|
415
|
+
|
384
416
|
var d = new Date(this.viewDate),
|
385
417
|
year = d.getUTCFullYear(),
|
386
418
|
month = d.getUTCMonth(),
|
419
|
+
dayMonth = d.getUTCDate(),
|
420
|
+
hours = d.getUTCHours(),
|
421
|
+
minutes = d.getUTCMinutes(),
|
387
422
|
startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
|
388
423
|
startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
|
389
424
|
endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
|
390
425
|
endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
|
391
|
-
currentDate = this.date
|
426
|
+
currentDate = (new UTCDate(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.date.getUTCDate())).valueOf(),
|
392
427
|
today = new Date();
|
393
|
-
this.picker.find('.
|
428
|
+
this.picker.find('.datetimepicker-days thead th:eq(1)')
|
394
429
|
.text(dates[this.language].months[month]+' '+year);
|
430
|
+
this.picker.find('.datetimepicker-hours thead th:eq(1)')
|
431
|
+
.text(dayMonth+' '+dates[this.language].months[month]+' '+year);
|
432
|
+
this.picker.find('.datetimepicker-minutes thead th:eq(1)')
|
433
|
+
.text(dayMonth+' '+dates[this.language].months[month]+' '+year);
|
395
434
|
this.picker.find('tfoot th.today')
|
396
435
|
.text(dates[this.language].today)
|
397
436
|
.toggle(this.todayBtn !== false);
|
398
437
|
this.updateNavArrows();
|
399
438
|
this.fillMonths();
|
400
|
-
var prevMonth = UTCDate(year, month
|
401
|
-
|
402
|
-
prevMonth.setUTCDate(day);
|
403
|
-
prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
|
439
|
+
var prevMonth = UTCDate(year, month, 0,0,0,0,0);
|
440
|
+
prevMonth.setUTCDate(prevMonth.getDate() - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
|
404
441
|
var nextMonth = new Date(prevMonth);
|
405
442
|
nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
|
406
443
|
nextMonth = nextMonth.valueOf();
|
@@ -409,15 +446,8 @@
|
|
409
446
|
while(prevMonth.valueOf() < nextMonth) {
|
410
447
|
if (prevMonth.getUTCDay() == this.weekStart) {
|
411
448
|
html.push('<tr>');
|
412
|
-
if(this.calendarWeeks){
|
413
|
-
// adapted from https://github.com/timrwood/moment/blob/master/moment.js#L128
|
414
|
-
var a = new Date(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth(), prevMonth.getUTCDate() - prevMonth.getDay() + 10 - (this.weekStart && this.weekStart%7 < 5 && 7)),
|
415
|
-
b = new Date(a.getFullYear(), 0, 4),
|
416
|
-
calWeek = ~~((a - b) / 864e5 / 7 + 1.5);
|
417
|
-
html.push('<td class="cw">'+ calWeek +'</td>');
|
418
|
-
}
|
419
449
|
}
|
420
|
-
clsName = '
|
450
|
+
clsName = '';
|
421
451
|
if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
|
422
452
|
clsName += ' old';
|
423
453
|
} else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
|
@@ -430,10 +460,10 @@
|
|
430
460
|
prevMonth.getUTCDate() == today.getDate()) {
|
431
461
|
clsName += ' today';
|
432
462
|
}
|
433
|
-
if (
|
463
|
+
if (prevMonth.valueOf() == currentDate) {
|
434
464
|
clsName += ' active';
|
435
465
|
}
|
436
|
-
if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
|
466
|
+
if ((prevMonth.valueOf() + 86400000) < this.startDate || prevMonth.valueOf() > this.endDate ||
|
437
467
|
$.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1) {
|
438
468
|
clsName += ' disabled';
|
439
469
|
}
|
@@ -443,15 +473,42 @@
|
|
443
473
|
}
|
444
474
|
prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
|
445
475
|
}
|
446
|
-
this.picker.find('.
|
447
|
-
var currentYear = this.date && this.date.getUTCFullYear();
|
476
|
+
this.picker.find('.datetimepicker-days tbody').empty().append(html.join(''));
|
448
477
|
|
449
|
-
|
478
|
+
html = [];
|
479
|
+
for (var i=0;i<24;i++) {
|
480
|
+
var actual = UTCDate(year, month, dayMonth, i);
|
481
|
+
clsName = '';
|
482
|
+
// We want the previous hour for the startDate
|
483
|
+
if ((actual.valueOf() + 3600000) < this.startDate || actual.valueOf() > this.endDate) {
|
484
|
+
clsName += ' disabled';
|
485
|
+
} else if (hours == i) {
|
486
|
+
clsName += ' active';
|
487
|
+
}
|
488
|
+
html.push('<span class="hour'+clsName+'">'+i+':00</span>');
|
489
|
+
}
|
490
|
+
this.picker.find('.datetimepicker-hours td').html(html.join(''));
|
491
|
+
|
492
|
+
html = [];
|
493
|
+
for(var i=0;i<60;i+=this.minuteStep) {
|
494
|
+
var actual = UTCDate(year, month, dayMonth, hours, i);
|
495
|
+
clsName = '';
|
496
|
+
if (actual.valueOf() < this.startDate || actual.valueOf() > this.endDate) {
|
497
|
+
clsName += ' disabled';
|
498
|
+
} else if (Math.floor(minutes/this.minuteStep) == Math.floor(i/this.minuteStep)) {
|
499
|
+
clsName += ' active';
|
500
|
+
}
|
501
|
+
html.push('<span class="minute'+clsName+'">'+hours+':'+(i<10?'0'+i:i)+'</span>');
|
502
|
+
}
|
503
|
+
this.picker.find('.datetimepicker-minutes td').html(html.join(''));
|
504
|
+
|
505
|
+
var currentYear = this.date.getUTCFullYear();
|
506
|
+
var months = this.picker.find('.datetimepicker-months')
|
450
507
|
.find('th:eq(1)')
|
451
|
-
|
452
|
-
|
508
|
+
.text(year)
|
509
|
+
.end()
|
453
510
|
.find('span').removeClass('active');
|
454
|
-
if (currentYear
|
511
|
+
if (currentYear == year) {
|
455
512
|
months.eq(this.date.getUTCMonth()).addClass('active');
|
456
513
|
}
|
457
514
|
if (year < startYear || year > endYear) {
|
@@ -466,10 +523,10 @@
|
|
466
523
|
|
467
524
|
html = '';
|
468
525
|
year = parseInt(year/10, 10) * 10;
|
469
|
-
var yearCont = this.picker.find('.
|
526
|
+
var yearCont = this.picker.find('.datetimepicker-years')
|
470
527
|
.find('th:eq(1)')
|
471
|
-
|
472
|
-
|
528
|
+
.text(year + '-' + (year + 9))
|
529
|
+
.end()
|
473
530
|
.find('td');
|
474
531
|
year -= 1;
|
475
532
|
for (var i = -1; i < 11; i++) {
|
@@ -482,22 +539,60 @@
|
|
482
539
|
updateNavArrows: function() {
|
483
540
|
var d = new Date(this.viewDate),
|
484
541
|
year = d.getUTCFullYear(),
|
485
|
-
month = d.getUTCMonth()
|
542
|
+
month = d.getUTCMonth(),
|
543
|
+
day = d.getUTCDate(),
|
544
|
+
hour = d.getUTCHours();
|
486
545
|
switch (this.viewMode) {
|
487
546
|
case 0:
|
488
|
-
if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
|
547
|
+
if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
|
548
|
+
&& month <= this.startDate.getUTCMonth()
|
549
|
+
&& day <= this.startDate.getUTCDate()
|
550
|
+
&& hour <= this.startDate.getUTCHours()) {
|
489
551
|
this.picker.find('.prev').css({visibility: 'hidden'});
|
490
552
|
} else {
|
491
553
|
this.picker.find('.prev').css({visibility: 'visible'});
|
492
554
|
}
|
493
|
-
if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
|
555
|
+
if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
|
556
|
+
&& month >= this.endDate.getUTCMonth()
|
557
|
+
&& day >= this.endDate.getUTCDate()
|
558
|
+
&& hour >= this.endDate.getUTCHours()) {
|
494
559
|
this.picker.find('.next').css({visibility: 'hidden'});
|
495
560
|
} else {
|
496
561
|
this.picker.find('.next').css({visibility: 'visible'});
|
497
562
|
}
|
498
563
|
break;
|
499
564
|
case 1:
|
565
|
+
if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
|
566
|
+
&& month <= this.startDate.getUTCMonth()
|
567
|
+
&& day <= this.startDate.getUTCDate()) {
|
568
|
+
this.picker.find('.prev').css({visibility: 'hidden'});
|
569
|
+
} else {
|
570
|
+
this.picker.find('.prev').css({visibility: 'visible'});
|
571
|
+
}
|
572
|
+
if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
|
573
|
+
&& month >= this.endDate.getUTCMonth()
|
574
|
+
&& day >= this.endDate.getUTCDate()) {
|
575
|
+
this.picker.find('.next').css({visibility: 'hidden'});
|
576
|
+
} else {
|
577
|
+
this.picker.find('.next').css({visibility: 'visible'});
|
578
|
+
}
|
579
|
+
break;
|
500
580
|
case 2:
|
581
|
+
if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
|
582
|
+
&& month <= this.startDate.getUTCMonth()) {
|
583
|
+
this.picker.find('.prev').css({visibility: 'hidden'});
|
584
|
+
} else {
|
585
|
+
this.picker.find('.prev').css({visibility: 'visible'});
|
586
|
+
}
|
587
|
+
if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
|
588
|
+
&& month >= this.endDate.getUTCMonth()) {
|
589
|
+
this.picker.find('.next').css({visibility: 'hidden'});
|
590
|
+
} else {
|
591
|
+
this.picker.find('.next').css({visibility: 'visible'});
|
592
|
+
}
|
593
|
+
break;
|
594
|
+
case 3:
|
595
|
+
case 4:
|
501
596
|
if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
|
502
597
|
this.picker.find('.prev').css({visibility: 'hidden'});
|
503
598
|
} else {
|
@@ -516,16 +611,25 @@
|
|
516
611
|
e.stopPropagation();
|
517
612
|
e.preventDefault();
|
518
613
|
|
519
|
-
if ($(e.target).hasClass('
|
614
|
+
if ($(e.target).hasClass('datetimepicker-close')){
|
520
615
|
this.hide();
|
521
616
|
}
|
522
617
|
|
523
618
|
var target = $(e.target).closest('span, td, th');
|
524
619
|
if (target.length == 1) {
|
620
|
+
if (target.is('.disabled')) {
|
621
|
+
this.element.trigger({
|
622
|
+
type: 'outOfRange',
|
623
|
+
date: this.viewDate,
|
624
|
+
startDate: this.startDate,
|
625
|
+
endDate: this.endDate
|
626
|
+
});
|
627
|
+
return;
|
628
|
+
}
|
525
629
|
switch(target[0].nodeName.toLowerCase()) {
|
526
630
|
case 'th':
|
527
631
|
switch(target[0].className) {
|
528
|
-
case '
|
632
|
+
case 'switch':
|
529
633
|
this.showMode(1);
|
530
634
|
break;
|
531
635
|
case 'prev':
|
@@ -533,10 +637,16 @@
|
|
533
637
|
var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
|
534
638
|
switch(this.viewMode){
|
535
639
|
case 0:
|
536
|
-
this.viewDate = this.
|
640
|
+
this.viewDate = this.moveHour(this.viewDate, dir);
|
537
641
|
break;
|
538
642
|
case 1:
|
643
|
+
this.viewDate = this.moveDate(this.viewDate, dir);
|
644
|
+
break;
|
539
645
|
case 2:
|
646
|
+
this.viewDate = this.moveMonth(this.viewDate, dir);
|
647
|
+
break;
|
648
|
+
case 3:
|
649
|
+
case 4:
|
540
650
|
this.viewDate = this.moveYear(this.viewDate, dir);
|
541
651
|
break;
|
542
652
|
}
|
@@ -544,41 +654,72 @@
|
|
544
654
|
break;
|
545
655
|
case 'today':
|
546
656
|
var date = new Date();
|
547
|
-
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(),
|
657
|
+
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
|
548
658
|
|
549
|
-
this.
|
550
|
-
|
551
|
-
this._setDate(date
|
659
|
+
this.viewMode = this.startViewMode;
|
660
|
+
this.showMode(0);
|
661
|
+
this._setDate(date);
|
552
662
|
break;
|
553
663
|
}
|
554
664
|
break;
|
555
665
|
case 'span':
|
556
666
|
if (!target.is('.disabled')) {
|
557
|
-
this.viewDate.setUTCDate(1);
|
558
667
|
if (target.is('.month')) {
|
668
|
+
this.viewDate.setUTCDate(1);
|
559
669
|
var month = target.parent().find('span').index(target);
|
560
670
|
this.viewDate.setUTCMonth(month);
|
561
671
|
this.element.trigger({
|
562
672
|
type: 'changeMonth',
|
563
673
|
date: this.viewDate
|
564
674
|
});
|
565
|
-
} else {
|
566
|
-
|
675
|
+
} else if (target.is('.year')) {
|
676
|
+
this.viewDate.setUTCDate(1);
|
677
|
+
var year = parseInt(target.text(), 10) || 0;
|
567
678
|
this.viewDate.setUTCFullYear(year);
|
568
679
|
this.element.trigger({
|
569
680
|
type: 'changeYear',
|
570
681
|
date: this.viewDate
|
571
682
|
});
|
683
|
+
} else if (target.is('.hour')){
|
684
|
+
var hours = parseInt(target.text(), 10) || 0;
|
685
|
+
var year = this.viewDate.getUTCFullYear(),
|
686
|
+
month = this.viewDate.getUTCMonth(),
|
687
|
+
day = this.viewDate.getUTCDate(),
|
688
|
+
minutes = this.viewDate.getUTCMinutes(),
|
689
|
+
seconds = this.viewDate.getUTCSeconds();
|
690
|
+
this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
|
691
|
+
} else if (target.is('.minute')){
|
692
|
+
var minutes = parseInt(target.text().substr(target.text().indexOf(':')+1), 10) || 0;
|
693
|
+
var year = this.viewDate.getUTCFullYear(),
|
694
|
+
month = this.viewDate.getUTCMonth(),
|
695
|
+
day = this.viewDate.getUTCDate(),
|
696
|
+
hours = this.viewDate.getUTCHours(),
|
697
|
+
seconds = this.viewDate.getUTCSeconds();
|
698
|
+
this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
|
699
|
+
}
|
700
|
+
if (this.viewMode != 0) {
|
701
|
+
var oldViewMode = this.viewMode;
|
702
|
+
this.showMode(-1);
|
703
|
+
this.fill();
|
704
|
+
if (oldViewMode == this.viewMode && this.autoclose) {
|
705
|
+
this.hide();
|
706
|
+
}
|
707
|
+
} else {
|
708
|
+
this.fill();
|
709
|
+
if (this.autoclose) {
|
710
|
+
this.hide();
|
711
|
+
}
|
572
712
|
}
|
573
|
-
this.showMode(-1);
|
574
|
-
this.fill();
|
575
713
|
}
|
576
714
|
break;
|
577
715
|
case 'td':
|
578
716
|
if (target.is('.day') && !target.is('.disabled')){
|
579
|
-
var day = parseInt(target.text(), 10)||1;
|
717
|
+
var day = parseInt(target.text(), 10) || 1;
|
580
718
|
var year = this.viewDate.getUTCFullYear(),
|
581
|
-
month = this.viewDate.getUTCMonth()
|
719
|
+
month = this.viewDate.getUTCMonth(),
|
720
|
+
hours = this.viewDate.getUTCHours(),
|
721
|
+
minutes = this.viewDate.getUTCMinutes(),
|
722
|
+
seconds = this.viewDate.getUTCSeconds();
|
582
723
|
if (target.is('.old')) {
|
583
724
|
if (month === 0) {
|
584
725
|
month = 11;
|
@@ -594,7 +735,13 @@
|
|
594
735
|
month += 1;
|
595
736
|
}
|
596
737
|
}
|
597
|
-
this._setDate(UTCDate(year, month, day,
|
738
|
+
this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
|
739
|
+
}
|
740
|
+
var oldViewMode = this.viewMode;
|
741
|
+
this.showMode(-1);
|
742
|
+
this.fill();
|
743
|
+
if (oldViewMode == this.viewMode && this.autoclose) {
|
744
|
+
this.hide();
|
598
745
|
}
|
599
746
|
break;
|
600
747
|
}
|
@@ -607,11 +754,11 @@
|
|
607
754
|
if (!which || which == 'view')
|
608
755
|
this.viewDate = date;
|
609
756
|
this.fill();
|
610
|
-
this.setValue();
|
611
757
|
this.element.trigger({
|
612
758
|
type: 'changeDate',
|
613
759
|
date: this.date
|
614
760
|
});
|
761
|
+
this.setValue();
|
615
762
|
var element;
|
616
763
|
if (this.isInput) {
|
617
764
|
element = this.element;
|
@@ -621,11 +768,27 @@
|
|
621
768
|
if (element) {
|
622
769
|
element.change();
|
623
770
|
if (this.autoclose && (!which || which == 'date')) {
|
624
|
-
this.hide();
|
771
|
+
//this.hide();
|
625
772
|
}
|
626
773
|
}
|
627
774
|
},
|
628
775
|
|
776
|
+
moveHour: function(date, dir){
|
777
|
+
if (!dir) return date;
|
778
|
+
var new_date = new Date(date.valueOf());
|
779
|
+
dir = dir > 0 ? 1 : -1;
|
780
|
+
new_date.setUTCHours(new_date.getUTCHours() + dir);
|
781
|
+
return new_date;
|
782
|
+
},
|
783
|
+
|
784
|
+
moveDate: function(date, dir){
|
785
|
+
if (!dir) return date;
|
786
|
+
var new_date = new Date(date.valueOf());
|
787
|
+
dir = dir > 0 ? 1 : -1;
|
788
|
+
new_date.setUTCDate(new_date.getUTCDate() + dir);
|
789
|
+
return new_date;
|
790
|
+
},
|
791
|
+
|
629
792
|
moveMonth: function(date, dir){
|
630
793
|
if (!dir) return date;
|
631
794
|
var new_date = new Date(date.valueOf()),
|
@@ -765,32 +928,39 @@
|
|
765
928
|
|
766
929
|
showMode: function(dir) {
|
767
930
|
if (dir) {
|
768
|
-
|
931
|
+
var newViewMode = Math.max(0, Math.min(DPGlobal.modes.length - 1, this.viewMode + dir));
|
932
|
+
if (newViewMode >= this.minView && newViewMode <= this.maxView) {
|
933
|
+
this.viewMode = newViewMode;
|
934
|
+
}
|
769
935
|
}
|
770
936
|
/*
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
937
|
+
vitalets: fixing bug of very special conditions:
|
938
|
+
jquery 1.7.1 + webkit + show inline datetimepicker in bootstrap popover.
|
939
|
+
Method show() does not set display css correctly and datetimepicker is not shown.
|
940
|
+
Changed to .css('display', 'block') solve the problem.
|
941
|
+
See https://github.com/vitalets/x-editable/issues/37
|
776
942
|
|
777
|
-
|
943
|
+
In jquery 1.7.2+ everything works fine.
|
778
944
|
*/
|
779
|
-
//this.picker.find('>div').hide().filter('.
|
780
|
-
this.picker.find('>div').hide().filter('.
|
945
|
+
//this.picker.find('>div').hide().filter('.datetimepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
|
946
|
+
this.picker.find('>div').hide().filter('.datetimepicker-'+DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
|
781
947
|
this.updateNavArrows();
|
948
|
+
},
|
949
|
+
|
950
|
+
reset: function(e) {
|
951
|
+
this._setDate(null, 'date');
|
782
952
|
}
|
783
953
|
};
|
784
954
|
|
785
|
-
$.fn.
|
955
|
+
$.fn.fdatetimepicker = function ( option ) {
|
786
956
|
var args = Array.apply(null, arguments);
|
787
957
|
args.shift();
|
788
958
|
return this.each(function () {
|
789
959
|
var $this = $(this),
|
790
|
-
data = $this.data('
|
960
|
+
data = $this.data('datetimepicker'),
|
791
961
|
options = typeof option == 'object' && option;
|
792
962
|
if (!data) {
|
793
|
-
$this.data('
|
963
|
+
$this.data('datetimepicker', (data = new Datetimepicker(this, $.extend({}, $.fn.fdatetimepicker.defaults,options))));
|
794
964
|
}
|
795
965
|
if (typeof option == 'string' && typeof data[option] == 'function') {
|
796
966
|
data[option].apply(data, args);
|
@@ -798,13 +968,10 @@
|
|
798
968
|
});
|
799
969
|
};
|
800
970
|
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
};
|
806
|
-
$.fn.fdatepicker.Constructor = Datepicker;
|
807
|
-
var dates = $.fn.fdatepicker.dates = {
|
971
|
+
$.fn.fdatetimepicker.defaults = {
|
972
|
+
};
|
973
|
+
$.fn.fdatetimepicker.Constructor = Datetimepicker;
|
974
|
+
var dates = $.fn.fdatetimepicker.dates = {
|
808
975
|
en: {
|
809
976
|
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
810
977
|
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
@@ -817,6 +984,16 @@
|
|
817
984
|
|
818
985
|
var DPGlobal = {
|
819
986
|
modes: [
|
987
|
+
{
|
988
|
+
clsName: 'minutes',
|
989
|
+
navFnc: 'Hours',
|
990
|
+
navStep: 1
|
991
|
+
},
|
992
|
+
{
|
993
|
+
clsName: 'hours',
|
994
|
+
navFnc: 'Date',
|
995
|
+
navStep: 1
|
996
|
+
},
|
820
997
|
{
|
821
998
|
clsName: 'days',
|
822
999
|
navFnc: 'Month',
|
@@ -833,28 +1010,37 @@
|
|
833
1010
|
navStep: 10
|
834
1011
|
}],
|
835
1012
|
isLeapYear: function (year) {
|
836
|
-
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
|
1013
|
+
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
|
837
1014
|
},
|
838
1015
|
getDaysInMonth: function (year, month) {
|
839
|
-
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
|
1016
|
+
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
|
840
1017
|
},
|
841
|
-
validParts: /dd?|
|
842
|
-
nonpunctuation: /[^ -\/:-@\[
|
1018
|
+
validParts: /hh?|ii?|ss?|dd?|mm?|MM?|yy(?:yy)?/g,
|
1019
|
+
nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,
|
843
1020
|
parseFormat: function(format){
|
844
1021
|
// IE treats \0 as a string end in inputs (truncating the value),
|
845
1022
|
// so it's a bad format delimiter, anyway
|
846
1023
|
var separators = format.replace(this.validParts, '\0').split('\0'),
|
847
1024
|
parts = format.match(this.validParts);
|
848
|
-
if (!separators || !separators.length || !parts || parts.length
|
1025
|
+
if (!separators || !separators.length || !parts || parts.length == 0){
|
849
1026
|
throw new Error("Invalid date format.");
|
850
1027
|
}
|
851
1028
|
return {separators: separators, parts: parts};
|
852
1029
|
},
|
853
1030
|
parseDate: function(date, format, language) {
|
854
|
-
if (date instanceof Date) return date;
|
855
|
-
if (
|
856
|
-
|
857
|
-
|
1031
|
+
if (date instanceof Date) return new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
|
1032
|
+
if (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(date)) {
|
1033
|
+
format = this.parseFormat('yyyy-mm-dd');
|
1034
|
+
}
|
1035
|
+
if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(date)) {
|
1036
|
+
format = this.parseFormat('yyyy-mm-dd hh:ii');
|
1037
|
+
}
|
1038
|
+
if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(date)) {
|
1039
|
+
format = this.parseFormat('yyyy-mm-dd hh:ii:ss');
|
1040
|
+
}
|
1041
|
+
if (/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(date)) {
|
1042
|
+
var part_re = /([-+]\d+)([dmwy])/,
|
1043
|
+
parts = date.match(/([-+]\d+)([dmwy])/g),
|
858
1044
|
part, dir;
|
859
1045
|
date = new Date();
|
860
1046
|
for (var i=0; i<parts.length; i++) {
|
@@ -865,23 +1051,29 @@
|
|
865
1051
|
date.setUTCDate(date.getUTCDate() + dir);
|
866
1052
|
break;
|
867
1053
|
case 'm':
|
868
|
-
date =
|
1054
|
+
date = Datetimepicker.prototype.moveMonth.call(Datetimepicker.prototype, date, dir);
|
869
1055
|
break;
|
870
1056
|
case 'w':
|
871
1057
|
date.setUTCDate(date.getUTCDate() + dir * 7);
|
872
1058
|
break;
|
873
1059
|
case 'y':
|
874
|
-
date =
|
1060
|
+
date = Datetimepicker.prototype.moveYear.call(Datetimepicker.prototype, date, dir);
|
875
1061
|
break;
|
876
1062
|
}
|
877
1063
|
}
|
878
|
-
return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(),
|
1064
|
+
return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
879
1065
|
}
|
880
1066
|
var parts = date && date.match(this.nonpunctuation) || [],
|
881
1067
|
date = new Date(),
|
882
1068
|
parsed = {},
|
883
|
-
setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
|
1069
|
+
setters_order = ['hh', 'h', 'ii', 'i', 'ss', 's', 'yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
|
884
1070
|
setters_map = {
|
1071
|
+
hh: function(d,v){ return d.setUTCHours(v); },
|
1072
|
+
h: function(d,v){ return d.setUTCHours(v); },
|
1073
|
+
ii: function(d,v){ return d.setUTCMinutes(v); },
|
1074
|
+
i: function(d,v){ return d.setUTCMinutes(v); },
|
1075
|
+
ss: function(d,v){ return d.setUTCSeconds(v); },
|
1076
|
+
s: function(d,v){ return d.setUTCSeconds(v); },
|
885
1077
|
yyyy: function(d,v){ return d.setUTCFullYear(v); },
|
886
1078
|
yy: function(d,v){ return d.setUTCFullYear(2000+v); },
|
887
1079
|
m: function(d,v){
|
@@ -898,19 +1090,11 @@
|
|
898
1090
|
val, filtered, part;
|
899
1091
|
setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
|
900
1092
|
setters_map['dd'] = setters_map['d'];
|
901
|
-
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
902
|
-
|
903
|
-
|
904
|
-
if (parts.length != fparts.length) {
|
905
|
-
fparts = $(fparts).filter(function(i,p){
|
906
|
-
return $.inArray(p, setters_order) !== -1;
|
907
|
-
}).toArray();
|
908
|
-
}
|
909
|
-
// Process remainder
|
910
|
-
if (parts.length == fparts.length) {
|
911
|
-
for (var i=0, cnt = fparts.length; i < cnt; i++) {
|
1093
|
+
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);//date.getHours(), date.getMinutes(), date.getSeconds());
|
1094
|
+
if (parts.length == format.parts.length) {
|
1095
|
+
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
912
1096
|
val = parseInt(parts[i], 10);
|
913
|
-
part =
|
1097
|
+
part = format.parts[i];
|
914
1098
|
if (isNaN(val)) {
|
915
1099
|
switch(part) {
|
916
1100
|
case 'MM':
|
@@ -936,69 +1120,115 @@
|
|
936
1120
|
for (var i=0, s; i<setters_order.length; i++){
|
937
1121
|
s = setters_order[i];
|
938
1122
|
if (s in parsed && !isNaN(parsed[s]))
|
939
|
-
setters_map[s](date, parsed[s])
|
1123
|
+
setters_map[s](date, parsed[s])
|
940
1124
|
}
|
941
1125
|
}
|
942
1126
|
return date;
|
943
1127
|
},
|
944
1128
|
formatDate: function(date, format, language){
|
1129
|
+
if (date == null) {
|
1130
|
+
return '';
|
1131
|
+
}
|
945
1132
|
var val = {
|
1133
|
+
h: date.getUTCHours(),
|
1134
|
+
i: date.getUTCMinutes(),
|
1135
|
+
s: date.getUTCSeconds(),
|
946
1136
|
d: date.getUTCDate(),
|
947
|
-
D: dates[language].daysShort[date.getUTCDay()],
|
948
|
-
DD: dates[language].days[date.getUTCDay()],
|
949
1137
|
m: date.getUTCMonth() + 1,
|
950
1138
|
M: dates[language].monthsShort[date.getUTCMonth()],
|
951
1139
|
MM: dates[language].months[date.getUTCMonth()],
|
952
1140
|
yy: date.getUTCFullYear().toString().substring(2),
|
953
1141
|
yyyy: date.getUTCFullYear()
|
954
1142
|
};
|
1143
|
+
val.hh = (val.h < 10 ? '0' : '') + val.h;
|
1144
|
+
val.ii = (val.i < 10 ? '0' : '') + val.i;
|
1145
|
+
val.ss = (val.s < 10 ? '0' : '') + val.s;
|
955
1146
|
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
956
1147
|
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
957
1148
|
var date = [],
|
958
1149
|
seps = $.extend([], format.separators);
|
959
1150
|
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
960
1151
|
if (seps.length)
|
961
|
-
date.push(seps.shift())
|
1152
|
+
date.push(seps.shift())
|
962
1153
|
date.push(val[format.parts[i]]);
|
963
1154
|
}
|
964
1155
|
return date.join('');
|
965
1156
|
},
|
1157
|
+
convertViewMode: function(viewMode){
|
1158
|
+
switch (viewMode) {
|
1159
|
+
case 4:
|
1160
|
+
case 'decade':
|
1161
|
+
viewMode = 4;
|
1162
|
+
break;
|
1163
|
+
case 3:
|
1164
|
+
case 'year':
|
1165
|
+
viewMode = 3;
|
1166
|
+
break;
|
1167
|
+
case 2:
|
1168
|
+
case 'month':
|
1169
|
+
viewMode = 2;
|
1170
|
+
break;
|
1171
|
+
case 1:
|
1172
|
+
case 'day':
|
1173
|
+
viewMode = 1;
|
1174
|
+
break;
|
1175
|
+
case 0:
|
1176
|
+
case 'hour':
|
1177
|
+
viewMode = 0;
|
1178
|
+
break;
|
1179
|
+
}
|
1180
|
+
|
1181
|
+
return viewMode;
|
1182
|
+
},
|
966
1183
|
headTemplate: '<thead>'+
|
967
1184
|
'<tr>'+
|
968
1185
|
'<th class="prev"><i class="icon-chevron-left"/></th>'+
|
969
|
-
'<th colspan="5" class="
|
1186
|
+
'<th colspan="5" class="switch"></th>'+
|
970
1187
|
'<th class="next"><i class="icon-chevron-right"/></th>'+
|
971
1188
|
'</tr>'+
|
972
1189
|
'</thead>',
|
973
1190
|
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
|
974
1191
|
footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
|
975
1192
|
};
|
976
|
-
DPGlobal.template = '<div class="
|
977
|
-
|
978
|
-
|
1193
|
+
DPGlobal.template = '<div class="datetimepicker">'+
|
1194
|
+
'<div class="datetimepicker-minutes">'+
|
1195
|
+
'<table class=" table-condensed">'+
|
1196
|
+
DPGlobal.headTemplate+
|
1197
|
+
DPGlobal.contTemplate+
|
1198
|
+
DPGlobal.footTemplate+
|
1199
|
+
'</table>'+
|
1200
|
+
'</div>'+
|
1201
|
+
'<div class="datetimepicker-hours">'+
|
1202
|
+
'<table class=" table-condensed">'+
|
1203
|
+
DPGlobal.headTemplate+
|
1204
|
+
DPGlobal.contTemplate+
|
1205
|
+
DPGlobal.footTemplate+
|
1206
|
+
'</table>'+
|
1207
|
+
'</div>'+
|
1208
|
+
'<div class="datetimepicker-days">'+
|
979
1209
|
'<table class=" table-condensed">'+
|
980
1210
|
DPGlobal.headTemplate+
|
981
1211
|
'<tbody></tbody>'+
|
982
1212
|
DPGlobal.footTemplate+
|
983
1213
|
'</table>'+
|
984
1214
|
'</div>'+
|
985
|
-
'<div class="
|
1215
|
+
'<div class="datetimepicker-months">'+
|
986
1216
|
'<table class="table-condensed">'+
|
987
1217
|
DPGlobal.headTemplate+
|
988
1218
|
DPGlobal.contTemplate+
|
989
1219
|
DPGlobal.footTemplate+
|
990
1220
|
'</table>'+
|
991
1221
|
'</div>'+
|
992
|
-
'<div class="
|
1222
|
+
'<div class="datetimepicker-years">'+
|
993
1223
|
'<table class="table-condensed">'+
|
994
1224
|
DPGlobal.headTemplate+
|
995
1225
|
DPGlobal.contTemplate+
|
996
1226
|
DPGlobal.footTemplate+
|
997
1227
|
'</table>'+
|
998
1228
|
'</div>'+
|
999
|
-
'<a class="button
|
1229
|
+
'<a class="button datetimepicker-close small alert right" style="width:auto;"><i class="icon-remove"></i></a>'+
|
1000
1230
|
'</div>';
|
1001
1231
|
|
1002
|
-
$.fn.
|
1232
|
+
$.fn.fdatetimepicker.DPGlobal = DPGlobal;
|
1003
1233
|
|
1004
1234
|
}( window.jQuery );
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/*
|
2
2
|
.datepicker {
|
3
3
|
.prev, .next {font-style:normal;}
|
4
|
-
.prev:after {content:"
|
5
|
-
.next:after {content:"
|
4
|
+
.prev:after {content:"«";}
|
5
|
+
.next:after {content:"»";}
|
6
6
|
}
|
7
7
|
*/
|
8
8
|
/*!
|
@@ -16,5 +16,5 @@
|
|
16
16
|
* Improvements by Andrew Rowls
|
17
17
|
* Licensed under the Apache License v2.0
|
18
18
|
* http://www.apache.org/licenses/LICENSE-2.0
|
19
|
-
*/.
|
20
|
-
/* This beautiful CSS-File has been crafted with LESS (lesscss.org) and compiled by simpLESS (wearekiss.com/simpless) */
|
19
|
+
*/.datetimepicker.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;float:left;display:none;min-width:160px;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;*border-right-width:2px;*border-bottom-width:2px;color:#333;font-family:"Open Sans",sans-serif;font-size:13px;line-height:18px}.datetimepicker.dropdown-menu th,.datetimepicker.dropdown-menu td{padding:4px 5px}.datetimepicker{display:none;position:absolute;padding:4px;margin-top:1px;direction:ltr}.datetimepicker-inline{width:220px;display:none}.datetimepicker-rtl{direction:rtl}.datetimepicker-rtl table tr td span{float:right}.datetimepicker-dropdown{top:0;left:0}.datetimepicker-dropdown:before{content:'';display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:rgba(0,0,0,.2);position:absolute;top:-7px;left:6px}.datetimepicker-dropdown:after{content:'';display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #fff;position:absolute;top:-6px;left:7px}.datetimepicker>div{display:none}.datetimepicker.days div.datepicker-days{display:block}.datetimepicker.months div.datepicker-months{display:block}.datetimepicker.years div.datepicker-years{display:block}.datetimepicker table{border:0;margin:0}.datetimepicker td,.datetimepicker th{text-align:center;width:20px;height:20px;border:0;font-size:12px;padding:4px 8px;background:#fff;cursor:pointer}.datetimepicker td.active.day,.datetimepicker th.active.day{background:#2ba6cb}.datetimepicker td.active.year,.datetimepicker th.active.year{background:#2ba6cb}.datetimepicker td span.active,.datetimepicker th span.active{background:#2ba6cb}.table-striped .datetimepicker table tr td,.table-striped .datetimepicker table tr th{background-color:transparent}.datetimepicker table tr td span{display:block;width:23%;height:54px;line-height:54px;float:left;margin:1%;cursor:pointer}.datetimepicker th.switch{width:145px}.datetimepicker thead tr:first-child th,.datetimepicker tfoot tr:first-child th{cursor:pointer}.datetimepicker .cw{font-size:10px;width:12px;padding:0 2px 0 5px;vertical-align:middle}.datetimepicker thead tr:first-child th.cw{cursor:default;background-color:transparent}.datetimepicker-dropdown::before,.datetimepicker-dropdown::after{display:none}.datetimepicker-close{position:absolute;top:-30px;right:0;width:15px;height:30px;padding:0;display:none}
|
20
|
+
/* This beautiful CSS-File has been crafted with LESS (lesscss.org) and compiled by simpLESS (wearekiss.com/simpless) */
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foundation-datetimepicker-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ali Ibrahim
|