X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;f=public%2Fjs%2Fajaxize.js;fp=public%2Fjs%2Fajaxize.js;h=0000000000000000000000000000000000000000;hb=1de0f433144272946051bb0df886b8c43459beb8;hp=6680110f23ba080081439e7b5ec47bf475f3e240;hpb=d9f13fbba43193040911105caf393aff945eb02d;p=syj.git diff --git a/public/js/ajaxize.js b/public/js/ajaxize.js deleted file mode 100644 index 6680110..0000000 --- a/public/js/ajaxize.js +++ /dev/null @@ -1,58 +0,0 @@ -/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier, - and is published under the AGPL license. */ - -// wrapper around Form.request that sets up the submit listener, stops the -// submit event, calls presubmit function, calls Form.request and calls a -// postsubmit function -Element.addMethods('form', {ajaxize : function(form, options) { - var reqoptions, timeout; - - options = Object.clone(options); - reqoptions = Object.clone(options); - timeout = null; - - function onSuccess(transport, json) { - if (timeout) { - window.clearTimeout(timeout); - timeout = null; - } - if (transport.getStatus() === 0) { - options.onFailure(transport, json); - } else { - options.onSuccess(transport, json); - } - } - - function onFailure(transport, json) { - if (timeout) { - window.clearTimeout(timeout); - timeout = null; - } - options.onFailure(transport, json); - } - - delete(reqoptions.presubmit); - delete(reqoptions.postsubmit); - - $(form).observe('submit', function(evt) { - var req; - - evt.stop(); // cancel form submission - if (Object.isFunction(options.presubmit)) { - if (options.presubmit(this) === false) { - return; - } - } - req = this.request(Object.extend(reqoptions, { - onSuccess: onSuccess, - onFailure: onFailure - })); - timeout = (function() { - options.onFailure(null); - req.abort(); - }).delay(options.timeout || 20); - if (Object.isFunction(options.postsubmit)) { - options.postsubmit(this); - } - }); -}});