bootstrap-daterangepicker-rails 0.1.2 → 0.1.3

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: 48d1d921190567838b8d750b8a0543f42d7a1944
4
- data.tar.gz: 89eb649d63c227c3f4e99d4decf08cc9d727d8af
3
+ metadata.gz: 059447fff851eed85759905810971d1607b496ee
4
+ data.tar.gz: 920a8fc2a0e5840151267b848437b1ad2688c2ed
5
5
  SHA512:
6
- metadata.gz: 7e7691eabd19697ec20ff742991ce6d3ef277220444ae1fdaba5c27ae45f248a405dff57b07c06a298e7b8adc6134d3f252ee306b268009cc137909b83dd6896
7
- data.tar.gz: 2a12aa143bff6190925b761ed1b69a0a381f9909cc758c12a487df1402a30b0278af76c68e3e81a684ee5d13c9344cadb57120e6d7249198f1aaf9b97006bdcc
6
+ metadata.gz: b4d43f429ef43c9c3a132e42e978587677c6b7592ec48cdb4f448232ca643e4488c93736ad5a55abcc8484c7c3359b5d9550c3dae356e13a514d4e79515b2bb4
7
+ data.tar.gz: 2888774e20022cd74de920ccd57929daa21a21b63435e1cebccd4f051ffdfac8e919c3e1b5f8ab1fa71ac55dd84719a010beb489c2f8febddc04de5c7931c348
@@ -1,7 +1,7 @@
1
1
  module Bootstrap
2
2
  module Daterangepicker
3
3
  module Rails
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
6
6
  end
7
7
  end
@@ -1,36 +1,36 @@
1
1
  /**
2
- * @version: 2.1.12
3
- * @author: Dan Grossman http://www.dangrossman.info/
4
- * @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved.
5
- * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
6
- * @website: https://www.improvely.com/
7
- */
2
+ * @version: 2.1.17
3
+ * @author: Dan Grossman http://www.dangrossman.info/
4
+ * @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved.
5
+ * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
6
+ * @website: https://www.improvely.com/
7
+ */
8
8
 
