Merge pull request #4695 from expsa/eltayar
Final Fix: Both Gregorian and Hijri calendars auto-hide on outside click
This commit is contained in:
commit
eb2d2f3fd0
|
|
@ -92,17 +92,26 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this._outsideClickHandler = function(e) {
|
this._outsideClickHandler = function(e) {
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
if (!$target.closest('.calendars-popup').length &&
|
|
||||||
!$target.closest('.o_hijri').length &&
|
var shouldIgnore = $target.closest('.calendars-popup').length ||
|
||||||
!$target.hasClass('o_hijri') &&
|
$target.closest('.o_hijri').length ||
|
||||||
!$target.closest('.calendars').length) {
|
$target.hasClass('o_hijri') ||
|
||||||
self._hideHijriCalendar();
|
$target.closest('.calendars').length ||
|
||||||
|
$target.closest('.bootstrap-datetimepicker-widget').length ||
|
||||||
|
$target.closest('.datepicker').length ||
|
||||||
|
$target.hasClass('o_datepicker_input') ||
|
||||||
|
$target.hasClass('o_datepicker_button') ||
|
||||||
|
$target.closest('.datetimepicker').length ||
|
||||||
|
$target.closest('.datetimepicker-dropdown').length;
|
||||||
|
|
||||||
|
if (!shouldIgnore) {
|
||||||
|
self._hideAllCalendars();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this._keydownHandler = function(e) {
|
this._keydownHandler = function(e) {
|
||||||
if (e.keyCode === 27) {
|
if (e.keyCode === 27) {
|
||||||
self._hideHijriCalendar();
|
self._hideAllCalendars();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -115,10 +124,17 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) {
|
||||||
$(document).off('keydown.hijri_calendar');
|
$(document).off('keydown.hijri_calendar');
|
||||||
},
|
},
|
||||||
|
|
||||||
_hideHijriCalendar: function() {
|
_hideAllCalendars: function() {
|
||||||
if (this.$input_hijri && this.$input_hijri.calendarsPicker) {
|
if (this.$input_hijri && this.$input_hijri.calendarsPicker) {
|
||||||
this.$input_hijri.calendarsPicker('hide');
|
this.$input_hijri.calendarsPicker('hide');
|
||||||
}
|
}
|
||||||
|
if (this.$el && this.$el.data('DateTimePicker')) {
|
||||||
|
this.$el.data('DateTimePicker').hide();
|
||||||
|
} else if (this.$el && this.$el.datetimepicker) {
|
||||||
|
try {
|
||||||
|
this.$el.datetimepicker('hide');
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changeDatetime: function () {
|
changeDatetime: function () {
|
||||||
|
|
@ -161,7 +177,7 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) {
|
||||||
var date_value = moment(time.str_to_date(formatted_date)).add(1, 'days');
|
var date_value = moment(time.str_to_date(formatted_date)).add(1, 'days');
|
||||||
this.setValue(this._parseClient(date_value));
|
this.setValue(this._parseClient(date_value));
|
||||||
this.trigger("datetime_changed");
|
this.trigger("datetime_changed");
|
||||||
this._hideHijriCalendar();
|
this._hideAllCalendars();
|
||||||
},
|
},
|
||||||
|
|
||||||
_parseDate: function (v) {
|
_parseDate: function (v) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue