jquery-timepicker-rails 1.4.3 → 1.11.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c978407cf2665af4f801c09c347d41e493133053
4
- data.tar.gz: 037931e33cf27380cdf92a93131d2e37ef0129bb
3
+ metadata.gz: ef2cbc213827a30a13b9d4fdfbfd7998f5c93b9f
4
+ data.tar.gz: be613ced6533e11f03a24b3cb5fd2d16b0ed3b68
5
5
  SHA512:
6
- metadata.gz: 831b5fe6f57a22b12e3cb9f4b9d3290eff7272c850833d7dff3fd221cb1f61cd8a1683875ddf8ed1fbc8fe5387c183dc020f3a8c40db0df136e5861eae46f9a2
7
- data.tar.gz: 2d7cf44e2a010096a9490ed8f836386fb2e6ce149af1464804504f4da75a8b27478cdea06e8dc998f3d260832497ba11d32070be707930fef83db5194d175dad
6
+ metadata.gz: d7ad75d6a2e4810859c057c92d668e83bcf5d53f0c0591925ca9d717c6907465926234fd0e13f8d170b65ea245e0130df4dbf2d9ea949e0eea1823d6578f631a
7
+ data.tar.gz: cc1976e3ccc106ee026c1bf648bc6b7835af6ebb12dd97960940eb5a3da2d4e5a06395dc50059b2c0727a2a887c15dbfcaf6468d8d4c44e8215c1fb8cdf82b49
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # jQuery timepicker for Rails
2
2
  [![Gem Version](https://badge.fury.io/rb/jquery-timepicker-rails.png)](http://badge.fury.io/rb/jquery-timepicker-rails)
3
3
 
4
- jquery-timepicker packaged for the Rails 3.1+ asset pipeline.
5
- Check [jquery-timepicker project home page](http://github.com/jonthornton/jquery-timepicker).
4
+ jquery-timepicker and Datepair.js packaged for the Rails 3.1+ asset pipeline.
5
+ See the [jquery-timepicker project home page](http://github.com/jonthornton/jquery-timepicker) and the [Datepair.js home page](https://github.com/jonthornton/Datepair.js).
6
6
 
7
7
  ## Installation
8
8
 
@@ -28,13 +28,13 @@ Add the following stylesheet file to `app/assets/stylesheets/application.css`:
28
28
 
29
29
  *= require jquery.timepicker.css
30
30
 
31
- Optionally, you can also use `jquery.datepair.js`:
31
+ You can also include `Datepair.js`, and optionally it's accompanying jquery plugin, `jquery.datepair.js`:
32
32
 
33
+ //= require Datepair
33
34
  //= require jquery.datepair.js
34
35
 
35
- Most people will prefer to copy-paste this file in order to customize it.
36
-
37
- jquery-timepicker depends on jQuery and [bootstrap-datepicker](http://github.com/eternicode/bootstrap-datepicker) or [jQuery UI Datepicker](http://jqueryui.com/demos/datepicker/).
36
+ Datepair.js depends on [bootstrap-datepicker](http://github.com/eternicode/bootstrap-datepicker) or [jQuery UI Datepicker](http://jqueryui.com/demos/datepicker/).
37
+ jquery-timepicker depends on `jQuery`.
38
38
 
39
39
  ## License
40
40
 
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Timepicker
3
3
  module Rails
4
- VERSION = '1.4.3'
4
+ VERSION = '1.11.4'
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,347 @@
1
+ var _ONE_DAY = 86400000;
2
+ var jq = window.Zepto || window.jQuery;
3
+
4
+ function simpleExtend(obj1, obj2) {
5
+ var out = obj2 || {};
6
+
7
+ for (var i in obj1) {
8
+ if (!(i in out)) {
9
+ out[i] = obj1[i];
10
+ }
11
+ }
12
+
13
+ return out;
14
+ }
15
+
16
+ // IE's custom event support is totally borked.
17
+ // Use jQuery if possible
18
+ function triggerSimpleCustomEvent(el, eventName) {
19
+ if (jq) {
20
+ jq(el).trigger(eventName);
21
+ } else {
22
+ var event = document.createEvent('CustomEvent');
23
+ event.initCustomEvent(eventName, true, true, {});
24
+ el.dispatchEvent(event);
25
+ }
26
+ }
27
+
28
+ // el.classList not supported by < IE10
29
+ // use jQuery if available
30
+ function hasClass(el, className) {
31
+ if (jq) {
32
+ return jq(el).hasClass(className);
33
+ } else {
34
+ return el.classList.contains(className);
35
+ }
36
+ }
37
+
38
+ function Datepair(container, options) {
39
+ this.dateDelta = null;
40
+ this.timeDelta = null;
41
+ this._defaults = {
42
+ startClass: 'start',
43
+ endClass: 'end',
44
+ timeClass: 'time',
45
+ dateClass: 'date',
46
+ defaultDateDelta: 0,
47
+ defaultTimeDelta: 3600000,
48
+ anchor: 'start',
49
+
50
+ // defaults for jquery-timepicker; override when using other input widgets
51
+ parseTime: function(input){
52
+ return jq(input).timepicker('getTime');
53
+ },
54
+ updateTime: function(input, dateObj){
55
+ jq(input).timepicker('setTime', dateObj);
56
+ },
57
+ setMinTime: function(input, dateObj){
58
+ jq(input).timepicker('option', 'minTime', dateObj);
59
+ },
60
+
61
+ // defaults for bootstrap datepicker; override when using other input widgets
62
+ parseDate: function(input){
63
+ return input.value && jq(input).datepicker('getDate');
64
+ },
65
+ updateDate: function(input, dateObj){
66
+ jq(input).datepicker('update', dateObj);
67
+ }
68
+ };
69
+
70
+ this.container = container;
71
+ this.settings = simpleExtend(this._defaults, options);
72
+
73
+ this.startDateInput = this.container.querySelector('.'+this.settings.startClass+'.'+this.settings.dateClass);
74
+ this.endDateInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.dateClass);
75
+ this.startTimeInput = this.container.querySelector('.'+this.settings.startClass+'.'+this.settings.timeClass);
76
+ this.endTimeInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.timeClass);
77
+
78
+ // initialize date and time deltas
79
+ this.refresh();
80
+
81
+ // init starts here
82
+ this._bindChangeHandler();
83
+ }
84
+
85
+ Datepair.prototype = {
86
+ constructor: Datepair,
87
+
88
+ option: function(key, value)
89
+ {
90
+ if (typeof key == 'object') {
91
+ this.settings = simpleExtend(this.settings, key);
92
+
93
+ } else if (typeof key == 'string' && typeof value != 'undefined') {
94
+ this.settings[key] = value;
95
+
96
+ } else if (typeof key == 'string') {
97
+ return this.settings[key];
98
+ }
99
+
100
+ this._updateEndMintime();
101
+ },
102
+
103
+ getTimeDiff: function()
104
+ {
105
+ // due to the fact that times can wrap around, timeDiff for any
106
+ // time-only pair will always be >= 0
107
+ var delta = this.dateDelta + this.timeDelta;
108
+ if (delta < 0 && (!this.startDateInput || !this.endDateInput) ) {
109
+ delta += _ONE_DAY;
110
+ }
111
+
112
+ return delta;
113
+ },
114
+
115
+ refresh: function()
116
+ {
117
+ if (this.startDateInput && this.startDateInput.value && this.endDateInput && this.endDateInput.value) {
118
+ var startDate = this.settings.parseDate(this.startDateInput);
119
+ var endDate = this.settings.parseDate(this.endDateInput);
120
+ if (startDate && endDate) {
121
+ this.dateDelta = endDate.getTime() - startDate.getTime();
122
+ }
123
+ }
124
+ if (this.startTimeInput && this.startTimeInput.value && this.endTimeInput && this.endTimeInput.value) {
125
+ var startTime = this.settings.parseTime(this.startTimeInput);
126
+ var endTime = this.settings.parseTime(this.endTimeInput);
127
+ if (startTime && endTime) {
128
+ this.timeDelta = endTime.getTime() - startTime.getTime();
129
+ this._updateEndMintime();
130
+ }
131
+ }
132
+ },
133
+
134
+ remove: function()
135
+ {
136
+ this._unbindChangeHandler();
137
+ },
138
+
139
+ _bindChangeHandler: function(){
140
+ // addEventListener doesn't work with synthetic "change" events
141
+ // fired by jQuery's trigger() functioin. If jQuery is present,
142
+ // use that for event binding
143
+ if (jq) {
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);
168
+ } else {
169
+ this.dateDelta = null;
170
+ }
171
+
172
+ } else if (hasClass(e.target, this.settings.timeClass)) {
173
+ if (e.target.value != '') {
174
+ this._timeChanged(e.target);
175
+ } else {
176
+ this.timeDelta = null;
177
+ }
178
+ }
179
+
180
+ this._validateRanges();
181
+ this._updateEndMintime();
182
+ this._bindChangeHandler();
183
+ },
184
+
185
+ _dateChanged: function(target){
186
+ if (!this.startDateInput || !this.endDateInput) {
187
+ return;
188
+ }
189
+
190
+ var startDate = this.settings.parseDate(this.startDateInput);
191
+ var endDate = this.settings.parseDate(this.endDateInput);
192
+
193
+ if (!startDate || !endDate) {
194
+ if (this.settings.defaultDateDelta !== null) {
195
+ if (startDate) {
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);
202
+ }
203
+
204
+ this.dateDelta = this.settings.defaultDateDelta * _ONE_DAY;
205
+ } else {
206
+ this.dateDelta = null;
207
+ }
208
+
209
+ return;
210
+ }
211
+
212
+ if (this.settings.anchor == 'start' && hasClass(target, this.settings.startClass)) {
213
+ var newDate = new Date(startDate.getTime() + this.dateDelta);
214
+ this.settings.updateDate(this.endDateInput, newDate);
215
+ } else if (this.settings.anchor == 'end' && hasClass(target, this.settings.endClass)) {
216
+ var newDate = new Date(endDate.getTime() - this.dateDelta);
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();
226
+ }
227
+ }
228
+ },
229
+
230
+ _timeChanged: function(target){
231
+ if (!this.startTimeInput || !this.endTimeInput) {
232
+ return;
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;
251
+ }
252
+
253
+ return;
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);
275
+ }
276
+
277
+ if ((+startDate == +endDate) && (endTime < startTime)) {
278
+ var thisInput = hasClass(target, this.settings.endClass) ? this.endTimeInput : this.startTimeInput;
279
+ var otherInput = hasClass(target, this.settings.startClass) ? this.endTimeInput : this.startTimeInput;
280
+ var selectedTime = this.settings.parseTime(thisInput);
281
+ this.timeDelta = 0;
282
+ this.settings.updateTime(otherInput, selectedTime);
283
+ } else {
284
+ this.timeDelta = endTime.getTime() - startTime.getTime();
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);
313
+ }
314
+ }
315
+ this.timeDelta = newDelta;
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
+ }
334
+
335
+ if (this.startDateInput && this.endDateInput && this.dateDelta === null) {
336
+ triggerSimpleCustomEvent(this.container, 'rangeIncomplete');
337
+ return;
338
+ }
339
+
340
+ // due to the fact that times can wrap around, any time-only pair will be considered valid
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
+ };
@@ -1,279 +1,3 @@
1
- /*!
2
- * datepair.js v0.2.2 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
3
- * Copyright (c) 2014 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
- }
21
- }
22
-
23
- return out;
24
- }
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
- }
36
- }
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
- }
46
- }
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
-
59
- // defaults for jquery-timepicker; override when using other input widgets
60
- parseTime: function(input){
61
- return jq(input).timepicker('getTime');
62
- },
63
- updateTime: function(input, dateObj){
64
- jq(input).timepicker('setTime', dateObj);
65
- },
66
- setMinTime: function(input, dateObj){
67
- jq(input).timepicker('option', 'minTime', dateObj);
68
- },
69
-
70
- // defaults for bootstrap datepicker; override when using other input widgets
71
- parseDate: function(input){
72
- return jq(input).datepicker('getDate');
73
- },
74
- updateDate: function(input, dateObj){
75
- jq(input).datepicker('update', dateObj);
76
- }
77
- };
78
-
79
- this.container = container;
80
- this.settings = simpleExtend(this._defaults, options);
81
-
82
- this.startDateInput = this.container.querySelector('.'+this.settings.startClass+'.'+this.settings.dateClass);
83
- this.endDateInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.dateClass);
84
- this.startTimeInput = this.container.querySelector('.'+this.settings.startClass+'.'+this.settings.timeClass);
85
- this.endTimeInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.timeClass);
86
-
87
- // initialize date and time deltas
88
- if (this.startDateInput && this.startDateInput.value && this.startDateInput && this.endDateInput.value) {
89
- var startDate = this.settings.parseDate(this.startDateInput);
90
- var endDate = this.settings.parseDate(this.endDateInput);
91
- this.dateDelta = endDate.getTime() - startDate.getTime();
92
- }
93
- if (this.startTimeInput && this.startTimeInput.value && this.endTimeInput && this.endTimeInput.value) {
94
- var startTime = this.settings.parseTime(this.startTimeInput);
95
- var endTime = this.settings.parseTime(this.endTimeInput);
96
- this.timeDelta = endTime.getTime() - startTime.getTime();
97
- }
98
-
99
- // init starts here
100
- this._bindChangeHandler();
101
- }
102
-
103
- Datepair.prototype = {
104
- constructor: Datepair,
105
-
106
- _bindChangeHandler: function(){
107
- // addEventListener doesn't work with synthetic "change" events
108
- // fired by jQuery's trigger() functioin. If jQuery is present,
109
- // use that for event binding
110
- if (jq) {
111
- jq(this.container).on('change.datepair', jq.proxy(this.handleEvent, this));
112
- } else {
113
- this.container.addEventListener('change', this, false);
114
- }
115
- },
116
-
117
- _unbindChangeHandler: function(){
118
- if (jq) {
119
- jq(this.container).off('change.datepair');
120
- } else {
121
- this.container.removeEventListener('change', this, false);
122
- }
123
- },
124
-
125
- // This function will be called when passing 'this' to addEventListener
126
- handleEvent: function(e){
127
- // temporarily unbind the change handler to prevent triggering this
128
- // if we update other inputs
129
- this._unbindChangeHandler();
130
-
131
- if (hasClass(e.target, this.settings.dateClass)) {
132
- if (e.target.value != '') {
133
- this._dateChanged(e.target);
134
- } else {
135
- this.dateDelta = null;
136
- }
137
-
138
- } else if (hasClass(e.target, this.settings.timeClass)) {
139
- if (e.target.value != '') {
140
- this._timeChanged(e.target);
141
- } else {
142
- this.timeDelta = null;
143
- }
144
- }
145
-
146
- this._validateRanges();
147
- this._updateEndMintime()
148
- this._bindChangeHandler();
149
- },
150
-
151
- _dateChanged: function(target){
152
- if (!this.startDateInput || !this.endDateInput) {
153
- return
154
- }
155
-
156
- if (!this.startDateInput.value || !this.endDateInput.value) {
157
- if (this.settings.defaultDateDelta !== null) {
158
- if (this.startDateInput.value) {
159
- var startDate = this.settings.parseDate(this.startDateInput);
160
- var newEnd = new Date(startDate.getTime() + this.settings.defaultDateDelta * _ONE_DAY);
161
- this.settings.updateDate(this.endDateInput, newEnd);
162
-
163
- } else if (this.endDateInput.value) {
164
- var endDate = this.settings.parseDate($endDateInput);
165
- var newStart = new Date(endDate.getTime() - this.settings.defaultDateDelta * _ONE_DAY);
166
- this.settings.updateDate(this.startDateInput, newStart);
167
- }
168
-
169
- this.dateDelta = this.settings.defaultDateDelta * _ONE_DAY;
170
- } else {
171
- this.dateDelta = null;
172
- }
173
-
174
- return;
175
- }
176
-
177
- var startDate = this.settings.parseDate(this.startDateInput);
178
- var endDate = this.settings.parseDate(this.endDateInput);
179
-
180
- if (hasClass(target, this.settings.startClass)) {
181
- var newEndDate = new Date(startDate.getTime() + this.dateDelta);
182
- this.settings.updateDate(this.endDateInput, newEndDate);
183
- } else if (hasClass(target, this.settings.endClass)) {
184
- if (endDate < startDate) {
185
- this.dateDelta = 0;
186
- this.settings.updateDate(this.startDateInput, endDate);
187
- } else {
188
- this.dateDelta = endDate.getTime() - startDate.getTime();
189
- }
190
- }
191
- },
192
-
193
- _timeChanged: function(target){
194
- if (!this.startTimeInput || !this.endTimeInput) {
195
- return
196
- }
197
-
198
- if (!this.startTimeInput.value || !this.endTimeInput.value) {
199
- if (this.settings.defaultTimeDelta !== null) {
200
- if (this.startTimeInput.value) {
201
- var startTime = this.settings.parseTime(this.startTimeInput);
202
- var newEnd = new Date(startTime.getTime() + this.settings.defaultTimeDelta);
203
- this.settings.updateTime(this.endTimeInput, newEnd);
204
- } else if (this.endTimeInput.value) {
205
- var endTime = this.settings.parseTime(this.endTimeInput);
206
- var newStart = new Date(endTime.getTime() - this.settings.defaultTimeDelta);
207
- this.settings.updateTime(this.startTimeInput, newStart);
208
- }
209
-
210
- this.timeDelta = this.settings.defaultTimeDelta;
211
- } else {
212
- this.timeDelta = null;
213
- }
214
-
215
- return;
216
- }
217
-
218
- var startTime = this.settings.parseTime(this.startTimeInput);
219
- var endTime = this.settings.parseTime(this.endTimeInput);
220
-
221
- if (hasClass(target, this.settings.startClass)) {
222
- var newEndTime = new Date(startTime.getTime() + this.timeDelta);
223
- this.settings.updateTime(this.endTimeInput, newEndTime);
224
- endTime = this.settings.parseTime(this.endTimeInput);
225
- }
226
-
227
- if (this.endDateInput && this.endDateInput.value && this.dateDelta + this.timeDelta < _ONE_DAY && (endTime.getTime() - startTime.getTime()) * this.timeDelta < 0) {
228
- var offset = (endTime < startTime) ? _ONE_DAY : -1 * _ONE_DAY;
229
- var endDate = this.settings.parseDate(this.endDateInput);
230
- this.settings.updateDate(this.endDateInput, new Date(endDate.getTime() + offset));
231
- this._dateChanged(this.endDateInput);
232
- }
233
-
234
- this.timeDelta = endTime.getTime() - startTime.getTime();
235
- },
236
-
237
- _updateEndMintime: function(){
238
- if (typeof this.settings.setMinTime != 'function') return;
239
-
240
- var startTime = null;
241
- if (!this.dateDelta || this.dateDelta < _ONE_DAY || (this.timeDelta && this.dateDelta + this.timeDelta < _ONE_DAY)) {
242
- startTime = this.settings.parseTime(this.startTimeInput);
243
- }
244
-
245
- this.settings.setMinTime(this.endTimeInput, startTime);
246
- },
247
-
248
- _validateRanges: function(){
249
- if (this.startTimeInput && this.endTimeInput && this.timeDelta === null) {
250
- triggerSimpleCustomEvent(this.container, 'rangeIncomplete');
251
- return;
252
- }
253
-
254
- if (this.startDateInput && this.endDateInput && this.dateDelta === null) {
255
- triggerSimpleCustomEvent(this.container, 'rangeIncomplete');
256
- return;
257
- }
258
-
259
- if (this.dateDelta + this.timeDelta >= 0) {
260
- triggerSimpleCustomEvent(this.container, 'rangeSelected');
261
- } else {
262
- triggerSimpleCustomEvent(this.container, 'rangeError');
263
- }
264
- }
265
- }
266
-
267
- window.Datepair = Datepair;
268
-
269
- }(window, document));
270
-
271
- /*!
272
- * datepair.js v0.2.2 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
273
- * Copyright (c) 2014 Jon Thornton - http://jonthornton.github.com/Datepair.js
274
- * License: MIT
275
- */
276
-
277
1
  (function($) {
278
2
 
279
3
  if(!$) {
@@ -301,7 +25,7 @@
301
25
  }
302
26
  });
303
27
 
304
- return out;
28
+ return out || this;
305
29
  };
306
30
 
307
31
  //////////////
@@ -313,4 +37,4 @@
313
37
  $this.datepair($this.data());
314
38
  });
315
39
 
316
- }(window.Zepto || window.jQuery));
40
+ }(window.Zepto || window.jQuery));