|
55 | 55 | this.autoUpdateInput = true;
|
56 | 56 | this.alwaysShowCalendars = false;
|
57 | 57 | this.ranges = {};
|
| 58 | + this.userChangedSelection = false; |
58 | 59 |
|
59 | 60 | this.opens = 'right';
|
60 | 61 | if (this.element.hasClass('pull-right'))
|
|
1105 | 1106 |
|
1106 | 1107 | show: function(e) {
|
1107 | 1108 | if (this.isShowing) return;
|
| 1109 | + this.userChangedSelection = false; |
1108 | 1110 |
|
1109 | 1111 | // Create a click proxy that is private to this instance of datepicker, for unbinding
|
1110 | 1112 | this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
|
|
1143 | 1145 | }
|
1144 | 1146 |
|
1145 | 1147 | //if a new date range was selected, invoke the user callback function
|
1146 |
| - if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate)) |
| 1148 | + if (this.userChangedSelection || !this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate)) { |
1147 | 1149 | this.callback(this.startDate.clone(), this.endDate.clone(), this.chosenLabel);
|
| 1150 | + } |
1148 | 1151 |
|
1149 | 1152 | //if picker is attached to a text input, update it
|
1150 | 1153 | this.updateElement();
|
|
1315 | 1318 | //special case: clicking the same date for start/end,
|
1316 | 1319 | //but the time of the end date is before the start date
|
1317 | 1320 | this.setEndDate(this.startDate.clone());
|
| 1321 | + this.userChangedSelection = true; |
1318 | 1322 | } else { // picking end
|
1319 | 1323 | if (this.timePicker) {
|
1320 | 1324 | var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
|
|
1337 | 1341 | this.calculateChosenLabel();
|
1338 | 1342 | this.clickApply();
|
1339 | 1343 | }
|
| 1344 | + this.userChangedSelection = true; |
1340 | 1345 | }
|
1341 | 1346 |
|
1342 | 1347 | if (this.singleDatePicker) {
|
| 1348 | + this.userChangedSelection = true; |
1343 | 1349 | this.setEndDate(this.startDate);
|
1344 | 1350 | if (!this.timePicker)
|
1345 | 1351 | this.clickApply();
|
|
1439 | 1445 | },
|
1440 | 1446 |
|
1441 | 1447 | timeChanged: function(e) {
|
| 1448 | + this.userChangedSelection = true; |
1442 | 1449 |
|
1443 | 1450 | var cal = $(e.target).closest('.drp-calendar'),
|
1444 | 1451 | isLeft = cal.hasClass('left');
|
|
1509 | 1516 |
|
1510 | 1517 | if (!start.isValid() || !end.isValid()) return;
|
1511 | 1518 |
|
| 1519 | + this.userChangedSelection = false |
1512 | 1520 | this.setStartDate(start);
|
1513 | 1521 | this.setEndDate(end);
|
1514 | 1522 | this.updateView();
|
|
0 commit comments