修改BUG:$.bc增加loading弹窗时间过短导致弹窗无法关闭问题

This commit is contained in:
Argo-MacBookPro 2018-10-11 15:25:41 +08:00
parent 07337b1968
commit 4174fdf0b0
2 changed files with 22 additions and 24 deletions

View File

@ -133,11 +133,19 @@
return;
}
var loadFlag = "loading";
if (options.loading && options.modal) {
$(options.modal).find('.close').addClass('hidden');
$(options.modal).modal('show');
var $modal = $(options.modal);
if (!$modal.hasClass('event')) {
$modal.on('shown.bs.modal', function () {
var $this = $(this);
if ($this.hasClass(loadFlag)) return;
$this.modal('hide');
});
}
$(options.modal).addClass(loadFlag).modal('show');
setTimeout(function () {
$(options.modal).find('.close').removeClass('hidden');
$(options.modal).find('.close').removeClass('d-none');
}, options.loadingTimeout);
}
@ -204,15 +212,6 @@
window.lgbSwal = $.lgbSwal;
$.fn.extend({
bc: function (options) {
if (this.attr('lgb_click')) return this;
this.attr('lgb_click', true);
var callback = options.callback;
var that = this;
options.callback = function () { that.removeAttr('lgb_click'); if ($.isFunction(callback)) callback.apply(arguments); };
$.bc(options);
return this;
},
autoCenter: function (options) {
options = $.extend({ top: 0 }, options);
var that = this;

View File

@ -132,11 +132,19 @@
return;
}
var loadFlag = "loading";
if (options.loading && options.modal) {
$(options.modal).find('.close').addClass('hidden');
$(options.modal).modal('show');
var $modal = $(options.modal);
if (!$modal.hasClass('event')) {
$modal.on('shown.bs.modal', function () {
var $this = $(this);
if ($this.hasClass(loadFlag)) return;
$this.modal('hide');
});
}
$(options.modal).addClass(loadFlag).modal('show');
setTimeout(function () {
$(options.modal).find('.close').removeClass('hidden');
$(options.modal).find('.close').removeClass('d-none');
}, options.loadingTimeout);
}
@ -203,15 +211,6 @@
window.lgbSwal = $.lgbSwal;
$.fn.extend({
bc: function (options) {
if (this.attr('lgb_click')) return this;
this.attr('lgb_click', true);
const callback = options.callback;
const that = this;
options.callback = function () { that.removeAttr('lgb_click'); if ($.isFunction(callback)) callback.apply(arguments); };
$.bc(options);
return this;
},
autoCenter: function (options) {
options = $.extend({ top: 0 }, options);
var that = this;