jquery-timepicker-rails 1.11.4 → 1.11.10
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a397fd3da149e1039b92dc3886bf3849df093f1
|
4
|
+
data.tar.gz: ac9349fbcbc15cf5c9b44cb9ffe0e0042810677f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66686385c46b9dbff562210de8a3020c370cff440d88033ba56fb6e4c7d390afcf44e29ca5f95cb55f9821936c1d9b2da42c64713cdb2b7052d9948407b78cf0
|
7
|
+
data.tar.gz: '0308a662a4dec4d0b66faa483fb03b2425a5bbd346cc62ff29d070cfc2185480b4e1f6da7d463cb048e513c0059758a9a591615fa9c898d3d64e53f49fcff7c4'
|
@@ -1,347 +1,361 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
/*!
|
2
|
+
* datepair.js v0.4.15 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
|
3
|
+
* Copyright (c) 2016 Jon Thornton - http://jonthornton.github.com/Datepair.js
|
4
|
+
* License: MIT
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function(window, document) {
|
8
|
+
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
var _ONE_DAY = 86400000;
|
12
|
+
var jq = window.Zepto || window.jQuery;
|
13
|
+
|
14
|
+
function simpleExtend(obj1, obj2) {
|
15
|
+
var out = obj2 || {};
|
16
|
+
|
17
|
+
for (var i in obj1) {
|
18
|
+
if (!(i in out)) {
|
19
|
+
out[i] = obj1[i];
|
20
|
+
}
|
10
21
|
}
|
22
|
+
|
23
|
+
return out;
|
11
24
|
}
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
event.initCustomEvent(eventName, true, true, {});
|
24
|
-
el.dispatchEvent(event);
|
25
|
+
|
26
|
+
// IE's custom event support is totally borked.
|
27
|
+
// Use jQuery if possible
|
28
|
+
function triggerSimpleCustomEvent(el, eventName) {
|
29
|
+
if (jq) {
|
30
|
+
jq(el).trigger(eventName);
|
31
|
+
} else {
|
32
|
+
var event = document.createEvent('CustomEvent');
|
33
|
+
event.initCustomEvent(eventName, true, true, {});
|
34
|
+
el.dispatchEvent(event);
|
35
|
+
}
|
25
36
|
}
|
26
|
-
|
27
|
-
|
28
|
-
//
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
37
|
+
|
38
|
+
// el.classList not supported by < IE10
|
39
|
+
// use jQuery if available
|
40
|
+
function hasClass(el, className) {
|
41
|
+
if (jq) {
|
42
|
+
return jq(el).hasClass(className);
|
43
|
+
} else {
|
44
|
+
return el.classList.contains(className);
|
45
|
+
}
|
35
46
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
|
48
|
+
function Datepair(container, options) {
|
49
|
+
this.dateDelta = null;
|
50
|
+
this.timeDelta = null;
|
51
|
+
this._defaults = {
|
52
|
+
startClass: 'start',
|
53
|
+
endClass: 'end',
|
54
|
+
timeClass: 'time',
|
55
|
+
dateClass: 'date',
|
56
|
+
defaultDateDelta: 0,
|
57
|
+
defaultTimeDelta: 3600000,
|
58
|
+
anchor: 'start',
|
59
|
+
|
60
|
+
// defaults for jquery-timepicker; override when using other input widgets
|
61
|
+
parseTime: function(input){
|
62
|
+
return jq(input).timepicker('getTime');
|
63
|
+
},
|
64
|
+
updateTime: function(input, dateObj){
|
65
|
+
jq(input).timepicker('setTime', dateObj);
|
66
|
+
},
|
67
|
+
setMinTime: function(input, dateObj){
|
68
|
+
jq(input).timepicker('option', 'minTime', dateObj);
|
69
|
+
},
|
70
|
+
|
71
|
+
// defaults for bootstrap datepicker; override when using other input widgets
|
72
|
+
parseDate: function(input){
|
73
|
+
return input.value && jq(input).datepicker('getDate');
|
74
|
+
},
|
75
|
+
updateDate: function(input, dateObj){
|
76
|
+
jq(input).datepicker('update', dateObj);
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
this.container = container;
|
81
|
+
this.settings = simpleExtend(this._defaults, options);
|
82
|
+
|
83
|
+
this.startDateInput = this.container.querySelector('.'+this.settings.startClass+'.'+this.settings.dateClass);
|
84
|
+
this.endDateInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.dateClass);
|
85
|
+
this.startTimeInput = this.container.querySelector('.'+this.settings.startClass+'.'+this.settings.timeClass);
|
86
|
+
this.endTimeInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.timeClass);
|
87
|
+
|
88
|
+
// initialize date and time deltas
|
89
|
+
this.refresh();
|
90
|
+
|
91
|
+
// init starts here
|
92
|
+
this._bindChangeHandler();
|
93
|
+
}
|
94
|
+
|
95
|
+
Datepair.prototype = {
|
96
|
+
constructor: Datepair,
|
97
|
+
|
98
|
+
option: function(key, value)
|
99
|
+
{
|
100
|
+
if (typeof key == 'object') {
|
101
|
+
this.settings = simpleExtend(this.settings, key);
|
102
|
+
|
103
|
+
} else if (typeof key == 'string' && typeof value != 'undefined') {
|
104
|
+
this.settings[key] = value;
|
105
|
+
|
106
|
+
} else if (typeof key == 'string') {
|
107
|
+
return this.settings[key];
|
108
|
+
}
|
109
|
+
|
110
|
+
this._updateEndMintime();
|
53
111
|
},
|
54
|
-
|
55
|
-
|
112
|
+
|
113
|
+
getTimeDiff: function()
|
114
|
+
{
|
115
|
+
// due to the fact that times can wrap around, timeDiff for any
|
116
|
+
// time-only pair will always be >= 0
|
117
|
+
var delta = this.dateDelta + this.timeDelta;
|
118
|
+
if (delta < 0 && (!this.startDateInput || !this.endDateInput) ) {
|
119
|
+
delta += _ONE_DAY;
|
120
|
+
}
|
121
|
+
|
122
|
+
return delta;
|
56
123
|
},
|
57
|
-
|
58
|
-
|
124
|
+
|
125
|
+
refresh: function()
|
126
|
+
{
|
127
|
+
if (this.startDateInput && this.startDateInput.value && this.endDateInput && this.endDateInput.value) {
|
128
|
+
var startDate = this.settings.parseDate(this.startDateInput);
|
129
|
+
var endDate = this.settings.parseDate(this.endDateInput);
|
130
|
+
if (startDate && endDate) {
|
131
|
+
this.dateDelta = endDate.getTime() - startDate.getTime();
|
132
|
+
}
|
133
|
+
}
|
134
|
+
if (this.startTimeInput && this.startTimeInput.value && this.endTimeInput && this.endTimeInput.value) {
|
135
|
+
var startTime = this.settings.parseTime(this.startTimeInput);
|
136
|
+
var endTime = this.settings.parseTime(this.endTimeInput);
|
137
|
+
if (startTime && endTime) {
|
138
|
+
this.timeDelta = endTime.getTime() - startTime.getTime();
|
139
|
+
this._updateEndMintime();
|
140
|
+
}
|
141
|
+
}
|
59
142
|
},
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
143
|
+
|
144
|
+
remove: function()
|
145
|
+
{
|
146
|
+
this._unbindChangeHandler();
|
64
147
|
},
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
if (this.startDateInput && this.startDateInput.value && this.endDateInput && this.endDateInput.value) {
|
148
|
+
|
149
|
+
_bindChangeHandler: function(){
|
150
|
+
// addEventListener doesn't work with synthetic "change" events
|
151
|
+
// fired by jQuery's trigger() functioin. If jQuery is present,
|
152
|
+
// use that for event binding
|
153
|
+
if (jq) {
|
154
|
+
jq(this.container).on('change.datepair', jq.proxy(this.handleEvent, this));
|
155
|
+
} else {
|
156
|
+
this.container.addEventListener('change', this, false);
|
157
|
+
}
|
158
|
+
},
|
159
|
+
|
160
|
+
_unbindChangeHandler: function(){
|
161
|
+
if (jq) {
|
162
|
+
jq(this.container).off('change.datepair');
|
163
|
+
} else {
|
164
|
+
this.container.removeEventListener('change', this, false);
|
165
|
+
}
|
166
|
+
},
|
167
|
+
|
168
|
+
// This function will be called when passing 'this' to addEventListener
|
169
|
+
handleEvent: function(e){
|
170
|
+
// temporarily unbind the change handler to prevent triggering this
|
171
|
+
// if we update other inputs
|
172
|
+
this._unbindChangeHandler();
|
173
|
+
|
174
|
+
if (hasClass(e.target, this.settings.dateClass)) {
|
175
|
+
if (e.target.value != '') {
|
176
|
+
this._dateChanged(e.target);
|
177
|
+
this._timeChanged(e.target);
|
178
|
+
} else {
|
179
|
+
this.dateDelta = null;
|
180
|
+
}
|
181
|
+
|
182
|
+
} else if (hasClass(e.target, this.settings.timeClass)) {
|
183
|
+
if (e.target.value != '') {
|
184
|
+
this._timeChanged(e.target);
|
185
|
+
} else {
|
186
|
+
this.timeDelta = null;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
this._validateRanges();
|
191
|
+
this._updateEndMintime();
|
192
|
+
this._bindChangeHandler();
|
193
|
+
},
|
194
|
+
|
195
|
+
_dateChanged: function(target){
|
196
|
+
if (!this.startDateInput || !this.endDateInput) {
|
197
|
+
return;
|
198
|
+
}
|
199
|
+
|
118
200
|
var startDate = this.settings.parseDate(this.startDateInput);
|
119
201
|
var endDate = this.settings.parseDate(this.endDateInput);
|
120
|
-
|
121
|
-
|
202
|
+
|
203
|
+
if (!startDate || !endDate) {
|
204
|
+
if (this.settings.defaultDateDelta !== null) {
|
205
|
+
if (startDate) {
|
206
|
+
var newEnd = new Date(startDate.getTime() + this.settings.defaultDateDelta * _ONE_DAY);
|
207
|
+
this.settings.updateDate(this.endDateInput, newEnd);
|
208
|
+
|
209
|
+
} else if (endDate) {
|
210
|
+
var newStart = new Date(endDate.getTime() - this.settings.defaultDateDelta * _ONE_DAY);
|
211
|
+
this.settings.updateDate(this.startDateInput, newStart);
|
212
|
+
}
|
213
|
+
|
214
|
+
this.dateDelta = this.settings.defaultDateDelta * _ONE_DAY;
|
215
|
+
} else {
|
216
|
+
this.dateDelta = null;
|
217
|
+
}
|
218
|
+
|
219
|
+
return;
|
122
220
|
}
|
123
|
-
|
124
|
-
|
221
|
+
|
222
|
+
if (this.settings.anchor == 'start' && hasClass(target, this.settings.startClass)) {
|
223
|
+
var newDate = new Date(startDate.getTime() + this.dateDelta);
|
224
|
+
this.settings.updateDate(this.endDateInput, newDate);
|
225
|
+
} else if (this.settings.anchor == 'end' && hasClass(target, this.settings.endClass)) {
|
226
|
+
var newDate = new Date(endDate.getTime() - this.dateDelta);
|
227
|
+
this.settings.updateDate(this.startDateInput, newDate);
|
228
|
+
} else {
|
229
|
+
if (endDate < startDate) {
|
230
|
+
var otherInput = hasClass(target, this.settings.startClass) ? this.endDateInput : this.startDateInput;
|
231
|
+
var selectedDate = this.settings.parseDate(target);
|
232
|
+
this.dateDelta = 0;
|
233
|
+
this.settings.updateDate(otherInput, selectedDate);
|
234
|
+
} else {
|
235
|
+
this.dateDelta = endDate.getTime() - startDate.getTime();
|
236
|
+
}
|
237
|
+
}
|
238
|
+
},
|
239
|
+
|
240
|
+
_timeChanged: function(target){
|
241
|
+
if (!this.startTimeInput || !this.endTimeInput) {
|
242
|
+
return;
|
243
|
+
}
|
244
|
+
|
125
245
|
var startTime = this.settings.parseTime(this.startTimeInput);
|
126
246
|
var endTime = this.settings.parseTime(this.endTimeInput);
|
127
|
-
|
128
|
-
|
129
|
-
this.
|
247
|
+
|
248
|
+
if (!startTime || !endTime) {
|
249
|
+
if (this.settings.defaultTimeDelta !== null) {
|
250
|
+
if (startTime) {
|
251
|
+
var newEnd = new Date(startTime.getTime() + this.settings.defaultTimeDelta);
|
252
|
+
this.settings.updateTime(this.endTimeInput, newEnd);
|
253
|
+
} else if (endTime) {
|
254
|
+
var newStart = new Date(endTime.getTime() - this.settings.defaultTimeDelta);
|
255
|
+
this.settings.updateTime(this.startTimeInput, newStart);
|
256
|
+
}
|
257
|
+
|
258
|
+
this.timeDelta = this.settings.defaultTimeDelta;
|
259
|
+
} else {
|
260
|
+
this.timeDelta = null;
|
261
|
+
}
|
262
|
+
|
263
|
+
return;
|
130
264
|
}
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
jq(this.container).on('change.datepair', jq.proxy(this.handleEvent, this));
|
145
|
-
} else {
|
146
|
-
this.container.addEventListener('change', this, false);
|
147
|
-
}
|
148
|
-
},
|
149
|
-
|
150
|
-
_unbindChangeHandler: function(){
|
151
|
-
if (jq) {
|
152
|
-
jq(this.container).off('change.datepair');
|
153
|
-
} else {
|
154
|
-
this.container.removeEventListener('change', this, false);
|
155
|
-
}
|
156
|
-
},
|
157
|
-
|
158
|
-
// This function will be called when passing 'this' to addEventListener
|
159
|
-
handleEvent: function(e){
|
160
|
-
// temporarily unbind the change handler to prevent triggering this
|
161
|
-
// if we update other inputs
|
162
|
-
this._unbindChangeHandler();
|
163
|
-
|
164
|
-
if (hasClass(e.target, this.settings.dateClass)) {
|
165
|
-
if (e.target.value != '') {
|
166
|
-
this._dateChanged(e.target);
|
167
|
-
this._timeChanged(e.target);
|
265
|
+
|
266
|
+
if (this.settings.anchor == 'start' && hasClass(target, this.settings.startClass)) {
|
267
|
+
var newTime = new Date(startTime.getTime() + this.timeDelta);
|
268
|
+
this.settings.updateTime(this.endTimeInput, newTime);
|
269
|
+
endTime = this.settings.parseTime(this.endTimeInput);
|
270
|
+
|
271
|
+
this._doMidnightRollover(startTime, endTime);
|
272
|
+
} else if (this.settings.anchor == 'end' && hasClass(target, this.settings.endClass)) {
|
273
|
+
var newTime = new Date(endTime.getTime() - this.timeDelta);
|
274
|
+
this.settings.updateTime(this.startTimeInput, newTime);
|
275
|
+
startTime = this.settings.parseTime(this.startTimeInput);
|
276
|
+
|
277
|
+
this._doMidnightRollover(startTime, endTime);
|
168
278
|
} else {
|
169
|
-
this.
|
279
|
+
this._doMidnightRollover(startTime, endTime);
|
280
|
+
|
281
|
+
var startDate, endDate;
|
282
|
+
if (this.startDateInput && this.endDateInput) {
|
283
|
+
startDate = this.settings.parseDate(this.startDateInput);
|
284
|
+
endDate = this.settings.parseDate(this.endDateInput);
|
285
|
+
}
|
286
|
+
|
287
|
+
if ((+startDate == +endDate) && (endTime < startTime)) {
|
288
|
+
var thisInput = hasClass(target, this.settings.endClass) ? this.endTimeInput : this.startTimeInput;
|
289
|
+
var otherInput = hasClass(target, this.settings.startClass) ? this.endTimeInput : this.startTimeInput;
|
290
|
+
var selectedTime = this.settings.parseTime(thisInput);
|
291
|
+
this.timeDelta = 0;
|
292
|
+
this.settings.updateTime(otherInput, selectedTime);
|
293
|
+
} else {
|
294
|
+
this.timeDelta = endTime.getTime() - startTime.getTime();
|
295
|
+
}
|
170
296
|
}
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
297
|
+
|
298
|
+
|
299
|
+
},
|
300
|
+
|
301
|
+
_doMidnightRollover: function(startTime, endTime) {
|
302
|
+
if (!this.startDateInput || !this.endDateInput) {
|
303
|
+
return;
|
177
304
|
}
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
var newEnd = new Date(startDate.getTime() + this.settings.defaultDateDelta * _ONE_DAY);
|
197
|
-
this.settings.updateDate(this.endDateInput, newEnd);
|
198
|
-
|
199
|
-
} else if (endDate) {
|
200
|
-
var newStart = new Date(endDate.getTime() - this.settings.defaultDateDelta * _ONE_DAY);
|
201
|
-
this.settings.updateDate(this.startDateInput, newStart);
|
305
|
+
|
306
|
+
var endDate = this.settings.parseDate(this.endDateInput);
|
307
|
+
var startDate = this.settings.parseDate(this.startDateInput);
|
308
|
+
var newDelta = endTime.getTime() - startTime.getTime();
|
309
|
+
var offset = (endTime < startTime) ? _ONE_DAY : -1 * _ONE_DAY;
|
310
|
+
|
311
|
+
if (this.dateDelta !== null
|
312
|
+
&& this.dateDelta + this.timeDelta <= _ONE_DAY
|
313
|
+
&& this.dateDelta + newDelta != 0
|
314
|
+
&& (offset > 0 || this.dateDelta != 0)
|
315
|
+
&& ((newDelta >= 0 && this.timeDelta < 0) || (newDelta < 0 && this.timeDelta >= 0))) {
|
316
|
+
|
317
|
+
if (this.settings.anchor == 'start') {
|
318
|
+
this.settings.updateDate(this.endDateInput, new Date(endDate.getTime() + offset));
|
319
|
+
this._dateChanged(this.endDateInput);
|
320
|
+
} else if (this.settings.anchor == 'end') {
|
321
|
+
this.settings.updateDate(this.startDateInput, new Date(startDate.getTime() - offset));
|
322
|
+
this._dateChanged(this.startDateInput);
|
202
323
|
}
|
203
|
-
|
204
|
-
this.dateDelta = this.settings.defaultDateDelta * _ONE_DAY;
|
205
|
-
} else {
|
206
|
-
this.dateDelta = null;
|
207
324
|
}
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
this.settings.updateDate(this.startDateInput, newDate);
|
218
|
-
} else {
|
219
|
-
if (endDate < startDate) {
|
220
|
-
var otherInput = hasClass(target, this.settings.startClass) ? this.endDateInput : this.startDateInput;
|
221
|
-
var selectedDate = this.settings.parseDate(target);
|
222
|
-
this.dateDelta = 0;
|
223
|
-
this.settings.updateDate(otherInput, selectedDate);
|
224
|
-
} else {
|
225
|
-
this.dateDelta = endDate.getTime() - startDate.getTime();
|
325
|
+
this.timeDelta = newDelta;
|
326
|
+
},
|
327
|
+
|
328
|
+
_updateEndMintime: function(){
|
329
|
+
if (typeof this.settings.setMinTime != 'function') return;
|
330
|
+
|
331
|
+
var baseTime = null;
|
332
|
+
if (this.settings.anchor == 'start' && (!this.dateDelta || this.dateDelta < _ONE_DAY || (this.timeDelta && this.dateDelta + this.timeDelta < _ONE_DAY))) {
|
333
|
+
baseTime = this.settings.parseTime(this.startTimeInput);
|
226
334
|
}
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
var startTime = this.settings.parseTime(this.startTimeInput);
|
236
|
-
var endTime = this.settings.parseTime(this.endTimeInput);
|
237
|
-
|
238
|
-
if (!startTime || !endTime) {
|
239
|
-
if (this.settings.defaultTimeDelta !== null) {
|
240
|
-
if (startTime) {
|
241
|
-
var newEnd = new Date(startTime.getTime() + this.settings.defaultTimeDelta);
|
242
|
-
this.settings.updateTime(this.endTimeInput, newEnd);
|
243
|
-
} else if (endTime) {
|
244
|
-
var newStart = new Date(endTime.getTime() - this.settings.defaultTimeDelta);
|
245
|
-
this.settings.updateTime(this.startTimeInput, newStart);
|
246
|
-
}
|
247
|
-
|
248
|
-
this.timeDelta = this.settings.defaultTimeDelta;
|
249
|
-
} else {
|
250
|
-
this.timeDelta = null;
|
335
|
+
|
336
|
+
this.settings.setMinTime(this.endTimeInput, baseTime);
|
337
|
+
},
|
338
|
+
|
339
|
+
_validateRanges: function(){
|
340
|
+
if (this.startTimeInput && this.endTimeInput && this.timeDelta === null) {
|
341
|
+
triggerSimpleCustomEvent(this.container, 'rangeIncomplete');
|
342
|
+
return;
|
251
343
|
}
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
if (this.settings.anchor == 'start' && hasClass(target, this.settings.startClass)) {
|
257
|
-
var newTime = new Date(startTime.getTime() + this.timeDelta);
|
258
|
-
this.settings.updateTime(this.endTimeInput, newTime);
|
259
|
-
endTime = this.settings.parseTime(this.endTimeInput);
|
260
|
-
|
261
|
-
this._doMidnightRollover(startTime, endTime);
|
262
|
-
} else if (this.settings.anchor == 'end' && hasClass(target, this.settings.endClass)) {
|
263
|
-
var newTime = new Date(endTime.getTime() - this.timeDelta);
|
264
|
-
this.settings.updateTime(this.startTimeInput, newTime);
|
265
|
-
startTime = this.settings.parseTime(this.startTimeInput);
|
266
|
-
|
267
|
-
this._doMidnightRollover(startTime, endTime);
|
268
|
-
} else {
|
269
|
-
this._doMidnightRollover(startTime, endTime);
|
270
|
-
|
271
|
-
var startDate, endDate;
|
272
|
-
if (this.startDateInput && this.endDateInput) {
|
273
|
-
startDate = this.settings.parseDate(this.startDateInput);
|
274
|
-
endDate = this.settings.parseDate(this.endDateInput);
|
344
|
+
|
345
|
+
if (this.startDateInput && this.endDateInput && this.dateDelta === null) {
|
346
|
+
triggerSimpleCustomEvent(this.container, 'rangeIncomplete');
|
347
|
+
return;
|
275
348
|
}
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
var selectedTime = this.settings.parseTime(thisInput);
|
281
|
-
this.timeDelta = 0;
|
282
|
-
this.settings.updateTime(otherInput, selectedTime);
|
349
|
+
|
350
|
+
// due to the fact that times can wrap around, any time-only pair will be considered valid
|
351
|
+
if (!this.startDateInput || !this.endDateInput || this.dateDelta + this.timeDelta >= 0) {
|
352
|
+
triggerSimpleCustomEvent(this.container, 'rangeSelected');
|
283
353
|
} else {
|
284
|
-
this.
|
285
|
-
}
|
286
|
-
}
|
287
|
-
|
288
|
-
|
289
|
-
},
|
290
|
-
|
291
|
-
_doMidnightRollover: function(startTime, endTime) {
|
292
|
-
if (!this.startDateInput || !this.endDateInput) {
|
293
|
-
return;
|
294
|
-
}
|
295
|
-
|
296
|
-
var endDate = this.settings.parseDate(this.endDateInput);
|
297
|
-
var startDate = this.settings.parseDate(this.startDateInput);
|
298
|
-
var newDelta = endTime.getTime() - startTime.getTime();
|
299
|
-
var offset = (endTime < startTime) ? _ONE_DAY : -1 * _ONE_DAY;
|
300
|
-
|
301
|
-
if (this.dateDelta !== null
|
302
|
-
&& this.dateDelta + this.timeDelta <= _ONE_DAY
|
303
|
-
&& this.dateDelta + newDelta != 0
|
304
|
-
&& (offset > 0 || this.dateDelta != 0)
|
305
|
-
&& ((newDelta >= 0 && this.timeDelta < 0) || (newDelta < 0 && this.timeDelta >= 0))) {
|
306
|
-
|
307
|
-
if (this.settings.anchor == 'start') {
|
308
|
-
this.settings.updateDate(this.endDateInput, new Date(endDate.getTime() + offset));
|
309
|
-
this._dateChanged(this.endDateInput);
|
310
|
-
} else if (this.settings.anchor == 'end') {
|
311
|
-
this.settings.updateDate(this.startDateInput, new Date(startDate.getTime() - offset));
|
312
|
-
this._dateChanged(this.startDateInput);
|
354
|
+
triggerSimpleCustomEvent(this.container, 'rangeError');
|
313
355
|
}
|
314
356
|
}
|
315
|
-
|
316
|
-
},
|
317
|
-
|
318
|
-
_updateEndMintime: function(){
|
319
|
-
if (typeof this.settings.setMinTime != 'function') return;
|
320
|
-
|
321
|
-
var baseTime = null;
|
322
|
-
if (this.settings.anchor == 'start' && (!this.dateDelta || this.dateDelta < _ONE_DAY || (this.timeDelta && this.dateDelta + this.timeDelta < _ONE_DAY))) {
|
323
|
-
baseTime = this.settings.parseTime(this.startTimeInput);
|
324
|
-
}
|
325
|
-
|
326
|
-
this.settings.setMinTime(this.endTimeInput, baseTime);
|
327
|
-
},
|
328
|
-
|
329
|
-
_validateRanges: function(){
|
330
|
-
if (this.startTimeInput && this.endTimeInput && this.timeDelta === null) {
|
331
|
-
triggerSimpleCustomEvent(this.container, 'rangeIncomplete');
|
332
|
-
return;
|
333
|
-
}
|
357
|
+
};
|
334
358
|
|
335
|
-
|
336
|
-
triggerSimpleCustomEvent(this.container, 'rangeIncomplete');
|
337
|
-
return;
|
338
|
-
}
|
359
|
+
window.Datepair = Datepair;
|
339
360
|
|
340
|
-
|
341
|
-
if (!this.startDateInput || !this.endDateInput || this.dateDelta + this.timeDelta >= 0) {
|
342
|
-
triggerSimpleCustomEvent(this.container, 'rangeSelected');
|
343
|
-
} else {
|
344
|
-
triggerSimpleCustomEvent(this.container, 'rangeError');
|
345
|
-
}
|
346
|
-
}
|
347
|
-
};
|
361
|
+
}(window, document));
|
@@ -1,3 +1,9 @@
|
|
1
|
+
/*!
|
2
|
+
* datepair.js v0.4.15 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
|
3
|
+
* Copyright (c) 2016 Jon Thornton - http://jonthornton.github.com/Datepair.js
|
4
|
+
* License: MIT
|
5
|
+
*/
|
6
|
+
|
1
7
|
(function($) {
|
2
8
|
|
3
9
|
if(!$) {
|
@@ -20,6 +26,11 @@
|
|
20
26
|
$this.data('datepair', data);
|
21
27
|
}
|
22
28
|
|
29
|
+
if (option === 'remove') {
|
30
|
+
out = data['remove']();
|
31
|
+
$this.removeData('datepair', data);
|
32
|
+
}
|
33
|
+
|
23
34
|
if (typeof option === 'string') {
|
24
35
|
out = data[option]();
|
25
36
|
}
|
@@ -37,4 +48,4 @@
|
|
37
48
|
$this.datepair($this.data());
|
38
49
|
});
|
39
50
|
|
40
|
-
}(window.Zepto || window.jQuery));
|
51
|
+
}(window.Zepto || window.jQuery));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* jquery-timepicker v1.11.
|
2
|
+
* jquery-timepicker v1.11.10 - A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.
|
3
3
|
* Copyright (c) 2015 Jon Thornton - http://jonthornton.github.com/jquery-timepicker/
|
4
4
|
* License: MIT
|
5
5
|
*/
|
@@ -30,6 +30,58 @@
|
|
30
30
|
hrs: 'hrs'
|
31
31
|
};
|
32
32
|
|
33
|
+
var _DEFAULTS = {
|
34
|
+
appendTo: 'body',
|
35
|
+
className: null,
|
36
|
+
closeOnWindowScroll: false,
|
37
|
+
disableTextInput: false,
|
38
|
+
disableTimeRanges: [],
|
39
|
+
disableTouchKeyboard: false,
|
40
|
+
durationTime: null,
|
41
|
+
forceRoundTime: false,
|
42
|
+
maxTime: null,
|
43
|
+
minTime: null,
|
44
|
+
noneOption: false,
|
45
|
+
orientation: 'l',
|
46
|
+
roundingFunction: function(seconds, settings) {
|
47
|
+
if (seconds === null) {
|
48
|
+
return null;
|
49
|
+
} else if (typeof settings.step !== "number") {
|
50
|
+
// TODO: nearest fit irregular steps
|
51
|
+
return seconds;
|
52
|
+
} else {
|
53
|
+
var offset = seconds % (settings.step*60); // step is in minutes
|
54
|
+
|
55
|
+
var start = settings.minTime || 0;
|
56
|
+
|
57
|
+
// adjust offset by start mod step so that the offset is aligned not to 00:00 but to the start
|
58
|
+
offset -= start % (settings.step * 60);
|
59
|
+
|
60
|
+
if (offset >= settings.step*30) {
|
61
|
+
// if offset is larger than a half step, round up
|
62
|
+
seconds += (settings.step*60) - offset;
|
63
|
+
} else {
|
64
|
+
// round down
|
65
|
+
seconds -= offset;
|
66
|
+
}
|
67
|
+
|
68
|
+
return _moduloSeconds(seconds, settings);
|
69
|
+
}
|
70
|
+
},
|
71
|
+
scrollDefault: null,
|
72
|
+
selectOnBlur: false,
|
73
|
+
show2400: false,
|
74
|
+
showDuration: false,
|
75
|
+
showOn: ['click', 'focus'],
|
76
|
+
showOnFocus: true,
|
77
|
+
step: 30,
|
78
|
+
stopScrollPropagation: false,
|
79
|
+
timeFormat: 'g:ia',
|
80
|
+
typeaheadHighlight: true,
|
81
|
+
useSelect: false,
|
82
|
+
wrapHours: true
|
83
|
+
};
|
84
|
+
|
33
85
|
var methods = {
|
34
86
|
init: function(options)
|
35
87
|
{
|
@@ -39,13 +91,13 @@
|
|
39
91
|
|
40
92
|
// pick up settings from data attributes
|
41
93
|
var attributeOptions = [];
|
42
|
-
for (var key in
|
94
|
+
for (var key in _DEFAULTS) {
|
43
95
|
if (self.data(key)) {
|
44
96
|
attributeOptions[key] = self.data(key);
|
45
97
|
}
|
46
98
|
}
|
47
99
|
|
48
|
-
var settings = $.extend({},
|
100
|
+
var settings = $.extend({}, _DEFAULTS, options, attributeOptions);
|
49
101
|
|
50
102
|
if (settings.lang) {
|
51
103
|
_lang = $.extend(_lang, settings.lang);
|
@@ -71,7 +123,7 @@
|
|
71
123
|
self.on('keydown.timepicker', _disableTextInputHandler);
|
72
124
|
}
|
73
125
|
|
74
|
-
_formatValue.call(self.get(0));
|
126
|
+
_formatValue.call(self.get(0), null, 'initial');
|
75
127
|
}
|
76
128
|
});
|
77
129
|
},
|
@@ -243,6 +295,8 @@
|
|
243
295
|
|
244
296
|
self.data('timepicker-settings', settings);
|
245
297
|
|
298
|
+
_formatValue.call(self.get(0), {'type':'change'}, 'initial');
|
299
|
+
|
246
300
|
if (list) {
|
247
301
|
list.remove();
|
248
302
|
self.data('timepicker-list', false);
|
@@ -507,8 +561,8 @@
|
|
507
561
|
row.text(timeString);
|
508
562
|
} else {
|
509
563
|
var row = $('<li />');
|
510
|
-
row.addClass(timeInt %
|
511
|
-
row.data('time', (timeInt
|
564
|
+
row.addClass((timeInt % _ONE_DAY) < (_ONE_DAY / 2) ? 'ui-timepicker-am' : 'ui-timepicker-pm');
|
565
|
+
row.data('time', _moduloSeconds(timeInt, settings));
|
512
566
|
row.text(timeString);
|
513
567
|
}
|
514
568
|
|
@@ -748,17 +802,21 @@
|
|
748
802
|
});
|
749
803
|
|
750
804
|
if (settings.forceRoundTime) {
|
751
|
-
|
805
|
+
var roundSeconds = settings.roundingFunction(seconds, settings);
|
806
|
+
if (roundSeconds != seconds) {
|
807
|
+
seconds = roundSeconds;
|
808
|
+
origin = null;
|
809
|
+
}
|
752
810
|
}
|
753
811
|
|
754
812
|
var prettyTime = _int2time(seconds, settings);
|
755
813
|
|
756
814
|
if (rangeError) {
|
757
|
-
if (_setTimeValue(self, prettyTime, 'error')) {
|
815
|
+
if (_setTimeValue(self, prettyTime, 'error') || e && e.type == 'change') {
|
758
816
|
self.trigger('timeRangeError');
|
759
817
|
}
|
760
818
|
} else {
|
761
|
-
_setTimeValue(self, prettyTime);
|
819
|
+
_setTimeValue(self, prettyTime, origin);
|
762
820
|
}
|
763
821
|
}
|
764
822
|
|
@@ -787,7 +845,7 @@
|
|
787
845
|
self.data('ui-timepicker-value', value);
|
788
846
|
if (source == 'select') {
|
789
847
|
self.trigger('selectTime').trigger('changeTime').trigger('change', 'timepicker');
|
790
|
-
} else if (
|
848
|
+
} else if (['error', 'initial'].indexOf(source) == -1) {
|
791
849
|
self.trigger('changeTime');
|
792
850
|
}
|
793
851
|
|
@@ -1174,6 +1232,14 @@
|
|
1174
1232
|
return ("0" + n).slice(-2);
|
1175
1233
|
}
|
1176
1234
|
|
1235
|
+
function _moduloSeconds(seconds, settings) {
|
1236
|
+
if (seconds == _ONE_DAY && settings.show2400) {
|
1237
|
+
return seconds;
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
return seconds%_ONE_DAY;
|
1241
|
+
}
|
1242
|
+
|
1177
1243
|
// Plugin entry
|
1178
1244
|
$.fn.timepicker = function(method)
|
1179
1245
|
{
|
@@ -1188,55 +1254,4 @@
|
|
1188
1254
|
else if(typeof method === "object" || !method) { return methods.init.apply(this, arguments); }
|
1189
1255
|
else { $.error("Method "+ method + " does not exist on jQuery.timepicker"); }
|
1190
1256
|
};
|
1191
|
-
// Global defaults
|
1192
|
-
$.fn.timepicker.defaults = {
|
1193
|
-
appendTo: 'body',
|
1194
|
-
className: null,
|
1195
|
-
closeOnWindowScroll: false,
|
1196
|
-
disableTextInput: false,
|
1197
|
-
disableTimeRanges: [],
|
1198
|
-
disableTouchKeyboard: false,
|
1199
|
-
durationTime: null,
|
1200
|
-
forceRoundTime: false,
|
1201
|
-
maxTime: null,
|
1202
|
-
minTime: null,
|
1203
|
-
noneOption: false,
|
1204
|
-
orientation: 'l',
|
1205
|
-
roundingFunction: function(seconds, settings) {
|
1206
|
-
if (seconds === null) {
|
1207
|
-
return null;
|
1208
|
-
} else if (typeof settings.step !== "number") {
|
1209
|
-
// TODO: nearest fit irregular steps
|
1210
|
-
return seconds;
|
1211
|
-
} else {
|
1212
|
-
var offset = seconds % (settings.step*60); // step is in minutes
|
1213
|
-
|
1214
|
-
if (offset >= settings.step*30) {
|
1215
|
-
// if offset is larger than a half step, round up
|
1216
|
-
seconds += (settings.step*60) - offset;
|
1217
|
-
} else {
|
1218
|
-
// round down
|
1219
|
-
seconds -= offset;
|
1220
|
-
}
|
1221
|
-
|
1222
|
-
if (seconds == _ONE_DAY && settings.show2400) {
|
1223
|
-
return seconds;
|
1224
|
-
}
|
1225
|
-
|
1226
|
-
return seconds%_ONE_DAY;
|
1227
|
-
}
|
1228
|
-
},
|
1229
|
-
scrollDefault: null,
|
1230
|
-
selectOnBlur: false,
|
1231
|
-
show2400: false,
|
1232
|
-
showDuration: false,
|
1233
|
-
showOn: ['click', 'focus'],
|
1234
|
-
showOnFocus: true,
|
1235
|
-
step: 30,
|
1236
|
-
stopScrollPropagation: false,
|
1237
|
-
timeFormat: 'g:ia',
|
1238
|
-
typeaheadHighlight: true,
|
1239
|
-
useSelect: false,
|
1240
|
-
wrapHours: true
|
1241
|
-
};
|
1242
1257
|
}));
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-timepicker-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanguy Krotoff (jQuery plugin by Jon Thornton)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.6.
|
95
|
+
rubygems_version: 2.6.8
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: jquery-timepicker packaged for the Rails 3.1+ asset pipeline
|