Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
trigger single calendar callback if not input is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
kalepail committed Jan 26, 2017
1 parent f7bde75 commit 33e4aaf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
19 changes: 9 additions & 10 deletions dev/js/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@
self.presetToggle();

if (self.calIsOpen) {

if ($(self.selected).hasClass("dr-date-end"))
if ($(self.selected).hasClass('dr-date-end'))
self.calendarSaveDates();

self.calendarSetDates();
Expand Down Expand Up @@ -319,11 +318,11 @@


Calendar.prototype.calendarSaveDates = function() {
if (this.type == 'double') {
if (this.type === 'double') {
if (!moment(this.orig_end_date).isSame(this.end_date) || !moment(this.orig_start_date).isSame(this.start_date))
return this.callback();
} else {
if ($(this.selected).html().length && !moment(this.orig_current_date).isSame(this.current_date))
if (!this.required || !moment(this.orig_current_date).isSame(this.current_date))
return this.callback();
}
}
Expand Down Expand Up @@ -765,19 +764,19 @@
var string = moment(date).format(cal.format.input);

if (other) {
$('.dr-date', cal.element)
.not(cal.selected)
.html(other.format(cal.format.input));
$('.dr-date', cal.element)
.not(cal.selected)
.html(other.format(cal.format.input));
}

$(cal.selected).html(string);
cal.calendarOpen(cal.selected);

if ($(cal.selected).hasClass('dr-date-start')) {
$('.dr-date-end', cal.element).trigger('click');
$('.dr-date-end', cal.element).trigger('click');
} else {
cal.calendarSaveDates();
cal.calendarClose('force');
cal.calendarSaveDates();
cal.calendarClose('force');
}
}

Expand Down
19 changes: 9 additions & 10 deletions public/js/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@
self.presetToggle();

if (self.calIsOpen) {

if ($(self.selected).hasClass("dr-date-end"))
if ($(self.selected).hasClass('dr-date-end'))
self.calendarSaveDates();

self.calendarSetDates();
Expand Down Expand Up @@ -319,11 +318,11 @@


Calendar.prototype.calendarSaveDates = function() {
if (this.type == 'double') {
if (this.type === 'double') {
if (!moment(this.orig_end_date).isSame(this.end_date) || !moment(this.orig_start_date).isSame(this.start_date))
return this.callback();
} else {
if ($(this.selected).html().length && !moment(this.orig_current_date).isSame(this.current_date))
if (!this.required || !moment(this.orig_current_date).isSame(this.current_date))
return this.callback();
}
}
Expand Down Expand Up @@ -765,19 +764,19 @@
var string = moment(date).format(cal.format.input);

if (other) {
$('.dr-date', cal.element)
.not(cal.selected)
.html(other.format(cal.format.input));
$('.dr-date', cal.element)
.not(cal.selected)
.html(other.format(cal.format.input));
}

$(cal.selected).html(string);
cal.calendarOpen(cal.selected);

if ($(cal.selected).hasClass('dr-date-start')) {
$('.dr-date-end', cal.element).trigger('click');
$('.dr-date-end', cal.element).trigger('click');
} else {
cal.calendarSaveDates();
cal.calendarClose('force');
cal.calendarSaveDates();
cal.calendarClose('force');
}
}

Expand Down

0 comments on commit 33e4aaf

Please sign in to comment.