X-Git-Url: https://dev.renevier.net/gitweb.cgi?a=blobdiff_plain;f=public%2Fjs%2Futils.js;h=dfc1a3d76952e960e706653b6a94dfdfa9c616d4;hb=db98e1f62272cff0b425133aa3b909c5cfa6183d;hp=f437d150d8f821000afa9adda7253547deb0c0eb;hpb=6cc4b3cd4538430770c935bd3192f1f72d75d96b;p=syj.git diff --git a/public/js/utils.js b/public/js/utils.js index f437d15..dfc1a3d 100644 --- a/public/js/utils.js +++ b/public/js/utils.js @@ -10,14 +10,18 @@ var CloseBtn = Class.create({ return; } + if (typeof options !== "object") { + options = {}; + } + style = Object.extend({ float: "right", margin: "2px", fontWeight: "bold", padding: "0px" - }, typeof options === "object" ? options.style: {}); + }, options.style); - imgsrc = (options && options.closeBtnSrc) || "icons/close.png"; + imgsrc = (options.closeBtnSrc) || "icons/close.png"; btn = new Element("input", { type: "image", src: imgsrc, alt: "X"}).setStyle(style); elt.insert({top: btn}); btn.observe("click", function(evt) { @@ -212,11 +216,37 @@ Element.addMethods('form', { reqoptions.method = this.method; } + if (reqoptions.onFailure) { + reqoptions.onFailure = reqoptions.onFailure.wrap(function(proceed, transport, json) { + form.enable(); + proceed(transport, json); + }); + } else { + reqoptions.onFailure = function() { + form.enable(); + }; + } + + if (reqoptions.onSuccess) { + reqoptions.onSuccess = reqoptions.onSuccess.wrap(function(proceed, transport, json) { + form.enable(); + proceed(transport, json); + }); + } else { + reqoptions.onSuccess = function() { + form.enable(); + }; + } + new Ajax.TimedRequest(action, options.delay || 20, reqoptions); if (Object.isFunction(options.postsubmit)) { options.postsubmit(this); } + Form.getElements(form).each(function(elt) { + elt.blur(); + elt.disable(); + }); }); },