bootstrap3-datetimepicker-rails 3.0.0.2 → 3.0.2.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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -6
  3. data/lib/bootstrap3-datetimepicker-rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/bootstrap-datetimepicker.js +476 -346
  5. data/vendor/assets/javascripts/bootstrap-datetimepicker.min.js +1 -105
  6. data/vendor/assets/stylesheets/bootstrap-datetimepicker.css +6 -5
  7. data/vendor/assets/stylesheets/bootstrap-datetimepicker.min.css +2 -1
  8. metadata +8 -69
  9. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ar-ma.js +0 -56
  10. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ar.js +0 -56
  11. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.bg.js +0 -86
  12. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.br.js +0 -107
  13. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.bs.js +0 -139
  14. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.by.js +0 -153
  15. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ca.js +0 -66
  16. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.cs.js +0 -155
  17. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.cv.js +0 -59
  18. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.da.js +0 -56
  19. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.de.js +0 -71
  20. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.el.js +0 -79
  21. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.en-au.js +0 -62
  22. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.en-ca.js +0 -59
  23. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.en-gb.js +0 -63
  24. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.eo.js +0 -65
  25. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.es.js +0 -66
  26. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.et.js +0 -60
  27. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.eu.js +0 -60
  28. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fa.js +0 -97
  29. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fi.js +0 -103
  30. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fr-ca.js +0 -54
  31. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fr.js +0 -58
  32. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.gl.js +0 -71
  33. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.he.js +0 -77
  34. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hi.js +0 -105
  35. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hr.js +0 -140
  36. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hu.js +0 -98
  37. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.id.js +0 -67
  38. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.is.js +0 -124
  39. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.it.js +0 -59
  40. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ja.js +0 -58
  41. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ka.js +0 -108
  42. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ko.js +0 -56
  43. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.lt.js +0 -118
  44. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.lv.js +0 -77
  45. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ml.js +0 -64
  46. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.mr.js +0 -104
  47. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ms-my.js +0 -66
  48. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nb.js +0 -57
  49. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ne.js +0 -105
  50. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nl.js +0 -67
  51. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nn.js +0 -56
  52. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pl.js +0 -98
  53. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pt-BR.js +0 -56
  54. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pt.js +0 -60
  55. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ro.js +0 -56
  56. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ru.js +0 -163
  57. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sk.js +0 -156
  58. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sl.js +0 -144
  59. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sq.js +0 -57
  60. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sv.js +0 -63
  61. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.th.js +0 -58
  62. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tr.js +0 -93
  63. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tzm-la.js +0 -55
  64. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tzm.js +0 -55
  65. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.uk.js +0 -157
  66. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.uz.js +0 -55
  67. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.vn.js +0 -62
  68. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.zh-CN.js +0 -108
  69. data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.zh-TW.js +0 -84
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c129cde925729055f449f84030304590372802e
4
- data.tar.gz: 786d7fff3c0a5e645a9854aa2980a2b4767e3e1f
3
+ metadata.gz: d5ff932fd4a46d57a323f954467d1b90917653ca
4
+ data.tar.gz: f5fdbe7ac674615c373ecaf4fbbe1cbda76c7da1
5
5
  SHA512:
