Add jquery-form extensions.

pull/279/head
Halil İbrahim Kalkan 7 years ago
parent 2649254ca2
commit c62474dc13

@ -44,6 +44,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared
"/libs/abp/jquery/abp.ajax.js",
"/libs/abp/jquery/abp.resource-loader.js",
"/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery/jquery-extensions.js",
"/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js",
"/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js",
"/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/modal-manager.js",
"/libs/abp/aspnetcore.mvc.ui.theme.shared/datatables/datatables-extensions.js"

@ -0,0 +1,47 @@
(function ($) {
if (!$ || !$.fn.ajaxForm) {
return;
}
$.fn.abpAjaxForm = function (userOptions) {
userOptions = userOptions || {};
var options = $.extend({}, $.fn.abpAjaxForm.defaults, userOptions);
options.beforeSubmit = function (arr, $form) {
userOptions.beforeSubmit && userOptions.beforeSubmit.apply(this, arguments);
$form.find("button[type='submit']").buttonBusy(true);
//TODO: Disable other buttons..?
};
options.error = function (jqXhr) {
if (jqXhr.getResponseHeader('_AbpErrorFormat') === 'true') {
abp.ajax.logError(jqXhr.responseJSON.error);
var messagePromise = abp.ajax.showError(jqXhr.responseJSON.error);
if (jqXhr.status === 401) {
abp.ajax.handleUnAuthorizedRequest(messagePromise);
}
} else {
abp.ajax.handleErrorStatusCode(jqXhr.status);
}
};
//TODO: Error?
options.complete = function (jqXhr, status, $form) {
if ($.contains(document, $form[0])) {
$form.find("button[type='submit']").buttonBusy(false);
//TODO: Re-enable other buttons..?
}
userOptions.complete && userOptions.complete.apply(this, arguments);
};
return this.ajaxForm(options);
};
$.fn.abpAjaxForm.defaults = {
method: 'POST'
};
})(jQuery);

@ -80,6 +80,14 @@
return obj;
};
$.fn.focusEndOfText = function () {
return this.each(function () {
var $this = $(this);
setTimeout(function () {
$this.focus();
$this[0].selectionStart = $this[0].selectionEnd = 10000;
}, 0);
});
};
})(jQuery);
Loading…
Cancel
Save