重构代码:同步公共脚本
This commit is contained in:
parent
6a3263a29d
commit
0ae84888d9
|
@ -144,24 +144,22 @@
|
||||||
var loadingHandler = null;
|
var loadingHandler = null;
|
||||||
if (options.loading && options.modal) {
|
if (options.loading && options.modal) {
|
||||||
var $modal = $(options.modal);
|
var $modal = $(options.modal);
|
||||||
if (!$modal.hasClass('event')) {
|
$modal.on('shown.bs.modal', function () {
|
||||||
$modal.on('shown.bs.modal', function () {
|
var $this = $(this);
|
||||||
var $this = $(this);
|
if (loadingHandler !== null) {
|
||||||
if (loadingHandler !== null) {
|
window.clearTimeout(loadingHandler);
|
||||||
window.clearTimeout(loadingHandler);
|
loadingHandler = null;
|
||||||
loadingHandler = null;
|
}
|
||||||
}
|
if ($this.hasClass(loadFlag)) return;
|
||||||
if ($this.hasClass(loadFlag)) return;
|
$this.modal('hide');
|
||||||
$this.modal('hide');
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
loadingHandler = window.setTimeout(function () { $(options.modal).addClass(loadFlag).modal('show'); }, 300);
|
loadingHandler = window.setTimeout(function () { $(options.modal).addClass(loadFlag).modal('show'); }, 300);
|
||||||
setTimeout(function () {
|
var loadTimeoutHandler = setTimeout(function () {
|
||||||
$(options.modal).find('.close').removeClass('d-none');
|
$(options.modal).find('.close').removeClass('d-none');
|
||||||
|
clearTimeout(loadTimeoutHandler);
|
||||||
}, options.loadingTimeout);
|
}, options.loadingTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var data = options.method === 'get' ? options.data : JSON.stringify(options.data);
|
var data = options.method === 'get' ? options.data : JSON.stringify(options.data);
|
||||||
var url = options.id !== '' ? options.url + '/' + options.id : options.url;
|
var url = options.id !== '' ? options.url + '/' + options.id : options.url;
|
||||||
if (options.query) {
|
if (options.query) {
|
||||||
|
@ -386,7 +384,7 @@
|
||||||
if ($.isFunction(op.callback)) op.callback.apply(that, arguments);
|
if ($.isFunction(op.callback)) op.callback.apply(that, arguments);
|
||||||
return console.error(err.toString());
|
return console.error(err.toString());
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
if (op.invoke) op.invoke(connection).then(result => console.log(result)).catch(err => console.error(err.toString()));
|
if (op.invoke) op.invoke(connection).then(function (result) { console.log(result); }).catch(function (err) { console.error(err.toString()); });
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -439,12 +437,6 @@
|
||||||
"hideMethod": "fadeOut"
|
"hideMethod": "fadeOut"
|
||||||
};
|
};
|
||||||
|
|
||||||
$('[data-toggle="dropdown"].dropdown-select').dropdown('select');
|
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
|
||||||
$('[data-toggle="popover"]').popover();
|
|
||||||
$('[data-toggle="lgbinfo"]').lgbInfo();
|
|
||||||
$('.date').lgbDatePicker();
|
|
||||||
|
|
||||||
$('.collapse').on('shown.bs.collapse', function () {
|
$('.collapse').on('shown.bs.collapse', function () {
|
||||||
$.footer().removeClass('d-none');
|
$.footer().removeClass('d-none');
|
||||||
}).on('hidden.bs.collapse', function () {
|
}).on('hidden.bs.collapse', function () {
|
||||||
|
@ -454,10 +446,6 @@
|
||||||
}).on('show.bs.collapse', function () {
|
}).on('show.bs.collapse', function () {
|
||||||
$('footer').addClass('d-none');
|
$('footer').addClass('d-none');
|
||||||
});
|
});
|
||||||
|
|
||||||
// fix bug bootstrap-table 1.12.1 showToggle
|
|
||||||
if ($.fn.bootstrapTable) $.fn.bootstrapTable.Constructor.DEFAULTS.icons.toggle = $.fn.bootstrapTable.Constructor.DEFAULTS.icons.toggleOff;
|
|
||||||
|
|
||||||
|
|
||||||
$(window).on('resize', function () {
|
$(window).on('resize', function () {
|
||||||
$.footer();
|
$.footer();
|
||||||
|
|
|
@ -132,12 +132,13 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
swal({
|
swal({
|
||||||
title: "您确定要删除吗?",
|
title: "删除数据",
|
||||||
|
text: "您确定要删除选中的所有数据吗",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
closeOnConfirm: true,
|
cancelButtonClass: 'btn-secondary',
|
||||||
confirmButtonText: "是的,我要删除",
|
confirmButtonText: "我要删除",
|
||||||
confirmButtonColor: "#d9534f",
|
confirmButtonClass: "btn-danger ml-2",
|
||||||
cancelButtonText: "取消"
|
cancelButtonText: "取消"
|
||||||
}, function () {
|
}, function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
}).on('inserted.bs.tooltip', this.options.childClass, function () {
|
}).on('inserted.bs.tooltip', this.options.childClass, function () {
|
||||||
$('#' + $(this).attr('aria-describedby')).addClass(that.options.errorClass);
|
$('#' + $(this).attr('aria-describedby')).addClass(that.options.errorClass);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!this.options.validButtons) return;
|
if (!this.options.validButtons) return;
|
||||||
this.$element.find(this.options.validButtons).on('click.lgb.validate', function (e) {
|
this.$element.find(this.options.validButtons).on('click.lgb.validate', function (e) {
|
||||||
var valid = that.valid();
|
var valid = that.valid();
|
||||||
|
|
Loading…
Reference in New Issue