9
9
  (function(root, factory) {
10
10
 
11
- if (typeof define === 'function' && define.amd) {
12
- define(['moment', 'jquery', 'exports'], function(momentjs, $, exports) {
13
- root.daterangepicker = factory(root, exports, momentjs, $);
14
- });
15
-
16
- } else if (typeof exports !== 'undefined') {
17
- var momentjs = require('moment');
18
- var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined; //isomorphic issue
19
- if (!jQuery) {
20
- try {
21
- jQuery = require('jquery');
22
- if (!jQuery.fn) jQuery.fn = {}; //isomorphic issue
23
- } catch (err) {
24
- if (!jQuery) throw new Error('jQuery dependency not found');
25
- }
26
- }
27
-
28
- factory(root, exports, momentjs, jQuery);
29
-
30
- // Finally, as a browser global.
31
- } else {
32
- root.daterangepicker = factory(root, {}, root.moment || moment, (root.jQuery || root.Zepto || root.ender || root.$));
33
- }
11
+ if (typeof define === 'function' && define.amd) {
12
+ define(['moment', 'jquery', 'exports'], function(momentjs, $, exports) {
13
+ root.daterangepicker = factory(root, exports, momentjs, $);
14
+ });
15
+
16
+ } else if (typeof exports !== 'undefined') {
17
+ var momentjs = require('moment');
18
+ var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined; //isomorphic issue
19
+ if (!jQuery) {
20
+ try {
21
+ jQuery = require('jquery');
22
+ if (!jQuery.fn) jQuery.fn = {}; //isomorphic issue
23
+ } catch (err) {
24
+ if (!jQuery) throw new Error('jQuery dependency not found');
25
+ }
26
+ }
27
+
28
+ factory(root, exports, momentjs, jQuery);
29
+
30
+ // Finally, as a browser global.
31
+ } else {
32
+ root.daterangepicker = factory(root, {}, root.moment || moment, (root.jQuery || root.Zepto || root.ender || root.$));
33
+ }
34
34
 
35
35
  }(this || {}, function(root, daterangepicker, moment, $) { // 'this' doesn't exist on a server
36
36
 
@@ -99,34 +99,34 @@
99
99
  if (typeof options.template !== 'string')
100
100
  options.template = '<div class="daterangepicker dropdown-menu">' +
101
101
  '<div class="calendar left">' +
102
- '<div class="daterangepicker_input">' +
103
- '<input class="input-mini" type="text" name="daterangepicker_start" value="" />' +
104
- '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
105
- '<div class="calendar-time">' +
106
- '<div></div>' +
107
- '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
108
- '</div>' +
109
- '</div>' +
110
- '<div class="calendar-table"></div>' +
102
+ '<div class="daterangepicker_input">' +
103
+ '<input class="input-mini" type="text" name="daterangepicker_start" value="" />' +
104
+ '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
105
+ '<div class="calendar-time">' +
106
+ '<div></div>' +
107
+ '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
108
+ '</div>' +
109
+ '</div>' +
110
+ '<div class="calendar-table"></div>' +
111
111
  '</div>' +
112
112
  '<div class="calendar right">' +
113
- '<div class="daterangepicker_input">' +
114
- '<input class="input-mini" type="text" name="daterangepicker_end" value="" />' +
115
- '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
116
- '<div class="calendar-time">' +
117
- '<div></div>' +
118
- '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
119
- '</div>' +
120
- '</div>' +
121
- '<div class="calendar-table"></div>' +
113
+ '<div class="daterangepicker_input">' +
114
+ '<input class="input-mini" type="text" name="daterangepicker_end" value="" />' +
115
+ '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
116
+ '<div class="calendar-time">' +
117
+ '<div></div>' +
118
+ '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
119
+ '</div>' +
120
+ '</div>' +
121
+ '<div class="calendar-table"></div>' +
122
122
  '</div>' +
123
123
  '<div class="ranges">' +
124
- '<div class="range_inputs">' +
125
- '<button class="applyBtn" disabled="disabled" type="button"></button> ' +
126
- '<button class="cancelBtn" type="button"></button>' +
127
- '</div>' +
124
+ '<div class="range_inputs">' +
125
+ '<button class="applyBtn" disabled="disabled" type="button"></button> ' +
126
+ '<button class="cancelBtn" type="button"></button>' +
128
127
  '</div>' +
129
- '</div>';
128
+ '</div>' +
129
+ '</div>';
130
130
 
131
131
  this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
132
132
  this.container = $(options.template).appendTo(this.parentEl);
@@ -147,22 +147,22 @@
147
147
  this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
148
148
 
149
149
  if (typeof options.locale.monthNames === 'object')
150
- this.locale.monthNames = options.locale.monthNames.slice();
150
+ this.locale.monthNames = options.locale.monthNames.slice();
151
151
 
152
152
  if (typeof options.locale.firstDay === 'number')
153
- this.locale.firstDay = options.locale.firstDay;
153
+ this.locale.firstDay = options.locale.firstDay;
154
154
 
155
155
  if (typeof options.locale.applyLabel === 'string')
156
- this.locale.applyLabel = options.locale.applyLabel;
156
+ this.locale.applyLabel = options.locale.applyLabel;
157
157
 
158
158
  if (typeof options.locale.cancelLabel === 'string')
159
- this.locale.cancelLabel = options.locale.cancelLabel;
159
+ this.locale.cancelLabel = options.locale.cancelLabel;
160
160
 
161
161
  if (typeof options.locale.weekLabel === 'string')
162
- this.locale.weekLabel = options.locale.weekLabel;
162
+ this.locale.weekLabel = options.locale.weekLabel;
163
163
 
164
164
  if (typeof options.locale.customRangeLabel === 'string')
165
- this.locale.customRangeLabel = options.locale.customRangeLabel;
165
+ this.locale.customRangeLabel = options.locale.customRangeLabel;
166
166
 
167
167
  }
168
168
 
@@ -317,7 +317,12 @@
317
317
  if ((this.minDate && end.isBefore(this.minDate)) || (maxDate && start.isAfter(maxDate)))
318
318
  continue;
319
319
 
320
- this.ranges[range] = [start, end];
320
+ //Support unicode chars in the range names.
321
+ var elem = document.createElement('textarea');
322
+ elem.innerHTML = range;
323
+ var rangeHtml = elem.value;
324
+
325
+ this.ranges[rangeHtml] = [start, end];
321
326
  }
322
327
 
323
328
  var list = '<ul>';
@@ -483,6 +488,8 @@
483
488
  if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
484
489
  this.endDate = this.startDate.clone().add(this.dateLimit);
485
490
 
491
+ this.previousRightTime = this.endDate.clone();
492
+
486
493
  if (!this.isShowing)
487
494
  this.updateElement();
488
495
 
@@ -523,7 +530,7 @@
523
530
  (this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
524
531
  &&
525
532
  (this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
526
- ) {
533
+ ) {
527
534
  return;
528
535
  }
529
536
 
@@ -562,7 +569,7 @@
562
569
  minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
563
570
  second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
564
571
  if (!this.timePicker24Hour) {
565
- var ampm = this.container.find('.left .ampmselect').val();
572
+ var ampm = this.container.find('.right .ampmselect').val();
566
573
  if (ampm === 'PM' && hour < 12)
567
574
  hour += 12;
568
575
  if (ampm === 'AM' && hour === 12)
@@ -839,8 +846,32 @@
839
846
  selected = this.startDate.clone();
840
847
  minDate = this.minDate;
841
848
  } else if (side == 'right') {
842
- selected = this.endDate ? this.endDate.clone() : this.startDate.clone();
849
+ selected = this.endDate ? this.endDate.clone() : this.previousRightTime.clone();
843
850
  minDate = this.startDate;
851
+
852
+ //Preserve the time already selected
853
+ var timeSelector = this.container.find('.calendar.right .calendar-time div');
854
+ if (timeSelector.html() != '') {
855
+
856
+ selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
857
+ selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
858
+ selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());
859
+
860
+ if (!this.timePicker24Hour) {
861
+ var ampm = timeSelector.find('.ampmselect option:selected').val();
862
+ if (ampm === 'PM' && selected.hour() < 12)
863
+ selected.hour(selected.hour() + 12);
864
+ if (ampm === 'AM' && selected.hour() === 12)
865
+ selected.hour(0);
866
+ }
867
+
868
+ if (selected.isBefore(this.startDate))
869
+ selected = this.startDate.clone();
870
+
871
+ if (selected.isAfter(maxDate))
872
+ selected = maxDate.clone();
873
+
874
+ }
844
875
  }
845
876
 
846
877
  //
@@ -1012,7 +1043,7 @@
1012
1043
  this.container.css({
1013
1044
  top: containerTop,
1014
1045
  left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
1015
- - this.container.outerWidth() / 2,
1046
+ - this.container.outerWidth() / 2,
1016
1047
  right: 'auto'
1017
1048
  });
1018
1049
  if (this.container.offset().left < 0) {
@@ -1041,18 +1072,23 @@
1041
1072
 
1042
1073
  // Create a click proxy that is private to this instance of datepicker, for unbinding
1043
1074
  this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
1075
+
1044
1076
  // Bind global datepicker mousedown for hiding and
1045
1077
  $(document)
1046
- .on('mousedown.daterangepicker', this._outsideClickProxy)
1047
- // also support mobile devices
1048
- .on('touchend.daterangepicker', this._outsideClickProxy)
1049
- // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
1050
- .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
1051
- // and also close when focus changes to outside the picker (eg. tabbing between controls)
1052
- .on('focusin.daterangepicker', this._outsideClickProxy);
1078
+ .on('mousedown.daterangepicker', this._outsideClickProxy)
1079
+ // also support mobile devices
1080
+ .on('touchend.daterangepicker', this._outsideClickProxy)
1081
+ // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
1082
+ .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
1083
+ // and also close when focus changes to outside the picker (eg. tabbing between controls)
1084
+ .on('focusin.daterangepicker', this._outsideClickProxy);
1085
+
1086
+ // Reposition the picker if the window is resized while it's open
1087
+ $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
1053
1088
 
1054
1089
  this.oldStartDate = this.startDate.clone();
1055
1090
  this.oldEndDate = this.endDate.clone();
1091
+ this.previousRightTime = this.endDate.clone();
1056
1092
 
1057
1093
  this.updateView();
1058
1094
  this.container.show();
@@ -1078,6 +1114,7 @@
1078
1114
  this.updateElement();
1079
1115
 
1080
1116
  $(document).off('.daterangepicker');
1117
+ $(window).off('.daterangepicker');
1081
1118
  this.container.hide();
1082
1119
  this.element.trigger('hide.daterangepicker', this);
1083
1120
  this.isShowing = false;
@@ -1097,11 +1134,11 @@
1097
1134
  // itself then call this.hide()
1098
1135
  if (
1099
1136
  // ie modal dialog fix
1100
- e.type == "focusin" ||
1101
- target.closest(this.element).length ||
1102
- target.closest(this.container).length ||
1103
- target.closest('.calendar-table').length
1104
- ) return;
1137
+ e.type == "focusin" ||
1138
+ target.closest(this.element).length ||
1139
+ target.closest(this.container).length ||
1140
+ target.closest('.calendar-table').length
1141
+ ) return;
1105
1142
  this.hide();
1106
1143
  },
