更新脚本:删除不使用的脚本。微调bc方法,提高阅读性

This commit is contained in:
Argo-MacBookPro 2018-10-01 19:10:43 +08:00
parent da1f1731fa
commit 204daacfff
2 changed files with 38 additions and 54 deletions

View File

@ -151,6 +151,17 @@
} }
url = url + "?" + qs.join('&'); url = url + "?" + qs.join('&');
} }
function success(result) {
if ($.isFunction(options.callback)) {
options.callback.call(options, result);
}
if (options.modal && (result || options.loading)) {
$(options.modal).modal('hide');
}
if (options.title) toastr[result ? 'success' : 'error'](options.title + (result ? "成功" : "失败"));
}
var ajaxSettings = { var ajaxSettings = {
url: $.formatUrl(url), url: $.formatUrl(url),
data: data, data: data,
@ -170,16 +181,6 @@
crossDomain: true crossDomain: true
}); });
$.ajax(ajaxSettings); $.ajax(ajaxSettings);
function success(result) {
if ($.isFunction(options.callback)) {
options.callback.call(options, result);
}
if (options.modal && (result || options.loading)) {
$(options.modal).modal('hide');
}
if (options.title) toastr[result ? 'success' : 'error'](options.title + (result ? "成功" : "失败"));
}
}, },
lgbSwal: function (options) { lgbSwal: function (options) {
if ($.isFunction(swal)) { if ($.isFunction(swal)) {
@ -192,23 +193,6 @@
while (document.getElementById(prefix)); while (document.getElementById(prefix));
return prefix; return prefix;
}, },
fullScreenStatus: function fullScreenStatus(value) {
if (value !== undefined) window.fullscreen = value;
return document.fullscreen ||
document.mozFullScreen ||
document.webkitIsFullScreen || window.fullscreen ||
false;
},
formatter: function (key) {
if (!this[key]) {
this[key] = {};
var that = this;
$.each($('#' + key).children(), function (index, element) {
that[key][$(element).attr('value')] = $(element).text();
});
}
return this;
},
formatUrl: function (url) { formatUrl: function (url) {
if (!url) return url; if (!url) return url;
if (url.substr(0, 4) === "http") return url; if (url.substr(0, 4) === "http") return url;
@ -220,23 +204,13 @@
window.lgbSwal = $.lgbSwal; window.lgbSwal = $.lgbSwal;
$.fn.extend({ $.fn.extend({
fixCollapse: function () { bc: function (options) {
var $root = this; if (this.attr('lgb_click')) return this;
var $collapse = $root.find('a[data-toggle="collapse"]:visible'); this.attr('lgb_click', true);
$collapse.each(function () { const callback = options.callback;
var $this = $(this); const that = this;
if ($this.attr('href') !== '#') return; options.callback = function () { that.removeAttr('lgb_click'); if ($.isFunction(callback)) callback.apply(arguments); };
var $target = $this.parent().next(); $.bc(options);
var tId = $.getUID('collapse');
$target.attr('id', tId);
$this.attr('href', '#' + tId);
});
return this;
},
adjustDialog: function () {
var $modal_dialog = this;
var m_top = Math.max(0, ($(window).height() - $modal_dialog.height()) / 2);
$modal_dialog.css({ 'margin': m_top + 'px auto' });
return this; return this;
}, },
autoCenter: function (options) { autoCenter: function (options) {

View File

@ -150,6 +150,17 @@
} }
url = url + "?" + qs.join('&'); url = url + "?" + qs.join('&');
} }
function success(result) {
if ($.isFunction(options.callback)) {
options.callback.call(options, result);
}
if (options.modal && (result || options.loading)) {
$(options.modal).modal('hide');
}
if (options.title) toastr[result ? 'success' : 'error'](options.title + (result ? "成功" : "失败"));
}
var ajaxSettings = { var ajaxSettings = {
url: $.formatUrl(url), url: $.formatUrl(url),
data: data, data: data,
@ -169,16 +180,6 @@
crossDomain: true crossDomain: true
}); });
$.ajax(ajaxSettings); $.ajax(ajaxSettings);
function success(result) {
if ($.isFunction(options.callback)) {
options.callback.call(options, result);
}
if (options.modal && (result || options.loading)) {
$(options.modal).modal('hide');
}
if (options.title) toastr[result ? 'success' : 'error'](options.title + (result ? "成功" : "失败"));
}
}, },
lgbSwal: function (options) { lgbSwal: function (options) {
if ($.isFunction(swal)) { if ($.isFunction(swal)) {
@ -202,6 +203,15 @@
window.lgbSwal = $.lgbSwal; window.lgbSwal = $.lgbSwal;
$.fn.extend({ $.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) { autoCenter: function (options) {
options = $.extend({ top: 0 }, options); options = $.extend({ top: 0 }, options);
var that = this; var that = this;