From a5195654646caee5e19c4d82140e86b91b552c58 Mon Sep 17 00:00:00 2001 From: Nicolas Badia Date: Mon, 23 Oct 2017 08:17:14 +0200 Subject: [PATCH] Updates to version 1.1 --- form-submitter.js | 2 +- form-submitter.min.js | 12 ++++++------ package.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/form-submitter.js b/form-submitter.js index 207d4fb..9238ac6 100755 --- a/form-submitter.js +++ b/form-submitter.js @@ -3,7 +3,7 @@ // Description: jQuery plugin used in GestiXi websites to handle form submission // Copyright: ©2013-2016 GestiXi // License: Licensed under the MIT license (see LICENCE) -// Version: 1.0 +// Version: 1.1 // Author: Nicolas BADIA // ========================================================================== diff --git a/form-submitter.min.js b/form-submitter.min.js index 86628c4..d410846 100755 --- a/form-submitter.min.js +++ b/form-submitter.min.js @@ -1,6 +1,6 @@ -/*! Form Submitter v1.0 | ©2013-2016 GestiXi | Licensed under the MIT license */ -!function(f){f.fn.formSubmitter=function(a){return this.each(function(){var b=f(this),c="FORM"===b[0].tagName?b.parent().find("form"):b.find("form"),e=c.data("formSubmitter");if(e)console.warn("formSubmitter is already handling the form");else{var d=f.extend({},f.fn.formSubmitter.defaults,"object"==typeof a&&a);c.data("formSubmitter",e=new g(this,c,d));c.find("input[type=submit]").on("click touchstart",function(){c.find("input[type=submit]").removeAttr("clicked");f(this).attr("clicked","true")}); -c.on("submit",function(a){a.preventDefault();if(d.willSend.call(e,a)){var b=f("input[type=submit][clicked=true]");b.prop("disabled",!0);e.clickedButton=b;e.handler(a);d.didSend.call(e,a)}})}})};f.fn.formSubmitter.defaults={willSend:function(a){return!0},formSettings:function(a){a=this.$form;return{method:a.attr("method"),url:a.attr("action"),data:a.serialize()}},didSend:function(a){},willReceive:function(a){return JSON.parse(a)},didReceive:function(a,b){},notificationLayout:"position:fixed;top:10px;left:10px;width:350px;z-index:1000;"}; -var g=function(a,b,c){this.element=a;this.$form=b;this.options=c};f.fn.formSubmitter.Constructor=g;g.prototype={constructor:g,element:null,$form:null,options:null,handler:function(a){var b=this,c=this.options;a=c.formSettings.call(this,a);f.ajax(a).done(function(a){var d=b.clickedButton;d&&d.prop("disabled",!1);if(a=c.willReceive.call(b,a))d=b.handleResponse(a),c.didReceive.call(b,a,d)});return!1},handleResponse:function(a){var b=this.$form,c=a.notification,e=a.helpInline,d=a.submitForm,g=a.redirectUrl; -g&&(document.location.href=g);d&&this.submitForm(d);f(".help-inline").html("");f(".form-group").removeClass("has-error");if(e){var e=JSON.parse(e),h;for(h in e)d=b.find(".help-inline."+h),d.html(e[h]),d.closest(".form-group").addClass("has-error")}c&&this.notify(c);return a},notify:function(a){f("#notification-container").length||f('
').appendTo("body");var b=f(a);b.hide().appendTo("#notification-container").slideDown().delay(8E3).fadeOut(400, -function(){b.remove()})},submitForm:function(a){a=JSON.parse(a);var b=document.createElement("form");b.setAttribute("method",a.method||"post");b.setAttribute("action",a.action);for(var c=0;c').appendTo("body");var b=f(a);b.hide().appendTo("#notification-container").slideDown().delay(c).fadeOut(400, +function(){b.remove()})},submitForm:function(a){a=JSON.parse(a);var c=document.createElement("form");c.setAttribute("method",a.method||"post");c.setAttribute("action",a.action);for(var b=0;b