1107
1144
 
@@ -1244,7 +1281,7 @@
1244
1281
  // * if single date picker mode, and time picker isn't enabled, apply the selection immediately
1245
1282
  //
1246
1283
 
1247
- if (this.endDate || date.isBefore(this.startDate)) {
1284
+ if (this.endDate || date.isBefore(this.startDate, 'day')) {
1248
1285
  if (this.timePicker) {
1249
1286
  var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
1250
1287
  if (!this.timePicker24Hour) {
@@ -1260,6 +1297,10 @@
1260
1297
  }
1261
1298
  this.endDate = null;
1262
1299
  this.setStartDate(date.clone());
1300
+ } else if (!this.endDate && date.isBefore(this.startDate)) {
1301
+ //special case: clicking the same date for start/end,
1302
+ //but the time of the end date is before the start date
1303
+ this.setEndDate(this.startDate.clone());
1263
1304
  } else {
1264
1305
  if (this.timePicker) {
1265
1306
  var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
@@ -1366,8 +1407,11 @@
1366
1407
  start.minute(minute);
1367
1408
  start.second(second);
1368
1409
  this.setStartDate(start);
1369
- if (this.singleDatePicker)
1410
+ if (this.singleDatePicker) {
1370
1411
  this.endDate = this.startDate.clone();
1412
+ } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
1413
+ this.setEndDate(start.clone());
1414
+ }
1371
1415
  } else if (this.endDate) {
1372
1416
  var end = this.endDate.clone();
1373
1417
  end.hour(hour);
@@ -1419,6 +1463,7 @@
1419
1463
  elementChanged: function() {
1420
1464
  if (!this.element.is('input')) return;
1421
1465
  if (!this.element.val().length) return;
1466
+ if (this.element.val().length < this.locale.format.length) return;
1422
1467
 
1423
1468
  var dateString = this.element.val().split(this.locale.separator),
1424
1469
  start = null,
@@ -1434,6 +1479,8 @@
1434
1479
  end = start;
1435
1480
  }
1436
1481
 
1482
+ if (!start.isValid() || !end.isValid()) return;
1483
+
1437
1484
  this.setStartDate(start);
1438
1485
  this.setEndDate(end);
1439
1486
  this.updateView();
@@ -1474,4 +1521,6 @@
1474
1521
  return this;
1475
1522
  };
1476
1523
 
1524
+ return DateRangePicker;
1525
+
1477
1526
  }));
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-daterangepicker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Grossman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-19 00:00:00.000000000 Z
12
+ date: 2016-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.2.2
77
+ rubygems_version: 2.4.5.1
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Rails 4.1x plugin to allow for the easy use of Dan Grossman's Bootstrap DateRangePicker