bootstrap3-datetimepicker-rails 3.0.0.2 → 3.0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/lib/bootstrap3-datetimepicker-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-datetimepicker.js +476 -346
- data/vendor/assets/javascripts/bootstrap-datetimepicker.min.js +1 -105
- data/vendor/assets/stylesheets/bootstrap-datetimepicker.css +6 -5
- data/vendor/assets/stylesheets/bootstrap-datetimepicker.min.css +2 -1
- metadata +8 -69
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ar-ma.js +0 -56
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ar.js +0 -56
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.bg.js +0 -86
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.br.js +0 -107
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.bs.js +0 -139
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.by.js +0 -153
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ca.js +0 -66
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.cs.js +0 -155
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.cv.js +0 -59
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.da.js +0 -56
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.de.js +0 -71
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.el.js +0 -79
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.en-au.js +0 -62
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.en-ca.js +0 -59
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.en-gb.js +0 -63
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.eo.js +0 -65
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.es.js +0 -66
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.et.js +0 -60
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.eu.js +0 -60
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fa.js +0 -97
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fi.js +0 -103
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fr-ca.js +0 -54
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.fr.js +0 -58
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.gl.js +0 -71
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.he.js +0 -77
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hi.js +0 -105
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hr.js +0 -140
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.hu.js +0 -98
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.id.js +0 -67
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.is.js +0 -124
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.it.js +0 -59
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ja.js +0 -58
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ka.js +0 -108
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ko.js +0 -56
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.lt.js +0 -118
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.lv.js +0 -77
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ml.js +0 -64
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.mr.js +0 -104
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ms-my.js +0 -66
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nb.js +0 -57
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ne.js +0 -105
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nl.js +0 -67
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.nn.js +0 -56
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pl.js +0 -98
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pt-BR.js +0 -56
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.pt.js +0 -60
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ro.js +0 -56
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.ru.js +0 -163
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sk.js +0 -156
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sl.js +0 -144
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sq.js +0 -57
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.sv.js +0 -63
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.th.js +0 -58
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tr.js +0 -93
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tzm-la.js +0 -55
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.tzm.js +0 -55
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.uk.js +0 -157
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.uz.js +0 -55
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.vn.js +0 -62
- data/vendor/assets/javascripts/locales/bootstrap-datetimepicker.zh-CN.js +0 -108
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5ff932fd4a46d57a323f954467d1b90917653ca
|
4
|
+
data.tar.gz: f5fdbe7ac674615c373ecaf4fbbe1cbda76c7da1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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', '
|
17
|
-
gem 'bootstrap3-datetimepicker-rails', '~> 3.0.
|
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
|
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
|
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
|
/*
|
2
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
69
|
+
dDate,
|
69
70
|
|
70
|
-
|
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.
|
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()
|
90
|
-
picker.component = picker.element.find(
|
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
|
-
|
101
|
+
localeData = pMoment().localeData();
|
99
102
|
|
100
103
|
if (!picker.format) {
|
101
|
-
picker.format = (picker.options.pickDate ? longDateFormat
|
102
|
-
if (picker.options.pickDate && picker.options.pickTime)
|
103
|
-
|
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 (
|
106
|
-
picker.format = picker.format.split(
|
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(
|
118
|
+
picker.use24hours = picker.format.toLowerCase().indexOf('a') < 1;
|
114
119
|
|
115
|
-
if (picker.component)
|
120
|
+
if (picker.component) {
|
121
|
+
icon = picker.component.find('span');
|
122
|
+
}
|
116
123
|
|
117
124
|
if (picker.options.pickTime) {
|
118
|
-
if (icon)
|
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.
|
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 !==
|
192
|
+
if (picker.options.defaultDate !== '' && getPickerInput().val() === '') {
|
193
|
+
picker.setValue(picker.options.defaultDate);
|
194
|
+
}
|
177
195
|
if (picker.options.minuteStepping !== 1) {
|
178
|
-
|
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
|
-
|
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)))
|
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
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
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.
|
367
|
+
pMoment.locale(picker.options.language);
|
308
368
|
var dateStr = newDate;
|
309
369
|
if (!dateStr) {
|
310
370
|
dateStr = getPickerInput().val();
|
311
|
-
if (dateStr)
|
312
|
-
|
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(
|
378
|
+
picker.viewDate = pMoment(picker.date).startOf('month');
|
315
379
|
fillDate();
|
316
380
|
fillTime();
|
317
381
|
},
|
318
382
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
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.
|
340
|
-
var html = '', i
|
341
|
-
|
342
|
-
html += '<span class="month">' + monthsShort[i
|
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)
|
349
|
-
|
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(
|
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
|
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
|
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,
|
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()
|
449
|
+
if (prevMonth.year() < year || (prevMonth.year() === year && prevMonth.month() < month)) {
|
384
450
|
clsName += ' old';
|
385
|
-
} else if (prevMonth.year() > year || (prevMonth.year()
|
451
|
+
} else if (prevMonth.year() > year || (prevMonth.year() === year && prevMonth.month() > month)) {
|
386
452
|
clsName += ' new';
|
387
453
|
}
|
388
|
-
if (prevMonth.isSame(pMoment({
|
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
|
401
|
-
if (prevMonth.day()
|
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,
|
476
|
+
prevMonth.add(1, 'd');
|
411
477
|
|
412
|
-
if (currentDate
|
413
|
-
|
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()
|
418
|
-
|
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
|
495
|
+
if ((year === startYear && startMonth > i) || (year < startYear)) {
|
430
496
|
$(months[i]).addClass('disabled');
|
431
|
-
} else if ((year
|
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.
|
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
|
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)
|
586
|
+
if (!picker.date) {
|
587
|
+
return;
|
588
|
+
}
|
519
589
|
var timeComponents = picker.widget.find('.timepicker span[data-time-component]'),
|
520
|
-
|
521
|
-
|
590
|
+
hour = picker.date.hours(),
|
591
|
+
period = picker.date.format('A');
|
522
592
|
if (!picker.use24hours) {
|
523
|
-
if (hour
|
524
|
-
|
525
|
-
else if (hour
|
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')
|
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
|
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
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
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
|
-
|
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.
|
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)
|
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('
|
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')
|
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.
|
835
|
-
var formatted = ''
|
836
|
-
if (!picker.unset)
|
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)
|
925
|
+
if (!picker.options.pickTime) {
|
926
|
+
picker.hide();
|
927
|
+
}
|
840
928
|
},
|
841
929
|
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
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.
|
869
|
-
var maxDate = picker.options.maxDate
|
870
|
-
|
871
|
-
|
872
|
-
if(timeUnit) {
|
873
|
-
maxDate =
|
874
|
-
minDate =
|
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))
|
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[
|
973
|
+
return picker.options.disabledDates[date.format('YYYY-MM-DD')] === true;
|
882
974
|
},
|
883
975
|
isInEnableDates = function (date) {
|
884
|
-
pMoment.
|
976
|
+
pMoment.locale(picker.options.language);
|
885
977
|
if (picker.options.enabledDates === false) {
|
886
978
|
return true;
|
887
979
|
}
|
888
|
-
return picker.options.enabledDates[
|
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
|
-
|
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(
|
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)
|
913
|
-
|
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
|
-
}
|
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
|
-
|
954
|
-
|
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
|
-
|
1066
|
+
}
|
1067
|
+
],
|
1068
|
+
headTemplate:
|
971
1069
|
'<thead>' +
|
972
|
-
|
973
|
-
|
974
|
-
|
1070
|
+
'<tr>' +
|
1071
|
+
'<th class="prev">‹</th><th colspan="5" class="switch"></th><th class="next">›</th>' +
|
1072
|
+
'</tr>' +
|
975
1073
|
'</thead>',
|
976
|
-
|
977
|
-
|
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
|
-
|
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
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
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
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
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
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
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
|
-
|
1025
|
-
|
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
|
-
|
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(
|
1063
|
-
|
1064
|
-
|
1161
|
+
if (picker.widget.hasClass('picker-open')) {
|
1162
|
+
picker.widget.hide();
|
1163
|
+
picker.widget.removeClass('picker-open');
|
1065
1164
|
}
|
1066
1165
|
else {
|
1067
|
-
|
1068
|
-
|
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'))
|
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'))
|
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(
|
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(
|
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.
|
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))
|
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({
|
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)
|
1142
|
-
|
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,
|
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)
|
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)
|
1162
|
-
|
1271
|
+
if (picker.viewDate) {
|
1272
|
+
update();
|
1273
|
+
}
|
1274
|
+
};
|
1163
1275
|
|
1164
1276
|
picker.setMaxDate = function (date) {
|
1165
|
-
if (date
|
1166
|
-
|
1167
|
-
|
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
|
1172
|
-
|
1173
|
-
|
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)
|
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:
|
1194
|
-
maxDate:
|
1323
|
+
minDate: pMoment({y: 1900}),
|
1324
|
+
maxDate: pMoment().add(100, 'y'),
|
1195
1325
|
showToday: true,
|
1196
1326
|
collapse: true,
|
1197
|
-
language:
|
1198
|
-
defaultDate:
|
1327
|
+
language: 'en',
|
1328
|
+
defaultDate: '',
|
1199
1329
|
disabledDates: false,
|
1200
1330
|
enabledDates: false,
|
1201
1331
|
icons: {},
|
1202
1332
|
useStrict: false,
|
1203
|
-
direction:
|
1333
|
+
direction: 'auto',
|
1204
1334
|
sideBySide: false,
|
1205
|
-
daysOfWeekDisabled: false
|
1335
|
+
daysOfWeekDisabled: false,
|
1336
|
+
widgetParent: false
|
1206
1337
|
};
|
1207
|
-
|
1208
1338
|
}));
|