Display close button also for auto-disposable notices if hideClose === false

The notice component was ignoring "hideClose" setting when "static" was set to false
(= auto disposable notice after timeout). This commit makes the behavior more transparent
by always respecting each of the settings. Note that jQuery's "delay()" can't be used now
since it blocks also other close events with the timout (events from close button).

[MAILPOET-1448]
This commit is contained in:
Jan Jakeš
2018-07-29 13:59:13 +02:00
parent 364facabd5
commit c5ee742b01

View File

@@ -166,8 +166,12 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) { // eslint-disab
// if the notice is not static, it has to disappear after a timeout
if (this.options.static === false) {
this.element.delay(this.options.timeout).trigger('close');
} else if (this.options.hideClose === false) {
setTimeout(function (target) { // eslint-disable-line func-names
target.trigger('close');
}, this.options.timeout, this.element);
}
if (this.options.hideClose === false) {
this.element.append('<a href="javascript:;" class="mailpoet_notice_close"><span class="dashicons dashicons-dismiss"></span></a>');
this.element.find('.mailpoet_notice_close').on('click', function () { // eslint-disable-line func-names
jQuery(this).trigger('close');