jquery-timepicker-rails 1.3.4 → 1.3.5

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: 45718952790f6cd76d6c394f4d97163710f83281
4
- data.tar.gz: 93e2971f8062d9bd1a20ed023971860adc567368
3
+ metadata.gz: 9fd1716bf9fb44052c53d2beb071f2ba87898996
4
+ data.tar.gz: b4876c48e96e8b41bf668ef6929f695d58d96096
5
5
  SHA512:
6
- metadata.gz: 61017dad9c1c2bd5b8658a3491fbbf664535f44662dd5f90e57edec154c0f3aff542f15affb3e5621d2263b571a433c4d3cdbeb884201cb05d3f7909edaf6ed9
7
- data.tar.gz: 6875ae7462327372bdce4d30143e2b98d8e344214946e2267df75c631e789eae4b6f2b1a84dbe2825f94f2a222ddda5d5792f1480d24d8d9c85e866943298342
6
+ metadata.gz: 2b862ed1f469bf4b9da10d9393bf66f3af554847431276f829c6b86277e97bfc1f1c5adde3685852170776f471309edb99d77de2527f849d4c46cb7355ffee6d
7
+ data.tar.gz: 3cf0d50775de147f466954c0b804190499872f88d6a8e1d836e9931d15ab0183e0cd3f37ec62c717a0c51dc824079bd8b6ddb473ada5e89ddaa73d265fe716de
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Timepicker
3
3
  module Rails
4
- VERSION = "1.3.4"
4
+ VERSION = "1.3.5"
5
5
  end
6
6
  end
7
7
  end
@@ -67,6 +67,8 @@ requires jQuery 1.7+
67
67
  var startDate = settings.parseDate($startDateInput);
68
68
  var endDate = settings.parseDate($endDateInput);
69
69
  $self.data('datepair-datedelta', endDate.getTime() - startDate.getTime());
70
+ } else {
71
+ $self.data('datepair-datedelta', null);
70
72
  }
71
73
 
72
74
  // initialize datepair-timedelta
@@ -77,6 +79,8 @@ requires jQuery 1.7+
77
79
  var startTime = settings.parseTime($startTimeInput);
78
80
  var endTime = settings.parseTime($endTimeInput);
79
81
  $self.data('datepair-timedelta', endTime.getTime() - startTime.getTime());
82
+ } else {
83
+ $self.data('datepair-timedelta', null);
80
84
  }
81
85
 
82
86
  _updateEndMintime($self);
@@ -107,9 +111,11 @@ requires jQuery 1.7+
107
111
 
108
112
  remove: function()
109
113
  {
110
- var self = this;
111
- self.removeData('datepair-settings');
112
- self.off('.timepicker');
114
+ var $self = this;
115
+ $self.removeData('datepair-settings');
116
+ _unbindChangeHandler($self)
117
+
118
+ return $self;
113
119
  }
114
120
  };
115
121
 
@@ -145,15 +151,23 @@ requires jQuery 1.7+
145
151
  var settings = $self.data('datepair-settings');
146
152
  var $target = $(e.target);
147
153
 
148
- if ($target.val() != '') {
149
- if ($target.hasClass(settings.dateClass)) {
154
+ if ($target.hasClass(settings.dateClass)) {
155
+ if ($target.val() != '') {
150
156
  _dateChanged($self, $target);
157
+ } else {
158
+ $self.data('datepair-datedelta', null);
159
+ }
151
160
 
152
- } else if ($target.hasClass(settings.timeClass)) {
161
+ } else if ($target.hasClass(settings.timeClass)) {
162
+ if ($target.val() != '') {
153
163
  _timeChanged($self, $target);
164
+ } else {
165
+ $self.data('datepair-timedelta', null);
154
166
  }
155
167
  }
156
168
 
169
+ _validateRanges($self);
170
+ _updateEndMintime($self)
157
171
  _bindChangeHandler($self);
158
172
  }
159
173
 
@@ -196,7 +210,7 @@ requires jQuery 1.7+
196
210
  settings.updateDate($endDateInput, newEnd);
197
211
  } else if ($endDateInput.val()) {
198
212
  var endDate = settings.parseDate($endDateInput);
199
- var newStart = new Date(endDate.getTime() + settings.defaultDateDelta * _ONE_DAY);
213
+ var newStart = new Date(endDate.getTime() - settings.defaultDateDelta * _ONE_DAY);
200
214
  settings.updateDate($startDateInput, newStart);
201
215
  }
202
216
 
@@ -205,7 +219,6 @@ requires jQuery 1.7+
205
219
  $self.data('datepair-datedelta', null);
206
220
  }
207
221
 
208
- _updateEndMintime($self);
209
222
  return;
210
223
  }
211
224
 
@@ -223,8 +236,6 @@ requires jQuery 1.7+
223
236
  $self.data('datepair-datedelta', endDate.getTime() - startDate.getTime());
224
237
  }
225
238
  }
226
-
227
- _updateEndMintime($self);
228
239
  }
229
240
 
230
241
  function _updateEndMintime($self)
@@ -257,7 +268,7 @@ requires jQuery 1.7+
257
268
  settings.updateTime($endTimeInput, newEnd);
258
269
  } else if ($endTimeInput.val()) {
259
270
  var endTime = settings.parseTime($endTimeInput);
260
- var newStart = new Date(endDate.getTime() + settings.defaultTimeDelta);
271
+ var newStart = new Date(endTime.getTime() - settings.defaultTimeDelta);
261
272
  settings.updateTime($startTimeInput, newStart);
262
273
  }
263
274
 
@@ -266,7 +277,6 @@ requires jQuery 1.7+
266
277
  $self.data('datepair-timedelta', null);
267
278
  }
268
279
 
269
- _updateEndMintime($self);
270
280
  return;
271
281
  }
272
282
 
@@ -281,17 +291,39 @@ requires jQuery 1.7+
281
291
 
282
292
  if ((endTime.getTime() - startTime.getTime()) * $self.data('datepair-timedelta') < 0) {
283
293
  var $endDateInput = _getEndDateInput($self);
284
- var endDate = settings.parseDate($endDateInput);
285
- var offset = (endTime < startTime) ? _ONE_DAY : -1 * _ONE_DAY;
286
-
287
- settings.updateDate($endDateInput, new Date(endDate.getTime() + offset));
288
- var newDelta = $self.data('datepair-timedelta') + offset;
289
- $self.data('datepair-timedelta', newDelta);
294
+ if ($endDateInput.val()) {
295
+ var offset = (endTime < startTime) ? _ONE_DAY : -1 * _ONE_DAY;
296
+ var endDate = settings.parseDate($endDateInput);
297
+ settings.updateDate($endDateInput, new Date(endDate.getTime() + offset));
298
+ _dateChanged($self, $endDateInput);
299
+ }
290
300
  }
291
301
 
292
302
  $self.data('datepair-timedelta', endTime.getTime() - startTime.getTime());
303
+ }
304
+
305
+ function _validateRanges($self)
306
+ {
307
+ var $startTimeInput = _getStartTimeInput($self);
308
+ var $endTimeInput = _getEndTimeInput($self);
309
+
310
+ if ($startTimeInput.length && $endTimeInput.length && $self.data('datepair-timedelta') === null) {
311
+ $self.trigger('rangeIncomplete');
312
+ return;
313
+ }
293
314
 
294
- _updateEndMintime($self);
315
+ var $startDateInput = _getStartDateInput($self);
316
+ var $endDateInput = _getEndDateInput($self);
317
+ if ($startDateInput.length && $endDateInput.length && $self.data('datepair-datedelta') === null) {
318
+ $self.trigger('rangeIncomplete');
319
+ return;
320
+ }
321
+
322
+ if ($self.data('datepair-datedelta') + $self.data('datepair-timedelta') >= 0) {
323
+ $self.trigger('rangeSelected');
324
+ } else {
325
+ $self.trigger('rangeError');
326
+ }
295
327
  }
296
328
 
297
329
 
@@ -1,5 +1,5 @@
1
1
  /************************
2
- jquery-timepicker v1.3.4
2
+ jquery-timepicker v1.3.5
3
3
  http://jonthornton.github.com/jquery-timepicker/
4
4
 
5
5
  requires jQuery 1.7+
@@ -359,12 +359,18 @@ requires jQuery 1.7+
359
359
  }
360
360
 
361
361
  if (settings.noneOption) {
362
- var defaultLabel = (settings.useSelect) ? 'Time...' : 'None';
363
- var label = (typeof settings.noneOption == 'string') ? settings.noneOption : defaultLabel;
364
- if (settings.useSelect) {
365
- list.append($('<option value="">'+label+'</option>'));
362
+ if (settings.noneOption === true) {
363
+ settings.noneOption = (settings.useSelect) ? 'Time...' : 'None';
364
+ }
365
+
366
+ if ($.isArray(settings.noneOption)) {
367
+ for (var i in settings.noneOption) {
368
+ var noneElement = _generateNoneElement(settings.noneOption[i], settings.useSelect);
369
+ list.append(noneElement);
370
+ }
366
371
  } else {
367
- list.append($('<li>'+label+'</li>'));
372
+ var noneElement = _generateNoneElement(settings.noneOption, settings.useSelect);
373
+ list.append(noneElement);
368
374
  }
369
375
  }
370
376
 
@@ -493,6 +499,34 @@ requires jQuery 1.7+
493
499
  }
494
500
  }
495
501
 
502
+ function _generateNoneElement(optionValue, useSelect)
503
+ {
504
+ var label, className, value;
505
+
506
+ if (typeof optionValue == 'object') {
507
+ label = optionValue.label;
508
+ className = optionValue.className;
509
+ value = optionValue.value;
510
+ } else if (typeof optionValue == 'string') {
511
+ label = optionValue;
512
+ } else {
513
+ $.error('Invalid noneOption value');
514
+ }
515
+
516
+ if (useSelect) {
517
+ return $('<option />', {
518
+ 'value': value,
519
+ 'class': className,
520
+ 'text': label
521
+ });
522
+ } else {
523
+ return $('<li />', {
524
+ 'class': className,
525
+ 'text': label
526
+ }).data('time', value);
527
+ }
528
+ }
529
+
496
530
  function _roundTime(time, settings)
497
531
  {
498
532
  if (!$.isNumeric(time)) {
@@ -543,6 +577,9 @@ requires jQuery 1.7+
543
577
  // loop through the menu items
544
578
  list.find('li').each(function(i, obj) {
545
579
  var jObj = $(obj);
580
+ if (typeof jObj.data('time') != 'number') {
581
+ return;
582
+ }
546
583
 
547
584
  var offset = jObj.data('time') - value;
548
585
 
@@ -842,8 +879,12 @@ requires jQuery 1.7+
842
879
  }
843
880
 
844
881
  if (timeValue !== null) {
845
- var timeString = _int2time(timeValue, settings.timeFormat);
846
- _setTimeValue(self, timeString, 'select');
882
+ if (typeof timeValue == 'string') {
883
+ self.val(timeValue);
884
+ } else {
885
+ var timeString = _int2time(timeValue, settings.timeFormat);
886
+ _setTimeValue(self, timeString, 'select');
887
+ }
847
888
  }
848
889
 
849
890
  //self.trigger('change').trigger('selectTime');
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.3.4
4
+ version: 1.3.5
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: 2014-02-24 00:00:00.000000000 Z
12
+ date: 2014-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties