chronopicker 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1461 @@
1
+ !function ($) {
2
+
3
+ "use strict"; // jshint ;_;
4
+
5
+
6
+ /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
7
+ * ======================================================= */
8
+
9
+ $(function () {
10
+
11
+ $.support.transition = (function () {
12
+
13
+ var transitionEnd = (function () {
14
+
15
+ var el = document.createElement('bootstrap')
16
+ , transEndEventNames = {
17
+ 'WebkitTransition' : 'webkitTransitionEnd'
18
+ , 'MozTransition' : 'transitionend'
19
+ , 'OTransition' : 'oTransitionEnd otransitionend'
20
+ , 'transition' : 'transitionend'
21
+ }
22
+ , name
23
+
24
+ for (name in transEndEventNames){
25
+ if (el.style[name] !== undefined) {
26
+ return transEndEventNames[name]
27
+ }
28
+ }
29
+
30
+ }())
31
+
32
+ return transitionEnd && {
33
+ end: transitionEnd
34
+ }
35
+
36
+ })()
37
+
38
+ })
39
+
40
+ }(window.jQuery);/* =============================================================
41
+ * bootstrap-collapse.js v2.2.2
42
+ * http://twitter.github.com/bootstrap/javascript.html#collapse
43
+ * =============================================================
44
+ * Copyright 2012 Twitter, Inc.
45
+ *
46
+ * Licensed under the Apache License, Version 2.0 (the "License");
47
+ * you may not use this file except in compliance with the License.
48
+ * You may obtain a copy of the License at
49
+ *
50
+ * http://www.apache.org/licenses/LICENSE-2.0
51
+ *
52
+ * Unless required by applicable law or agreed to in writing, software
53
+ * distributed under the License is distributed on an "AS IS" BASIS,
54
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55
+ * See the License for the specific language governing permissions and
56
+ * limitations under the License.
57
+ * ============================================================ */
58
+
59
+
60
+ !function ($) {
61
+
62
+ "use strict"; // jshint ;_;
63
+
64
+
65
+ /* COLLAPSE PUBLIC CLASS DEFINITION
66
+ * ================================ */
67
+
68
+ var Collapse = function (element, options) {
69
+ this.$element = $(element)
70
+ this.options = $.extend({}, $.fn.collapse.defaults, options)
71
+
72
+ if (this.options.parent) {
73
+ this.$parent = $(this.options.parent)
74
+ }
75
+
76
+ this.options.toggle && this.toggle()
77
+ }
78
+
79
+ Collapse.prototype = {
80
+
81
+ constructor: Collapse
82
+
83
+ , dimension: function () {
84
+ var hasWidth = this.$element.hasClass('width')
85
+ return hasWidth ? 'width' : 'height'
86
+ }
87
+
88
+ , show: function () {
89
+ var dimension
90
+ , scroll
91
+ , actives
92
+ , hasData
93
+
94
+ if (this.transitioning) return
95
+
96
+ dimension = this.dimension()
97
+ scroll = $.camelCase(['scroll', dimension].join('-'))
98
+ actives = this.$parent && this.$parent.find('> .accordion-group > .in')
99
+
100
+ if (actives && actives.length) {
101
+ hasData = actives.data('collapse')
102
+ if (hasData && hasData.transitioning) return
103
+ actives.collapse('hide')
104
+ hasData || actives.data('collapse', null)
105
+ }
106
+
107
+ this.$element[dimension](0)
108
+ this.transition('addClass', $.Event('show'), 'shown')
109
+ $.support.transition && this.$element[dimension](this.$element[0][scroll])
110
+ }
111
+
112
+ , hide: function () {
113
+ var dimension
114
+ if (this.transitioning) return
115
+ dimension = this.dimension()
116
+ this.reset(this.$element[dimension]())
117
+ this.transition('removeClass', $.Event('hide'), 'hidden')
118
+ this.$element[dimension](0)
119
+ }
120
+
121
+ , reset: function (size) {
122
+ var dimension = this.dimension()
123
+
124
+ this.$element
125
+ .removeClass('collapse')
126
+ [dimension](size || 'auto')
127
+ [0].offsetWidth
128
+
129
+ this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
130
+
131
+ return this
132
+ }
133
+
134
+ , transition: function (method, startEvent, completeEvent) {
135
+ var that = this
136
+ , complete = function () {
137
+ if (startEvent.type == 'show') that.reset()
138
+ that.transitioning = 0
139
+ that.$element.trigger(completeEvent)
140
+ }
141
+
142
+ this.$element.trigger(startEvent)
143
+
144
+ if (startEvent.isDefaultPrevented()) return
145
+
146
+ this.transitioning = 1
147
+
148
+ this.$element[method]('in')
149
+
150
+ $.support.transition && this.$element.hasClass('collapse') ?
151
+ this.$element.one($.support.transition.end, complete) :
152
+ complete()
153
+ }
154
+
155
+ , toggle: function () {
156
+ this[this.$element.hasClass('in') ? 'hide' : 'show']()
157
+ }
158
+
159
+ }
160
+
161
+
162
+ /* COLLAPSE PLUGIN DEFINITION
163
+ * ========================== */
164
+
165
+ var old = $.fn.collapse
166
+
167
+ $.fn.collapse = function (option) {
168
+ return this.each(function () {
169
+ var $this = $(this)
170
+ , data = $this.data('collapse')
171
+ , options = typeof option == 'object' && option
172
+ if (!data) $this.data('collapse', (data = new Collapse(this, options)))
173
+ if (typeof option == 'string') data[option]()
174
+ })
175
+ }
176
+
177
+ $.fn.collapse.defaults = {
178
+ toggle: true
179
+ }
180
+
181
+ $.fn.collapse.Constructor = Collapse
182
+
183
+
184
+ /* COLLAPSE NO CONFLICT
185
+ * ==================== */
186
+
187
+ $.fn.collapse.noConflict = function () {
188
+ $.fn.collapse = old
189
+ return this
190
+ }
191
+
192
+
193
+ /* COLLAPSE DATA-API
194
+ * ================= */
195
+
196
+ $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
197
+ var $this = $(this), href
198
+ , target = $this.attr('data-target')
199
+ || e.preventDefault()
200
+ || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
201
+ , option = $(target).data('collapse') ? 'toggle' : $this.data()
202
+ $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
203
+ $(target).collapse(option)
204
+ })
205
+
206
+ }(window.jQuery);
207
+
208
+ /**
209
+ * @license
210
+ * =========================================================
211
+ * bootstrap-datetimepicker.js
212
+ * http://www.eyecon.ro/bootstrap-datepicker
213
+ * =========================================================
214
+ * Copyright 2012 Stefan Petre
215
+ *
216
+ * Contributions:
217
+ * - Andrew Rowls
218
+ * - Thiago de Arruda
219
+ *
220
+ * Licensed under the Apache License, Version 2.0 (the "License");
221
+ * you may not use this file except in compliance with the License.
222
+ * You may obtain a copy of the License at
223
+ *
224
+ * http://www.apache.org/licenses/LICENSE-2.0
225
+ *
226
+ * Unless required by applicable law or agreed to in writing, software
227
+ * distributed under the License is distributed on an "AS IS" BASIS,
228
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
229
+ * See the License for the specific language governing permissions and
230
+ * limitations under the License.
231
+ * =========================================================
232
+ */
233
+
234
+ (function($) {
235
+
236
+ // Picker object
237
+ var smartPhone = (window.orientation != undefined);
238
+ var DateTimePicker = function(element, options) {
239
+ this.id = dpgId++;
240
+ this.init(element, options);
241
+ };
242
+
243
+ var dateToDate = function(dt) {
244
+ if (typeof dt === 'string') {
245
+ return new Date(dt);
246
+ }
247
+ return dt;
248
+ };
249
+
250
+ DateTimePicker.prototype = {
251
+ constructor: DateTimePicker,
252
+
253
+ init: function(element, options) {
254
+ var icon;
255
+ if (!(options.pickTime || options.pickDate))
256
+ throw new Error('Must choose at least one picker');
257
+ this.options = options;
258
+ this.$element = $(element);
259
+ this.language = options.language in dates ? options.language : 'en'
260
+ this.pickDate = options.pickDate;
261
+ this.pickTime = options.pickTime;
262
+ this.isInput = this.$element.is('input');
263
+ this.component = false;
264
+ if (this.$element.is('.input-append') || this.$element.is('.input-prepend'))
265
+ this.component = this.$element.find('.add-on');
266
+ this.format = options.format;
267
+ if (!this.format) {
268
+ if (this.isInput) this.format = this.$element.data('format');
269
+ else this.format = this.$element.find('input').data('format');
270
+ if (!this.format) this.format = 'MM/dd/yyyy';
271
+ }
272
+ this._compileFormat();
273
+ if (this.component) {
274
+ icon = this.component.find('i');
275
+ }
276
+ if (this.pickTime) {
277
+ if (icon && icon.length) this.timeIcon = icon.data('time-icon');
278
+ if (!this.timeIcon) this.timeIcon = 'icon-time';
279
+ icon.addClass(this.timeIcon);
280
+ }
281
+ if (this.pickDate) {
282
+ if (icon && icon.length) this.dateIcon = icon.data('date-icon');
283
+ if (!this.dateIcon) this.dateIcon = 'icon-calendar';
284
+ icon.removeClass(this.timeIcon);
285
+ icon.addClass(this.dateIcon);
286
+ }
287
+ this.widget = $(getTemplate(this.timeIcon, options.pickDate, options.pickTime, options.pick12HourFormat, options.pickSeconds)).appendTo('body');
288
+ this.minViewMode = options.minViewMode||this.$element.data('date-minviewmode')||0;
289
+ if (typeof this.minViewMode === 'string') {
290
+ switch (this.minViewMode) {
291
+ case 'months':
292
+ this.minViewMode = 1;
293
+ break;
294
+ case 'years':
295
+ this.minViewMode = 2;
296
+ break;
297
+ default:
298
+ this.minViewMode = 0;
299
+ break;
300
+ }
301
+ }
302
+ this.viewMode = options.viewMode||this.$element.data('date-viewmode')||0;
303
+ if (typeof this.viewMode === 'string') {
304
+ switch (this.viewMode) {
305
+ case 'months':
306
+ this.viewMode = 1;
307
+ break;
308
+ case 'years':
309
+ this.viewMode = 2;
310
+ break;
311
+ default:
312
+ this.viewMode = 0;
313
+ break;
314
+ }
315
+ }
316
+ this.startViewMode = this.viewMode;
317
+ this.weekStart = options.weekStart||this.$element.data('date-weekstart')||0;
318
+ this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
319
+ this.setStartDate(options.startDate || this.$element.data('date-startdate'));
320
+ this.setEndDate(options.endDate || this.$element.data('date-enddate'));
321
+ this.fillDow();
322
+ this.fillMonths();
323
+ this.fillHours();
324
+ this.fillMinutes();
325
+ this.fillSeconds();
326
+ this.update();
327
+ this.showMode();
328
+ this._attachDatePickerEvents();
329
+ },
330
+
331
+ show: function(e) {
332
+ this.widget.show();
333
+ this.height = this.component ? this.component.outerHeight() : this.$element.outerHeight();
334
+ this.place();
335
+ this.$element.trigger({
336
+ type: 'show',
337
+ date: this._date
338
+ });
339
+ this._attachDatePickerGlobalEvents();
340
+ if (e) {
341
+ e.stopPropagation();
342
+ e.preventDefault();
343
+ }
344
+ },
345
+
346
+ disable: function(){
347
+ this.$element.find('input').prop('disabled',true);
348
+ this._detachDatePickerEvents();
349
+ },
350
+ enable: function(){
351
+ this.$element.find('input').prop('disabled',false);
352
+ this._attachDatePickerEvents();
353
+ },
354
+
355
+ hide: function() {
356
+ // Ignore event if in the middle of a picker transition
357
+ var collapse = this.widget.find('.collapse')
358
+ for (var i = 0; i < collapse.length; i++) {
359
+ var collapseData = collapse.eq(i).data('collapse');
360
+ if (collapseData && collapseData.transitioning)
361
+ return;
362
+ }
363
+ this.widget.hide();
364
+ this.viewMode = this.startViewMode;
365
+ this.showMode();
366
+ this.set();
367
+ this.$element.trigger({
368
+ type: 'hide',
369
+ date: this._date
370
+ });
371
+ this._detachDatePickerGlobalEvents();
372
+ },
373
+
374
+ set: function() {
375
+ var formatted = '';
376
+ if (!this._unset) formatted = this.formatDate(this._date);
377
+ if (!this.isInput) {
378
+ if (this.component){
379
+ var input = this.$element.find('input');
380
+ input.val(formatted);
381
+ this._resetMaskPos(input);
382
+ }
383
+ this.$element.data('date', formatted);
384
+ } else {
385
+ this.$element.val(formatted);
386
+ this._resetMaskPos(this.$element);
387
+ }
388
+ },
389
+
390
+ setValue: function(newDate) {
391
+ if (!newDate) {
392
+ this._unset = true;
393
+ } else {
394
+ this._unset = false;
395
+ }
396
+ if (typeof newDate === 'string') {
397
+ this._date = this.parseDate(newDate);
398
+ } else if(newDate) {
399
+ this._date = new Date(newDate);
400
+ }
401
+ this.set();
402
+ this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0);
403
+ this.fillDate();
404
+ this.fillTime();
405
+ },
406
+
407
+ getDate: function() {
408
+ if (this._unset) return null;
409
+ return new Date(this._date.valueOf());
410
+ },
411
+
412
+ setDate: function(date) {
413
+ if (!date) this.setValue(null);
414
+ else this.setValue(date.valueOf());
415
+ },
416
+
417
+ setStartDate: function(date) {
418
+ if (date instanceof Date) {
419
+ this.startDate = date;
420
+ } else if (typeof date === 'string') {
421
+ this.startDate = new UTCDate(date);
422
+ if (! this.startDate.getUTCFullYear()) {
423
+ this.startDate = -Infinity;
424
+ }
425
+ } else {
426
+ this.startDate = -Infinity;
427
+ }
428
+ if (this.viewDate) {
429
+ this.update();
430
+ }
431
+ },
432
+
433
+ setEndDate: function(date) {
434
+ if (date instanceof Date) {
435
+ this.endDate = date;
436
+ } else if (typeof date === 'string') {
437
+ this.endDate = new UTCDate(date);
438
+ if (! this.endDate.getUTCFullYear()) {
439
+ this.endDate = Infinity;
440
+ }
441
+ } else {
442
+ this.endDate = Infinity;
443
+ }
444
+ if (this.viewDate) {
445
+ this.update();
446
+ }
447
+ },
448
+
449
+ getLocalDate: function() {
450
+ if (this._unset) return null;
451
+ var d = this._date;
452
+ return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(),
453
+ d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds());
454
+ },
455
+
456
+ setLocalDate: function(localDate) {
457
+ if (!localDate) this.setValue(null);
458
+ else
459
+ this.setValue(Date.UTC(
460
+ localDate.getFullYear(),
461
+ localDate.getMonth(),
462
+ localDate.getDate(),
463
+ localDate.getHours(),
464
+ localDate.getMinutes(),
465
+ localDate.getSeconds(),
466
+ localDate.getMilliseconds()));
467
+ },
468
+
469
+ place: function(){
470
+ var offset = this.component ? this.component.offset() : this.$element.offset();
471
+ this.widget.css({
472
+ top: offset.top + this.height,
473
+ left: offset.left
474
+ });
475
+ },
476
+
477
+ notifyChange: function(){
478
+ this.$element.trigger({
479
+ type: 'changeDate',
480
+ date: this.getDate(),
481
+ localDate: this.getLocalDate()
482
+ });
483
+ },
484
+
485
+ update: function(newDate){
486
+ var dateStr = newDate;
487
+ if (!dateStr) {
488
+ if (this.isInput) {
489
+ dateStr = this.$element.val();
490
+ } else {
491
+ dateStr = this.$element.find('input').val();
492
+ }
493
+ if (!dateStr) {
494
+ var tmp = new Date()
495
+ this._date = UTCDate(tmp.getFullYear(),
496
+ tmp.getMonth(),
497
+ tmp.getDate(),
498
+ tmp.getHours(),
499
+ tmp.getMinutes(),
500
+ tmp.getSeconds(),
501
+ tmp.getMilliseconds())
502
+ } else {
503
+ this._date = this.parseDate(dateStr);
504
+ }
505
+ }
506
+ this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0);
507
+ this.fillDate();
508
+ this.fillTime();
509
+ },
510
+
511
+ fillDow: function() {
512
+ var dowCnt = this.weekStart;
513
+ var html = '<tr>';
514
+ while (dowCnt < this.weekStart + 7) {
515
+ html += '<th class="dow">' + dates[this.language].daysMin[(dowCnt++) % 7] + '</th>';
516
+ }
517
+ html += '</tr>';
518
+ this.widget.find('.datepicker-days thead').append(html);
519
+ },
520
+
521
+ fillMonths: function() {
522
+ var html = '';
523
+ var i = 0
524
+ while (i < 12) {
525
+ html += '<span class="month">' + dates[this.language].monthsShort[i++] + '</span>';
526
+ }
527
+ this.widget.find('.datepicker-months td').append(html);
528
+ },
529
+
530
+ fillDate: function() {
531
+ var year = this.viewDate.getUTCFullYear();
532
+ var month = this.viewDate.getUTCMonth();
533
+ var currentDate = UTCDate(
534
+ this._date.getUTCFullYear(),
535
+ this._date.getUTCMonth(),
536
+ this._date.getUTCDate(),
537
+ 0, 0, 0, 0
538
+ );
539
+ var startYear = typeof this.startDate === 'object' ? this.startDate.getUTCFullYear() : -Infinity;
540
+ var startMonth = typeof this.startDate === 'object' ? this.startDate.getUTCMonth() : -1;
541
+ var endYear = typeof this.endDate === 'object' ? this.endDate.getUTCFullYear() : Infinity;
542
+ var endMonth = typeof this.endDate === 'object' ? this.endDate.getUTCMonth() : 12;
543
+
544
+ this.widget.find('.datepicker-days').find('.disabled').removeClass('disabled');
545
+ this.widget.find('.datepicker-months').find('.disabled').removeClass('disabled');
546
+ this.widget.find('.datepicker-years').find('.disabled').removeClass('disabled');
547
+
548
+ this.widget.find('.datepicker-days th:eq(1)').text(
549
+ dates[this.language].months[month] + ' ' + year);
550
+
551
+ var prevMonth = UTCDate(year, month-1, 28, 0, 0, 0, 0);
552
+ var day = DPGlobal.getDaysInMonth(
553
+ prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
554
+ prevMonth.setUTCDate(day);
555
+ prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7) % 7);
556
+ if ((year == startYear && month <= startMonth) || year < startYear) {
557
+ this.widget.find('.datepicker-days th:eq(0)').addClass('disabled');
558
+ }
559
+ if ((year == endYear && month >= endMonth) || year > endYear) {
560
+ this.widget.find('.datepicker-days th:eq(2)').addClass('disabled');
561
+ }
562
+
563
+ var nextMonth = new Date(prevMonth.valueOf());
564
+ nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
565
+ nextMonth = nextMonth.valueOf();
566
+ var html = [];
567
+ var clsName;
568
+ while (prevMonth.valueOf() < nextMonth) {
569
+ if (prevMonth.getUTCDay() === this.weekStart) {
570
+ html.push('<tr>');
571
+ }
572
+ clsName = '';
573
+ if (prevMonth.getUTCFullYear() < year ||
574
+ (prevMonth.getUTCFullYear() == year &&
575
+ prevMonth.getUTCMonth() < month)) {
576
+ clsName += ' old';
577
+ } else if (prevMonth.getUTCFullYear() > year ||
578
+ (prevMonth.getUTCFullYear() == year &&
579
+ prevMonth.getUTCMonth() > month)) {
580
+ clsName += ' new';
581
+ }
582
+ if (prevMonth.valueOf() === currentDate.valueOf()) {
583
+ clsName += ' active';
584
+ }
585
+ if ((prevMonth.valueOf() + 86400000) <= this.startDate) {
586
+ clsName += ' disabled';
587
+ }
588
+ if (prevMonth.valueOf() > this.endDate) {
589
+ clsName += ' disabled';
590
+ }
591
+ html.push('<td class="day' + clsName + '">' + prevMonth.getUTCDate() + '</td>');
592
+ if (prevMonth.getUTCDay() === this.weekEnd) {
593
+ html.push('</tr>');
594
+ }
595
+ prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
596
+ }
597
+ this.widget.find('.datepicker-days tbody').empty().append(html.join(''));
598
+ var currentYear = this._date.getUTCFullYear();
599
+
600
+ var months = this.widget.find('.datepicker-months').find(
601
+ 'th:eq(1)').text(year).end().find('span').removeClass('active');
602
+ if (currentYear === year) {
603
+ months.eq(this._date.getUTCMonth()).addClass('active');
604
+ }
605
+ if (currentYear - 1 < startYear) {
606
+ this.widget.find('.datepicker-months th:eq(0)').addClass('disabled');
607
+ }
608
+ if (currentYear + 1 > endYear) {
609
+ this.widget.find('.datepicker-months th:eq(2)').addClass('disabled');
610
+ }
611
+ for (var i = 0; i < 12; i++) {
612
+ if ((year == startYear && startMonth > i) || (year < startYear)) {
613
+ $(months[i]).addClass('disabled');
614
+ } else if ((year == endYear && endMonth < i) || (year > endYear)) {
615
+ $(months[i]).addClass('disabled');
616
+ }
617
+ }
618
+
619
+ html = '';
620
+ year = parseInt(year/10, 10) * 10;
621
+ var yearCont = this.widget.find('.datepicker-years').find(
622
+ 'th:eq(1)').text(year + '-' + (year + 9)).end().find('td');
623
+ this.widget.find('.datepicker-years').find('th').removeClass('disabled');
624
+ if (startYear > year) {
625
+ this.widget.find('.datepicker-years').find('th:eq(0)').addClass('disabled');
626
+ }
627
+ if (endYear < year+9) {
628
+ this.widget.find('.datepicker-years').find('th:eq(2)').addClass('disabled');
629
+ }
630
+ year -= 1;
631
+ for (var i = -1; i < 11; i++) {
632
+ html += '<span class="year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + ((year < startYear || year > endYear) ? ' disabled' : '') + '">' + year + '</span>';
633
+ year += 1;
634
+ }
635
+ yearCont.html(html);
636
+ },
637
+
638
+ fillHours: function() {
639
+ var table = this.widget.find(
640
+ '.timepicker .timepicker-hours table');
641
+ table.parent().hide();
642
+ var html = '';
643
+ if (this.options.pick12HourFormat) {
644
+ var current = 1;
645
+ for (var i = 0; i < 3; i += 1) {
646
+ html += '<tr>';
647
+ for (var j = 0; j < 4; j += 1) {
648
+ var c = current.toString();
649
+ html += '<td class="hour">' + padLeft(c, 2, '0') + '</td>';
650
+ current++;
651
+ }
652
+ html += '</tr>'
653
+ }
654
+ } else {
655
+ var current = 0;
656
+ for (var i = 0; i < 6; i += 1) {
657
+ html += '<tr>';
658
+ for (var j = 0; j < 4; j += 1) {
659
+ var c = current.toString();
660
+ html += '<td class="hour">' + padLeft(c, 2, '0') + '</td>';
661
+ current++;
662
+ }
663
+ html += '</tr>'
664
+ }
665
+ }
666
+ table.html(html);
667
+ },
668
+
669
+ fillMinutes: function() {
670
+ var table = this.widget.find(
671
+ '.timepicker .timepicker-minutes table');
672
+ table.parent().hide();
673
+ var html = '';
674
+ var current = 0;
675
+ for (var i = 0; i < 5; i++) {
676
+ html += '<tr>';
677
+ for (var j = 0; j < 4; j += 1) {
678
+ var c = current.toString();
679
+ html += '<td class="minute">' + padLeft(c, 2, '0') + '</td>';
680
+ current += 3;
681
+ }
682
+ html += '</tr>';
683
+ }
684
+ table.html(html);
685
+ },
686
+
687
+ fillSeconds: function() {
688
+ var table = this.widget.find(
689
+ '.timepicker .timepicker-seconds table');
690
+ table.parent().hide();
691
+ var html = '';
692
+ var current = 0;
693
+ for (var i = 0; i < 5; i++) {
694
+ html += '<tr>';
695
+ for (var j = 0; j < 4; j += 1) {
696
+ var c = current.toString();
697
+ html += '<td class="second">' + padLeft(c, 2, '0') + '</td>';
698
+ current += 3;
699
+ }
700
+ html += '</tr>';
701
+ }
702
+ table.html(html);
703
+ },
704
+
705
+ fillTime: function() {
706
+ if (!this._date)
707
+ return;
708
+ var timeComponents = this.widget.find('.timepicker span[data-time-component]');
709
+ var table = timeComponents.closest('table');
710
+ var is12HourFormat = this.options.pick12HourFormat;
711
+ var hour = this._date.getUTCHours();
712
+ var period = 'AM';
713
+ if (is12HourFormat) {
714
+ if (hour >= 12) period = 'PM';
715
+ if (hour === 0) hour = 12;
716
+ else if (hour != 12) hour = hour % 12;
717
+ this.widget.find(
718
+ '.timepicker [data-action=togglePeriod]').text(period);
719
+ }
720
+ hour = padLeft(hour.toString(), 2, '0');
721
+ var minute = padLeft(this._date.getUTCMinutes().toString(), 2, '0');
722
+ var second = padLeft(this._date.getUTCSeconds().toString(), 2, '0');
723
+ timeComponents.filter('[data-time-component=hours]').text(hour);
724
+ timeComponents.filter('[data-time-component=minutes]').text(minute);
725
+ timeComponents.filter('[data-time-component=seconds]').text(second);
726
+ },
727
+
728
+ click: function(e) {
729
+ e.stopPropagation();
730
+ e.preventDefault();
731
+ this._unset = false;
732
+ var target = $(e.target).closest('span, td, th');
733
+ if (target.length === 1) {
734
+ if (! target.is('.disabled')) {
735
+ switch(target[0].nodeName.toLowerCase()) {
736
+ case 'th':
737
+ switch(target[0].className) {
738
+ case 'switch':
739
+ this.showMode(1);
740
+ break;
741
+ case 'prev':
742
+ case 'next':
743
+ var vd = this.viewDate;
744
+ var navFnc = DPGlobal.modes[this.viewMode].navFnc;
745
+ var step = DPGlobal.modes[this.viewMode].navStep;
746
+ if (target[0].className === 'prev') step = step * -1;
747
+ vd['set' + navFnc](vd['get' + navFnc]() + step);
748
+ this.fillDate();
749
+ this.set();
750
+ break;
751
+ }
752
+ break;
753
+ case 'span':
754
+ if (target.is('.month')) {
755
+ var month = target.parent().find('span').index(target);
756
+ this.viewDate.setUTCMonth(month);
757
+ } else {
758
+ var year = parseInt(target.text(), 10) || 0;
759
+ this.viewDate.setUTCFullYear(year);
760
+ }
761
+ if (this.viewMode !== 0) {
762
+ this._date = UTCDate(
763
+ this.viewDate.getUTCFullYear(),
764
+ this.viewDate.getUTCMonth(),
765
+ this.viewDate.getUTCDate(),
766
+ this._date.getUTCHours(),
767
+ this._date.getUTCMinutes(),
768
+ this._date.getUTCSeconds(),
769
+ this._date.getUTCMilliseconds()
770
+ );
771
+ this.notifyChange();
772
+ }
773
+ this.showMode(-1);
774
+ this.fillDate();
775
+ this.set();
776
+ break;
777
+ case 'td':
778
+ if (target.is('.day')) {
779
+ var day = parseInt(target.text(), 10) || 1;
780
+ var month = this.viewDate.getUTCMonth();
781
+ var year = this.viewDate.getUTCFullYear();
782
+ if (target.is('.old')) {
783
+ if (month === 0) {
784
+ month = 11;
785
+ year -= 1;
786
+ } else {
787
+ month -= 1;
788
+ }
789
+ } else if (target.is('.new')) {
790
+ if (month == 11) {
791
+ month = 0;
792
+ year += 1;
793
+ } else {
794
+ month += 1;
795
+ }
796
+ }
797
+ this._date = UTCDate(
798
+ year, month, day,
799
+ this._date.getUTCHours(),
800
+ this._date.getUTCMinutes(),
801
+ this._date.getUTCSeconds(),
802
+ this._date.getUTCMilliseconds()
803
+ );
804
+ this.viewDate = UTCDate(
805
+ year, month, Math.min(28, day) , 0, 0, 0, 0);
806
+ this.fillDate();
807
+ this.set();
808
+ this.notifyChange();
809
+ }
810
+ break;
811
+ }
812
+ }
813
+ }
814
+ },
815
+
816
+ actions: {
817
+ incrementHours: function(e) {
818
+ this._date.setUTCHours(this._date.getUTCHours() + 1);
819
+ },
820
+
821
+ incrementMinutes: function(e) {
822
+ this._date.setUTCMinutes(this._date.getUTCMinutes() + 1);
823
+ },
824
+
825
+ incrementSeconds: function(e) {
826
+ this._date.setUTCSeconds(this._date.getUTCSeconds() + 1);
827
+ },
828
+
829
+ decrementHours: function(e) {
830
+ this._date.setUTCHours(this._date.getUTCHours() - 1);
831
+ },
832
+
833
+ decrementMinutes: function(e) {
834
+ this._date.setUTCMinutes(this._date.getUTCMinutes() - 1);
835
+ },
836
+
837
+ decrementSeconds: function(e) {
838
+ this._date.setUTCSeconds(this._date.getUTCSeconds() - 1);
839
+ },
840
+
841
+ togglePeriod: function(e) {
842
+ var hour = this._date.getUTCHours();
843
+ if (hour >= 12) hour -= 12;
844
+ else hour += 12;
845
+ this._date.setUTCHours(hour);
846
+ },
847
+
848
+ showPicker: function() {
849
+ this.widget.find('.timepicker > div:not(.timepicker-picker)').hide();
850
+ this.widget.find('.timepicker .timepicker-picker').show();
851
+ },
852
+
853
+ showHours: function() {
854
+ this.widget.find('.timepicker .timepicker-picker').hide();
855
+ this.widget.find('.timepicker .timepicker-hours').show();
856
+ },
857
+
858
+ showMinutes: function() {
859
+ this.widget.find('.timepicker .timepicker-picker').hide();
860
+ this.widget.find('.timepicker .timepicker-minutes').show();
861
+ },
862
+
863
+ showSeconds: function() {
864
+ this.widget.find('.timepicker .timepicker-picker').hide();
865
+ this.widget.find('.timepicker .timepicker-seconds').show();
866
+ },
867
+
868
+ selectHour: function(e) {
869
+ var tgt = $(e.target);
870
+ var value = parseInt(tgt.text(), 10);
871
+ if (this.options.pick12HourFormat) {
872
+ var current = this._date.getUTCHours();
873
+ if (current >= 12) {
874
+ if (value != 12) value = (value + 12) % 24;
875
+ } else {
876
+ if (value === 12) value = 0;
877
+ else value = value % 12;
878
+ }
879
+ }
880
+ this._date.setUTCHours(value);
881
+ this.actions.showPicker.call(this);
882
+ },
883
+
884
+ selectMinute: function(e) {
885
+ var tgt = $(e.target);
886
+ var value = parseInt(tgt.text(), 10);
887
+ this._date.setUTCMinutes(value);
888
+ this.actions.showPicker.call(this);
889
+ },
890
+
891
+ selectSecond: function(e) {
892
+ var tgt = $(e.target);
893
+ var value = parseInt(tgt.text(), 10);
894
+ this._date.setUTCSeconds(value);
895
+ this.actions.showPicker.call(this);
896
+ }
897
+ },
898
+
899
+ doAction: function(e) {
900
+ e.stopPropagation();
901
+ e.preventDefault();
902
+ if (!this._date) this._date = UTCDate(1970, 0, 0, 0, 0, 0, 0);
903
+ var action = $(e.currentTarget).data('action');
904
+ var rv = this.actions[action].apply(this, arguments);
905
+ this.set();
906
+ this.fillTime();
907
+ this.notifyChange();
908
+ return rv;
909
+ },
910
+
911
+ stopEvent: function(e) {
912
+ e.stopPropagation();
913
+ e.preventDefault();
914
+ },
915
+
916
+ // part of the following code was taken from
917
+ // http://cloud.github.com/downloads/digitalBush/jquery.maskedinput/jquery.maskedinput-1.3.js
918
+ keydown: function(e) {
919
+ var self = this, k = e.which, input = $(e.target);
920
+ if (k == 8 || k == 46) {
921
+ // backspace and delete cause the maskPosition
922
+ // to be recalculated
923
+ setTimeout(function() {
924
+ self._resetMaskPos(input);
925
+ });
926
+ }
927
+ },
928
+
929
+ keypress: function(e) {
930
+ var k = e.which;
931
+ if (k == 8 || k == 46) {
932
+ // For those browsers which will trigger
933
+ // keypress on backspace/delete
934
+ return;
935
+ }
936
+ var input = $(e.target);
937
+ var c = String.fromCharCode(k);
938
+ var val = input.val() || '';
939
+ val += c;
940
+ var mask = this._mask[this._maskPos];
941
+ if (!mask) {
942
+ return false;
943
+ }
944
+ if (mask.end != val.length) {
945
+ return;
946
+ }
947
+ if (!mask.pattern.test(val.slice(mask.start))) {
948
+ val = val.slice(0, val.length - 1);
949
+ while ((mask = this._mask[this._maskPos]) && mask.character) {
950
+ val += mask.character;
951
+ // advance mask position past static
952
+ // part
953
+ this._maskPos++;
954
+ }
955
+ val += c;
956
+ if (mask.end != val.length) {
957
+ input.val(val);
958
+ return false;
959
+ } else {
960
+ if (!mask.pattern.test(val.slice(mask.start))) {
961
+ input.val(val.slice(0, mask.start));
962
+ return false;
963
+ } else {
964
+ input.val(val);
965
+ this._maskPos++;
966
+ return false;
967
+ }
968
+ }
969
+ } else {
970
+ this._maskPos++;
971
+ }
972
+ },
973
+
974
+ change: function(e) {
975
+ var input = $(e.target);
976
+ var val = input.val();
977
+ if (this._formatPattern.test(val)) {
978
+ this.update();
979
+ this.setValue(this._date.getTime());
980
+ this.notifyChange();
981
+ this.set();
982
+ } else if (val && val.trim()) {
983
+ this.setValue(this._date.getTime());
984
+ if (this._date) this.set();
985
+ else input.val('');
986
+ } else {
987
+ if (this._date) {
988
+ this.setValue(null);
989
+ // unset the date when the input is
990
+ // erased
991
+ this.notifyChange();
992
+ this._unset = true;
993
+ }
994
+ }
995
+ this._resetMaskPos(input);
996
+ },
997
+
998
+ showMode: function(dir) {
999
+ if (dir) {
1000
+ this.viewMode = Math.max(this.minViewMode, Math.min(
1001
+ 2, this.viewMode + dir));
1002
+ }
1003
+ this.widget.find('.datepicker > div').hide().filter(
1004
+ '.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
1005
+ },
1006
+
1007
+ destroy: function() {
1008
+ this._detachDatePickerEvents();
1009
+ this._detachDatePickerGlobalEvents();
1010
+ this.widget.remove();
1011
+ this.$element.removeData('datetimepicker');
1012
+ this.component.removeData('datetimepicker');
1013
+ },
1014
+
1015
+ formatDate: function(d) {
1016
+ return this.format.replace(formatReplacer, function(match) {
1017
+ var methodName, property, rv, len = match.length;
1018
+ if (match === 'ms')
1019
+ len = 1;
1020
+ property = dateFormatComponents[match].property
1021
+ if (property === 'Hours12') {
1022
+ rv = d.getUTCHours();
1023
+ if (rv === 0) rv = 12;
1024
+ else if (rv !== 12) rv = rv % 12;
1025
+ } else if (property === 'Period12') {
1026
+ if (d.getUTCHours() >= 12) return 'PM';
1027
+ else return 'AM';
1028
+ } else {
1029
+ methodName = 'get' + property;
1030
+ rv = d[methodName]();
1031
+ }
1032
+ if (methodName === 'getUTCMonth') rv = rv + 1;
1033
+ if (methodName === 'getUTCYear') rv = rv + 1900 - 2000;
1034
+ return padLeft(rv.toString(), len, '0');
1035
+ });
1036
+ },
1037
+
1038
+ parseDate: function(str) {
1039
+ var match, i, property, methodName, value, parsed = {};
1040
+ if (!(match = this._formatPattern.exec(str)))
1041
+ return null;
1042
+ for (i = 1; i < match.length; i++) {
1043
+ property = this._propertiesByIndex[i];
1044
+ if (!property)
1045
+ continue;
1046
+ value = match[i];
1047
+ if (/^\d+$/.test(value))
1048
+ value = parseInt(value, 10);
1049
+ parsed[property] = value;
1050
+ }
1051
+ return this._finishParsingDate(parsed);
1052
+ },
1053
+
1054
+ _resetMaskPos: function(input) {
1055
+ var val = input.val();
1056
+ for (var i = 0; i < this._mask.length; i++) {
1057
+ if (this._mask[i].end > val.length) {
1058
+ // If the mask has ended then jump to
1059
+ // the next
1060
+ this._maskPos = i;
1061
+ break;
1062
+ } else if (this._mask[i].end === val.length) {
1063
+ this._maskPos = i + 1;
1064
+ break;
1065
+ }
1066
+ }
1067
+ },
1068
+
1069
+ _finishParsingDate: function(parsed) {
1070
+ var year, month, date, hours, minutes, seconds, milliseconds;
1071
+ year = parsed.UTCFullYear;
1072
+ if (parsed.UTCYear) year = 2000 + parsed.UTCYear;
1073
+ if (!year) year = 1970;
1074
+ if (parsed.UTCMonth) month = parsed.UTCMonth - 1;
1075
+ else month = 0;
1076
+ date = parsed.UTCDate || 1;
1077
+ hours = parsed.UTCHours || 0;
1078
+ minutes = parsed.UTCMinutes || 0;
1079
+ seconds = parsed.UTCSeconds || 0;
1080
+ milliseconds = parsed.UTCMilliseconds || 0;
1081
+ if (parsed.Hours12) {
1082
+ hours = parsed.Hours12;
1083
+ }
1084
+ if (parsed.Period12) {
1085
+ if (/pm/i.test(parsed.Period12)) {
1086
+ if (hours != 12) hours = (hours + 12) % 24;
1087
+ } else {
1088
+ hours = hours % 12;
1089
+ }
1090
+ }
1091
+ return UTCDate(year, month, date, hours, minutes, seconds, milliseconds);
1092
+ },
1093
+
1094
+ _compileFormat: function () {
1095
+ var match, component, components = [], mask = [],
1096
+ str = this.format, propertiesByIndex = {}, i = 0, pos = 0;
1097
+ while (match = formatComponent.exec(str)) {
1098
+ component = match[0];
1099
+ if (component in dateFormatComponents) {
1100
+ i++;
1101
+ propertiesByIndex[i] = dateFormatComponents[component].property;
1102
+ components.push('\\s*' + dateFormatComponents[component].getPattern(
1103
+ this) + '\\s*');
1104
+ mask.push({
1105
+ pattern: new RegExp(dateFormatComponents[component].getPattern(
1106
+ this)),
1107
+ property: dateFormatComponents[component].property,
1108
+ start: pos,
1109
+ end: pos += component.length
1110
+ });
1111
+ }
1112
+ else {
1113
+ components.push(escapeRegExp(component));
1114
+ mask.push({
1115
+ pattern: new RegExp(escapeRegExp(component)),
1116
+ character: component,
1117
+ start: pos,
1118
+ end: ++pos
1119
+ });
1120
+ }
1121
+ str = str.slice(component.length);
1122
+ }
1123
+ this._mask = mask;
1124
+ this._maskPos = 0;
1125
+ this._formatPattern = new RegExp(
1126
+ '^\\s*' + components.join('') + '\\s*$');
1127
+ this._propertiesByIndex = propertiesByIndex;
1128
+ },
1129
+
1130
+ _attachDatePickerEvents: function() {
1131
+ var self = this;
1132
+ // this handles date picker clicks
1133
+ this.widget.on('click', '.datepicker *', $.proxy(this.click, this));
1134
+ // this handles time picker clicks
1135
+ this.widget.on('click', '[data-action]', $.proxy(this.doAction, this));
1136
+ this.widget.on('mousedown', $.proxy(this.stopEvent, this));
1137
+ if (this.pickDate && this.pickTime) {
1138
+ this.widget.on('click.togglePicker', '.accordion-toggle', function(e) {
1139
+ e.stopPropagation();
1140
+ var $this = $(this);
1141
+ var $parent = $this.closest('ul');
1142
+ var expanded = $parent.find('.collapse.in');
1143
+ var closed = $parent.find('.collapse:not(.in)');
1144
+
1145
+ if (expanded && expanded.length) {
1146
+ var collapseData = expanded.data('collapse');
1147
+ if (collapseData && collapseData.transitioning) return;
1148
+ expanded.collapse('hide');
1149
+ closed.collapse('show')
1150
+ $this.find('i').toggleClass(self.timeIcon + ' ' + self.dateIcon);
1151
+ self.$element.find('.add-on i').toggleClass(self.timeIcon + ' ' + self.dateIcon);
1152
+ }
1153
+ });
1154
+ }
1155
+ if (this.isInput) {
1156
+ this.$element.on({
1157
+ 'focus': $.proxy(this.show, this),
1158
+ 'change': $.proxy(this.change, this)
1159
+ });
1160
+ if (this.options.maskInput) {
1161
+ this.$element.on({
1162
+ 'keydown': $.proxy(this.keydown, this),
1163
+ 'keypress': $.proxy(this.keypress, this)
1164
+ });
1165
+ }
1166
+ } else {
1167
+ this.$element.on({
1168
+ 'change': $.proxy(this.change, this)
1169
+ }, 'input');
1170
+ if (this.options.maskInput) {
1171
+ this.$element.on({
1172
+ 'keydown': $.proxy(this.keydown, this),
1173
+ 'keypress': $.proxy(this.keypress, this)
1174
+ }, 'input');
1175
+ }
1176
+ if (this.component){
1177
+ this.component.on('click', $.proxy(this.show, this));
1178
+ } else {
1179
+ this.$element.on('click', $.proxy(this.show, this));
1180
+ }
1181
+ }
1182
+ },
1183
+
1184
+ _attachDatePickerGlobalEvents: function() {
1185
+ $(window).on(
1186
+ 'resize.datetimepicker' + this.id, $.proxy(this.place, this));
1187
+ if (!this.isInput) {
1188
+ $(document).on(
1189
+ 'mousedown.datetimepicker' + this.id, $.proxy(this.hide, this));
1190
+ }
1191
+ },
1192
+
1193
+ _detachDatePickerEvents: function() {
1194
+ this.widget.off('click', '.datepicker *', this.click);
1195
+ this.widget.off('click', '[data-action]');
1196
+ this.widget.off('mousedown', this.stopEvent);
1197
+ if (this.pickDate && this.pickTime) {
1198
+ this.widget.off('click.togglePicker');
1199
+ }
1200
+ if (this.isInput) {
1201
+ this.$element.off({
1202
+ 'focus': this.show,
1203
+ 'change': this.change
1204
+ });
1205
+ if (this.options.maskInput) {
1206
+ this.$element.off({
1207
+ 'keydown': this.keydown,
1208
+ 'keypress': this.keypress
1209
+ });
1210
+ }
1211
+ } else {
1212
+ this.$element.off({
1213
+ 'change': this.change
1214
+ }, 'input');
1215
+ if (this.options.maskInput) {
1216
+ this.$element.off({
1217
+ 'keydown': this.keydown,
1218
+ 'keypress': this.keypress
1219
+ }, 'input');
1220
+ }
1221
+ if (this.component){
1222
+ this.component.off('click', this.show);
1223
+ } else {
1224
+ this.$element.off('click', this.show);
1225
+ }
1226
+ }
1227
+ },
1228
+
1229
+ _detachDatePickerGlobalEvents: function () {
1230
+ $(window).off('resize.datetimepicker' + this.id);
1231
+ if (!this.isInput) {
1232
+ $(document).off('mousedown.datetimepicker' + this.id);
1233
+ }
1234
+ }
1235
+ };
1236
+
1237
+ $.fn.datetimepicker = function ( option, val ) {
1238
+ return this.each(function () {
1239
+ var $this = $(this),
1240
+ data = $this.data('datetimepicker'),
1241
+ options = typeof option === 'object' && option;
1242
+ if (!data) {
1243
+ $this.data('datetimepicker', (data = new DateTimePicker(
1244
+ this, $.extend({}, $.fn.datetimepicker.defaults,options))));
1245
+ }
1246
+ if (typeof option === 'string') data[option](val);
1247
+ });
1248
+ };
1249
+
1250
+ $.fn.datetimepicker.defaults = {
1251
+ maskInput: false,
1252
+ pickDate: true,
1253
+ pickTime: true,
1254
+ pick12HourFormat: false,
1255
+ pickSeconds: true,
1256
+ startDate: -Infinity,
1257
+ endDate: Infinity
1258
+ };
1259
+ $.fn.datetimepicker.Constructor = DateTimePicker;
1260
+ var dpgId = 0;
1261
+ var dates = $.fn.datetimepicker.dates = {
1262
+ en: {
1263
+ days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
1264
+ "Friday", "Saturday", "Sunday"],
1265
+ daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
1266
+ daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
1267
+ months: ["January", "February", "March", "April", "May", "June",
1268
+ "July", "August", "September", "October", "November", "December"],
1269
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
1270
+ "Aug", "Sep", "Oct", "Nov", "Dec"]
1271
+ }
1272
+ };
1273
+
1274
+ var dateFormatComponents = {
1275
+ dd: {property: 'UTCDate', getPattern: function() { return '(0?[1-9]|[1-2][0-9]|3[0-1])\\b';}},
1276
+ MM: {property: 'UTCMonth', getPattern: function() {return '(0?[1-9]|1[0-2])\\b';}},
1277
+ yy: {property: 'UTCYear', getPattern: function() {return '(\\d{2})\\b'}},
1278
+ yyyy: {property: 'UTCFullYear', getPattern: function() {return '(\\d{4})\\b';}},
1279
+ hh: {property: 'UTCHours', getPattern: function() {return '(0?[0-9]|1[0-9]|2[0-3])\\b';}},
1280
+ mm: {property: 'UTCMinutes', getPattern: function() {return '(0?[0-9]|[1-5][0-9])\\b';}},
1281
+ ss: {property: 'UTCSeconds', getPattern: function() {return '(0?[0-9]|[1-5][0-9])\\b';}},
1282
+ ms: {property: 'UTCMilliseconds', getPattern: function() {return '([0-9]{1,3})\\b';}},
1283
+ HH: {property: 'Hours12', getPattern: function() {return '(0?[1-9]|1[0-2])\\b';}},
1284
+ PP: {property: 'Period12', getPattern: function() {return '(AM|PM|am|pm|Am|aM|Pm|pM)\\b';}}
1285
+ };
1286
+
1287
+ var keys = [];
1288
+ for (var k in dateFormatComponents) keys.push(k);
1289
+ keys[keys.length - 1] += '\\b';
1290
+ keys.push('.');
1291
+
1292
+ var formatComponent = new RegExp(keys.join('\\b|'));
1293
+ keys.pop();
1294
+ var formatReplacer = new RegExp(keys.join('\\b|'), 'g');
1295
+
1296
+ function escapeRegExp(str) {
1297
+ // http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
1298
+ return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
1299
+ }
1300
+
1301
+ function padLeft(s, l, c) {
1302
+ if (l < s.length) return s;
1303
+ else return Array(l - s.length + 1).join(c || ' ') + s;
1304
+ }
1305
+
1306
+ function getTemplate(timeIcon, pickDate, pickTime, is12Hours, showSeconds) {
1307
+ if (pickDate && pickTime) {
1308
+ return (
1309
+ '<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
1310
+ '<ul>' +
1311
+ '<li class="collapse in">' +
1312
+ '<div class="datepicker">' +
1313
+ DPGlobal.template +
1314
+ '</div>' +
1315
+ '</li>' +
1316
+ '<li class="picker-switch"><a class="accordion-toggle"><i class="' + timeIcon + '"></i></a></li>' +
1317
+ '<li class="collapse">' +
1318
+ '<div class="timepicker">' +
1319
+ TPGlobal.getTemplate(is12Hours, showSeconds) +
1320
+ '</div>' +
1321
+ '</li>' +
1322
+ '</ul>' +
1323
+ '</div>'
1324
+ );
1325
+ } else if (pickTime) {
1326
+ return (
1327
+ '<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
1328
+ '<div class="timepicker">' +
1329
+ TPGlobal.getTemplate(is12Hours, showSeconds) +
1330
+ '</div>' +
1331
+ '</div>'
1332
+ );
1333
+ } else {
1334
+ return (
1335
+ '<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
1336
+ '<div class="datepicker">' +
1337
+ DPGlobal.template +
1338
+ '</div>' +
1339
+ '</div>'
1340
+ );
1341
+ }
1342
+ }
1343
+
1344
+ function UTCDate() {
1345
+ return new Date(Date.UTC.apply(Date, arguments));
1346
+ }
1347
+
1348
+ var DPGlobal = {
1349
+ modes: [
1350
+ {
1351
+ clsName: 'days',
1352
+ navFnc: 'UTCMonth',
1353
+ navStep: 1
1354
+ },
1355
+ {
1356
+ clsName: 'months',
1357
+ navFnc: 'UTCFullYear',
1358
+ navStep: 1
1359
+ },
1360
+ {
1361
+ clsName: 'years',
1362
+ navFnc: 'UTCFullYear',
1363
+ navStep: 10
1364
+ }],
1365
+ isLeapYear: function (year) {
1366
+ return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
1367
+ },
1368
+ getDaysInMonth: function (year, month) {
1369
+ return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
1370
+ },
1371
+ headTemplate:
1372
+ '<thead>' +
1373
+ '<tr>' +
1374
+ '<th class="prev">&lsaquo;</th>' +
1375
+ '<th colspan="5" class="switch"></th>' +
1376
+ '<th class="next">&rsaquo;</th>' +
1377
+ '</tr>' +
1378
+ '</thead>',
1379
+ contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
1380
+ };
1381
+ DPGlobal.template =
1382
+ '<div class="datepicker-days">' +
1383
+ '<table class="table-condensed">' +
1384
+ DPGlobal.headTemplate +
1385
+ '<tbody></tbody>' +
1386
+ '</table>' +
1387
+ '</div>' +
1388
+ '<div class="datepicker-months">' +
1389
+ '<table class="table-condensed">' +
1390
+ DPGlobal.headTemplate +
1391
+ DPGlobal.contTemplate+
1392
+ '</table>'+
1393
+ '</div>'+
1394
+ '<div class="datepicker-years">'+
1395
+ '<table class="table-condensed">'+
1396
+ DPGlobal.headTemplate+
1397
+ DPGlobal.contTemplate+
1398
+ '</table>'+
1399
+ '</div>';
1400
+ var TPGlobal = {
1401
+ hourTemplate: '<span data-action="showHours" data-time-component="hours" class="timepicker-hour"></span>',
1402
+ minuteTemplate: '<span data-action="showMinutes" data-time-component="minutes" class="timepicker-minute"></span>',
1403
+ secondTemplate: '<span data-action="showSeconds" data-time-component="seconds" class="timepicker-second"></span>'
1404
+ };
1405
+ TPGlobal.getTemplate = function(is12Hours, showSeconds) {
1406
+ return (
1407
+ '<div class="timepicker-picker">' +
1408
+ '<table class="table-condensed"' +
1409
+ (is12Hours ? ' data-hour-format="12"' : '') +
1410
+ '>' +
1411
+ '<tr>' +
1412
+ '<td><a href="#" class="btn" data-action="incrementHours"><i class="icon-chevron-up"></i></a></td>' +
1413
+ '<td class="separator"></td>' +
1414
+ '<td><a href="#" class="btn" data-action="incrementMinutes"><i class="icon-chevron-up"></i></a></td>' +
1415
+ (showSeconds ?
1416
+ '<td class="separator"></td>' +
1417
+ '<td><a href="#" class="btn" data-action="incrementSeconds"><i class="icon-chevron-up"></i></a></td>': '')+
1418
+ (is12Hours ? '<td class="separator"></td>' : '') +
1419
+ '</tr>' +
1420
+ '<tr>' +
1421
+ '<td>' + TPGlobal.hourTemplate + '</td> ' +
1422
+ '<td class="separator">:</td>' +
1423
+ '<td>' + TPGlobal.minuteTemplate + '</td> ' +
1424
+ (showSeconds ?
1425
+ '<td class="separator">:</td>' +
1426
+ '<td>' + TPGlobal.secondTemplate + '</td>' : '') +
1427
+ (is12Hours ?
1428
+ '<td class="separator"></td>' +
1429
+ '<td>' +
1430
+ '<button type="button" class="btn btn-primary" data-action="togglePeriod"></button>' +
1431
+ '</td>' : '') +
1432
+ '</tr>' +
1433
+ '<tr>' +
1434
+ '<td><a href="#" class="btn" data-action="decrementHours"><i class="icon-chevron-down"></i></a></td>' +
1435
+ '<td class="separator"></td>' +
1436
+ '<td><a href="#" class="btn" data-action="decrementMinutes"><i class="icon-chevron-down"></i></a></td>' +
1437
+ (showSeconds ?
1438
+ '<td class="separator"></td>' +
1439
+ '<td><a href="#" class="btn" data-action="decrementSeconds"><i class="icon-chevron-down"></i></a></td>': '') +
1440
+ (is12Hours ? '<td class="separator"></td>' : '') +
1441
+ '</tr>' +
1442
+ '</table>' +
1443
+ '</div>' +
1444
+ '<div class="timepicker-hours" data-action="selectHour">' +
1445
+ '<table class="table-condensed">' +
1446
+ '</table>'+
1447
+ '</div>'+
1448
+ '<div class="timepicker-minutes" data-action="selectMinute">' +
1449
+ '<table class="table-condensed">' +
1450
+ '</table>'+
1451
+ '</div>'+
1452
+ (showSeconds ?
1453
+ '<div class="timepicker-seconds" data-action="selectSecond">' +
1454
+ '<table class="table-condensed">' +
1455
+ '</table>'+
1456
+ '</div>': '')
1457
+ );
1458
+ }
1459
+
1460
+
1461
+ })(window.jQuery);