smalot-bootstrap-datetimepicker-rails 0.0.1

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.
Files changed (46) hide show
  1. data/LICENSE.txt +22 -0
  2. data/README.md +42 -0
  3. data/lib/smalot-bootstrap-datetimepicker-rails.rb +8 -0
  4. data/lib/smalot-bootstrap-datetimepicker-rails/version.rb +5 -0
  5. data/vendor/assets/javascripts/bootstrap-datetimepicker.js +1698 -0
  6. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.bg.js +16 -0
  7. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ca.js +16 -0
  8. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.cs.js +17 -0
  9. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.da.js +16 -0
  10. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.de.js +18 -0
  11. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.el.js +15 -0
  12. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.es.js +16 -0
  13. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fi.js +16 -0
  14. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fr.js +18 -0
  15. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.he.js +17 -0
  16. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hr.js +15 -0
  17. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hu.js +17 -0
  18. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.id.js +15 -0
  19. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.is.js +16 -0
  20. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.it.js +18 -0
  21. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ja.js +16 -0
  22. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.kr.js +15 -0
  23. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.lt.js +18 -0
  24. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.lv.js +18 -0
  25. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ms.js +16 -0
  26. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nb.js +16 -0
  27. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nl.js +16 -0
  28. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pl.js +17 -0
  29. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pt-BR.js +17 -0
  30. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pt.js +17 -0
  31. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ro.js +17 -0
  32. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.rs-latin.js +16 -0
  33. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.rs.js +16 -0
  34. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ru.js +16 -0
  35. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sk.js +17 -0
  36. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sl.js +16 -0
  37. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sv.js +16 -0
  38. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sw.js +17 -0
  39. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.th.js +16 -0
  40. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tr.js +17 -0
  41. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ua.js +15 -0
  42. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.uk.js +16 -0
  43. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.zh-CN.js +16 -0
  44. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.zh-TW.js +16 -0
  45. data/vendor/assets/stylesheets/bootstrap-datetimepicker.css +414 -0
  46. metadata +93 -0
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Nicolas Buduroi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # bootstrap-datetimepicker-rails
2
+
3
+ This gem packages the bootstrap-datetimepicker (JavaScripts & stylesheets) for Rails 3.1+ asset pipeline. It adds ability to use [bootstrap-datetimepicker](http://www.malot.fr/bootstrap-datetimepicker/) within your Rails app without puting files inside `vendor` directory.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'smalot-bootstrap-datetimepicker-rails'
10
+
11
+ Add the following directive to your Javascript manifest file (`application.js`):
12
+
13
+ //= require bootstrap-datetimepicker
14
+
15
+ If you want to include a localization file, also add the following directive:
16
+
17
+ //= require locales/bootstrap-datetimepicker.<locale>
18
+
19
+ Add the following line to your stylesheet file:
20
+
21
+ ```scss
22
+ @import 'bootstrap';
23
+ @import 'bootstrap-datetimepicker';
24
+ ```
25
+
26
+ or if you're having problems (or using less) require it in your main stylesheet manifest file:
27
+
28
+ ```scss
29
+ *= require bootstrap-datetimepicker
30
+ ```
31
+
32
+ ## Contributing to the original plugin
33
+
34
+ If you've encountered some plugin-related issues, please contribute directly to https://github.com/smalot/bootstrap-datetimepicker/issues.
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create new Pull Request
@@ -0,0 +1,8 @@
1
+ require 'smalot-bootstrap-datetimepicker-rails/version'
2
+
3
+ module SmalotBootstrapDatetimepicker
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module SmalotBootstrapDatetimepicker
2
+ module Rails
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,1698 @@
1
+ /* =========================================================
2
+ * bootstrap-datetimepicker.js
3
+ * =========================================================
4
+ * Copyright 2012 Stefan Petre
5
+ * Improvements by Andrew Rowls
6
+ * Improvements by Sébastien Malot
7
+ * Improvements by Yun Lai
8
+ * Project URL : http://www.malot.fr/bootstrap-datetimepicker
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ * ========================================================= */
22
+
23
+ /*
24
+ * Improvement by CuGBabyBeaR @ 2013-09-12
25
+ *
26
+ * Make it work in bootstrap v3
27
+ */
28
+
29
+ !function ($) {
30
+
31
+ function UTCDate() {
32
+ return new Date(Date.UTC.apply(Date, arguments));
33
+ }
34
+
35
+ function UTCToday() {
36
+ var today = new Date();
37
+ return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate(), today.getUTCHours(), today.getUTCMinutes(), today.getUTCSeconds(), 0);
38
+ }
39
+
40
+ // Picker object
41
+
42
+ var Datetimepicker = function (element, options) {
43
+ var that = this;
44
+
45
+ this.element = $(element);
46
+
47
+ this.language = options.language || this.element.data('date-language') || "en";
48
+ this.language = this.language in dates ? this.language : "en";
49
+ this.isRTL = dates[this.language].rtl || false;
50
+ this.formatType = options.formatType || this.element.data('format-type') || 'standard';
51
+ this.format = DPGlobal.parseFormat(options.format || this.element.data('date-format') || dates[this.language].format || DPGlobal.getDefaultFormat(this.formatType, 'input'), this.formatType);
52
+ this.isInline = false;
53
+ this.isVisible = false;
54
+ this.isInput = this.element.is('input');
55
+
56
+ this.bootcssVer = this.isInput ? (this.element.is('.form-control') ? 3 : 2) : ( this.bootcssVer = this.element.is('.input-group') ? 3 : 2 );
57
+
58
+ this.component = this.element.is('.date') ? ( this.bootcssVer == 3 ? this.element.find('.input-group-addon .glyphicon-th, .input-group-addon .glyphicon-time, .input-group-addon .glyphicon-calendar').parent() : this.element.find('.add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar').parent()) : false;
59
+ this.componentReset = this.element.is('.date') ? ( this.bootcssVer == 3 ? this.element.find('.input-group-addon .glyphicon-remove').parent() : this.element.find('.add-on .icon-remove').parent()) : false;
60
+ this.hasInput = this.component && this.element.find('input').length;
61
+ if (this.component && this.component.length === 0) {
62
+ this.component = false;
63
+ }
64
+ this.linkField = options.linkField || this.element.data('link-field') || false;
65
+ this.linkFormat = DPGlobal.parseFormat(options.linkFormat || this.element.data('link-format') || DPGlobal.getDefaultFormat(this.formatType, 'link'), this.formatType);
66
+ this.minuteStep = options.minuteStep || this.element.data('minute-step') || 5;
67
+ this.pickerPosition = options.pickerPosition || this.element.data('picker-position') || 'bottom-right';
68
+ this.showMeridian = options.showMeridian || this.element.data('show-meridian') || false;
69
+ this.initialDate = options.initialDate || new Date();
70
+
71
+ this._attachEvents();
72
+
73
+ this.formatViewType = "datetime";
74
+ if ('formatViewType' in options) {
75
+ this.formatViewType = options.formatViewType;
76
+ } else if ('formatViewType' in this.element.data()) {
77
+ this.formatViewType = this.element.data('formatViewType');
78
+ }
79
+
80
+ this.minView = 0;
81
+ if ('minView' in options) {
82
+ this.minView = options.minView;
83
+ } else if ('minView' in this.element.data()) {
84
+ this.minView = this.element.data('min-view');
85
+ }
86
+ this.minView = DPGlobal.convertViewMode(this.minView);
87
+
88
+ this.maxView = DPGlobal.modes.length - 1;
89
+ if ('maxView' in options) {
90
+ this.maxView = options.maxView;
91
+ } else if ('maxView' in this.element.data()) {
92
+ this.maxView = this.element.data('max-view');
93
+ }
94
+ this.maxView = DPGlobal.convertViewMode(this.maxView);
95
+
96
+ this.wheelViewModeNavigation = false;
97
+ if ('wheelViewModeNavigation' in options) {
98
+ this.wheelViewModeNavigation = options.wheelViewModeNavigation;
99
+ } else if ('wheelViewModeNavigation' in this.element.data()) {
100
+ this.wheelViewModeNavigation = this.element.data('view-mode-wheel-navigation');
101
+ }
102
+
103
+ this.wheelViewModeNavigationInverseDirection = false;
104
+
105
+ if ('wheelViewModeNavigationInverseDirection' in options) {
106
+ this.wheelViewModeNavigationInverseDirection = options.wheelViewModeNavigationInverseDirection;
107
+ } else if ('wheelViewModeNavigationInverseDirection' in this.element.data()) {
108
+ this.wheelViewModeNavigationInverseDirection = this.element.data('view-mode-wheel-navigation-inverse-dir');
109
+ }
110
+
111
+ this.wheelViewModeNavigationDelay = 100;
112
+ if ('wheelViewModeNavigationDelay' in options) {
113
+ this.wheelViewModeNavigationDelay = options.wheelViewModeNavigationDelay;
114
+ } else if ('wheelViewModeNavigationDelay' in this.element.data()) {
115
+ this.wheelViewModeNavigationDelay = this.element.data('view-mode-wheel-navigation-delay');
116
+ }
117
+
118
+ this.startViewMode = 2;
119
+ if ('startView' in options) {
120
+ this.startViewMode = options.startView;
121
+ } else if ('startView' in this.element.data()) {
122
+ this.startViewMode = this.element.data('start-view');
123
+ }
124
+ this.startViewMode = DPGlobal.convertViewMode(this.startViewMode);
125
+ this.viewMode = this.startViewMode;
126
+
127
+ this.viewSelect = this.minView;
128
+ if ('viewSelect' in options) {
129
+ this.viewSelect = options.viewSelect;
130
+ } else if ('viewSelect' in this.element.data()) {
131
+ this.viewSelect = this.element.data('view-select');
132
+ }
133
+ this.viewSelect = DPGlobal.convertViewMode(this.viewSelect);
134
+
135
+ this.forceParse = true;
136
+ if ('forceParse' in options) {
137
+ this.forceParse = options.forceParse;
138
+ } else if ('dateForceParse' in this.element.data()) {
139
+ this.forceParse = this.element.data('date-force-parse');
140
+ }
141
+
142
+ this.picker = $((this.bootcssVer == 3) ? DPGlobal.templateV3 : DPGlobal.template)
143
+ .appendTo(this.isInline ? this.element : 'body')
144
+ .on({
145
+ click: $.proxy(this.click, this),
146
+ mousedown: $.proxy(this.mousedown, this)
147
+ });
148
+
149
+ if (this.wheelViewModeNavigation) {
150
+ if ($.fn.mousewheel) {
151
+ this.picker.on({mousewheel: $.proxy(this.mousewheel, this)});
152
+ } else {
153
+ console.log("Mouse Wheel event is not supported. Please include the jQuery Mouse Wheel plugin before enabling this option");
154
+ }
155
+ }
156
+
157
+ if (this.isInline) {
158
+ this.picker.addClass('datetimepicker-inline');
159
+ } else {
160
+ this.picker.addClass('datetimepicker-dropdown-' + this.pickerPosition + ' dropdown-menu');
161
+ }
162
+ if (this.isRTL) {
163
+ this.picker.addClass('datetimepicker-rtl');
164
+ if (this.bootcssVer == 3) {
165
+ this.picker.find('.prev span, .next span')
166
+ .toggleClass('glyphicon-arrow-left glyphicon-arrow-right');
167
+ } else {
168
+ this.picker.find('.prev i, .next i')
169
+ .toggleClass('icon-arrow-left icon-arrow-right');
170
+ }
171
+ ;
172
+
173
+ }
174
+ $(document).on('mousedown', function (e) {
175
+ // Clicked outside the datetimepicker, hide it
176
+ if ($(e.target).closest('.datetimepicker').length === 0) {
177
+ that.hide();
178
+ }
179
+ });
180
+
181
+ this.autoclose = false;
182
+ if ('autoclose' in options) {
183
+ this.autoclose = options.autoclose;
184
+ } else if ('dateAutoclose' in this.element.data()) {
185
+ this.autoclose = this.element.data('date-autoclose');
186
+ }
187
+
188
+ this.keyboardNavigation = true;
189
+ if ('keyboardNavigation' in options) {
190
+ this.keyboardNavigation = options.keyboardNavigation;
191
+ } else if ('dateKeyboardNavigation' in this.element.data()) {
192
+ this.keyboardNavigation = this.element.data('date-keyboard-navigation');
193
+ }
194
+
195
+ this.todayBtn = (options.todayBtn || this.element.data('date-today-btn') || false);
196
+ this.todayHighlight = (options.todayHighlight || this.element.data('date-today-highlight') || false);
197
+
198
+ this.weekStart = ((options.weekStart || this.element.data('date-weekstart') || dates[this.language].weekStart || 0) % 7);
199
+ this.weekEnd = ((this.weekStart + 6) % 7);
200
+ this.startDate = -Infinity;
201
+ this.endDate = Infinity;
202
+ this.daysOfWeekDisabled = [];
203
+ this.setStartDate(options.startDate || this.element.data('date-startdate'));
204
+ this.setEndDate(options.endDate || this.element.data('date-enddate'));
205
+ this.setDaysOfWeekDisabled(options.daysOfWeekDisabled || this.element.data('date-days-of-week-disabled'));
206
+ this.fillDow();
207
+ this.fillMonths();
208
+ this.update();
209
+ this.showMode();
210
+
211
+ if (this.isInline) {
212
+ this.show();
213
+ }
214
+ };
215
+
216
+ Datetimepicker.prototype = {
217
+ constructor: Datetimepicker,
218
+
219
+ _events: [],
220
+ _attachEvents: function () {
221
+ this._detachEvents();
222
+ if (this.isInput) { // single input
223
+ this._events = [
224
+ [this.element, {
225
+ focus: $.proxy(this.show, this),
226
+ keyup: $.proxy(this.update, this),
227
+ keydown: $.proxy(this.keydown, this)
228
+ }]
229
+ ];
230
+ }
231
+ else if (this.component && this.hasInput) { // component: input + button
232
+ this._events = [
233
+ // For components that are not readonly, allow keyboard nav
234
+ [this.element.find('input'), {
235
+ focus: $.proxy(this.show, this),
236
+ keyup: $.proxy(this.update, this),
237
+ keydown: $.proxy(this.keydown, this)
238
+ }],
239
+ [this.component, {
240
+ click: $.proxy(this.show, this)
241
+ }]
242
+ ];
243
+ if (this.componentReset) {
244
+ this._events.push([
245
+ this.componentReset,
246
+ {click: $.proxy(this.reset, this)}
247
+ ]);
248
+ }
249
+ }
250
+ else if (this.element.is('div')) { // inline datetimepicker
251
+ this.isInline = true;
252
+ }
253
+ else {
254
+ this._events = [
255
+ [this.element, {
256
+ click: $.proxy(this.show, this)
257
+ }]
258
+ ];
259
+ }
260
+ for (var i = 0, el, ev; i < this._events.length; i++) {
261
+ el = this._events[i][0];
262
+ ev = this._events[i][1];
263
+ el.on(ev);
264
+ }
265
+ },
266
+
267
+ _detachEvents: function () {
268
+ for (var i = 0, el, ev; i < this._events.length; i++) {
269
+ el = this._events[i][0];
270
+ ev = this._events[i][1];
271
+ el.off(ev);
272
+ }
273
+ this._events = [];
274
+ },
275
+
276
+ show: function (e) {
277
+ this.picker.show();
278
+ this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
279
+ if (this.forceParse) {
280
+ this.update();
281
+ }
282
+ this.place();
283
+ $(window).on('resize', $.proxy(this.place, this));
284
+ if (e) {
285
+ e.stopPropagation();
286
+ e.preventDefault();
287
+ }
288
+ this.isVisible = true;
289
+ this.element.trigger({
290
+ type: 'show',
291
+ date: this.date
292
+ });
293
+ },
294
+
295
+ hide: function (e) {
296
+ if (!this.isVisible) return;
297
+ if (this.isInline) return;
298
+ this.picker.hide();
299
+ $(window).off('resize', this.place);
300
+ this.viewMode = this.startViewMode;
301
+ this.showMode();
302
+ if (!this.isInput) {
303
+ $(document).off('mousedown', this.hide);
304
+ }
305
+
306
+ if (
307
+ this.forceParse &&
308
+ (
309
+ this.isInput && this.element.val() ||
310
+ this.hasInput && this.element.find('input').val()
311
+ )
312
+ )
313
+ this.setValue();
314
+ this.isVisible = false;
315
+ this.element.trigger({
316
+ type: 'hide',
317
+ date: this.date
318
+ });
319
+ },
320
+
321
+ remove: function () {
322
+ this._detachEvents();
323
+ this.picker.remove();
324
+ delete this.picker;
325
+ delete this.element.data().datetimepicker;
326
+ },
327
+
328
+ getDate: function () {
329
+ var d = this.getUTCDate();
330
+ return new Date(d.getTime() + (d.getTimezoneOffset() * 60000));
331
+ },
332
+
333
+ getUTCDate: function () {
334
+ return this.date;
335
+ },
336
+
337
+ setDate: function (d) {
338
+ this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset() * 60000)));
339
+ },
340
+
341
+ setUTCDate: function (d) {
342
+ if (d >= this.startDate && d <= this.endDate) {
343
+ this.date = d;
344
+ this.setValue();
345
+ this.viewDate = this.date;
346
+ this.fill();
347
+ } else {
348
+ this.element.trigger({
349
+ type: 'outOfRange',
350
+ date: d,
351
+ startDate: this.startDate,
352
+ endDate: this.endDate
353
+ });
354
+ }
355
+ },
356
+
357
+ setFormat: function (format) {
358
+ this.format = DPGlobal.parseFormat(format, this.formatType);
359
+ var element;
360
+ if (this.isInput) {
361
+ element = this.element;
362
+ } else if (this.component) {
363
+ element = this.element.find('input');
364
+ }
365
+ if (element && element.val()) {
366
+ this.setValue();
367
+ }
368
+ },
369
+
370
+ setValue: function () {
371
+ var formatted = this.getFormattedDate();
372
+ if (!this.isInput) {
373
+ if (this.component) {
374
+ this.element.find('input').val(formatted);
375
+ }
376
+ this.element.data('date', formatted);
377
+ } else {
378
+ this.element.val(formatted);
379
+ }
380
+ if (this.linkField) {
381
+ $('#' + this.linkField).val(this.getFormattedDate(this.linkFormat));
382
+ }
383
+ },
384
+
385
+ getFormattedDate: function (format) {
386
+ if (format == undefined) format = this.format;
387
+ return DPGlobal.formatDate(this.date, format, this.language, this.formatType);
388
+ },
389
+
390
+ setStartDate: function (startDate) {
391
+ this.startDate = startDate || -Infinity;
392
+ if (this.startDate !== -Infinity) {
393
+ this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language, this.formatType);
394
+ }
395
+ this.update();
396
+ this.updateNavArrows();
397
+ },
398
+
399
+ setEndDate: function (endDate) {
400
+ this.endDate = endDate || Infinity;
401
+ if (this.endDate !== Infinity) {
402
+ this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language, this.formatType);
403
+ }
404
+ this.update();
405
+ this.updateNavArrows();
406
+ },
407
+
408
+ setDaysOfWeekDisabled: function (daysOfWeekDisabled) {
409
+ this.daysOfWeekDisabled = daysOfWeekDisabled || [];
410
+ if (!$.isArray(this.daysOfWeekDisabled)) {
411
+ this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
412
+ }
413
+ this.daysOfWeekDisabled = $.map(this.daysOfWeekDisabled, function (d) {
414
+ return parseInt(d, 10);
415
+ });
416
+ this.update();
417
+ this.updateNavArrows();
418
+ },
419
+
420
+ place: function () {
421
+ if (this.isInline) return;
422
+
423
+ var index_highest = 0;
424
+ $('div').each(function () {
425
+ var index_current = parseInt($(this).css("zIndex"), 10);
426
+ if (index_current > index_highest) {
427
+ index_highest = index_current;
428
+ }
429
+ });
430
+ var zIndex = index_highest + 10;
431
+
432
+ var offset, top, left;
433
+ if (this.component) {
434
+ offset = this.component.offset();
435
+ left = offset.left;
436
+ if (this.pickerPosition == 'bottom-left' || this.pickerPosition == 'top-left') {
437
+ left += this.component.outerWidth() - this.picker.outerWidth();
438
+ }
439
+ } else {
440
+ offset = this.element.offset();
441
+ left = offset.left;
442
+ }
443
+ if (this.pickerPosition == 'top-left' || this.pickerPosition == 'top-right') {
444
+ top = offset.top - this.picker.outerHeight();
445
+ } else {
446
+ top = offset.top + this.height;
447
+ }
448
+ this.picker.css({
449
+ top: top,
450
+ left: left,
451
+ zIndex: zIndex
452
+ });
453
+ },
454
+
455
+ update: function () {
456
+ var date, fromArgs = false;
457
+ if (arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
458
+ date = arguments[0];
459
+ fromArgs = true;
460
+ } else {
461
+ date = this.element.data('date') || (this.isInput ? this.element.val() : this.element.find('input').val()) || this.initialDate;
462
+ if (typeof date == 'string' || date instanceof String) {
463
+ date = date.replace(/^\s+|\s+$/g,'');
464
+ }
465
+ }
466
+
467
+ if (!date) {
468
+ date = new Date();
469
+ fromArgs = false;
470
+ }
471
+
472
+ this.date = DPGlobal.parseDate(date, this.format, this.language, this.formatType);
473
+
474
+ if (fromArgs) this.setValue();
475
+
476
+ if (this.date < this.startDate) {
477
+ this.viewDate = new Date(this.startDate);
478
+ } else if (this.date > this.endDate) {
479
+ this.viewDate = new Date(this.endDate);
480
+ } else {
481
+ this.viewDate = new Date(this.date);
482
+ }
483
+ this.fill();
484
+ },
485
+
486
+ fillDow: function () {
487
+ var dowCnt = this.weekStart,
488
+ html = '<tr>';
489
+ while (dowCnt < this.weekStart + 7) {
490
+ html += '<th class="dow">' + dates[this.language].daysMin[(dowCnt++) % 7] + '</th>';
491
+ }
492
+ html += '</tr>';
493
+ this.picker.find('.datetimepicker-days thead').append(html);
494
+ },
495
+
496
+ fillMonths: function () {
497
+ var html = '',
498
+ i = 0;
499
+ while (i < 12) {
500
+ html += '<span class="month">' + dates[this.language].monthsShort[i++] + '</span>';
501
+ }
502
+ this.picker.find('.datetimepicker-months td').html(html);
503
+ },
504
+
505
+ fill: function () {
506
+ if (this.date == null || this.viewDate == null) {
507
+ return;
508
+ }
509
+ var d = new Date(this.viewDate),
510
+ year = d.getUTCFullYear(),
511
+ month = d.getUTCMonth(),
512
+ dayMonth = d.getUTCDate(),
513
+ hours = d.getUTCHours(),
514
+ minutes = d.getUTCMinutes(),
515
+ startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
516
+ startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
517
+ endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
518
+ endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
519
+ currentDate = (new UTCDate(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.date.getUTCDate())).valueOf(),
520
+ today = new Date();
521
+ this.picker.find('.datetimepicker-days thead th:eq(1)')
522
+ .text(dates[this.language].months[month] + ' ' + year);
523
+ if (this.formatViewType == "time") {
524
+ var hourConverted = hours % 12 ? hours % 12 : 12;
525
+ var hoursDisplay = (hourConverted < 10 ? '0' : '') + hourConverted;
526
+ var minutesDisplay = (minutes < 10 ? '0' : '') + minutes;
527
+ var meridianDisplay = dates[this.language].meridiem[hours < 12 ? 0 : 1];
528
+ this.picker.find('.datetimepicker-hours thead th:eq(1)')
529
+ .text(hoursDisplay + ':' + minutesDisplay + ' ' + meridianDisplay.toUpperCase());
530
+ this.picker.find('.datetimepicker-minutes thead th:eq(1)')
531
+ .text(hoursDisplay + ':' + minutesDisplay + ' ' + meridianDisplay.toUpperCase());
532
+ } else {
533
+ this.picker.find('.datetimepicker-hours thead th:eq(1)')
534
+ .text(dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
535
+ this.picker.find('.datetimepicker-minutes thead th:eq(1)')
536
+ .text(dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
537
+ }
538
+ this.picker.find('tfoot th.today')
539
+ .text(dates[this.language].today)
540
+ .toggle(this.todayBtn !== false);
541
+ this.updateNavArrows();
542
+ this.fillMonths();
543
+ /*var prevMonth = UTCDate(year, month, 0,0,0,0,0);
544
+ prevMonth.setUTCDate(prevMonth.getDate() - (prevMonth.getUTCDay() - this.weekStart + 7)%7);*/
545
+ var prevMonth = UTCDate(year, month - 1, 28, 0, 0, 0, 0),
546
+ day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
547
+ prevMonth.setUTCDate(day);
548
+ prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7) % 7);
549
+ var nextMonth = new Date(prevMonth);
550
+ nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
551
+ nextMonth = nextMonth.valueOf();
552
+ var html = [];
553
+ var clsName;
554
+ while (prevMonth.valueOf() < nextMonth) {
555
+ if (prevMonth.getUTCDay() == this.weekStart) {
556
+ html.push('<tr>');
557
+ }
558
+ clsName = '';
559
+ if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
560
+ clsName += ' old';
561
+ } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
562
+ clsName += ' new';
563
+ }
564
+ // Compare internal UTC date with local today, not UTC today
565
+ if (this.todayHighlight &&
566
+ prevMonth.getUTCFullYear() == today.getFullYear() &&
567
+ prevMonth.getUTCMonth() == today.getMonth() &&
568
+ prevMonth.getUTCDate() == today.getDate()) {
569
+ clsName += ' today';
570
+ }
571
+ if (prevMonth.valueOf() == currentDate) {
572
+ clsName += ' active';
573
+ }
574
+ if ((prevMonth.valueOf() + 86400000) <= this.startDate || prevMonth.valueOf() > this.endDate ||
575
+ $.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1) {
576
+ clsName += ' disabled';
577
+ }
578
+ html.push('<td class="day' + clsName + '">' + prevMonth.getUTCDate() + '</td>');
579
+ if (prevMonth.getUTCDay() == this.weekEnd) {
580
+ html.push('</tr>');
581
+ }
582
+ prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
583
+ }
584
+ this.picker.find('.datetimepicker-days tbody').empty().append(html.join(''));
585
+
586
+ html = [];
587
+ var txt = '', meridian = '', meridianOld = '';
588
+ for (var i = 0; i < 24; i++) {
589
+ var actual = UTCDate(year, month, dayMonth, i);
590
+ clsName = '';
591
+ // We want the previous hour for the startDate
592
+ if ((actual.valueOf() + 3600000) <= this.startDate || actual.valueOf() > this.endDate) {
593
+ clsName += ' disabled';
594
+ } else if (hours == i) {
595
+ clsName += ' active';
596
+ }
597
+ if (this.showMeridian && dates[this.language].meridiem.length == 2) {
598
+ meridian = (i < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
599
+ if (meridian != meridianOld) {
600
+ if (meridianOld != '') {
601
+ html.push('</fieldset>');
602
+ }
603
+ html.push('<fieldset class="hour"><legend>' + meridian.toUpperCase() + '</legend>');
604
+ }
605
+ meridianOld = meridian;
606
+ txt = (i % 12 ? i % 12 : 12);
607
+ html.push('<span class="hour' + clsName + ' hour_' + (i < 12 ? 'am' : 'pm') + '">' + txt + '</span>');
608
+ if (i == 23) {
609
+ html.push('</fieldset>');
610
+ }
611
+ } else {
612
+ txt = i + ':00';
613
+ html.push('<span class="hour' + clsName + '">' + txt + '</span>');
614
+ }
615
+ }
616
+ this.picker.find('.datetimepicker-hours td').html(html.join(''));
617
+
618
+ html = [];
619
+ txt = '', meridian = '', meridianOld = '';
620
+ for (var i = 0; i < 60; i += this.minuteStep) {
621
+ var actual = UTCDate(year, month, dayMonth, hours, i, 0);
622
+ clsName = '';
623
+ if (actual.valueOf() < this.startDate || actual.valueOf() > this.endDate) {
624
+ clsName += ' disabled';
625
+ } else if (Math.floor(minutes / this.minuteStep) == Math.floor(i / this.minuteStep)) {
626
+ clsName += ' active';
627
+ }
628
+ if (this.showMeridian && dates[this.language].meridiem.length == 2) {
629
+ meridian = (hours < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
630
+ if (meridian != meridianOld) {
631
+ if (meridianOld != '') {
632
+ html.push('</fieldset>');
633
+ }
634
+ html.push('<fieldset class="minute"><legend>' + meridian.toUpperCase() + '</legend>');
635
+ }
636
+ meridianOld = meridian;
637
+ txt = (hours % 12 ? hours % 12 : 12);
638
+ //html.push('<span class="minute'+clsName+' minute_'+(hours<12?'am':'pm')+'">'+txt+'</span>');
639
+ html.push('<span class="minute' + clsName + '">' + txt + ':' + (i < 10 ? '0' + i : i) + '</span>');
640
+ if (i == 59) {
641
+ html.push('</fieldset>');
642
+ }
643
+ } else {
644
+ txt = i + ':00';
645
+ //html.push('<span class="hour'+clsName+'">'+txt+'</span>');
646
+ html.push('<span class="minute' + clsName + '">' + hours + ':' + (i < 10 ? '0' + i : i) + '</span>');
647
+ }
648
+ }
649
+ this.picker.find('.datetimepicker-minutes td').html(html.join(''));
650
+
651
+ var currentYear = this.date.getUTCFullYear();
652
+ var months = this.picker.find('.datetimepicker-months')
653
+ .find('th:eq(1)')
654
+ .text(year)
655
+ .end()
656
+ .find('span').removeClass('active');
657
+ if (currentYear == year) {
658
+ months.eq(this.date.getUTCMonth()).addClass('active');
659
+ }
660
+ if (year < startYear || year > endYear) {
661
+ months.addClass('disabled');
662
+ }
663
+ if (year == startYear) {
664
+ months.slice(0, startMonth).addClass('disabled');
665
+ }
666
+ if (year == endYear) {
667
+ months.slice(endMonth + 1).addClass('disabled');
668
+ }
669
+
670
+ html = '';
671
+ year = parseInt(year / 10, 10) * 10;
672
+ var yearCont = this.picker.find('.datetimepicker-years')
673
+ .find('th:eq(1)')
674
+ .text(year + '-' + (year + 9))
675
+ .end()
676
+ .find('td');
677
+ year -= 1;
678
+ for (var i = -1; i < 11; i++) {
679
+ html += '<span class="year' + (i == -1 || i == 10 ? ' old' : '') + (currentYear == year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : '') + '">' + year + '</span>';
680
+ year += 1;
681
+ }
682
+ yearCont.html(html);
683
+ this.place();
684
+ },
685
+
686
+ updateNavArrows: function () {
687
+ var d = new Date(this.viewDate),
688
+ year = d.getUTCFullYear(),
689
+ month = d.getUTCMonth(),
690
+ day = d.getUTCDate(),
691
+ hour = d.getUTCHours();
692
+ switch (this.viewMode) {
693
+ case 0:
694
+ if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
695
+ && month <= this.startDate.getUTCMonth()
696
+ && day <= this.startDate.getUTCDate()
697
+ && hour <= this.startDate.getUTCHours()) {
698
+ this.picker.find('.prev').css({visibility: 'hidden'});
699
+ } else {
700
+ this.picker.find('.prev').css({visibility: 'visible'});
701
+ }
702
+ if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
703
+ && month >= this.endDate.getUTCMonth()
704
+ && day >= this.endDate.getUTCDate()
705
+ && hour >= this.endDate.getUTCHours()) {
706
+ this.picker.find('.next').css({visibility: 'hidden'});
707
+ } else {
708
+ this.picker.find('.next').css({visibility: 'visible'});
709
+ }
710
+ break;
711
+ case 1:
712
+ if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
713
+ && month <= this.startDate.getUTCMonth()
714
+ && day <= this.startDate.getUTCDate()) {
715
+ this.picker.find('.prev').css({visibility: 'hidden'});
716
+ } else {
717
+ this.picker.find('.prev').css({visibility: 'visible'});
718
+ }
719
+ if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
720
+ && month >= this.endDate.getUTCMonth()
721
+ && day >= this.endDate.getUTCDate()) {
722
+ this.picker.find('.next').css({visibility: 'hidden'});
723
+ } else {
724
+ this.picker.find('.next').css({visibility: 'visible'});
725
+ }
726
+ break;
727
+ case 2:
728
+ if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
729
+ && month <= this.startDate.getUTCMonth()) {
730
+ this.picker.find('.prev').css({visibility: 'hidden'});
731
+ } else {
732
+ this.picker.find('.prev').css({visibility: 'visible'});
733
+ }
734
+ if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
735
+ && month >= this.endDate.getUTCMonth()) {
736
+ this.picker.find('.next').css({visibility: 'hidden'});
737
+ } else {
738
+ this.picker.find('.next').css({visibility: 'visible'});
739
+ }
740
+ break;
741
+ case 3:
742
+ case 4:
743
+ if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
744
+ this.picker.find('.prev').css({visibility: 'hidden'});
745
+ } else {
746
+ this.picker.find('.prev').css({visibility: 'visible'});
747
+ }
748
+ if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
749
+ this.picker.find('.next').css({visibility: 'hidden'});
750
+ } else {
751
+ this.picker.find('.next').css({visibility: 'visible'});
752
+ }
753
+ break;
754
+ }
755
+ },
756
+
757
+ mousewheel: function (e) {
758
+
759
+ e.preventDefault();
760
+ e.stopPropagation();
761
+
762
+ if (this.wheelPause) {
763
+ return;
764
+ }
765
+
766
+ this.wheelPause = true;
767
+
768
+ var originalEvent = e.originalEvent;
769
+
770
+ var delta = originalEvent.wheelDelta;
771
+
772
+ var mode = delta > 0 ? 1 : (delta === 0) ? 0 : -1;
773
+
774
+ if (this.wheelViewModeNavigationInverseDirection) {
775
+ mode = -mode;
776
+ }
777
+
778
+ this.showMode(mode);
779
+
780
+ setTimeout($.proxy(function () {
781
+
782
+ this.wheelPause = false
783
+
784
+ }, this), this.wheelViewModeNavigationDelay);
785
+
786
+ },
787
+
788
+ click: function (e) {
789
+ e.stopPropagation();
790
+ e.preventDefault();
791
+ var target = $(e.target).closest('span, td, th, legend');
792
+ if (target.length == 1) {
793
+ if (target.is('.disabled')) {
794
+ this.element.trigger({
795
+ type: 'outOfRange',
796
+ date: this.viewDate,
797
+ startDate: this.startDate,
798
+ endDate: this.endDate
799
+ });
800
+ return;
801
+ }
802
+ switch (target[0].nodeName.toLowerCase()) {
803
+ case 'th':
804
+ switch (target[0].className) {
805
+ case 'switch':
806
+ this.showMode(1);
807
+ break;
808
+ case 'prev':
809
+ case 'next':
810
+ var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
811
+ switch (this.viewMode) {
812
+ case 0:
813
+ this.viewDate = this.moveHour(this.viewDate, dir);
814
+ break;
815
+ case 1:
816
+ this.viewDate = this.moveDate(this.viewDate, dir);
817
+ break;
818
+ case 2:
819
+ this.viewDate = this.moveMonth(this.viewDate, dir);
820
+ break;
821
+ case 3:
822
+ case 4:
823
+ this.viewDate = this.moveYear(this.viewDate, dir);
824
+ break;
825
+ }
826
+ this.fill();
827
+ break;
828
+ case 'today':
829
+ var date = new Date();
830
+ date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
831
+
832
+ // Respect startDate and endDate.
833
+ if (date < this.startDate) date = this.startDate;
834
+ else if (date > this.endDate) date = this.endDate;
835
+
836
+ this.viewMode = this.startViewMode;
837
+ this.showMode(0);
838
+ this._setDate(date);
839
+ this.fill();
840
+ if (this.autoclose) {
841
+ this.hide();
842
+ }
843
+ break;
844
+ }
845
+ break;
846
+ case 'span':
847
+ if (!target.is('.disabled')) {
848
+ var year = this.viewDate.getUTCFullYear(),
849
+ month = this.viewDate.getUTCMonth(),
850
+ day = this.viewDate.getUTCDate(),
851
+ hours = this.viewDate.getUTCHours(),
852
+ minutes = this.viewDate.getUTCMinutes(),
853
+ seconds = this.viewDate.getUTCSeconds();
854
+
855
+ if (target.is('.month')) {
856
+ this.viewDate.setUTCDate(1);
857
+ month = target.parent().find('span').index(target);
858
+ day = this.viewDate.getUTCDate();
859
+ this.viewDate.setUTCMonth(month);
860
+ this.element.trigger({
861
+ type: 'changeMonth',
862
+ date: this.viewDate
863
+ });
864
+ if (this.viewSelect >= 3) {
865
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
866
+ }
867
+ } else if (target.is('.year')) {
868
+ this.viewDate.setUTCDate(1);
869
+ year = parseInt(target.text(), 10) || 0;
870
+ this.viewDate.setUTCFullYear(year);
871
+ this.element.trigger({
872
+ type: 'changeYear',
873
+ date: this.viewDate
874
+ });
875
+ if (this.viewSelect >= 4) {
876
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
877
+ }
878
+ } else if (target.is('.hour')) {
879
+ hours = parseInt(target.text(), 10) || 0;
880
+ if (target.hasClass('hour_am') || target.hasClass('hour_pm')) {
881
+ if (hours == 12 && target.hasClass('hour_am')) {
882
+ hours = 0;
883
+ } else if (hours != 12 && target.hasClass('hour_pm')) {
884
+ hours += 12;
885
+ }
886
+ }
887
+ this.viewDate.setUTCHours(hours);
888
+ this.element.trigger({
889
+ type: 'changeHour',
890
+ date: this.viewDate
891
+ });
892
+ if (this.viewSelect >= 1) {
893
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
894
+ }
895
+ } else if (target.is('.minute')) {
896
+ minutes = parseInt(target.text().substr(target.text().indexOf(':') + 1), 10) || 0;
897
+ this.viewDate.setUTCMinutes(minutes);
898
+ this.element.trigger({
899
+ type: 'changeMinute',
900
+ date: this.viewDate
901
+ });
902
+ if (this.viewSelect >= 0) {
903
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
904
+ }
905
+ }
906
+ if (this.viewMode != 0) {
907
+ var oldViewMode = this.viewMode;
908
+ this.showMode(-1);
909
+ this.fill();
910
+ if (oldViewMode == this.viewMode && this.autoclose) {
911
+ this.hide();
912
+ }
913
+ } else {
914
+ this.fill();
915
+ if (this.autoclose) {
916
+ this.hide();
917
+ }
918
+ }
919
+ }
920
+ break;
921
+ case 'td':
922
+ if (target.is('.day') && !target.is('.disabled')) {
923
+ var day = parseInt(target.text(), 10) || 1;
924
+ var year = this.viewDate.getUTCFullYear(),
925
+ month = this.viewDate.getUTCMonth(),
926
+ hours = this.viewDate.getUTCHours(),
927
+ minutes = this.viewDate.getUTCMinutes(),
928
+ seconds = this.viewDate.getUTCSeconds();
929
+ if (target.is('.old')) {
930
+ if (month === 0) {
931
+ month = 11;
932
+ year -= 1;
933
+ } else {
934
+ month -= 1;
935
+ }
936
+ } else if (target.is('.new')) {
937
+ if (month == 11) {
938
+ month = 0;
939
+ year += 1;
940
+ } else {
941
+ month += 1;
942
+ }
943
+ }
944
+ this.viewDate.setUTCFullYear(year);
945
+ this.viewDate.setUTCMonth(month);
946
+ this.viewDate.setUTCDate(day);
947
+ this.element.trigger({
948
+ type: 'changeDay',
949
+ date: this.viewDate
950
+ });
951
+ if (this.viewSelect >= 2) {
952
+ this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
953
+ }
954
+ }
955
+ var oldViewMode = this.viewMode;
956
+ this.showMode(-1);
957
+ this.fill();
958
+ if (oldViewMode == this.viewMode && this.autoclose) {
959
+ this.hide();
960
+ }
961
+ break;
962
+ }
963
+ }
964
+ },
965
+
966
+ _setDate: function (date, which) {
967
+ if (!which || which == 'date')
968
+ this.date = date;
969
+ if (!which || which == 'view')
970
+ this.viewDate = date;
971
+ this.fill();
972
+ this.setValue();
973
+ var element;
974
+ if (this.isInput) {
975
+ element = this.element;
976
+ } else if (this.component) {
977
+ element = this.element.find('input');
978
+ }
979
+ if (element) {
980
+ element.change();
981
+ if (this.autoclose && (!which || which == 'date')) {
982
+ //this.hide();
983
+ }
984
+ }
985
+ this.element.trigger({
986
+ type: 'changeDate',
987
+ date: this.date
988
+ });
989
+ },
990
+
991
+ moveMinute: function (date, dir) {
992
+ if (!dir) return date;
993
+ var new_date = new Date(date.valueOf());
994
+ //dir = dir > 0 ? 1 : -1;
995
+ new_date.setUTCMinutes(new_date.getUTCMinutes() + (dir * this.minuteStep));
996
+ return new_date;
997
+ },
998
+
999
+ moveHour: function (date, dir) {
1000
+ if (!dir) return date;
1001
+ var new_date = new Date(date.valueOf());
1002
+ //dir = dir > 0 ? 1 : -1;
1003
+ new_date.setUTCHours(new_date.getUTCHours() + dir);
1004
+ return new_date;
1005
+ },
1006
+
1007
+ moveDate: function (date, dir) {
1008
+ if (!dir) return date;
1009
+ var new_date = new Date(date.valueOf());
1010
+ //dir = dir > 0 ? 1 : -1;
1011
+ new_date.setUTCDate(new_date.getUTCDate() + dir);
1012
+ return new_date;
1013
+ },
1014
+
1015
+ moveMonth: function (date, dir) {
1016
+ if (!dir) return date;
1017
+ var new_date = new Date(date.valueOf()),
1018
+ day = new_date.getUTCDate(),
1019
+ month = new_date.getUTCMonth(),
1020
+ mag = Math.abs(dir),
1021
+ new_month, test;
1022
+ dir = dir > 0 ? 1 : -1;
1023
+ if (mag == 1) {
1024
+ test = dir == -1
1025
+ // If going back one month, make sure month is not current month
1026
+ // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
1027
+ ? function () {
1028
+ return new_date.getUTCMonth() == month;
1029
+ }
1030
+ // If going forward one month, make sure month is as expected
1031
+ // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
1032
+ : function () {
1033
+ return new_date.getUTCMonth() != new_month;
1034
+ };
1035
+ new_month = month + dir;
1036
+ new_date.setUTCMonth(new_month);
1037
+ // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
1038
+ if (new_month < 0 || new_month > 11)
1039
+ new_month = (new_month + 12) % 12;
1040
+ } else {
1041
+ // For magnitudes >1, move one month at a time...
1042
+ for (var i = 0; i < mag; i++)
1043
+ // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
1044
+ new_date = this.moveMonth(new_date, dir);
1045
+ // ...then reset the day, keeping it in the new month
1046
+ new_month = new_date.getUTCMonth();
1047
+ new_date.setUTCDate(day);
1048
+ test = function () {
1049
+ return new_month != new_date.getUTCMonth();
1050
+ };
1051
+ }
1052
+ // Common date-resetting loop -- if date is beyond end of month, make it
1053
+ // end of month
1054
+ while (test()) {
1055
+ new_date.setUTCDate(--day);
1056
+ new_date.setUTCMonth(new_month);
1057
+ }
1058
+ return new_date;
1059
+ },
1060
+
1061
+ moveYear: function (date, dir) {
1062
+ return this.moveMonth(date, dir * 12);
1063
+ },
1064
+
1065
+ dateWithinRange: function (date) {
1066
+ return date >= this.startDate && date <= this.endDate;
1067
+ },
1068
+
1069
+ keydown: function (e) {
1070
+ if (this.picker.is(':not(:visible)')) {
1071
+ if (e.keyCode == 27) // allow escape to hide and re-show picker
1072
+ this.show();
1073
+ return;
1074
+ }
1075
+ var dateChanged = false,
1076
+ dir, day, month,
1077
+ newDate, newViewDate;
1078
+ switch (e.keyCode) {
1079
+ case 27: // escape
1080
+ this.hide();
1081
+ e.preventDefault();
1082
+ break;
1083
+ case 37: // left
1084
+ case 39: // right
1085
+ if (!this.keyboardNavigation) break;
1086
+ dir = e.keyCode == 37 ? -1 : 1;
1087
+ viewMode = this.viewMode;
1088
+ if (e.ctrlKey) {
1089
+ viewMode += 2;
1090
+ } else if (e.shiftKey) {
1091
+ viewMode += 1;
1092
+ }
1093
+ if (viewMode == 4) {
1094
+ newDate = this.moveYear(this.date, dir);
1095
+ newViewDate = this.moveYear(this.viewDate, dir);
1096
+ } else if (viewMode == 3) {
1097
+ newDate = this.moveMonth(this.date, dir);
1098
+ newViewDate = this.moveMonth(this.viewDate, dir);
1099
+ } else if (viewMode == 2) {
1100
+ newDate = this.moveDate(this.date, dir);
1101
+ newViewDate = this.moveDate(this.viewDate, dir);
1102
+ } else if (viewMode == 1) {
1103
+ newDate = this.moveHour(this.date, dir);
1104
+ newViewDate = this.moveHour(this.viewDate, dir);
1105
+ } else if (viewMode == 0) {
1106
+ newDate = this.moveMinute(this.date, dir);
1107
+ newViewDate = this.moveMinute(this.viewDate, dir);
1108
+ }
1109
+ if (this.dateWithinRange(newDate)) {
1110
+ this.date = newDate;
1111
+ this.viewDate = newViewDate;
1112
+ this.setValue();
1113
+ this.update();
1114
+ e.preventDefault();
1115
+ dateChanged = true;
1116
+ }
1117
+ break;
1118
+ case 38: // up
1119
+ case 40: // down
1120
+ if (!this.keyboardNavigation) break;
1121
+ dir = e.keyCode == 38 ? -1 : 1;
1122
+ viewMode = this.viewMode;
1123
+ if (e.ctrlKey) {
1124
+ viewMode += 2;
1125
+ } else if (e.shiftKey) {
1126
+ viewMode += 1;
1127
+ }
1128
+ if (viewMode == 4) {
1129
+ newDate = this.moveYear(this.date, dir);
1130
+ newViewDate = this.moveYear(this.viewDate, dir);
1131
+ } else if (viewMode == 3) {
1132
+ newDate = this.moveMonth(this.date, dir);
1133
+ newViewDate = this.moveMonth(this.viewDate, dir);
1134
+ } else if (viewMode == 2) {
1135
+ newDate = this.moveDate(this.date, dir * 7);
1136
+ newViewDate = this.moveDate(this.viewDate, dir * 7);
1137
+ } else if (viewMode == 1) {
1138
+ if (this.showMeridian) {
1139
+ newDate = this.moveHour(this.date, dir * 6);
1140
+ newViewDate = this.moveHour(this.viewDate, dir * 6);
1141
+ } else {
1142
+ newDate = this.moveHour(this.date, dir * 4);
1143
+ newViewDate = this.moveHour(this.viewDate, dir * 4);
1144
+ }
1145
+ } else if (viewMode == 0) {
1146
+ newDate = this.moveMinute(this.date, dir * 4);
1147
+ newViewDate = this.moveMinute(this.viewDate, dir * 4);
1148
+ }
1149
+ if (this.dateWithinRange(newDate)) {
1150
+ this.date = newDate;
1151
+ this.viewDate = newViewDate;
1152
+ this.setValue();
1153
+ this.update();
1154
+ e.preventDefault();
1155
+ dateChanged = true;
1156
+ }
1157
+ break;
1158
+ case 13: // enter
1159
+ if (this.viewMode != 0) {
1160
+ var oldViewMode = this.viewMode;
1161
+ this.showMode(-1);
1162
+ this.fill();
1163
+ if (oldViewMode == this.viewMode && this.autoclose) {
1164
+ this.hide();
1165
+ }
1166
+ } else {
1167
+ this.fill();
1168
+ if (this.autoclose) {
1169
+ this.hide();
1170
+ }
1171
+ }
1172
+ e.preventDefault();
1173
+ break;
1174
+ case 9: // tab
1175
+ this.hide();
1176
+ break;
1177
+ }
1178
+ if (dateChanged) {
1179
+ var element;
1180
+ if (this.isInput) {
1181
+ element = this.element;
1182
+ } else if (this.component) {
1183
+ element = this.element.find('input');
1184
+ }
1185
+ if (element) {
1186
+ element.change();
1187
+ }
1188
+ this.element.trigger({
1189
+ type: 'changeDate',
1190
+ date: this.date
1191
+ });
1192
+ }
1193
+ },
1194
+
1195
+ showMode: function (dir) {
1196
+ if (dir) {
1197
+ var newViewMode = Math.max(0, Math.min(DPGlobal.modes.length - 1, this.viewMode + dir));
1198
+ if (newViewMode >= this.minView && newViewMode <= this.maxView) {
1199
+ this.element.trigger({
1200
+ type: 'changeMode',
1201
+ date: this.viewDate,
1202
+ oldViewMode: this.viewMode,
1203
+ newViewMode: newViewMode
1204
+ });
1205
+
1206
+ this.viewMode = newViewMode;
1207
+ }
1208
+ }
1209
+ /*
1210
+ vitalets: fixing bug of very special conditions:
1211
+ jquery 1.7.1 + webkit + show inline datetimepicker in bootstrap popover.
1212
+ Method show() does not set display css correctly and datetimepicker is not shown.
1213
+ Changed to .css('display', 'block') solve the problem.
1214
+ See https://github.com/vitalets/x-editable/issues/37
1215
+
1216
+ In jquery 1.7.2+ everything works fine.
1217
+ */
1218
+ //this.picker.find('>div').hide().filter('.datetimepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
1219
+ this.picker.find('>div').hide().filter('.datetimepicker-' + DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
1220
+ this.updateNavArrows();
1221
+ },
1222
+
1223
+ reset: function (e) {
1224
+ this._setDate(null, 'date');
1225
+ }
1226
+ };
1227
+
1228
+ $.fn.datetimepicker = function (option) {
1229
+ var args = Array.apply(null, arguments);
1230
+ args.shift();
1231
+ return this.each(function () {
1232
+ var $this = $(this),
1233
+ data = $this.data('datetimepicker'),
1234
+ options = typeof option == 'object' && option;
1235
+ if (!data) {
1236
+ $this.data('datetimepicker', (data = new Datetimepicker(this, $.extend({}, $.fn.datetimepicker.defaults, options))));
1237
+ }
1238
+ if (typeof option == 'string' && typeof data[option] == 'function') {
1239
+ data[option].apply(data, args);
1240
+ }
1241
+ });
1242
+ };
1243
+
1244
+ $.fn.datetimepicker.defaults = {
1245
+ };
1246
+ $.fn.datetimepicker.Constructor = Datetimepicker;
1247
+ var dates = $.fn.datetimepicker.dates = {
1248
+ en: {
1249
+ days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
1250
+ daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
1251
+ daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
1252
+ months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
1253
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
1254
+ meridiem: ["am", "pm"],
1255
+ suffix: ["st", "nd", "rd", "th"],
1256
+ today: "Today"
1257
+ }
1258
+ };
1259
+
1260
+ var DPGlobal = {
1261
+ modes: [
1262
+ {
1263
+ clsName: 'minutes',
1264
+ navFnc: 'Hours',
1265
+ navStep: 1
1266
+ },
1267
+ {
1268
+ clsName: 'hours',
1269
+ navFnc: 'Date',
1270
+ navStep: 1
1271
+ },
1272
+ {
1273
+ clsName: 'days',
1274
+ navFnc: 'Month',
1275
+ navStep: 1
1276
+ },
1277
+ {
1278
+ clsName: 'months',
1279
+ navFnc: 'FullYear',
1280
+ navStep: 1
1281
+ },
1282
+ {
1283
+ clsName: 'years',
1284
+ navFnc: 'FullYear',
1285
+ navStep: 10
1286
+ }
1287
+ ],
1288
+ isLeapYear: function (year) {
1289
+ return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
1290
+ },
1291
+ getDaysInMonth: function (year, month) {
1292
+ return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
1293
+ },
1294
+ getDefaultFormat: function (type, field) {
1295
+ if (type == "standard") {
1296
+ if (field == 'input')
1297
+ return 'yyyy-mm-dd hh:ii';
1298
+ else
1299
+ return 'yyyy-mm-dd hh:ii:ss';
1300
+ } else if (type == "php") {
1301
+ if (field == 'input')
1302
+ return 'Y-m-d H:i';
1303
+ else
1304
+ return 'Y-m-d H:i:s';
1305
+ } else {
1306
+ throw new Error("Invalid format type.");
1307
+ }
1308
+ },
1309
+ validParts: function (type) {
1310
+ if (type == "standard") {
1311
+ return /hh?|HH?|p|P|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;
1312
+ } else if (type == "php") {
1313
+ return /[dDjlNwzFmMnStyYaABgGhHis]/g;
1314
+ } else {
1315
+ throw new Error("Invalid format type.");
1316
+ }
1317
+ },
1318
+ nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,
1319
+ parseFormat: function (format, type) {
1320
+ // IE treats \0 as a string end in inputs (truncating the value),
1321
+ // so it's a bad format delimiter, anyway
1322
+ var separators = format.replace(this.validParts(type), '\0').split('\0'),
1323
+ parts = format.match(this.validParts(type));
1324
+ if (!separators || !separators.length || !parts || parts.length == 0) {
1325
+ throw new Error("Invalid date format.");
1326
+ }
1327
+ return {separators: separators, parts: parts};
1328
+ },
1329
+ parseDate: function (date, format, language, type) {
1330
+ if (date instanceof Date) {
1331
+ var dateUTC = new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
1332
+ dateUTC.setMilliseconds(0);
1333
+ return dateUTC;
1334
+ }
1335
+ if (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(date)) {
1336
+ format = this.parseFormat('yyyy-mm-dd', type);
1337
+ }
1338
+ if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(date)) {
1339
+ format = this.parseFormat('yyyy-mm-dd hh:ii', type);
1340
+ }
1341
+ if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(date)) {
1342
+ format = this.parseFormat('yyyy-mm-dd hh:ii:ss', type);
1343
+ }
1344
+ if (/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(date)) {
1345
+ var part_re = /([-+]\d+)([dmwy])/,
1346
+ parts = date.match(/([-+]\d+)([dmwy])/g),
1347
+ part, dir;
1348
+ date = new Date();
1349
+ for (var i = 0; i < parts.length; i++) {
1350
+ part = part_re.exec(parts[i]);
1351
+ dir = parseInt(part[1]);
1352
+ switch (part[2]) {
1353
+ case 'd':
1354
+ date.setUTCDate(date.getUTCDate() + dir);
1355
+ break;
1356
+ case 'm':
1357
+ date = Datetimepicker.prototype.moveMonth.call(Datetimepicker.prototype, date, dir);
1358
+ break;
1359
+ case 'w':
1360
+ date.setUTCDate(date.getUTCDate() + dir * 7);
1361
+ break;
1362
+ case 'y':
1363
+ date = Datetimepicker.prototype.moveYear.call(Datetimepicker.prototype, date, dir);
1364
+ break;
1365
+ }
1366
+ }
1367
+ return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), 0);
1368
+ }
1369
+ var parts = date && date.match(this.nonpunctuation) || [],
1370
+ date = new Date(0, 0, 0, 0, 0, 0, 0),
1371
+ parsed = {},
1372
+ setters_order = ['hh', 'h', 'ii', 'i', 'ss', 's', 'yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'D', 'DD', 'd', 'dd', 'H', 'HH', 'p', 'P'],
1373
+ setters_map = {
1374
+ hh: function (d, v) {
1375
+ return d.setUTCHours(v);
1376
+ },
1377
+ h: function (d, v) {
1378
+ return d.setUTCHours(v);
1379
+ },
1380
+ HH: function (d, v) {
1381
+ return d.setUTCHours(v == 12 ? 0 : v);
1382
+ },
1383
+ H: function (d, v) {
1384
+ return d.setUTCHours(v == 12 ? 0 : v);
1385
+ },
1386
+ ii: function (d, v) {
1387
+ return d.setUTCMinutes(v);
1388
+ },
1389
+ i: function (d, v) {
1390
+ return d.setUTCMinutes(v);
1391
+ },
1392
+ ss: function (d, v) {
1393
+ return d.setUTCSeconds(v);
1394
+ },
1395
+ s: function (d, v) {
1396
+ return d.setUTCSeconds(v);
1397
+ },
1398
+ yyyy: function (d, v) {
1399
+ return d.setUTCFullYear(v);
1400
+ },
1401
+ yy: function (d, v) {
1402
+ return d.setUTCFullYear(2000 + v);
1403
+ },
1404
+ m: function (d, v) {
1405
+ v -= 1;
1406
+ while (v < 0) v += 12;
1407
+ v %= 12;
1408
+ d.setUTCMonth(v);
1409
+ while (d.getUTCMonth() != v)
1410
+ d.setUTCDate(d.getUTCDate() - 1);
1411
+ return d;
1412
+ },
1413
+ d: function (d, v) {
1414
+ return d.setUTCDate(v);
1415
+ },
1416
+ p: function (d, v) {
1417
+ return d.setUTCHours(v == 1 ? d.getUTCHours() + 12 : d.getUTCHours());
1418
+ }
1419
+ },
1420
+ val, filtered, part;
1421
+ setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
1422
+ setters_map['dd'] = setters_map['d'];
1423
+ setters_map['P'] = setters_map['p'];
1424
+ date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
1425
+ if (parts.length == format.parts.length) {
1426
+ for (var i = 0, cnt = format.parts.length; i < cnt; i++) {
1427
+ val = parseInt(parts[i], 10);
1428
+ part = format.parts[i];
1429
+ if (isNaN(val)) {
1430
+ switch (part) {
1431
+ case 'MM':
1432
+ filtered = $(dates[language].months).filter(function () {
1433
+ var m = this.slice(0, parts[i].length),
1434
+ p = parts[i].slice(0, m.length);
1435
+ return m == p;
1436
+ });
1437
+ val = $.inArray(filtered[0], dates[language].months) + 1;
1438
+ break;
1439
+ case 'M':
1440
+ filtered = $(dates[language].monthsShort).filter(function () {
1441
+ var m = this.slice(0, parts[i].length),
1442
+ p = parts[i].slice(0, m.length);
1443
+ return m == p;
1444
+ });
1445
+ val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
1446
+ break;
1447
+ case 'p':
1448
+ case 'P':
1449
+ val = $.inArray(parts[i].toLowerCase(), dates[language].meridiem);
1450
+ break;
1451
+ }
1452
+ }
1453
+ parsed[part] = val;
1454
+ }
1455
+ for (var i = 0, s; i < setters_order.length; i++) {
1456
+ s = setters_order[i];
1457
+ if (s in parsed && !isNaN(parsed[s]))
1458
+ setters_map[s](date, parsed[s])
1459
+ }
1460
+ }
1461
+ return date;
1462
+ },
1463
+ formatDate: function (date, format, language, type) {
1464
+ if (date == null) {
1465
+ return '';
1466
+ }
1467
+ var val;
1468
+ if (type == 'standard') {
1469
+ val = {
1470
+ // year
1471
+ yy: date.getUTCFullYear().toString().substring(2),
1472
+ yyyy: date.getUTCFullYear(),
1473
+ // month
1474
+ m: date.getUTCMonth() + 1,
1475
+ M: dates[language].monthsShort[date.getUTCMonth()],
1476
+ MM: dates[language].months[date.getUTCMonth()],
1477
+ // day
1478
+ d: date.getUTCDate(),
1479
+ D: dates[language].daysShort[date.getUTCDay()],
1480
+ DD: dates[language].days[date.getUTCDay()],
1481
+ p: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
1482
+ // hour
1483
+ h: date.getUTCHours(),
1484
+ // minute
1485
+ i: date.getUTCMinutes(),
1486
+ // second
1487
+ s: date.getUTCSeconds()
1488
+ };
1489
+
1490
+ if (dates[language].meridiem.length == 2) {
1491
+ val.H = (val.h % 12 == 0 ? 12 : val.h % 12);
1492
+ }
1493
+ else {
1494
+ val.H = val.h;
1495
+ }
1496
+ val.HH = (val.H < 10 ? '0' : '') + val.H;
1497
+ val.P = val.p.toUpperCase();
1498
+ val.hh = (val.h < 10 ? '0' : '') + val.h;
1499
+ val.ii = (val.i < 10 ? '0' : '') + val.i;
1500
+ val.ss = (val.s < 10 ? '0' : '') + val.s;
1501
+ val.dd = (val.d < 10 ? '0' : '') + val.d;
1502
+ val.mm = (val.m < 10 ? '0' : '') + val.m;
1503
+ } else if (type == 'php') {
1504
+ // php format
1505
+ val = {
1506
+ // year
1507
+ y: date.getUTCFullYear().toString().substring(2),
1508
+ Y: date.getUTCFullYear(),
1509
+ // month
1510
+ F: dates[language].months[date.getUTCMonth()],
1511
+ M: dates[language].monthsShort[date.getUTCMonth()],
1512
+ n: date.getUTCMonth() + 1,
1513
+ t: DPGlobal.getDaysInMonth(date.getUTCFullYear(), date.getUTCMonth()),
1514
+ // day
1515
+ j: date.getUTCDate(),
1516
+ l: dates[language].days[date.getUTCDay()],
1517
+ D: dates[language].daysShort[date.getUTCDay()],
1518
+ w: date.getUTCDay(), // 0 -> 6
1519
+ N: (date.getUTCDay() == 0 ? 7 : date.getUTCDay()), // 1 -> 7
1520
+ S: (date.getUTCDate() % 10 <= dates[language].suffix.length ? dates[language].suffix[date.getUTCDate() % 10 - 1] : ''),
1521
+ // hour
1522
+ a: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
1523
+ g: (date.getUTCHours() % 12 == 0 ? 12 : date.getUTCHours() % 12),
1524
+ G: date.getUTCHours(),
1525
+ // minute
1526
+ i: date.getUTCMinutes(),
1527
+ // second
1528
+ s: date.getUTCSeconds()
1529
+ };
1530
+ val.m = (val.n < 10 ? '0' : '') + val.n;
1531
+ val.d = (val.j < 10 ? '0' : '') + val.j;
1532
+ val.A = val.a.toString().toUpperCase();
1533
+ val.h = (val.g < 10 ? '0' : '') + val.g;
1534
+ val.H = (val.G < 10 ? '0' : '') + val.G;
1535
+ val.i = (val.i < 10 ? '0' : '') + val.i;
1536
+ val.s = (val.s < 10 ? '0' : '') + val.s;
1537
+ } else {
1538
+ throw new Error("Invalid format type.");
1539
+ }
1540
+ var date = [],
1541
+ seps = $.extend([], format.separators);
1542
+ for (var i = 0, cnt = format.parts.length; i < cnt; i++) {
1543
+ if (seps.length) {
1544
+ date.push(seps.shift());
1545
+ }
1546
+ date.push(val[format.parts[i]]);
1547
+ }
1548
+ if (seps.length) {
1549
+ date.push(seps.shift());
1550
+ }
1551
+ return date.join('');
1552
+ },
1553
+ convertViewMode: function (viewMode) {
1554
+ switch (viewMode) {
1555
+ case 4:
1556
+ case 'decade':
1557
+ viewMode = 4;
1558
+ break;
1559
+ case 3:
1560
+ case 'year':
1561
+ viewMode = 3;
1562
+ break;
1563
+ case 2:
1564
+ case 'month':
1565
+ viewMode = 2;
1566
+ break;
1567
+ case 1:
1568
+ case 'day':
1569
+ viewMode = 1;
1570
+ break;
1571
+ case 0:
1572
+ case 'hour':
1573
+ viewMode = 0;
1574
+ break;
1575
+ }
1576
+
1577
+ return viewMode;
1578
+ },
1579
+ headTemplate: '<thead>' +
1580
+ '<tr>' +
1581
+ '<th class="prev"><i class="icon-arrow-left"/></th>' +
1582
+ '<th colspan="5" class="switch"></th>' +
1583
+ '<th class="next"><i class="icon-arrow-right"/></th>' +
1584
+ '</tr>' +
1585
+ '</thead>',
1586
+ headTemplateV3: '<thead>' +
1587
+ '<tr>' +
1588
+ '<th class="prev"><i class="glyphicon glyphicon-arrow-left"></i> </th>' +
1589
+ '<th colspan="5" class="switch"></th>' +
1590
+ '<th class="next"><i class="glyphicon glyphicon-arrow-right"></i> </th>' +
1591
+ '</tr>' +
1592
+ '</thead>',
1593
+ contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
1594
+ footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
1595
+ };
1596
+ DPGlobal.template = '<div class="datetimepicker">' +
1597
+ '<div class="datetimepicker-minutes">' +
1598
+ '<table class=" table-condensed">' +
1599
+ DPGlobal.headTemplate +
1600
+ DPGlobal.contTemplate +
1601
+ DPGlobal.footTemplate +
1602
+ '</table>' +
1603
+ '</div>' +
1604
+ '<div class="datetimepicker-hours">' +
1605
+ '<table class=" table-condensed">' +
1606
+ DPGlobal.headTemplate +
1607
+ DPGlobal.contTemplate +
1608
+ DPGlobal.footTemplate +
1609
+ '</table>' +
1610
+ '</div>' +
1611
+ '<div class="datetimepicker-days">' +
1612
+ '<table class=" table-condensed">' +
1613
+ DPGlobal.headTemplate +
1614
+ '<tbody></tbody>' +
1615
+ DPGlobal.footTemplate +
1616
+ '</table>' +
1617
+ '</div>' +
1618
+ '<div class="datetimepicker-months">' +
1619
+ '<table class="table-condensed">' +
1620
+ DPGlobal.headTemplate +
1621
+ DPGlobal.contTemplate +
1622
+ DPGlobal.footTemplate +
1623
+ '</table>' +
1624
+ '</div>' +
1625
+ '<div class="datetimepicker-years">' +
1626
+ '<table class="table-condensed">' +
1627
+ DPGlobal.headTemplate +
1628
+ DPGlobal.contTemplate +
1629
+ DPGlobal.footTemplate +
1630
+ '</table>' +
1631
+ '</div>' +
1632
+ '</div>';
1633
+ DPGlobal.templateV3 = '<div class="datetimepicker">' +
1634
+ '<div class="datetimepicker-minutes">' +
1635
+ '<table class=" table-condensed">' +
1636
+ DPGlobal.headTemplateV3 +
1637
+ DPGlobal.contTemplate +
1638
+ DPGlobal.footTemplate +
1639
+ '</table>' +
1640
+ '</div>' +
1641
+ '<div class="datetimepicker-hours">' +
1642
+ '<table class=" table-condensed">' +
1643
+ DPGlobal.headTemplateV3 +
1644
+ DPGlobal.contTemplate +
1645
+ DPGlobal.footTemplate +
1646
+ '</table>' +
1647
+ '</div>' +
1648
+ '<div class="datetimepicker-days">' +
1649
+ '<table class=" table-condensed">' +
1650
+ DPGlobal.headTemplateV3 +
1651
+ '<tbody></tbody>' +
1652
+ DPGlobal.footTemplate +
1653
+ '</table>' +
1654
+ '</div>' +
1655
+ '<div class="datetimepicker-months">' +
1656
+ '<table class="table-condensed">' +
1657
+ DPGlobal.headTemplateV3 +
1658
+ DPGlobal.contTemplate +
1659
+ DPGlobal.footTemplate +
1660
+ '</table>' +
1661
+ '</div>' +
1662
+ '<div class="datetimepicker-years">' +
1663
+ '<table class="table-condensed">' +
1664
+ DPGlobal.headTemplateV3 +
1665
+ DPGlobal.contTemplate +
1666
+ DPGlobal.footTemplate +
1667
+ '</table>' +
1668
+ '</div>' +
1669
+ '</div>';
1670
+ $.fn.datetimepicker.DPGlobal = DPGlobal;
1671
+
1672
+ /* DATETIMEPICKER NO CONFLICT
1673
+ * =================== */
1674
+
1675
+ $.fn.datetimepicker.noConflict = function () {
1676
+ $.fn.datetimepicker = old;
1677
+ return this;
1678
+ };
1679
+
1680
+ /* DATETIMEPICKER DATA-API
1681
+ * ================== */
1682
+
1683
+ $(document).on(
1684
+ 'focus.datetimepicker.data-api click.datetimepicker.data-api',
1685
+ '[data-provide="datetimepicker"]',
1686
+ function (e) {
1687
+ var $this = $(this);
1688
+ if ($this.data('datetimepicker')) return;
1689
+ e.preventDefault();
1690
+ // component click requires us to explicitly show it
1691
+ $this.datetimepicker('show');
1692
+ }
1693
+ );
1694
+ $(function () {
1695
+ $('[data-provide="datetimepicker-inline"]').datetimepicker();
1696
+ });
1697
+
1698
+ }(window.jQuery);