6
- metadata.gz: 70107744c3fcb2234997a08901a7a1f634d87f9964f0df5eaadef2912e24879628434a19b723abf3c03b4c28c0b39b375f6b97f2df17b07cd93219318363ac58
7
- data.tar.gz: f87543e9208b668761bdf9dca6c1df0b0d8b7fd357bca5517dc0702ca2d59200b26be37590c3ae5763babc76783573268a8180568a531e6bd449654d20516e6f
6
+ metadata.gz: 508f9a55183e6da8250d82c8bd7bb98c490381ef9cd31131a77200202e67cc761f68118a29658b47bfcedb4abeca361e73b79d2af9fb97b70d2b2afaba3680f7
7
+ data.tar.gz: 27bcbc842078010fb931b40d6bcaefd088f01ad37e0b04cad6f12974bbee16c14fb5f9be0e46c480fc46b0128a1515809f20ad59be8b948dce6af91c4f230833
data/README.md CHANGED
@@ -12,9 +12,9 @@ actively maintained and works with [Bootstrap3](http://getbootstrap.com).
12
12
  ## Installation
13
13
 
14
14
  Add these lines to your application's Gemfile:
15
- ```
16
- gem 'momentjs-rails', '~> 2.5.0'
17
- gem 'bootstrap3-datetimepicker-rails', '~> 3.0.0.1'
15
+ ```ruby
16
+ gem 'momentjs-rails', '>= 2.8.1'
17
+ gem 'bootstrap3-datetimepicker-rails', '~> 3.0.2'
18
18
  ```
19
19
 
20
20
  And then execute:
@@ -28,7 +28,9 @@ $ gem install momentjs-rails
28
28
  $ gem install bootstrap3-datetimepicker-rails
29
29
  ```
30
30
 
31
- To start using the bootstrap-datetimepicker plugin in your rails application, enable it via the asset pipeline.
31
+ To start using the bootstrap-datetimepicker plugin in your Rails application, enable it via the asset pipeline.
32
+
33
+ If your server is running, you will need to **restart Rails** before using the gem.
32
34
 
33
35
  Add the following to your Javascript manifest file (`application.js`):
34
36
  ```js
@@ -39,18 +41,19 @@ Add the following to your Javascript manifest file (`application.js`):
39
41
  If you want to include a localization, also add:
40
42
  ```js
41
43
  //= require moment/<locale>
42
- //= require locales/bootstrap-datetimepicker.<locale>.js
43
44
  ```
44
45
 
45
46
  Add the following to your stylesheet file:
46
47
 
47
48
  If you are using SCSS, modify your `application.css.scss`
48
49
  ```scss
50
+ // import bootstrap-sprockets before bootstrap if using bootstrap >= 3.2
51
+ @import "bootstrap-sprockets";
49
52
  @import 'bootstrap';
50
53
  @import 'bootstrap-datetimepicker';
51
54
  ```
52
55
 
53
- If you're using just plain CSS, modify your `application.css`
56
+ If you're using plain CSS, modify your `application.css`
54
57
  ```css
55
58
  *= require bootstrap
56
59
  *= require bootstrap-datetimepicker
@@ -1,5 +1,5 @@
1
1
  module Bootstrap3Datetimepicker
2
2
  module Rails
3
- VERSION = '3.0.0.2'
3
+ VERSION = '3.0.2.1'
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*
2
- Version 3.0.0
2
+ //! version : 3.0.2
3
3
  =========================================================
4
4
  bootstrap-datetimepicker.js
5
5
  https://github.com/Eonasdan/bootstrap-datetimepicker
@@ -27,6 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
27
  THE SOFTWARE.
28
28
  */
29
29
  ; (function (factory) {
30
+ 'use strict';
30
31
  if (typeof define === 'function' && define.amd) {
31
32
  // AMD is used - Register as an anonymous module.
32
33
  define(['jquery', 'moment'], factory);
@@ -43,10 +44,10 @@ THE SOFTWARE.
43
44
  }
44
45
 
45
46
  (function ($, moment) {
47
+ 'use strict';
46
48
  if (typeof moment === 'undefined') {
47
- alert("momentjs is required");
48
49
  throw new Error('momentjs is required');
49
- };
50
+ }
50
51
 
51
52
  var dpgId = 0,
52
53
 
@@ -56,18 +57,19 @@ THE SOFTWARE.
56
57
  DateTimePicker = function (element, options) {
57
58
  var defaults = $.fn.datetimepicker.defaults,
58
59
 
59
- icons = {
60
- time: 'glyphicon glyphicon-time',
61
- date: 'glyphicon glyphicon-calendar',
62
- up: 'glyphicon glyphicon-chevron-up',
63
- down: 'glyphicon glyphicon-chevron-down'
64
- },
60
+ icons = {
61
+ time: 'glyphicon glyphicon-time',
62
+ date: 'glyphicon glyphicon-calendar',
63
+ up: 'glyphicon glyphicon-chevron-up',
64
+ down: 'glyphicon glyphicon-chevron-down'
65
+ },
65
66
 
66
67
  picker = this,
67
68
 
68
- init = function () {
69
+ dDate,
69
70
 
70
- var icon = false, i, dDate, longDateFormat;
71
+ init = function () {
72
+ var icon = false, localeData, rInterval;
71
73
  picker.options = $.extend({}, defaults, options);
72
74
  picker.options.icons = $.extend({}, icons, picker.options.icons);
73
75
 
@@ -75,19 +77,20 @@ THE SOFTWARE.
75
77
 
76
78
  dataToOptions();
77
79
 
78
- if (!(picker.options.pickTime || picker.options.pickDate))
80
+ if (!(picker.options.pickTime || picker.options.pickDate)) {
79
81
  throw new Error('Must choose at least one picker');
82
+ }
80
83
 
81
84
  picker.id = dpgId++;
82
- pMoment.lang(picker.options.language);
85
+ pMoment.locale(picker.options.language);
83
86
  picker.date = pMoment();
84
87
  picker.unset = false;
85
88
  picker.isInput = picker.element.is('input');
86
89
  picker.component = false;
87
90
 
88
91
  if (picker.element.hasClass('input-group')) {
89
- if (picker.element.find('.datepickerbutton').size() == 0) {//in case there is more then one 'input-group-addon' Issue #48
90
- picker.component = picker.element.find("[class^='input-group-']");
92
+ if (picker.element.find('.datepickerbutton').size() === 0) {//in case there is more then one 'input-group-addon' Issue #48
93
+ picker.component = picker.element.find('[class^="input-group-"]');
91
94
  }
92
95
  else {
93
96
  picker.component = picker.element.find('.datepickerbutton');
@@ -95,27 +98,33 @@ THE SOFTWARE.
95
98
  }
96
99
  picker.format = picker.options.format;
97
100
 
98
- longDateFormat = pMoment()._lang._longDateFormat;
101
+ localeData = pMoment().localeData();
99
102
 
100
103
  if (!picker.format) {
101
- picker.format = (picker.options.pickDate ? longDateFormat.L : '');
102
- if (picker.options.pickDate && picker.options.pickTime) picker.format += ' ';
103
- picker.format += (picker.options.pickTime ? longDateFormat.LT : '');
104
+ picker.format = (picker.options.pickDate ? localeData.longDateFormat('L') : '');
105
+ if (picker.options.pickDate && picker.options.pickTime) {
106
+ picker.format += ' ';
107
+ }
108
+ picker.format += (picker.options.pickTime ? localeData.longDateFormat('LT') : '');
104
109
  if (picker.options.useSeconds) {
105
- if (~longDateFormat.LT.indexOf(' A')) {
106
- picker.format = picker.format.split(" A")[0] + ":ss A";
110
+ if (localeData.longDateFormat('LT').indexOf(' A') !== -1) {
111
+ picker.format = picker.format.split(' A')[0] + ':ss A';
107
112
  }
108
113
  else {
109
114
  picker.format += ':ss';
110
115
  }
111
116
  }
112
117
  }
113
- picker.use24hours = picker.format.toLowerCase().indexOf("a") < 1;
118
+ picker.use24hours = picker.format.toLowerCase().indexOf('a') < 1;
114
119
 
115
- if (picker.component) icon = picker.component.find('span');
120
+ if (picker.component) {
121
+ icon = picker.component.find('span');
122
+ }
116
123
 
117
124
  if (picker.options.pickTime) {
118
- if (icon) icon.addClass(picker.options.icons.time);
125
+ if (icon) {
126
+ icon.addClass(picker.options.icons.time);
127
+ }
119
128
  }
120
129
  if (picker.options.pickDate) {
121
130
  if (icon) {
@@ -124,7 +133,14 @@ THE SOFTWARE.
124
133
  }
125
134
  }
126
135
 
127
- picker.widget = $(getTemplate()).appendTo('body');
136
+ picker.options.widgetParent =
137
+ typeof picker.options.widgetParent === 'string' && picker.options.widgetParent ||
138
+ picker.element.parents().filter(function () {
139
+ return 'scroll' === $(this).css('overflow-y');
140
+ }).get(0) ||
141
+ 'body';
142
+
143
+ picker.widget = $(getTemplate()).appendTo(picker.options.widgetParent);
128
144
 
129
145
  if (picker.options.useSeconds && !picker.use24hours) {
130
146
  picker.widget.width(300);
@@ -173,9 +189,11 @@ THE SOFTWARE.
173
189
  update();
174
190
  showMode();
175
191
  attachDatePickerEvents();
176
- if (picker.options.defaultDate !== "" && getPickerInput().val() == "") picker.setValue(picker.options.defaultDate);
192
+ if (picker.options.defaultDate !== '' && getPickerInput().val() === '') {
193
+ picker.setValue(picker.options.defaultDate);
194
+ }
177
195
  if (picker.options.minuteStepping !== 1) {
178
- var rInterval = picker.options.minuteStepping;
196
+ rInterval = picker.options.minuteStepping;
179
197
  picker.date.minutes((Math.round(picker.date.minutes() / rInterval) * rInterval) % 60).seconds(0);
180
198
  }
181
199
  },
@@ -185,65 +203,104 @@ THE SOFTWARE.
185
203
 
186
204
  if (picker.isInput) {
187
205
  return picker.element;
188
- } else {
189
- input = picker.element.find('.datepickerinput');
190
- if (input.size() === 0) {
191
- input = picker.element.find('input');
192
- }
193
- else if (!input.is('input')) {
194
- throw new Error('CSS class "datepickerinput" cannot be applied to non input element');
195
- }
196
- return input;
197
206
  }
207
+ input = picker.element.find('.datepickerinput');
208
+ if (input.size() === 0) {
209
+ input = picker.element.find('input');
210
+ }
211
+ else if (!input.is('input')) {
212
+ throw new Error('CSS class "datepickerinput" cannot be applied to non input element');
213
+ }
214
+ return input;
198
215
  },
199
216
 
200
217
  dataToOptions = function () {
201
- var eData
218
+ var eData;
202
219
  if (picker.element.is('input')) {
203
220
  eData = picker.element.data();
204
221
  }
205
222
  else {
206
- eData = picker.element.data();
223
+ eData = picker.element.find('input').data();
224
+ }
225
+ if (eData.dateFormat !== undefined) {
226
+ picker.options.format = eData.dateFormat;
227
+ }
228
+ if (eData.datePickdate !== undefined) {
229
+ picker.options.pickDate = eData.datePickdate;
230
+ }
231
+ if (eData.datePicktime !== undefined) {
232
+ picker.options.pickTime = eData.datePicktime;
233
+ }
234
+ if (eData.dateUseminutes !== undefined) {
235
+ picker.options.useMinutes = eData.dateUseminutes;
236
+ }
237
+ if (eData.dateUseseconds !== undefined) {
238
+ picker.options.useSeconds = eData.dateUseseconds;
239
+ }
240
+ if (eData.dateUsecurrent !== undefined) {
241
+ picker.options.useCurrent = eData.dateUsecurrent;
242
+ }
243
+ if (eData.dateMinutestepping !== undefined) {
244
+ picker.options.minuteStepping = eData.dateMinutestepping;
245
+ }
246
+ if (eData.dateMindate !== undefined) {
247
+ picker.options.minDate = eData.dateMindate;
248
+ }
249
+ if (eData.dateMaxdate !== undefined) {
250
+ picker.options.maxDate = eData.dateMaxdate;
251
+ }
252
+ if (eData.dateShowtoday !== undefined) {
253
+ picker.options.showToday = eData.dateShowtoday;
254
+ }
255
+ if (eData.dateCollapse !== undefined) {
256
+ picker.options.collapse = eData.dateCollapse;
257
+ }
258
+ if (eData.dateLanguage !== undefined) {
259
+ picker.options.language = eData.dateLanguage;
260
+ }
261
+ if (eData.dateDefaultdate !== undefined) {
262
+ picker.options.defaultDate = eData.dateDefaultdate;
263
+ }
264
+ if (eData.dateDisableddates !== undefined) {
265
+ picker.options.disabledDates = eData.dateDisableddates;
266
+ }
267
+ if (eData.dateEnableddates !== undefined) {
268
+ picker.options.enabledDates = eData.dateEnableddates;
269
+ }
270
+ if (eData.dateIcons !== undefined) {
271
+ picker.options.icons = eData.dateIcons;
272
+ }
273
+ if (eData.dateUsestrict !== undefined) {
274
+ picker.options.useStrict = eData.dateUsestrict;
275
+ }
276
+ if (eData.dateDirection !== undefined) {
277
+ picker.options.direction = eData.dateDirection;
278
+ }
279
+ if (eData.dateSidebyside !== undefined) {
280
+ picker.options.sideBySide = eData.dateSidebyside;
207
281
  }
208
- if (eData.dateFormat !== undefined) picker.options.format = eData.dateFormat;
209
- if (eData.datePickdate !== undefined) picker.options.pickDate = eData.datePickdate;
210
- if (eData.datePicktime !== undefined) picker.options.pickTime = eData.datePicktime;
211
- if (eData.dateUseminutes !== undefined) picker.options.useMinutes = eData.dateUseminutes;
212
- if (eData.dateUseseconds !== undefined) picker.options.useSeconds = eData.dateUseseconds;
213
- if (eData.dateUsecurrent !== undefined) picker.options.useCurrent = eData.dateUsecurrent;
214
- if (eData.dateMinutestepping !== undefined) picker.options.minuteStepping = eData.dateMinutestepping;
215
- if (eData.dateMindate !== undefined) picker.options.minDate = eData.dateMindate;
216
- if (eData.dateMaxdate !== undefined) picker.options.maxDate = eData.dateMaxdate;
217
- if (eData.dateShowtoday !== undefined) picker.options.showToday = eData.dateShowtoday;
218
- if (eData.dateCollapse !== undefined) picker.options.collapse = eData.dateCollapse;
219
- if (eData.dateLanguage !== undefined) picker.options.language = eData.dateLanguage;
220
- if (eData.dateDefaultdate !== undefined) picker.options.defaultDate = eData.dateDefaultdate;
221
- if (eData.dateDisableddates !== undefined) picker.options.disabledDates = eData.dateDisableddates;
222
- if (eData.dateEnableddates !== undefined) picker.options.enabledDates = eData.dateEnableddates;
223
- if (eData.dateIcons !== undefined) picker.options.icons = eData.dateIcons;
224
- if (eData.dateUsestrict !== undefined) picker.options.useStrict = eData.dateUsestrict;
225
- if (eData.dateDirection !== undefined) picker.options.direction = eData.dateDirection;
226
- if (eData.dateSidebyside !== undefined) picker.options.sideBySide = eData.dateSidebyside;
227
282
  },
228
283
 
229
284
  place = function () {
230
285
  var position = 'absolute',
231
- offset = picker.component ? picker.component.offset() : picker.element.offset(), $window = $(window);
286
+ offset = picker.component ? picker.component.offset() : picker.element.offset(),
287
+ $window = $(window),
288
+ placePosition;
289
+
232
290
  picker.width = picker.component ? picker.component.outerWidth() : picker.element.outerWidth();
233
291
  offset.top = offset.top + picker.element.outerHeight();
234
292
 
235
- var placePosition;
236
293
  if (picker.options.direction === 'up') {
237
- placePosition = 'top'
294
+ placePosition = 'top';
238
295
  } else if (picker.options.direction === 'bottom') {
239
- placePosition = 'bottom'
296
+ placePosition = 'bottom';
240
297
  } else if (picker.options.direction === 'auto') {
241
298
  if (offset.top + picker.widget.height() > $window.height() + $window.scrollTop() && picker.widget.height() + picker.element.outerHeight() < offset.top) {
242
299
  placePosition = 'top';
243
300
  } else {
244
301
  placePosition = 'bottom';
245
302
  }
246
- };
303
+ }
247
304
  if (placePosition === 'top') {
248
305
  offset.top -= picker.widget.height() + picker.element.outerHeight() + 15;
249
306
  picker.widget.addClass('top').removeClass('bottom');
@@ -285,68 +342,77 @@ THE SOFTWARE.
285
342
  },
286
343
 
287
344
  notifyChange = function (oldDate, eventType) {
288
- if (pMoment(picker.date).isSame(pMoment(oldDate))) return;
345
+ if (pMoment(picker.date).isSame(pMoment(oldDate))) {
346
+ return;
347
+ }
289
348
  picker.element.trigger({
290
349
  type: 'dp.change',
291
350
  date: pMoment(picker.date),
292
351
  oldDate: pMoment(oldDate)
293
352
  });
294
353
 
295
- if (eventType !== 'change')
354
+ if (eventType !== 'change') {
296
355
  picker.element.change();
356
+ }
297
357
  },
298
358
 
299
- notifyError = function (date) {
300
- picker.element.trigger({
301
- type: 'dp.error',
302
- date: pMoment(date)
303
- });
304
- },
359
+ notifyError = function (date) {
360
+ picker.element.trigger({
361
+ type: 'dp.error',
362
+ date: pMoment(date, picker.format, picker.options.useStrict)
363
+ });
364
+ },
305
365
 
306
366
  update = function (newDate) {
307
- pMoment.lang(picker.options.language);
367
+ pMoment.locale(picker.options.language);
308
368
  var dateStr = newDate;
309
369
  if (!dateStr) {
310
370
  dateStr = getPickerInput().val();
311
- if (dateStr) picker.date = pMoment(dateStr, picker.format, picker.options.useStrict);
312
- if (!picker.date) picker.date = pMoment();
371
+ if (dateStr) {
372
+ picker.date = pMoment(dateStr, picker.format, picker.options.useStrict);
373
+ }
374
+ if (!picker.date) {
375
+ picker.date = pMoment();
376
+ }
313
377
  }
314
- picker.viewDate = pMoment(picker.date).startOf("month");
378
+ picker.viewDate = pMoment(picker.date).startOf('month');
315
379
  fillDate();
316
380
  fillTime();
317
381
  },
318
382
 
319
- fillDow = function () {
320
- pMoment.lang(picker.options.language);
321
- var html = $('<tr>'), weekdaysMin = pMoment.weekdaysMin(), i;
322
- if (pMoment()._lang._week.dow == 0) { // starts on Sunday
323
- for (i = 0; i < 7; i++) {
324
- html.append('<th class="dow">' + weekdaysMin[i] + '</th>');
325
- }
326
- } else {
327
- for (i = 1; i < 8; i++) {
328
- if (i == 7) {
329
- html.append('<th class="dow">' + weekdaysMin[0] + '</th>');
330
- } else {
331
- html.append('<th class="dow">' + weekdaysMin[i] + '</th>');
332
- }
333
- }
334
- }
335
- picker.widget.find('.datepicker-days thead').append(html);
336
- },
383
+ fillDow = function () {
384
+ pMoment.locale(picker.options.language);
385
+ var html = $('<tr>'), weekdaysMin = pMoment.weekdaysMin(), i;
386
+ if (pMoment().localeData()._week.dow === 0) { // starts on Sunday
387
+ for (i = 0; i < 7; i++) {
388
+ html.append('<th class="dow">' + weekdaysMin[i] + '</th>');
389
+ }
390
+ } else {
391
+ for (i = 1; i < 8; i++) {
392
+ if (i === 7) {
393
+ html.append('<th class="dow">' + weekdaysMin[0] + '</th>');
394
+ } else {
395
+ html.append('<th class="dow">' + weekdaysMin[i] + '</th>');
396
+ }
397
+ }
398
+ }
399
+ picker.widget.find('.datepicker-days thead').append(html);
400
+ },
337
401
 
338
402
  fillMonths = function () {
339
- pMoment.lang(picker.options.language);
340
- var html = '', i = 0, monthsShort = pMoment.monthsShort();
341
- while (i < 12) {
342
- html += '<span class="month">' + monthsShort[i++] + '</span>';
403
+ pMoment.locale(picker.options.language);
404
+ var html = '', i, monthsShort = pMoment.monthsShort();
405
+ for (i = 0; i < 12; i++) {
406
+ html += '<span class="month">' + monthsShort[i] + '</span>';
343
407
  }
344
408
  picker.widget.find('.datepicker-months td').append(html);
345
409
  },
346
410
 
347
411
  fillDate = function () {
348
- if(!picker.options.pickDate) return;
349
- pMoment.lang(picker.options.language);
412
+ if (!picker.options.pickDate) {
413
+ return;
414
+ }
415
+ pMoment.locale(picker.options.language);
350
416
  var year = picker.viewDate.year(),
351
417
  month = picker.viewDate.month(),
352
418
  startYear = picker.options.minDate.year(),
@@ -363,29 +429,29 @@ THE SOFTWARE.
363
429
  picker.widget.find('.datepicker-days th:eq(1)').text(
364
430
  months[month] + ' ' + year);
365
431
 
366
- prevMonth = pMoment(picker.viewDate).subtract("months", 1);
432
+ prevMonth = pMoment(picker.viewDate, picker.format, picker.options.useStrict).subtract(1, 'months');
367
433
  days = prevMonth.daysInMonth();
368
434
  prevMonth.date(days).startOf('week');
369
- if ((year == startYear && month <= startMonth) || year < startYear) {
435
+ if ((year === startYear && month <= startMonth) || year < startYear) {
370
436
  picker.widget.find('.datepicker-days th:eq(0)').addClass('disabled');
371
437
  }
372
- if ((year == endYear && month >= endMonth) || year > endYear) {
438
+ if ((year === endYear && month >= endMonth) || year > endYear) {
373
439
  picker.widget.find('.datepicker-days th:eq(2)').addClass('disabled');
374
440
  }
375
441
 
376
- nextMonth = pMoment(prevMonth).add(42, "d");
442
+ nextMonth = pMoment(prevMonth).add(42, 'd');
377
443
  while (prevMonth.isBefore(nextMonth)) {
378
444
  if (prevMonth.weekday() === pMoment().startOf('week').weekday()) {
379
445
  row = $('<tr>');
380
446
  html.push(row);
381
447
  }
382
448
  clsName = '';
383
- if (prevMonth.year() < year || (prevMonth.year() == year && prevMonth.month() < month)) {
449
+ if (prevMonth.year() < year || (prevMonth.year() === year && prevMonth.month() < month)) {
384
450
  clsName += ' old';
385
- } else if (prevMonth.year() > year || (prevMonth.year() == year && prevMonth.month() > month)) {
451
+ } else if (prevMonth.year() > year || (prevMonth.year() === year && prevMonth.month() > month)) {
386
452
  clsName += ' new';
387
453
  }
388
- if (prevMonth.isSame(pMoment({ y: picker.date.year(), M: picker.date.month(), d: picker.date.date() }))) {
454
+ if (prevMonth.isSame(pMoment({y: picker.date.year(), M: picker.date.month(), d: picker.date.date()}))) {
389
455
  clsName += ' active';
390
456
  }
391
457
  if (isInDisableDates(prevMonth, 'day') || !isInEnableDates(prevMonth)) {
@@ -397,8 +463,8 @@ THE SOFTWARE.
397
463
  }
398
464
  }
399
465
  if (picker.options.daysOfWeekDisabled) {
400
- for (i in picker.options.daysOfWeekDisabled) {
401
- if (prevMonth.day() == picker.options.daysOfWeekDisabled[i]) {
466
+ for (i = 0; i < picker.options.daysOfWeekDisabled.length; i++) {
467
+ if (prevMonth.day() === picker.options.daysOfWeekDisabled[i]) {
402
468
  clsName += ' disabled';
403
469
  break;
404
470
  }
@@ -407,15 +473,15 @@ THE SOFTWARE.
407
473
  row.append('<td class="day' + clsName + '">' + prevMonth.date() + '</td>');
408
474
 
409
475
  currentDate = prevMonth.date();
410
- prevMonth.add(1, "d");
476
+ prevMonth.add(1, 'd');
411
477
 
412
- if (currentDate == prevMonth.date()) {
413
- prevMonth.add(1, "d");
478
+ if (currentDate === prevMonth.date()) {
479
+ prevMonth.add(1, 'd');
414
480
  }
415
481
  }
416
482
  picker.widget.find('.datepicker-days tbody').empty().append(html);
417
- currentYear = picker.date.year(), months = picker.widget.find('.datepicker-months')
418
- .find('th:eq(1)').text(year).end().find('span').removeClass('active');
483
+ currentYear = picker.date.year();
484
+ months = picker.widget.find('.datepicker-months').find('th:eq(1)').text(year).end().find('span').removeClass('active');
419
485
  if (currentYear === year) {
420
486
  months.eq(picker.date.month()).addClass('active');
421
487
  }
@@ -426,9 +492,9 @@ THE SOFTWARE.
426
492
  picker.widget.find('.datepicker-months th:eq(2)').addClass('disabled');
427
493
  }
428
494
  for (i = 0; i < 12; i++) {
429
- if ((year == startYear && startMonth > i) || (year < startYear)) {
495
+ if ((year === startYear && startMonth > i) || (year < startYear)) {
430
496
  $(months[i]).addClass('disabled');
431
- } else if ((year == endYear && endMonth < i) || (year > endYear)) {
497
+ } else if ((year === endYear && endMonth < i) || (year > endYear)) {
432
498
  $(months[i]).addClass('disabled');
433
499
  }
434
500
  }
@@ -453,7 +519,7 @@ THE SOFTWARE.
453
519
  },
454
520
 
455
521
  fillHours = function () {
456
- pMoment.lang(picker.options.language);
522
+ pMoment.locale(picker.options.language);
457
523
  var table = picker.widget.find('.timepicker .timepicker-hours table'), html = '', current, i, j;
458
524
  table.parent().hide();
459
525
  if (picker.use24hours) {
@@ -484,7 +550,9 @@ THE SOFTWARE.
484
550
  fillMinutes = function () {
485
551
  var table = picker.widget.find('.timepicker .timepicker-minutes table'), html = '', current = 0, i, j, step = picker.options.minuteStepping;
486
552
  table.parent().hide();
487
- if (step == 1) step = 5;
553
+ if (step === 1) {
554
+ step = 5;
555
+ }
488
556
  for (i = 0; i < Math.ceil(60 / step / 4) ; i++) {
489
557
  html += '<tr>';
490
558
  for (j = 0; j < 4; j += 1) {
@@ -515,14 +583,18 @@ THE SOFTWARE.
515
583
  },
516
584
 
517
585
  fillTime = function () {
518
- if (!picker.date) return;
586
+ if (!picker.date) {
587
+ return;
588
+ }
519
589
  var timeComponents = picker.widget.find('.timepicker span[data-time-component]'),
520
- hour = picker.date.hours(),
521
- period = 'AM';
590
+ hour = picker.date.hours(),
591
+ period = picker.date.format('A');
522
592
  if (!picker.use24hours) {
523
- if (hour >= 12) period = 'PM';
524
- if (hour === 0) hour = 12;
525
- else if (hour != 12) hour = hour % 12;
593
+ if (hour === 0) {
594
+ hour = 12;
595
+ } else if (hour !== 12) {
596
+ hour = hour % 12;
597
+ }
526
598
  picker.widget.find('.timepicker [data-action=togglePeriod]').text(period);
527
599
  }
528
600
  timeComponents.filter('[data-time-component=hours]').text(padLeft(hour));
@@ -546,7 +618,9 @@ THE SOFTWARE.
546
618
  case 'prev':
547
619
  case 'next':
548
620
  step = dpGlobal.modes[picker.viewMode].navStep;
549
- if (target[0].className === 'prev') step = step * -1;
621
+ if (target[0].className === 'prev') {
622
+ step = step * -1;
623
+ }
550
624
  picker.viewDate.add(step, dpGlobal.modes[picker.viewMode].navFnc);
551
625
  fillDate();
552
626
  break;
@@ -588,7 +662,7 @@ THE SOFTWARE.
588
662
  month -= 1;
589
663
  }
590
664
  } else if (target.is('.new')) {
591
- if (month == 11) {
665
+ if (month === 11) {
592
666
  month = 0;
593
667
  year += 1;
594
668
  } else {
@@ -617,98 +691,108 @@ THE SOFTWARE.
617
691
  }
618
692
  },
619
693
 
620
- actions = {
621
- incrementHours: function () {
622
- checkDate("add", "hours", 1);
623
- },
624
-
625
- incrementMinutes: function () {
626
- checkDate("add", "minutes", picker.options.minuteStepping);
627
- },
628
-
629
- incrementSeconds: function () {
630
- checkDate("add", "seconds", 1);
631
- },
632
-
633
- decrementHours: function () {
634
- checkDate("subtract", "hours", 1);
635
- },
636
-
637
- decrementMinutes: function () {
638
- checkDate("subtract", "minutes", picker.options.minuteStepping);
639
- },
640
-
641
- decrementSeconds: function () {
642
- checkDate("subtract", "seconds", 1);
643
- },
644
-
645
- togglePeriod: function () {
646
- var hour = picker.date.hours();
647
- if (hour >= 12) hour -= 12;
648
- else hour += 12;
649
- picker.date.hours(hour);
650
- },
651
-
652
- showPicker: function () {
653
- picker.widget.find('.timepicker > div:not(.timepicker-picker)').hide();
654
- picker.widget.find('.timepicker .timepicker-picker').show();
655
- },
656
-
657
- showHours: function () {
658
- picker.widget.find('.timepicker .timepicker-picker').hide();
659
- picker.widget.find('.timepicker .timepicker-hours').show();
660
- },
661
-
662
- showMinutes: function () {
663
- picker.widget.find('.timepicker .timepicker-picker').hide();
664
- picker.widget.find('.timepicker .timepicker-minutes').show();
665
- },
666
-
667
- showSeconds: function () {
668
- picker.widget.find('.timepicker .timepicker-picker').hide();
669
- picker.widget.find('.timepicker .timepicker-seconds').show();
670
- },
671
-
672
- selectHour: function (e) {
673
- var period = picker.widget.find('.timepicker [data-action=togglePeriod]').text(), hour = parseInt($(e.target).text(), 10);
674
- if (period == "PM") hour += 12
675
- picker.date.hours(hour);
676
- actions.showPicker.call(picker);
677
- },
678
-
679
- selectMinute: function (e) {
680
- picker.date.minutes(parseInt($(e.target).text(), 10));
681
- actions.showPicker.call(picker);
682
- },
683
-
684
- selectSecond: function (e) {
685
- picker.date.seconds(parseInt($(e.target).text(), 10));
686
- actions.showPicker.call(picker);
687
- }
688
- },
689
-
690
- doAction = function (e) {
691
- var oldDate = pMoment(picker.date), action = $(e.currentTarget).data('action'), rv = actions[action].apply(picker, arguments);
692
- stopEvent(e);
693
- if (!picker.date) picker.date = pMoment({ y: 1970 });
694
- set();
695
- fillTime();
696
- notifyChange(oldDate, e.type);
697
- return rv;
698
- },
694
+ actions = {
695
+ incrementHours: function () {
696
+ checkDate('add', 'hours', 1);
697
+ },
698
+
699
+ incrementMinutes: function () {
700
+ checkDate('add', 'minutes', picker.options.minuteStepping);
701
+ },
702
+
703
+ incrementSeconds: function () {
704
+ checkDate('add', 'seconds', 1);
705
+ },
706
+
707
+ decrementHours: function () {
708
+ checkDate('subtract', 'hours', 1);
709
+ },
710
+
711
+ decrementMinutes: function () {
712
+ checkDate('subtract', 'minutes', picker.options.minuteStepping);
713
+ },
714
+
715
+ decrementSeconds: function () {
716
+ checkDate('subtract', 'seconds', 1);
717
+ },
718
+
719
+ togglePeriod: function () {
720
+ var hour = picker.date.hours();
721
+ if (hour >= 12) {
722
+ hour -= 12;
723
+ } else {
724
+ hour += 12;
725
+ }
726
+ picker.date.hours(hour);
727
+ },
728
+
729
+ showPicker: function () {
730
+ picker.widget.find('.timepicker > div:not(.timepicker-picker)').hide();
731
+ picker.widget.find('.timepicker .timepicker-picker').show();
732
+ },
733
+
734
+ showHours: function () {
735
+ picker.widget.find('.timepicker .timepicker-picker').hide();
736
+ picker.widget.find('.timepicker .timepicker-hours').show();
737
+ },
738
+
739
+ showMinutes: function () {
740
+ picker.widget.find('.timepicker .timepicker-picker').hide();
741
+ picker.widget.find('.timepicker .timepicker-minutes').show();
742
+ },
743
+
744
+ showSeconds: function () {
745
+ picker.widget.find('.timepicker .timepicker-picker').hide();
746
+ picker.widget.find('.timepicker .timepicker-seconds').show();
747
+ },
748
+
749
+ selectHour: function (e) {
750
+ var hour = parseInt($(e.target).text(), 10);
751
+ if (picker.date.hours() > 12) {
752
+ hour += 12;
753
+ }
754
+ picker.date.hours(hour);
755
+ actions.showPicker.call(picker);
756
+ },
757
+
758
+ selectMinute: function (e) {
759
+ picker.date.minutes(parseInt($(e.target).text(), 10));
760
+ actions.showPicker.call(picker);
761
+ },
762
+
763
+ selectSecond: function (e) {
764
+ picker.date.seconds(parseInt($(e.target).text(), 10));
765
+ actions.showPicker.call(picker);
766
+ }
767
+ },
768
+
769
+ doAction = function (e) {
770
+ var oldDate = pMoment(picker.date),
771
+ action = $(e.currentTarget).data('action'),
772
+ rv = actions[action].apply(picker, arguments);
773
+ stopEvent(e);
774
+ if (!picker.date) {
775
+ picker.date = pMoment({y: 1970});
776
+ }
777
+ set();
778
+ fillTime();
779
+ notifyChange(oldDate, e.type);
780
+ return rv;
781
+ },
699
782
 
700
783
  stopEvent = function (e) {
701
784
  e.stopPropagation();
702
785
  e.preventDefault();
703
786
  },
704
787
 
705
- keydown = function (e) {
706
- if (e.keyCode === 27) // allow escape to hide picker
788
+ keydown = function (e) {
789
+ if (e.keyCode === 27) { // allow escape to hide picker
707
790
  picker.hide();
791
+ }
708
792
  },
709
793
 
710
794
  change = function (e) {
711
- pMoment.lang(picker.options.language);
795
+ pMoment.locale(picker.options.language);
712
796
  var input = $(e.target), oldDate = pMoment(picker.date), newDate = pMoment(input.val(), picker.format, picker.options.useStrict);
713
797
  if (newDate.isValid() && !isInDisableDates(newDate) && isInEnableDates(newDate)) {
714
798
  update();
@@ -718,9 +802,9 @@ THE SOFTWARE.
718
802
  }
719
803
  else {
720
804
  picker.viewDate = oldDate;
805
+ picker.unset = true;
721
806
  notifyChange(oldDate, e.type);
722
807
  notifyError(newDate);
723
- picker.unset = true;
724
808
  }
725
809
  },
726
810
 
@@ -728,7 +812,6 @@ THE SOFTWARE.
728
812
  if (dir) {
729
813
  picker.viewMode = Math.max(picker.minViewMode, Math.min(2, picker.viewMode + dir));
730
814
  }
731
- var f = dpGlobal.modes[picker.viewMode].clsName;
732
815
  picker.widget.find('.datepicker > div').hide().filter('.datepicker-' + dpGlobal.modes[picker.viewMode].clsName).show();
733
816
  },
734
817
 
@@ -748,11 +831,13 @@ THE SOFTWARE.
748
831
 
749
832
  if (expanded && expanded.length) {
750
833
  collapseData = expanded.data('collapse');
751
- if (collapseData && collapseData.transitioning) return;
834
+ if (collapseData && collapseData.transitioning) {
835
+ return;
836
+ }
752
837
  expanded.collapse('hide');
753
838
  closed.collapse('show');
754
839
  $this.find('span').toggleClass(picker.options.icons.time + ' ' + picker.options.icons.date);
755
- picker.element.find('.input-group-addon span').toggleClass(picker.options.icons.time + ' ' + picker.options.icons.date);
840
+ picker.element.find('[class^="input-group-"] span').toggleClass(picker.options.icons.time + ' ' + picker.options.icons.date);
756
841
  }
757
842
  });
758
843
  }
@@ -818,12 +903,11 @@ THE SOFTWARE.
818
903
  if (picker.element) {
819
904
  var parents = picker.element.parents(), inFixed = false, i;
820
905
  for (i = 0; i < parents.length; i++) {
821
- if ($(parents[i]).css('position') == 'fixed') {
906
+ if ($(parents[i]).css('position') === 'fixed') {
822
907
  inFixed = true;
823
908
  break;
824
909
  }
825
910
  }
826
- ;
827
911
  return inFixed;
828
912
  } else {
829
913
  return false;
@@ -831,73 +915,84 @@ THE SOFTWARE.
831
915
  },
832
916
 
833
917
  set = function () {
834
- pMoment.lang(picker.options.language);
835
- var formatted = '', input;
836
- if (!picker.unset) formatted = pMoment(picker.date).format(picker.format);
918
+ pMoment.locale(picker.options.language);
919
+ var formatted = '';
920
+ if (!picker.unset) {
921
+ formatted = pMoment(picker.date).format(picker.format);
922
+ }
837
923
  getPickerInput().val(formatted);
838
924
  picker.element.data('date', formatted);
839
- if (!picker.options.pickTime) picker.hide();
925
+ if (!picker.options.pickTime) {
926
+ picker.hide();
927
+ }
840
928
  },
841
929
 
842
- checkDate = function (direction, unit, amount) {
843
- pMoment.lang(picker.options.language);
844
- var newDate;
845
- if (direction == "add") {
846
- newDate = pMoment(picker.date);
847
- if (newDate.hours() == 23) newDate.add(amount, unit);
848
- newDate.add(amount, unit);
849
- }
850
- else {
851
- newDate = pMoment(picker.date).subtract(amount, unit);
852
- }
853
- if (isInDisableDates(pMoment(newDate.subtract(amount, unit))) || isInDisableDates(newDate)) {
854
- notifyError(newDate.format(picker.format));
855
- return;
856
- }
857
-
858
- if (direction == "add") {
859
- picker.date.add(amount, unit);
860
- }
861
- else {
862
- picker.date.subtract(amount, unit);
863
- }
864
- picker.unset = false;
865
- },
930
+ checkDate = function (direction, unit, amount) {
931
+ pMoment.locale(picker.options.language);
932
+ var newDate;
933
+ if (direction === 'add') {
934
+ newDate = pMoment(picker.date);
935
+ if (newDate.hours() === 23) {
936
+ newDate.add(amount, unit);
937
+ }
938
+ newDate.add(amount, unit);
939
+ }
940
+ else {
941
+ newDate = pMoment(picker.date).subtract(amount, unit);
942
+ }
943
+ if (isInDisableDates(pMoment(newDate.subtract(amount, unit))) || isInDisableDates(newDate)) {
944
+ notifyError(newDate.format(picker.format));
945
+ return;
946
+ }
947
+
948
+ if (direction === 'add') {
949
+ picker.date.add(amount, unit);
950
+ }
951
+ else {
952
+ picker.date.subtract(amount, unit);
953
+ }
954
+ picker.unset = false;
955
+ },
866
956
 
867
957
  isInDisableDates = function (date, timeUnit) {
868
- pMoment.lang(picker.options.language);
869
- var maxDate = picker.options.maxDate;
870
- var minDate = picker.options.minDate;
871
-
872
- if(timeUnit) {
873
- maxDate = pMoment(maxDate).endOf(timeUnit);
874
- minDate = pMoment(minDate).startOf(timeUnit);
958
+ pMoment.locale(picker.options.language);
959
+ var maxDate = pMoment(picker.options.maxDate, picker.format, picker.options.useStrict),
960
+ minDate = pMoment(picker.options.minDate, picker.format, picker.options.useStrict);
961
+
962
+ if (timeUnit) {
963
+ maxDate = maxDate.endOf(timeUnit);
964
+ minDate = minDate.startOf(timeUnit);
875
965
  }
876
966
 
877
- if (date.isAfter(maxDate) || date.isBefore(minDate)) return true;
967
+ if (date.isAfter(maxDate) || date.isBefore(minDate)) {
968
+ return true;
969
+ }
878
970
  if (picker.options.disabledDates === false) {
879
971
  return false;
880
972
  }
881
- return picker.options.disabledDates[pMoment(date).format("YYYY-MM-DD")] === true;
973
+ return picker.options.disabledDates[date.format('YYYY-MM-DD')] === true;
882
974
  },
883
975
  isInEnableDates = function (date) {
884
- pMoment.lang(picker.options.language);
976
+ pMoment.locale(picker.options.language);
885
977
  if (picker.options.enabledDates === false) {
886
978
  return true;
887
979
  }
888
- return picker.options.enabledDates[pMoment(date).format("YYYY-MM-DD")] === true;
980
+ return picker.options.enabledDates[date.format('YYYY-MM-DD')] === true;
889
981
  },
890
982
 
891
983
  indexGivenDates = function (givenDatesArray) {
892
984
  // Store given enabledDates and disabledDates as keys.
893
985
  // This way we can check their existence in O(1) time instead of looping through whole array.
894
986
  // (for example: picker.options.enabledDates['2014-02-27'] === true)
895
- var givenDatesIndexed = {};
896
- var givenDatesCount = 0;
987
+ var givenDatesIndexed = {}, givenDatesCount = 0, i;
897
988
  for (i = 0; i < givenDatesArray.length; i++) {
898
- dDate = pMoment(givenDatesArray[i]);
989
+ if (pMoment.isMoment(givenDatesArray[i]) || givenDatesArray[i] instanceof Date) {
990
+ dDate = pMoment(givenDatesArray[i]);
991
+ } else {
992
+ dDate = pMoment(givenDatesArray[i], picker.format, picker.options.useStrict);
993
+ }
899
994
  if (dDate.isValid()) {
900
- givenDatesIndexed[dDate.format("YYYY-MM-DD")] = true;
995
+ givenDatesIndexed[dDate.format('YYYY-MM-DD')] = true;
901
996
  givenDatesCount++;
902
997
  }
903
998
  }
@@ -909,8 +1004,10 @@ THE SOFTWARE.
909
1004
 
910
1005
  padLeft = function (string) {
911
1006
  string = string.toString();
912
- if (string.length >= 2) return string;
913
- else return '0' + string;
1007
+ if (string.length >= 2) {
1008
+ return string;
1009
+ }
1010
+ return '0' + string;
914
1011
  },
915
1012
 
916
1013
  getTemplate = function () {
@@ -935,23 +1032,23 @@ THE SOFTWARE.
935
1032
  }
936
1033
  ret += '</div>';
937
1034
  return ret;
938
- } else if (picker.options.pickTime) {
1035
+ }
1036
+ if (picker.options.pickTime) {
939
1037
  return (
940
1038
  '<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
941
1039
  '<div class="timepicker">' + tpGlobal.getTemplate() + '</div>' +
942
1040
  '</div>'
943
1041
  );
944
- } else {
945
- return (
946
- '<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
947
- '<div class="datepicker">' + dpGlobal.template + '</div>' +
948
- '</div>'
949
- );
950
1042
  }
1043
+ return (
1044
+ '<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
1045
+ '<div class="datepicker">' + dpGlobal.template + '</div>' +
1046
+ '</div>'
1047
+ );
951
1048
  },
952
1049
 
953
- dpGlobal = {
954
- modes: [
1050
+ dpGlobal = {
1051
+ modes: [
955
1052
  {
956
1053
  clsName: 'days',
957
1054
  navFnc: 'month',
@@ -966,16 +1063,17 @@ THE SOFTWARE.
966
1063
  clsName: 'years',
967
1064
  navFnc: 'year',
968
1065
  navStep: 10
969
- }],
970
- headTemplate:
1066
+ }
1067
+ ],
1068
+ headTemplate:
971
1069
  '<thead>' +
972
- '<tr>' +
973
- '<th class="prev">&lsaquo;</th><th colspan="5" class="switch"></th><th class="next">&rsaquo;</th>' +
974
- '</tr>' +
1070
+ '<tr>' +
1071
+ '<th class="prev">&lsaquo;</th><th colspan="5" class="switch"></th><th class="next">&rsaquo;</th>' +
1072
+ '</tr>' +
975
1073
  '</thead>',
976
- contTemplate:
977
- '<tbody><tr><td colspan="7"></td></tr></tbody>'
978
- },
1074
+ contTemplate:
1075
+ '<tbody><tr><td colspan="7"></td></tr></tbody>'
1076
+ },
979
1077
 
980
1078
  tpGlobal = {
981
1079
  hourTemplate: '<span data-action="showHours" data-time-component="hours" class="timepicker-hour"></span>',
@@ -991,38 +1089,38 @@ THE SOFTWARE.
991
1089
  '<table class="table-condensed">' + dpGlobal.headTemplate + dpGlobal.contTemplate + '</table>' +
992
1090
  '</div>' +
993
1091
  '<div class="datepicker-years">' +
994
- '<table class="table-condensed">' + dpGlobal.headTemplate + dpGlobal.contTemplate + '</table>' +
1092
+ '<table class="table-condensed">' + dpGlobal.headTemplate + dpGlobal.contTemplate + '</table>' +
995
1093
  '</div>';
996
1094
 
997
1095
  tpGlobal.getTemplate = function () {
998
1096
  return (
999
1097
  '<div class="timepicker-picker">' +
1000
1098
  '<table class="table-condensed">' +
1001
- '<tr>' +
1002
- '<td><a href="#" class="btn" data-action="incrementHours"><span class="' + picker.options.icons.up + '"></span></a></td>' +
1003
- '<td class="separator"></td>' +
1004
- '<td>' + (picker.options.useMinutes ? '<a href="#" class="btn" data-action="incrementMinutes"><span class="' + picker.options.icons.up + '"></span></a>' : '') + '</td>' +
1099
+ '<tr>' +
1100
+ '<td><a href="#" class="btn" data-action="incrementHours"><span class="' + picker.options.icons.up + '"></span></a></td>' +
1101
+ '<td class="separator"></td>' +
1102
+ '<td>' + (picker.options.useMinutes ? '<a href="#" class="btn" data-action="incrementMinutes"><span class="' + picker.options.icons.up + '"></span></a>' : '') + '</td>' +
1005
1103
  (picker.options.useSeconds ?
1006
1104
  '<td class="separator"></td><td><a href="#" class="btn" data-action="incrementSeconds"><span class="' + picker.options.icons.up + '"></span></a></td>' : '') +
1007
- (picker.use24hours ? '' : '<td class="separator"></td>') +
1008
- '</tr>' +
1009
- '<tr>' +
1010
- '<td>' + tpGlobal.hourTemplate + '</td> ' +
1011
- '<td class="separator">:</td>' +
1012
- '<td>' + (picker.options.useMinutes ? tpGlobal.minuteTemplate : '<span class="timepicker-minute">00</span>') + '</td> ' +
1105
+ (picker.use24hours ? '' : '<td class="separator"></td>') +
1106
+ '</tr>' +
1107
+ '<tr>' +
1108
+ '<td>' + tpGlobal.hourTemplate + '</td> ' +
1109
+ '<td class="separator">:</td>' +
1110
+ '<td>' + (picker.options.useMinutes ? tpGlobal.minuteTemplate : '<span class="timepicker-minute">00</span>') + '</td> ' +
1013
1111
  (picker.options.useSeconds ?
1014
1112
  '<td class="separator">:</td><td>' + tpGlobal.secondTemplate + '</td>' : '') +
1015
- (picker.use24hours ? '' : '<td class="separator"></td>' +
1016
- '<td><button type="button" class="btn btn-primary" data-action="togglePeriod"></button></td>') +
1017
- '</tr>' +
1018
- '<tr>' +
1019
- '<td><a href="#" class="btn" data-action="decrementHours"><span class="' + picker.options.icons.down + '"></span></a></td>' +
1020
- '<td class="separator"></td>' +
1021
- '<td>' + (picker.options.useMinutes ? '<a href="#" class="btn" data-action="decrementMinutes"><span class="' + picker.options.icons.down + '"></span></a>' : '') + '</td>' +
1113
+ (picker.use24hours ? '' : '<td class="separator"></td>' +
1114
+ '<td><button type="button" class="btn btn-primary" data-action="togglePeriod"></button></td>') +
1115
+ '</tr>' +
1116
+ '<tr>' +
1117
+ '<td><a href="#" class="btn" data-action="decrementHours"><span class="' + picker.options.icons.down + '"></span></a></td>' +
1118
+ '<td class="separator"></td>' +
1119
+ '<td>' + (picker.options.useMinutes ? '<a href="#" class="btn" data-action="decrementMinutes"><span class="' + picker.options.icons.down + '"></span></a>' : '') + '</td>' +
1022
1120
  (picker.options.useSeconds ?
1023
1121
  '<td class="separator"></td><td><a href="#" class="btn" data-action="decrementSeconds"><span class="' + picker.options.icons.down + '"></span></a></td>' : '') +
1024
- (picker.use24hours ? '' : '<td class="separator"></td>') +
1025
- '</tr>' +
1122
+ (picker.use24hours ? '' : '<td class="separator"></td>') +
1123
+ '</tr>' +
1026
1124
  '</table>' +
1027
1125
  '</div>' +
1028
1126
  '<div class="timepicker-hours" data-action="selectHour">' +
@@ -1041,31 +1139,32 @@ THE SOFTWARE.
1041
1139
  detachDatePickerGlobalEvents();
1042
1140
  picker.widget.remove();
1043
1141
  picker.element.removeData('DateTimePicker');
1044
- if (picker.component)
1142
+ if (picker.component) {
1045
1143
  picker.component.removeData('DateTimePicker');
1144
+ }
1046
1145
  };
1047
1146
 
1048
1147
  picker.show = function (e) {
1049
1148
  if (picker.options.useCurrent) {
1050
- if (getPickerInput().val() == '') {
1149
+ if (getPickerInput().val() === '') {
1051
1150
  if (picker.options.minuteStepping !== 1) {
1052
1151
  var mDate = pMoment(),
1053
1152
  rInterval = picker.options.minuteStepping;
1054
- mDate.minutes((Math.round(mDate.minutes() / rInterval) * rInterval) % 60)
1055
- .seconds(0);
1056
- picker.setValue(mDate.format(picker.format))
1153
+ mDate.minutes((Math.round(mDate.minutes() / rInterval) * rInterval) % 60).seconds(0);
1154
+ picker.setValue(mDate.format(picker.format));
1057
1155
  } else {
1058
- picker.setValue(pMoment().format(picker.format))
1156
+ picker.setValue(pMoment().format(picker.format));
1059
1157
  }
1060
- };
1158
+ notifyChange('', e.type);
1159
+ }
1061
1160
  }
1062
- if (picker.widget.hasClass("picker-open")) {
1063
- picker.widget.hide();
1064
- picker.widget.removeClass("picker-open");
1161
+ if (picker.widget.hasClass('picker-open')) {
1162
+ picker.widget.hide();
1163
+ picker.widget.removeClass('picker-open');
1065
1164
  }
1066
1165
  else {
1067
- picker.widget.show();
1068
- picker.widget.addClass("picker-open");
1166
+ picker.widget.show();
1167
+ picker.widget.addClass('picker-open');
1069
1168
  }
1070
1169
  picker.height = picker.component ? picker.component.outerHeight() : picker.element.outerHeight();
1071
1170
  place();
@@ -1077,36 +1176,40 @@ THE SOFTWARE.
1077
1176
  if (e) {
1078
1177
  stopEvent(e);
1079
1178
  }
1080
- },
1179
+ };
1081
1180
 
1082
1181
  picker.disable = function () {
1083
1182
  var input = picker.element.find('input');
1084
- if (input.prop('disabled')) return;
1085
-
1183
+ if (input.prop('disabled')) {
1184
+ return;
1185
+ }
1086
1186
  input.prop('disabled', true);
1087
1187
  detachDatePickerEvents();
1088
- },
1188
+ };
1089
1189
 
1090
1190
  picker.enable = function () {
1091
1191
  var input = picker.element.find('input');
1092
- if (!input.prop('disabled')) return;
1093
-
1192
+ if (!input.prop('disabled')) {
1193
+ return;
1194
+ }
1094
1195
  input.prop('disabled', false);
1095
1196
  attachDatePickerEvents();
1096
- },
1197
+ };
1097
1198
 
1098
1199
  picker.hide = function (event) {
1099
- if (event && $(event.target).is(picker.element.attr("id")))
1200
+ if (event && $(event.target).is('#' + picker.element.attr('id'))) {
1100
1201
  return;
1202
+ }
1101
1203
  // Ignore event if in the middle of a picker transition
1102
1204
  var collapse = picker.widget.find('.collapse'), i, collapseData;
1103
1205
  for (i = 0; i < collapse.length; i++) {
1104
1206
  collapseData = collapse.eq(i).data('collapse');
1105
- if (collapseData && collapseData.transitioning)
1207
+ if (collapseData && collapseData.transitioning) {
1106
1208
  return;
1209
+ }
1107
1210
  }
1108
1211
  picker.widget.hide();
1109
- picker.widget.removeClass("picker-open");
1212
+ picker.widget.removeClass('picker-open');
1110
1213
  picker.viewMode = picker.startViewMode;
1111
1214
  showMode();
1112
1215
  picker.element.trigger({
@@ -1114,33 +1217,37 @@ THE SOFTWARE.
1114
1217
  date: pMoment(picker.date)
1115
1218
  });
1116
1219
  detachDatePickerGlobalEvents();
1117
- },
1220
+ };
1118
1221
 
1119
1222
  picker.setValue = function (newDate) {
1120
- pMoment.lang(picker.options.language);
1223
+ pMoment.locale(picker.options.language);
1121
1224
  if (!newDate) {
1122
1225
  picker.unset = true;
1123
1226
  set();
1124
1227
  } else {
1125
1228
  picker.unset = false;
1126
1229
  }
1127
- if (!pMoment.isMoment(newDate)) newDate = (newDate instanceof Date) ? pMoment(newDate) : pMoment(newDate, picker.format);
1230
+ if (!pMoment.isMoment(newDate)) {
1231
+ newDate = (newDate instanceof Date) ? pMoment(newDate) : pMoment(newDate, picker.format, picker.options.useStrict);
1232
+ }
1128
1233
  if (newDate.isValid()) {
1129
1234
  picker.date = newDate;
1130
1235
  set();
1131
- picker.viewDate = pMoment({ y: picker.date.year(), M: picker.date.month() });
1236
+ picker.viewDate = pMoment({y: picker.date.year(), M: picker.date.month()});
1132
1237
  fillDate();
1133
1238
  fillTime();
1134
1239
  }
1135
1240
  else {
1136
1241
  notifyError(newDate);
1137
1242
  }
1138
- },
1243
+ };
1139
1244
 
1140
1245
  picker.getDate = function () {
1141
- if (picker.unset) return null;
1142
- return picker.date;
1143
- },
1246
+ if (picker.unset) {
1247
+ return null;
1248
+ }
1249
+ return pMoment(picker.date);
1250
+ };
1144
1251
 
1145
1252
  picker.setDate = function (date) {
1146
1253
  var oldDate = pMoment(picker.date);
@@ -1149,28 +1256,49 @@ THE SOFTWARE.
1149
1256
  } else {
1150
1257
  picker.setValue(date);
1151
1258
  }
1152
- notifyChange(oldDate, "function");
1153
- },
1259
+ notifyChange(oldDate, 'function');
1260
+ };
1154
1261
 
1155
1262
  picker.setDisabledDates = function (dates) {
1156
1263
  picker.options.disabledDates = indexGivenDates(dates);
1157
- if (picker.viewDate) update();
1158
- },
1264
+ if (picker.viewDate) {
1265
+ update();
1266
+ }
1267
+ };
1268
+
1159
1269
  picker.setEnabledDates = function (dates) {
1160
1270
  picker.options.enabledDates = indexGivenDates(dates);
1161
- if (picker.viewDate) update();
1162
- },
1271
+ if (picker.viewDate) {
1272
+ update();
1273
+ }
1274
+ };
1163
1275
 
1164
1276
  picker.setMaxDate = function (date) {
1165
- if (date == undefined) return;
1166
- picker.options.maxDate = pMoment(date);
1167
- if (picker.viewDate) update();
1168
- },
1277
+ if (date === undefined) {
1278
+ return;
1279
+ }
1280
+ if (pMoment.isMoment(date) || date instanceof Date) {
1281
+ picker.options.maxDate = pMoment(date);
1282
+ } else {
1283
+ picker.options.maxDate = pMoment(date, picker.format, picker.options.useStrict);
1284
+ }
1285
+ if (picker.viewDate) {
1286
+ update();
1287
+ }
1288
+ };
1169
1289
 
1170
1290
  picker.setMinDate = function (date) {
1171
- if (date == undefined) return;
1172
- picker.options.minDate = pMoment(date);
1173
- if (picker.viewDate) update();
1291
+ if (date === undefined) {
1292
+ return;
1293
+ }
1294
+ if (pMoment.isMoment(date) || date instanceof Date) {
1295
+ picker.options.minDate = pMoment(date);
1296
+ } else {
1297
+ picker.options.minDate = pMoment(date, picker.format, picker.options.useStrict);
1298
+ }
1299
+ if (picker.viewDate) {
1300
+ update();
1301
+ }
1174
1302
  };
1175
1303
 
1176
1304
  init();
@@ -1179,10 +1307,12 @@ THE SOFTWARE.
1179
1307
  $.fn.datetimepicker = function (options) {
1180
1308
  return this.each(function () {
1181
1309
  var $this = $(this), data = $this.data('DateTimePicker');
1182
- if (!data) $this.data('DateTimePicker', new DateTimePicker(this, options));
1310
+ if (!data) {
1311
+ $this.data('DateTimePicker', new DateTimePicker(this, options));
1312
+ }
1183
1313
  });
1184
1314
  };
1185
-
1315
+
1186
1316
  $.fn.datetimepicker.defaults = {
1187
1317
  pickDate: true,
1188
1318
  pickTime: true,
@@ -1190,19 +1320,19 @@ THE SOFTWARE.
1190
1320
  useSeconds: false,
1191
1321
  useCurrent: true,
1192
1322
  minuteStepping: 1,
1193
- minDate: new pMoment({ y: 1900 }),
1194
- maxDate: new pMoment().add(100, "y"),
1323
+ minDate: pMoment({y: 1900}),
1324
+ maxDate: pMoment().add(100, 'y'),
1195
1325
  showToday: true,
1196
1326
  collapse: true,
1197
- language: "en",
1198
- defaultDate: "",
1327
+ language: 'en',
1328
+ defaultDate: '',
1199
1329
  disabledDates: false,
1200
1330
  enabledDates: false,
1201
1331
  icons: {},
1202
1332
  useStrict: false,
1203
- direction: "auto",
1333
+ direction: 'auto',
1204
1334
  sideBySide: false,
1205
- daysOfWeekDisabled: false
1335
+ daysOfWeekDisabled: false,
1336
+ widgetParent: false
1206
1337
  };
1207
-
1208
1338
  }));