From 204daacfffd84382306d6235948c31eaf62ad0f0 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Mon, 1 Oct 2018 19:10:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=84=9A=E6=9C=AC=EF=BC=9A?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E4=BD=BF=E7=94=A8=E7=9A=84=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E3=80=82=E5=BE=AE=E8=B0=83bc=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E9=AB=98=E9=98=85=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/wwwroot/js/longbow.common.js | 62 ++++++------------- Bootstrap.Client/wwwroot/js/longbow.common.js | 30 ++++++--- 2 files changed, 38 insertions(+), 54 deletions(-) diff --git a/Bootstrap.Admin/wwwroot/js/longbow.common.js b/Bootstrap.Admin/wwwroot/js/longbow.common.js index 54ea7cbf..22092288 100644 --- a/Bootstrap.Admin/wwwroot/js/longbow.common.js +++ b/Bootstrap.Admin/wwwroot/js/longbow.common.js @@ -151,6 +151,17 @@ } 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 = { url: $.formatUrl(url), data: data, @@ -170,16 +181,6 @@ crossDomain: true }); $.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) { if ($.isFunction(swal)) { @@ -192,23 +193,6 @@ while (document.getElementById(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) { if (!url) return url; if (url.substr(0, 4) === "http") return url; @@ -220,23 +204,13 @@ window.lgbSwal = $.lgbSwal; $.fn.extend({ - fixCollapse: function () { - var $root = this; - var $collapse = $root.find('a[data-toggle="collapse"]:visible'); - $collapse.each(function () { - var $this = $(this); - if ($this.attr('href') !== '#') return; - var $target = $this.parent().next(); - 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' }); + 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) { diff --git a/Bootstrap.Client/wwwroot/js/longbow.common.js b/Bootstrap.Client/wwwroot/js/longbow.common.js index 4d84dd20..7451b37a 100644 --- a/Bootstrap.Client/wwwroot/js/longbow.common.js +++ b/Bootstrap.Client/wwwroot/js/longbow.common.js @@ -150,6 +150,17 @@ } 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 = { url: $.formatUrl(url), data: data, @@ -169,16 +180,6 @@ crossDomain: true }); $.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) { if ($.isFunction(swal)) { @@ -202,6 +203,15 @@ 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;