bootstrap3-datetimepicker-rails 2.1.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/LICENSE.txt +22 -0
  2. data/README.md +67 -0
  3. data/lib/bootstrap3-datetimepicker-rails.rb +8 -0
  4. data/lib/bootstrap3-datetimepicker-rails/version.rb +5 -0
  5. data/vendor/assets/javascripts/bootstrap-datetimepicker.js +1084 -0
  6. data/vendor/assets/javascripts/bootstrap-datetimepicker.min.js +28 -0
  7. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ar-ma.js +56 -0
  8. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ar.js +56 -0
  9. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.bg.js +86 -0
  10. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.br.js +107 -0
  11. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.bs.js +139 -0
  12. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ca.js +66 -0
  13. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.cs.js +155 -0
  14. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.cv.js +59 -0
  15. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.da.js +56 -0
  16. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.de.js +71 -0
  17. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.el.js +79 -0
  18. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.en-au.js +62 -0
  19. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.en-ca.js +59 -0
  20. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.en-gb.js +63 -0
  21. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.eo.js +65 -0
  22. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.es.js +66 -0
  23. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.et.js +60 -0
  24. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.eu.js +60 -0
  25. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fa.js +97 -0
  26. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fi.js +103 -0
  27. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fr-ca.js +54 -0
  28. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fr.js +58 -0
  29. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.gl.js +71 -0
  30. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.he.js +77 -0
  31. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hi.js +105 -0
  32. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hr.js +140 -0
  33. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hu.js +98 -0
  34. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.id.js +67 -0
  35. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.is.js +124 -0
  36. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.it.js +59 -0
  37. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ja.js +58 -0
  38. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ka.js +108 -0
  39. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ko.js +56 -0
  40. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.lt.js +118 -0
  41. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.lv.js +77 -0
  42. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ml.js +64 -0
  43. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.mr.js +104 -0
  44. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ms-my.js +66 -0
  45. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nb.js +57 -0
  46. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ne.js +105 -0
  47. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nl.js +67 -0
  48. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nn.js +56 -0
  49. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pl.js +98 -0
  50. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pt-BR.js +56 -0
  51. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pt.js +60 -0
  52. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ro.js +56 -0
  53. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ru.js +163 -0
  54. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sk.js +156 -0
  55. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sl.js +144 -0
  56. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sq.js +57 -0
  57. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sv.js +63 -0
  58. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.th.js +58 -0
  59. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tr.js +93 -0
  60. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tzm-la.js +55 -0
  61. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tzm.js +55 -0
  62. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.uk.js +157 -0
  63. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.uz.js +55 -0
  64. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.vn.js +62 -0
  65. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.zh-CN.js +108 -0
  66. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.zh-TW.js +84 -0
  67. data/vendor/assets/stylesheets/bootstrap-datetimepicker.css +174 -0
  68. data/vendor/assets/stylesheets/bootstrap-datetimepicker.min.css +8 -0
  69. metadata +163 -0
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Trevor Strieber
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.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # bootstrap3-datetimepicker-rails
2
+
3
+ This gem packages the [bootstrap-datetimepicker](https://github.com/Eonasdan/bootstrap-datetimepicker) for the Rails 3.1+ asset pipeline.
4
+
5
+ Eonasdan's fork of tarruda's [bootstrap-datetimepicker](https://github.com/tarruda/bootstrap-datetimepicker) is
6
+ actively maintained and works with [Bootstrap3](http://getbootstrap.com).
7
+
8
+ [momentjs-rails](https://github.com/derekprior/momentjs-rails) is a required dependency.
9
+
10
+ ## Installation
11
+
12
+ Add these lines to your application's Gemfile:
13
+ ```
14
+ gem 'momentjs-rails', '~> '2.5.0'
15
+ gem 'bootstrap3-datetimepicker-rails', '~> 2.1.20'
16
+ ```
17
+
18
+ And then execute:
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself:
24
+ ```bash
25
+ $ gem install momentjs-rails
26
+ $ gem install bootstrap3-datetimepicker-rails
27
+ ```
28
+
29
+ To start using the bootstrap-datetimepicker plugin in your rails application, enable it via the asset pipeline.
30
+
31
+ Add the following to your Javascript manifest file (`application.js`):
32
+ ```js
33
+ //= require moment
34
+ //= require bootstrap-datetimepicker
35
+ ```
36
+
37
+ If you want to include a localization, also add:
38
+ ```js
39
+ //= require moment/<locale>
40
+ //= require locales/bootstrap-datetimepicker.<locale>
41
+ ```
42
+
43
+ Add the following to your stylesheet file:
44
+
45
+ If you are using SCSS, modify your `application.css.scss`
46
+ ```scss
47
+ @import 'bootstrap';
48
+ @import 'bootstrap-datetimepicker';
49
+ ```
50
+
51
+ If you're using just plain CSS, modify your `application.css`
52
+ ```css
53
+ *= require bootstrap
54
+ *= require bootstrap-datetimepicker
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ Check out the documentation at: http://eonasdan.github.io/bootstrap-datetimepicker/
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create new Pull Request
@@ -0,0 +1,8 @@
1
+ require 'bootstrap3-datetimepicker-rails/version'
2
+
3
+ module Bootstrap3Datetimepicker
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Bootstrap3Datetimepicker
2
+ module Rails
3
+ VERSION = '2.1.20'
4
+ end
5
+ end
@@ -0,0 +1,1084 @@
1
+ /**
2
+ * version 2.1.20
3
+ * @license
4
+ * =========================================================
5
+ * bootstrap-datetimepicker.js
6
+ * http://www.eyecon.ro/bootstrap-datepicker
7
+ * =========================================================
8
+ * Copyright 2012 Stefan Petre
9
+ *
10
+ * Contributions:
11
+ * - updated for Bootstrap v3 by Jonathan Peterson (@Eonasdan) and (almost)
12
+ * completely rewritten to use Momentjs
13
+ * - based on tarruda's bootstrap-datepicker
14
+ *
15
+ * Licensed under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License.
17
+ * You may obtain a copy of the License at
18
+ *
19
+ * http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software
22
+ * distributed under the License is distributed on an "AS IS" BASIS,
23
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ * See the License for the specific language governing permissions and
25
+ * limitations under the License.
26
+ * =========================================================
27
+ */
28
+ ; (function (factory) {
29
+ if (typeof define === 'function' && define.amd) {
30
+ // AMD is used - Register as an anonymous module.
31
+ define(['jquery', 'moment'], factory);
32
+ } else {
33
+ // AMD is not used - Attempt to fetch dependencies from scope.
34
+ if(!jQuery){
35
+ throw 'bootstrap-datetimepicker requires jQuery to be loaded first';
36
+ }else if(!moment) {
37
+ throw 'bootstrap-datetimepicker requires moment.js to be loaded first';
38
+ }else{
39
+ factory(jQuery, moment);
40
+ }
41
+ }
42
+ }
43
+
44
+ (function ($, moment) {
45
+ if (typeof moment === 'undefined') {
46
+ alert("momentjs is requried");
47
+ throw new Error('momentjs is required');
48
+ };
49
+
50
+ var dpgId = 0,
51
+
52
+ pMoment = moment,
53
+
54
+ // ReSharper disable once InconsistentNaming
55
+ DateTimePicker = function (element, options) {
56
+ var defaults = {
57
+ pickDate: true,
58
+ pickTime: true,
59
+ useMinutes: true,
60
+ useSeconds: false,
61
+ minuteStepping: 1,
62
+ startDate: new pMoment({ y: 1970 }),
63
+ endDate: new pMoment().add(50, "y"),
64
+ collapse: true,
65
+ language: pMoment.lang(),
66
+ defaultDate: "",
67
+ disabledDates: [],
68
+ enabledDates: false,
69
+ icons: {},
70
+ useStrict: false
71
+ },
72
+
73
+ icons = {
74
+ time: 'glyphicon glyphicon-time',
75
+ date: 'glyphicon glyphicon-calendar',
76
+ up: 'glyphicon glyphicon-chevron-up',
77
+ down: 'glyphicon glyphicon-chevron-down'
78
+ },
79
+
80
+ picker = this,
81
+
82
+ init = function () {
83
+
84
+ var icon = false, i, dDate, longDateFormat;
85
+ picker.options = $.extend({}, defaults, options);
86
+ picker.options.icons = $.extend({}, icons, picker.options.icons);
87
+
88
+ picker.element = $(element);
89
+
90
+ dataToOptions();
91
+
92
+ if (!(picker.options.pickTime || picker.options.pickDate))
93
+ throw new Error('Must choose at least one picker');
94
+
95
+ picker.id = dpgId++;
96
+ pMoment.lang(picker.options.language);
97
+ picker.date = pMoment();
98
+ picker.unset = false;
99
+ picker.isInput = picker.element.is('input');
100
+ picker.component = false;
101
+
102
+ if (picker.element.hasClass('input-group')) {
103
+ if (picker.element.find('.datepickerbutton').size() == 0) {//in case there is more then one 'input-group-addon` #48
104
+ picker.component = picker.element.find("[class^='input-group-']");
105
+ }
106
+ else {
107
+ picker.component = picker.element.find('.datepickerbutton');
108
+ }
109
+ }
110
+ picker.format = picker.options.format;
111
+
112
+ longDateFormat = pMoment()._lang._longDateFormat;
113
+
114
+ if (!picker.format) {
115
+ if (picker.isInput) picker.format = picker.element.data('format');
116
+ else picker.format = picker.element.find('input').data('format');
117
+ if (!picker.format) {
118
+ picker.format = (picker.options.pickDate ? longDateFormat.L : '');
119
+ if (picker.options.pickDate && picker.options.pickTime) picker.format += ' ';
120
+ picker.format += (picker.options.pickTime ? longDateFormat.LT : '');
121
+ if (picker.options.useSeconds) {
122
+ if (~longDateFormat.LT.indexOf(' A')) {
123
+ picker.format = picker.format.split(" A")[0] + ":ss A";
124
+ }
125
+ else {
126
+ picker.format += ':ss';
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ picker.options.use24hours = picker.format.toLowerCase().indexOf("a") < 1;
133
+
134
+ if (picker.component) icon = picker.component.find('span');
135
+
136
+ if (picker.options.pickTime) {
137
+ if (icon) icon.addClass(picker.options.icons.time);
138
+ }
139
+ if (picker.options.pickDate) {
140
+ if (icon) {
141
+ icon.removeClass(picker.options.icons.time);
142
+ icon.addClass(picker.options.icons.date);
143
+ }
144
+ }
145
+
146
+ picker.widget = $(getTemplate(picker.options.pickDate, picker.options.pickTime, picker.options.collapse)).appendTo('body');
147
+ picker.minViewMode = picker.options.minViewMode || picker.element.data('date-minviewmode') || 0;
148
+ if (typeof picker.minViewMode === 'string') {
149
+ switch (picker.minViewMode) {
150
+ case 'months':
151
+ picker.minViewMode = 1;
152
+ break;
153
+ case 'years':
154
+ picker.minViewMode = 2;
155
+ break;
156
+ default:
157
+ picker.minViewMode = 0;
158
+ break;
159
+ }
160
+ }
161
+ picker.viewMode = picker.options.viewMode || picker.element.data('date-viewmode') || 0;
162
+ if (typeof picker.viewMode === 'string') {
163
+ switch (picker.viewMode) {
164
+ case 'months':
165
+ picker.viewMode = 1;
166
+ break;
167
+ case 'years':
168
+ picker.viewMode = 2;
169
+ break;
170
+ default:
171
+ picker.viewMode = 0;
172
+ break;
173
+ }
174
+ }
175
+
176
+ for (i = 0; i < picker.options.disabledDates.length; i++) {
177
+ dDate = picker.options.disabledDates[i];
178
+ dDate = pMoment(dDate);
179
+ //if this is not a valid date then set it to the startdate -1 day so it's disabled.
180
+ if (!dDate.isValid()) dDate = pMoment(picker.options.startDate).subtract(1, "day");
181
+ picker.options.disabledDates[i] = dDate.format("L");
182
+ }
183
+
184
+ for (i = 0; i < picker.options.enabledDates.length; i++) {
185
+ dDate = picker.options.enabledDates[i];
186
+ dDate = pMoment(dDate);
187
+ //if this is not a valid date then set it to the startdate -1 day so it's disabled.
188
+ if (!dDate.isValid()) dDate = pMoment(picker.options.startDate).subtract(1, "day");
189
+ picker.options.enabledDates[i] = dDate.format("L");
190
+ }
191
+ picker.startViewMode = picker.viewMode;
192
+ picker.setStartDate(picker.options.startDate || picker.element.data('date-startdate'));
193
+ picker.setEndDate(picker.options.endDate || picker.element.data('date-enddate'));
194
+ fillDow();
195
+ fillMonths();
196
+ fillHours();
197
+ fillMinutes();
198
+ fillSeconds();
199
+ update();
200
+ showMode();
201
+ attachDatePickerEvents();
202
+ if (picker.options.defaultDate !== "") picker.setValue(picker.options.defaultDate);
203
+ },
204
+
205
+ dataToOptions = function () {
206
+ var eData = picker.element.data();
207
+ if (eData.pickdate !== undefined) picker.options.pickDate = eData.pickdate;
208
+ if (eData.picktime !== undefined) picker.options.pickTime = eData.picktime;
209
+ if (eData.useminutes !== undefined) picker.options.useMinutes = eData.useminutes;
210
+ if (eData.useseconds !== undefined) picker.options.useSeconds = eData.useseconds;
211
+ if (eData.minutestepping !== undefined) picker.options.minuteStepping = eData.minutestepping;
212
+ if (eData.startdate !== undefined) picker.options.startDate = eData.startdate;
213
+ if (eData.enddate !== undefined) picker.options.endDate = eData.enddate;
214
+ if (eData.collapse !== undefined) picker.options.collapse = eData.collapse;
215
+ if (eData.language !== undefined) picker.options.language = eData.language;
216
+ if (eData.defaultdate !== undefined) picker.options.defaultDate = eData.defaultdate;
217
+ if (eData.disableddates !== undefined) picker.options.disabledDates = eData.disableddates;
218
+ if (eData.enableddates !== undefined) picker.options.enabledDates = eData.enableddates;
219
+ if (eData.icons !== undefined) picker.options.icons = eData.icons;
220
+ if (eData.usestrict !== undefined) picker.options.useStrict = eData.usestrict;
221
+ },
222
+
223
+ place = function () {
224
+ var position = 'absolute',
225
+ offset = picker.component ? picker.component.offset() : picker.element.offset(), $window = $(window);
226
+ picker.width = picker.component ? picker.component.outerWidth() : picker.element.outerWidth();
227
+ offset.top = offset.top + picker.element.outerHeight();
228
+
229
+ //if (offset.top + picker.widget.height() > $window.height()) offset.top = offset.top - (picker.widget.height() + picker.height + 10);
230
+
231
+ if (picker.options.width !== undefined) {
232
+ picker.widget.width(picker.options.width);
233
+ }
234
+
235
+ if (picker.options.orientation === 'left') {
236
+ picker.widget.addClass('left-oriented');
237
+ offset.left = offset.left - picker.widget.width() + 20;
238
+ }
239
+
240
+ if (isInFixed()) {
241
+ position = 'fixed';
242
+ offset.top -= $window.scrollTop();
243
+ offset.left -= $window.scrollLeft();
244
+ }
245
+
246
+ if ($window.width() < offset.left + picker.widget.outerWidth()) {
247
+ offset.right = $window.width() - offset.left - picker.width;
248
+ offset.left = 'auto';
249
+ picker.widget.addClass('pull-right');
250
+ } else {
251
+ offset.right = 'auto';
252
+ picker.widget.removeClass('pull-right');
253
+ }
254
+
255
+ picker.widget.css({
256
+ position: position,
257
+ top: offset.top,
258
+ left: offset.left,
259
+ right: offset.right
260
+ });
261
+ },
262
+
263
+ notifyChange = function (oldDate, eventType) {
264
+ picker.element.trigger({
265
+ type: 'change.dp',
266
+ date: pMoment(picker.date),
267
+ oldDate: pMoment(oldDate)
268
+ });
269
+
270
+ if (eventType !== 'change')
271
+ picker.element.change();
272
+ },
273
+
274
+ notifyError = function (date) {
275
+ picker.element.trigger({
276
+ type: 'error.dp',
277
+ date: pMoment(date)
278
+ });
279
+ },
280
+
281
+ update = function (newDate) {
282
+ pMoment.lang(picker.options.language);
283
+ var dateStr = newDate;
284
+ if (!dateStr) {
285
+ if (picker.isInput) {
286
+ dateStr = picker.element.val();
287
+ } else {
288
+ dateStr = picker.element.find('input').val();
289
+ }
290
+ if (dateStr) picker.date = pMoment(dateStr, picker.format, picker.options.useStrict);
291
+ if (!picker.date) picker.date = pMoment();
292
+ }
293
+ picker.viewDate = pMoment(picker.date).startOf("month");
294
+ fillDate();
295
+ fillTime();
296
+ },
297
+
298
+ fillDow = function () {
299
+ pMoment.lang(picker.options.language);
300
+ var html = $('<tr>'), weekdaysMin = pMoment.weekdaysMin(), i;
301
+ if (pMoment()._lang._week.dow == 0) { // starts on Sunday
302
+ for(i = 0; i < 7; i++) {
303
+ html.append('<th class="dow">' + weekdaysMin[i] + '</th>');
304
+ }
305
+ } else {
306
+ for (i = 1; i < 8; i++) {
307
+ if (i == 7) {
308
+ html.append('<th class="dow">' + weekdaysMin[0] + '</th>');
309
+ } else {
310
+ html.append('<th class="dow">' + weekdaysMin[i] + '</th>');
311
+ }
312
+ }
313
+ }
314
+ picker.widget.find('.datepicker-days thead').append(html);
315
+ },
316
+
317
+ fillMonths = function () {
318
+ pMoment.lang(picker.options.language);
319
+ var html = '', i = 0, monthsShort = pMoment.monthsShort();
320
+ while (i < 12) {
321
+ html += '<span class="month">' + monthsShort[i++] + '</span>';
322
+ }
323
+ picker.widget.find('.datepicker-months td').append(html);
324
+ },
325
+
326
+ fillDate = function () {
327
+ pMoment.lang(picker.options.language);
328
+ var year = picker.viewDate.year(),
329
+ month = picker.viewDate.month(),
330
+ startYear = picker.options.startDate.year(),
331
+ startMonth = picker.options.startDate.month(),
332
+ endYear = picker.options.endDate.year(),
333
+ endMonth = picker.options.endDate.month(),
334
+ prevMonth, nextMonth, html = [], row, clsName, i, days, yearCont, currentYear, months = pMoment.months();
335
+
336
+ picker.widget.find('.datepicker-days').find('.disabled').removeClass('disabled');
337
+ picker.widget.find('.datepicker-months').find('.disabled').removeClass('disabled');
338
+ picker.widget.find('.datepicker-years').find('.disabled').removeClass('disabled');
339
+
340
+ picker.widget.find('.datepicker-days th:eq(1)').text(
341
+ months[month] + ' ' + year);
342
+
343
+ prevMonth = pMoment(picker.viewDate).subtract("months", 1);
344
+ days = prevMonth.daysInMonth();
345
+ prevMonth.date(days).startOf('week');
346
+ if ((year == startYear && month <= startMonth) || year < startYear) {
347
+ picker.widget.find('.datepicker-days th:eq(0)').addClass('disabled');
348
+ }
349
+ if ((year == endYear && month >= endMonth) || year > endYear) {
350
+ picker.widget.find('.datepicker-days th:eq(2)').addClass('disabled');
351
+ }
352
+
353
+ nextMonth = pMoment(prevMonth).add(42, "d");
354
+ while (prevMonth.isBefore(nextMonth)) {
355
+ if (prevMonth.weekday() === pMoment().startOf('week').weekday()) {
356
+ row = $('<tr>');
357
+ html.push(row);
358
+ }
359
+ clsName = '';
360
+ if (prevMonth.year() < year || (prevMonth.year() == year && prevMonth.month() < month)) {
361
+ clsName += ' old';
362
+ } else if (prevMonth.year() > year || (prevMonth.year() == year && prevMonth.month() > month)) {
363
+ clsName += ' new';
364
+ }
365
+ if (prevMonth.isSame(pMoment({ y: picker.date.year(), M: picker.date.month(), d: picker.date.date() }))) {
366
+ clsName += ' active';
367
+ }
368
+ if ((pMoment(prevMonth).add(1, "d") <= picker.options.startDate) || (prevMonth > picker.options.endDate) || isInDisableDates(prevMonth) || !isInEnableDates(prevMonth)) {
369
+ clsName += ' disabled';
370
+ }
371
+ row.append('<td class="day' + clsName + '">' + prevMonth.date() + '</td>');
372
+ prevMonth.add(1, "d");
373
+ }
374
+ picker.widget.find('.datepicker-days tbody').empty().append(html);
375
+ currentYear = pMoment().year(), months = picker.widget.find('.datepicker-months')
376
+ .find('th:eq(1)').text(year).end().find('span').removeClass('active');
377
+ if (currentYear === year) {
378
+ months.eq(pMoment().month()).addClass('active');
379
+ }
380
+ if (currentYear - 1 < startYear) {
381
+ picker.widget.find('.datepicker-months th:eq(0)').addClass('disabled');
382
+ }
383
+ if (currentYear + 1 > endYear) {
384
+ picker.widget.find('.datepicker-months th:eq(2)').addClass('disabled');
385
+ }
386
+ for (i = 0; i < 12; i++) {
387
+ if ((year == startYear && startMonth > i) || (year < startYear)) {
388
+ $(months[i]).addClass('disabled');
389
+ } else if ((year == endYear && endMonth < i) || (year > endYear)) {
390
+ $(months[i]).addClass('disabled');
391
+ }
392
+ }
393
+
394
+ html = '';
395
+ year = parseInt(year / 10, 10) * 10;
396
+ yearCont = picker.widget.find('.datepicker-years').find(
397
+ 'th:eq(1)').text(year + '-' + (year + 9)).end().find('td');
398
+ picker.widget.find('.datepicker-years').find('th').removeClass('disabled');
399
+ if (startYear > year) {
400
+ picker.widget.find('.datepicker-years').find('th:eq(0)').addClass('disabled');
401
+ }
402
+ if (endYear < year + 9) {
403
+ picker.widget.find('.datepicker-years').find('th:eq(2)').addClass('disabled');
404
+ }
405
+ year -= 1;
406
+ for (i = -1; i < 11; i++) {
407
+ html += '<span class="year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + ((year < startYear || year > endYear) ? ' disabled' : '') + '">' + year + '</span>';
408
+ year += 1;
409
+ }
410
+ yearCont.html(html);
411
+ },
412
+
413
+ fillHours = function () {
414
+ pMoment.lang(picker.options.language);
415
+ var table = picker.widget.find('.timepicker .timepicker-hours table'), html = '', current, i, j;
416
+ table.parent().hide();
417
+ if (picker.options.use24hours) {
418
+ current = 0;
419
+ for (i = 0; i < 6; i += 1) {
420
+ html += '<tr>';
421
+ for (j = 0; j < 4; j += 1) {
422
+ html += '<td class="hour">' + padLeft(current.toString()) + '</td>';
423
+ current++;
424
+ }
425
+ html += '</tr>';
426
+ }
427
+ }
428
+ else {
429
+ current = 1;
430
+ for (i = 0; i < 3; i += 1) {
431
+ html += '<tr>';
432
+ for (j = 0; j < 4; j += 1) {
433
+ html += '<td class="hour">' + padLeft(current.toString()) + '</td>';
434
+ current++;
435
+ }
436
+ html += '</tr>';
437
+ }
438
+ }
439
+ table.html(html);
440
+ },
441
+
442
+ fillMinutes = function () {
443
+ var table = picker.widget.find('.timepicker .timepicker-minutes table'), html = '', current = 0, i, j;
444
+ table.parent().hide();
445
+ for (i = 0; i < 5; i++) {
446
+ html += '<tr>';
447
+ for (j = 0; j < 4; j += 1) {
448
+ html += '<td class="minute">' + padLeft(current.toString()) + '</td>';
449
+ current += 3;
450
+ }
451
+ html += '</tr>';
452
+ }
453
+ table.html(html);
454
+ },
455
+
456
+ fillSeconds = function () {
457
+ var table = picker.widget.find('.timepicker .timepicker-seconds table'), html = '', current = 0, i, j;
458
+ table.parent().hide();
459
+ for (i = 0; i < 5; i++) {
460
+ html += '<tr>';
461
+ for (j = 0; j < 4; j += 1) {
462
+ html += '<td class="second">' + padLeft(current.toString()) + '</td>';
463
+ current += 3;
464
+ }
465
+ html += '</tr>';
466
+ }
467
+ table.html(html);
468
+ },
469
+
470
+ fillTime = function () {
471
+ if (!picker.date) return;
472
+ var timeComponents = picker.widget.find('.timepicker span[data-time-component]'),
473
+ hour = picker.date.hours(),
474
+ period = 'AM';
475
+ if (!picker.options.use24hours) {
476
+ if (hour >= 12) period = 'PM';
477
+ if (hour === 0) hour = 12;
478
+ else if (hour != 12) hour = hour % 12;
479
+ picker.widget.find('.timepicker [data-action=togglePeriod]').text(period);
480
+ }
481
+ timeComponents.filter('[data-time-component=hours]').text(padLeft(hour));
482
+ timeComponents.filter('[data-time-component=minutes]').text(padLeft(picker.date.minutes()));
483
+ timeComponents.filter('[data-time-component=seconds]').text(padLeft(picker.date.second()));
484
+ },
485
+
486
+ click = function (e) {
487
+ e.stopPropagation();
488
+ e.preventDefault();
489
+ picker.unset = false;
490
+ var target = $(e.target).closest('span, td, th'), month, year, step, day, oldDate = pMoment(picker.date);
491
+ if (target.length === 1) {
492
+ if (!target.is('.disabled')) {
493
+ switch (target[0].nodeName.toLowerCase()) {
494
+ case 'th':
495
+ switch (target[0].className) {
496
+ case 'switch':
497
+ showMode(1);
498
+ break;
499
+ case 'prev':
500
+ case 'next':
501
+ step = dpGlobal.modes[picker.viewMode].navStep;
502
+ if (target[0].className === 'prev') step = step * -1;
503
+ picker.viewDate.add(step, dpGlobal.modes[picker.viewMode].navFnc);
504
+ fillDate();
505
+ break;
506
+ }
507
+ break;
508
+ case 'span':
509
+ if (target.is('.month')) {
510
+ month = target.parent().find('span').index(target);
511
+ picker.viewDate.month(month);
512
+ } else {
513
+ year = parseInt(target.text(), 10) || 0;
514
+ picker.viewDate.year(year);
515
+ }
516
+ if (picker.viewMode !== 0) {
517
+ picker.date = pMoment({
518
+ y: picker.viewDate.year(),
519
+ M: picker.viewDate.month(),
520
+ d: picker.viewDate.date(),
521
+ h: picker.date.hours(),
522
+ m: picker.date.minutes()
523
+ });
524
+ notifyChange(oldDate, e.type);
525
+ }
526
+ showMode(-1);
527
+ fillDate();
528
+ break;
529
+ case 'td':
530
+ if (target.is('.day')) {
531
+ day = parseInt(target.text(), 10) || 1;
532
+ month = picker.viewDate.month();
533
+ year = picker.viewDate.year();
534
+ if (target.is('.old')) {
535
+ if (month === 0) {
536
+ month = 11;
537
+ year -= 1;
538
+ } else {
539
+ month -= 1;
540
+ }
541
+ } else if (target.is('.new')) {
542
+ if (month == 11) {
543
+ month = 0;
544
+ year += 1;
545
+ } else {
546
+ month += 1;
547
+ }
548
+ }
549
+ picker.date = pMoment({
550
+ y: year,
551
+ M: month,
552
+ d: day,
553
+ h: picker.date.hours(),
554
+ m: picker.date.minutes()
555
+ }
556
+ );
557
+ picker.viewDate = pMoment({
558
+ y: year, M: month, d: Math.min(28, day)
559
+ });
560
+ fillDate();
561
+ set();
562
+ notifyChange(oldDate, e.type);
563
+ }
564
+ break;
565
+ }
566
+ }
567
+ }
568
+ },
569
+
570
+ actions = {
571
+ incrementHours: function () {
572
+ checkDate("add", "hours", 1);
573
+ },
574
+
575
+ incrementMinutes: function () {
576
+ checkDate("add", "minutes", picker.options.minuteStepping);
577
+ },
578
+
579
+ incrementSeconds: function () {
580
+ checkDate("add", "seconds", 1);
581
+ },
582
+
583
+ decrementHours: function () {
584
+ checkDate("subtract", "hours", 1);
585
+ },
586
+
587
+ decrementMinutes: function () {
588
+ checkDate("subtract", "minutes", picker.options.minuteStepping);
589
+ },
590
+
591
+ decrementSeconds: function () {
592
+ checkDate("subtract", "seconds", 1);
593
+ },
594
+
595
+ togglePeriod: function () {
596
+ var hour = picker.date.hours();
597
+ if (hour >= 12) hour -= 12;
598
+ else hour += 12;
599
+ picker.date.hours(hour);
600
+ },
601
+
602
+ showPicker: function () {
603
+ picker.widget.find('.timepicker > div:not(.timepicker-picker)').hide();
604
+ picker.widget.find('.timepicker .timepicker-picker').show();
605
+ },
606
+
607
+ showHours: function () {
608
+ picker.widget.find('.timepicker .timepicker-picker').hide();
609
+ picker.widget.find('.timepicker .timepicker-hours').show();
610
+ },
611
+
612
+ showMinutes: function () {
613
+ picker.widget.find('.timepicker .timepicker-picker').hide();
614
+ picker.widget.find('.timepicker .timepicker-minutes').show();
615
+ },
616
+
617
+ showSeconds: function () {
618
+ picker.widget.find('.timepicker .timepicker-picker').hide();
619
+ picker.widget.find('.timepicker .timepicker-seconds').show();
620
+ },
621
+
622
+ selectHour: function (e) {
623
+ picker.date.hours(parseInt($(e.target).text(), 10));
624
+ actions.showPicker.call(picker);
625
+ },
626
+
627
+ selectMinute: function (e) {
628
+ picker.date.minutes(parseInt($(e.target).text(), 10));
629
+ actions.showPicker.call(picker);
630
+ },
631
+
632
+ selectSecond: function (e) {
633
+ picker.date.seconds(parseInt($(e.target).text(), 10));
634
+ actions.showPicker.call(picker);
635
+ }
636
+ },
637
+
638
+ doAction = function (e) {
639
+ var oldDate = pMoment(picker.date), action = $(e.currentTarget).data('action'), rv = actions[action].apply(picker, arguments);
640
+ stopEvent(e);
641
+ if (!picker.date) picker.date = pMoment({ y: 1970 });
642
+ set();
643
+ fillTime();
644
+ notifyChange(oldDate, e.type);
645
+ return rv;
646
+ },
647
+
648
+ stopEvent = function (e) {
649
+ e.stopPropagation();
650
+ e.preventDefault();
651
+ },
652
+
653
+ change = function (e) {
654
+ pMoment.lang(picker.options.language);
655
+ var input = $(e.target), oldDate = pMoment(picker.date), d = pMoment(input.val(), picker.format, picker.options.useStrict);
656
+ if (d.isValid()) {
657
+ update();
658
+ picker.setValue(d);
659
+ notifyChange(oldDate, e.type);
660
+ set();
661
+ }
662
+ else {
663
+ picker.viewDate = oldDate;
664
+ //picker.setValue(""); // unset the date when the input is erased
665
+ notifyChange(oldDate, e.type);
666
+ notifyError(d);
667
+ picker.unset = true;
668
+ input.val('');
669
+ }
670
+ },
671
+
672
+ showMode = function (dir) {
673
+ if (dir) {
674
+ picker.viewMode = Math.max(picker.minViewMode, Math.min(2, picker.viewMode + dir));
675
+ }
676
+
677
+ picker.widget.find('.datepicker > div').hide().filter('.datepicker-' + dpGlobal.modes[picker.viewMode].clsName).show();
678
+ },
679
+
680
+ attachDatePickerEvents = function () {
681
+ var $this, $parent, expanded, closed, collapseData;
682
+ picker.widget.on('click', '.datepicker *', $.proxy(click, this)); // this handles date picker clicks
683
+ picker.widget.on('click', '[data-action]', $.proxy(doAction, this)); // this handles time picker clicks
684
+ picker.widget.on('mousedown', $.proxy(stopEvent, this));
685
+ if (picker.options.pickDate && picker.options.pickTime) {
686
+ picker.widget.on('click.togglePicker', '.accordion-toggle', function (e) {
687
+ e.stopPropagation();
688
+ $this = $(this);
689
+ $parent = $this.closest('ul');
690
+ expanded = $parent.find('.in');
691
+ closed = $parent.find('.collapse:not(.in)');
692
+
693
+ if (expanded && expanded.length) {
694
+ collapseData = expanded.data('collapse');
695
+ if (collapseData && collapseData.transitioning) return;
696
+ expanded.collapse('hide');
697
+ closed.collapse('show');
698
+ $this.find('span').toggleClass(picker.options.icons.time + ' ' + picker.options.icons.date);
699
+ picker.element.find('.input-group-addon span').toggleClass(picker.options.icons.time + ' ' + picker.options.icons.date);
700
+ }
701
+ });
702
+ }
703
+ if (picker.isInput) {
704
+ picker.element.on({
705
+ 'focus': $.proxy(picker.show, this),
706
+ 'change': $.proxy(change, this),
707
+ 'blur': $.proxy(picker.hide, this)
708
+ });
709
+ } else {
710
+ picker.element.on({
711
+ 'change': $.proxy(change, this)
712
+ }, 'input');
713
+ if (picker.component) {
714
+ picker.component.on('click', $.proxy(picker.show, this));
715
+ } else {
716
+ picker.element.on('click', $.proxy(picker.show, this));
717
+ }
718
+ }
719
+ },
720
+
721
+ attachDatePickerGlobalEvents = function () {
722
+ $(window).on(
723
+ 'resize.datetimepicker' + picker.id, $.proxy(place, this));
724
+ if (!picker.isInput) {
725
+ $(document).on(
726
+ 'mousedown.datetimepicker' + picker.id, $.proxy(picker.hide, this));
727
+ }
728
+ },
729
+
730
+ detachDatePickerEvents = function () {
731
+ picker.widget.off('click', '.datepicker *', picker.click);
732
+ picker.widget.off('click', '[data-action]');
733
+ picker.widget.off('mousedown', picker.stopEvent);
734
+ if (picker.options.pickDate && picker.options.pickTime) {
735
+ picker.widget.off('click.togglePicker');
736
+ }
737
+ if (picker.isInput) {
738
+ picker.element.off({
739
+ 'focus': picker.show,
740
+ 'change': picker.change
741
+ });
742
+ } else {
743
+ picker.element.off({
744
+ 'change': picker.change
745
+ }, 'input');
746
+ if (picker.component) {
747
+ picker.component.off('click', picker.show);
748
+ } else {
749
+ picker.element.off('click', picker.show);
750
+ }
751
+ }
752
+ },
753
+
754
+ detachDatePickerGlobalEvents = function () {
755
+ $(window).off('resize.datetimepicker' + picker.id);
756
+ if (!picker.isInput) {
757
+ $(document).off('mousedown.datetimepicker' + picker.id);
758
+ }
759
+ },
760
+
761
+ isInFixed = function () {
762
+ if (picker.element) {
763
+ var parents = picker.element.parents(), inFixed = false, i;
764
+ for (i = 0; i < parents.length; i++) {
765
+ if ($(parents[i]).css('position') == 'fixed') {
766
+ inFixed = true;
767
+ break;
768
+ }
769
+ }
770
+ ;
771
+ return inFixed;
772
+ } else {
773
+ return false;
774
+ }
775
+ },
776
+
777
+ set = function () {
778
+ pMoment.lang(picker.options.language);
779
+ var formatted = '', input;
780
+ if (!picker.unset) formatted = pMoment(picker.date).format(picker.format);
781
+ if (!picker.isInput) {
782
+ if (picker.component) {
783
+ input = picker.element.find('input');
784
+ input.val(formatted);
785
+ }
786
+ picker.element.data('date', formatted);
787
+ } else {
788
+ picker.element.val(formatted);
789
+ }
790
+ if (!picker.options.pickTime) picker.hide();
791
+ },
792
+
793
+ checkDate = function (direction, unit, amount) {
794
+ pMoment.lang(picker.options.language);
795
+ var newDate;
796
+ if (direction == "add") {
797
+ newDate = pMoment(picker.date);
798
+ if (newDate.hours() == 23) newDate.add(amount, unit);
799
+ newDate.add(amount, unit);
800
+ }
801
+ else {
802
+ newDate = pMoment(picker.date).subtract(amount, unit);
803
+ }
804
+ if (newDate.isAfter(picker.options.endDate) || pMoment(newDate.subtract(amount, unit)).isBefore(picker.options.startDate) || isInDisableDates(newDate)) {
805
+ notifyError(newDate.format(picker.format));
806
+ return;
807
+ }
808
+
809
+ if (direction == "add") {
810
+ picker.date.add(amount, unit);
811
+ }
812
+ else {
813
+ picker.date.subtract(amount, unit);
814
+ }
815
+ },
816
+
817
+ isInDisableDates = function (date) {
818
+ pMoment.lang(picker.options.language);
819
+ var disabled = picker.options.disabledDates, i;
820
+ for (i in disabled) {
821
+ if (disabled[i] == pMoment(date).format("L")) {
822
+ return true;
823
+ }
824
+ }
825
+ return false;
826
+ },
827
+
828
+ isInEnableDates = function (date) {
829
+ pMoment.lang(picker.options.language);
830
+ var enabled = picker.options.enabledDates, i;
831
+ if (enabled.length) {
832
+ for (i in enabled) {
833
+ if (enabled[i] == pMoment(date).format("L")) {
834
+ return true;
835
+ }
836
+ }
837
+ return false;
838
+ }
839
+ return enabled === false ? true : false;
840
+ },
841
+ padLeft = function (string) {
842
+ string = string.toString();
843
+ if (string.length >= 2) return string;
844
+ else return '0' + string;
845
+ },
846
+
847
+ getTemplate = function (pickDate, pickTime, collapse) {
848
+ if (pickDate && pickTime) {
849
+ return (
850
+ '<div class="bootstrap-datetimepicker-widget dropdown-menu" style="z-index:9999 !important;">' +
851
+ '<ul class="list-unstyled">' +
852
+ '<li' + (collapse ? ' class="collapse in"' : '') + '>' +
853
+ '<div class="datepicker">' + dpGlobal.template + '</div>' +
854
+ '</li>' +
855
+ '<li class="picker-switch accordion-toggle"><a class="btn" style="width:100%"><span class="' + picker.options.icons.time + '"></span></a></li>' +
856
+ '<li' + (collapse ? ' class="collapse"' : '') + '>' +
857
+ '<div class="timepicker">' + tpGlobal.getTemplate() + '</div>' +
858
+ '</li>' +
859
+ '</ul>' +
860
+ '</div>'
861
+ );
862
+ } else if (pickTime) {
863
+ return (
864
+ '<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
865
+ '<div class="timepicker">' + tpGlobal.getTemplate() + '</div>' +
866
+ '</div>'
867
+ );
868
+ } else {
869
+ return (
870
+ '<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
871
+ '<div class="datepicker">' + dpGlobal.template + '</div>' +
872
+ '</div>'
873
+ );
874
+ }
875
+ },
876
+
877
+ dpGlobal = {
878
+ modes: [
879
+ {
880
+ clsName: 'days',
881
+ navFnc: 'month',
882
+ navStep: 1
883
+ },
884
+ {
885
+ clsName: 'months',
886
+ navFnc: 'year',
887
+ navStep: 1
888
+ },
889
+ {
890
+ clsName: 'years',
891
+ navFnc: 'year',
892
+ navStep: 10
893
+ }],
894
+ headTemplate:
895
+ '<thead>' +
896
+ '<tr>' +
897
+ '<th class="prev">&lsaquo;</th><th colspan="5" class="switch"></th><th class="next">&rsaquo;</th>' +
898
+ '</tr>' +
899
+ '</thead>',
900
+ contTemplate:
901
+ '<tbody><tr><td colspan="7"></td></tr></tbody>'
902
+ },
903
+
904
+ tpGlobal = {
905
+ hourTemplate: '<span data-action="showHours" data-time-component="hours" class="timepicker-hour"></span>',
906
+ minuteTemplate: '<span data-action="showMinutes" data-time-component="minutes" class="timepicker-minute"></span>',
907
+ secondTemplate: '<span data-action="showSeconds" data-time-component="seconds" class="timepicker-second"></span>'
908
+ };
909
+
910
+ dpGlobal.template =
911
+ '<div class="datepicker-days">' +
912
+ '<table class="table-condensed">' + dpGlobal.headTemplate + '<tbody></tbody></table>' +
913
+ '</div>' +
914
+ '<div class="datepicker-months">' +
915
+ '<table class="table-condensed">' + dpGlobal.headTemplate + dpGlobal.contTemplate + '</table>' +
916
+ '</div>' +
917
+ '<div class="datepicker-years">' +
918
+ '<table class="table-condensed">' + dpGlobal.headTemplate + dpGlobal.contTemplate + '</table>' +
919
+ '</div>';
920
+
921
+ tpGlobal.getTemplate = function () {
922
+ return (
923
+ '<div class="timepicker-picker">' +
924
+ '<table class="table-condensed">' +
925
+ '<tr>' +
926
+ '<td><a href="#" class="btn" data-action="incrementHours"><span class="' + picker.options.icons.up + '"></span></a></td>' +
927
+ '<td class="separator"></td>' +
928
+ '<td>' + (picker.options.useMinutes ? '<a href="#" class="btn" data-action="incrementMinutes"><span class="' + picker.options.icons.up + '"></span></a>' : '') + '</td>' +
929
+ (picker.options.useSeconds ?
930
+ '<td class="separator"></td><td><a href="#" class="btn" data-action="incrementSeconds"><span class="' + picker.options.icons.up + '"></span></a></td>' : '') +
931
+ (picker.options.use24hours ? '' : '<td class="separator"></td>') +
932
+ '</tr>' +
933
+ '<tr>' +
934
+ '<td>' + tpGlobal.hourTemplate + '</td> ' +
935
+ '<td class="separator">:</td>' +
936
+ '<td>' + (picker.options.useMinutes ? tpGlobal.minuteTemplate : '<span class="timepicker-minute">00</span>') + '</td> ' +
937
+ (picker.options.useSeconds ?
938
+ '<td class="separator">:</td><td>' + tpGlobal.secondTemplate + '</td>' : '') +
939
+ (picker.options.use24hours ? '' : '<td class="separator"></td>' +
940
+ '<td><button type="button" class="btn btn-primary" data-action="togglePeriod"></button></td>') +
941
+ '</tr>' +
942
+ '<tr>' +
943
+ '<td><a href="#" class="btn" data-action="decrementHours"><span class="' + picker.options.icons.down + '"></span></a></td>' +
944
+ '<td class="separator"></td>' +
945
+ '<td>' + (picker.options.useMinutes ? '<a href="#" class="btn" data-action="decrementMinutes"><span class="' + picker.options.icons.down + '"></span></a>' : '') + '</td>' +
946
+ (picker.options.useSeconds ?
947
+ '<td class="separator"></td><td><a href="#" class="btn" data-action="decrementSeconds"><span class="' + picker.options.icons.down + '"></span></a></td>' : '') +
948
+ (picker.options.use24hours ? '' : '<td class="separator"></td>') +
949
+ '</tr>' +
950
+ '</table>' +
951
+ '</div>' +
952
+ '<div class="timepicker-hours" data-action="selectHour">' +
953
+ '<table class="table-condensed"></table>' +
954
+ '</div>' +
955
+ '<div class="timepicker-minutes" data-action="selectMinute">' +
956
+ '<table class="table-condensed"></table>' +
957
+ '</div>' +
958
+ (picker.options.useSeconds ?
959
+ '<div class="timepicker-seconds" data-action="selectSecond"><table class="table-condensed"></table></div>' : '')
960
+ );
961
+ };
962
+
963
+ picker.destroy = function () {
964
+ detachDatePickerEvents();
965
+ detachDatePickerGlobalEvents();
966
+ picker.widget.remove();
967
+ picker.element.removeData('DateTimePicker');
968
+ if (picker.component)
969
+ picker.component.removeData('DateTimePicker');
970
+ };
971
+
972
+ picker.show = function (e) {
973
+ picker.widget.show();
974
+ picker.height = picker.component ? picker.component.outerHeight() : picker.element.outerHeight();
975
+ place();
976
+ picker.element.trigger({
977
+ type: 'show.dp',
978
+ date: pMoment(picker.date)
979
+ });
980
+ attachDatePickerGlobalEvents();
981
+ if (e) {
982
+ stopEvent(e);
983
+ }
984
+ },
985
+
986
+ picker.disable = function () {
987
+ var input = picker.element.find('input');
988
+ if(!input.prop('disabled')) return;
989
+
990
+ input.prop('disabled', true);
991
+ detachDatePickerEvents();
992
+ },
993
+
994
+ picker.enable = function () {
995
+ var input = picker.element.find('input');
996
+ if(!input.prop('disabled')) return;
997
+
998
+ input.prop('disabled', true);
999
+ attachDatePickerEvents();
1000
+ },
1001
+
1002
+ picker.hide = function (event) {
1003
+ if (event && $(event.target).is(picker.element.attr("id")))
1004
+ return;
1005
+ // Ignore event if in the middle of a picker transition
1006
+ var collapse = picker.widget.find('.collapse'), i, collapseData;
1007
+ for (i = 0; i < collapse.length; i++) {
1008
+ collapseData = collapse.eq(i).data('collapse');
1009
+ if (collapseData && collapseData.transitioning)
1010
+ return;
1011
+ }
1012
+ picker.widget.hide();
1013
+ picker.viewMode = picker.startViewMode;
1014
+ showMode();
1015
+ picker.element.trigger({
1016
+ type: 'hide.dp',
1017
+ date: pMoment(picker.date)
1018
+ });
1019
+ detachDatePickerGlobalEvents();
1020
+ },
1021
+
1022
+ picker.setValue = function (newDate) {
1023
+ pMoment.lang(picker.options.language);
1024
+ if (!newDate) {
1025
+ picker.unset = true;
1026
+ } else {
1027
+ picker.unset = false;
1028
+ }
1029
+ if (!pMoment.isMoment(newDate)) newDate = pMoment(newDate);
1030
+ if (newDate.isValid()) {
1031
+ picker.date = newDate;
1032
+ set();
1033
+ picker.viewDate = pMoment({ y: picker.date.year(), M: picker.date.month() });
1034
+ fillDate();
1035
+ fillTime();
1036
+ }
1037
+ else {
1038
+ notifyError(newDate);
1039
+ }
1040
+ },
1041
+
1042
+ picker.getDate = function () {
1043
+ if (picker.unset) return null;
1044
+ return picker.date;
1045
+ },
1046
+
1047
+ picker.setDate = function (date) {
1048
+ date = pMoment(date);
1049
+ if (!date) picker.setValue(null);
1050
+ else picker.setValue(date);
1051
+ },
1052
+
1053
+ picker.setEnabledDates = function (dates) {
1054
+ if (!dates) picker.options.enabledDates = false;
1055
+ else picker.options.enabledDates = dates;
1056
+ if (picker.viewDate) update();
1057
+ },
1058
+
1059
+ picker.setEndDate = function (date) {
1060
+ picker.options.endDate = pMoment(date);
1061
+ if (!picker.options.endDate.isValid()) {
1062
+ picker.options.endDate = pMoment().add(50, "y");
1063
+ }
1064
+ if (picker.viewDate) update();
1065
+ },
1066
+
1067
+ picker.setStartDate = function (date) {
1068
+ picker.options.startDate = pMoment(date);
1069
+ if (!picker.options.startDate.isValid()) {
1070
+ picker.options.startDate = pMoment({ y: 1970 });
1071
+ }
1072
+ if (picker.viewDate) update();
1073
+ };
1074
+
1075
+ init();
1076
+ };
1077
+
1078
+ $.fn.datetimepicker = function (options) {
1079
+ return this.each(function () {
1080
+ var $this = $(this), data = $this.data('DateTimePicker');
1081
+ if (!data) $this.data('DateTimePicker', new DateTimePicker(this, options));
1082
+ });
1083
+ };
1084
+ }));