X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;f=public%2Fjs%2Fforms.js;fp=public%2Fjs%2Fforms.js;h=0000000000000000000000000000000000000000;hb=1de0f433144272946051bb0df886b8c43459beb8;hp=738b056f67c6840d8dd9ec8df9c97f1baea0ccf9;hpb=d9f13fbba43193040911105caf393aff945eb02d;p=syj.git diff --git a/public/js/forms.js b/public/js/forms.js deleted file mode 100644 index 738b056..0000000 --- a/public/js/forms.js +++ /dev/null @@ -1,51 +0,0 @@ -/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier, - and is published under the AGPL license. */ -Element.addMethods(['input', 'textarea'], { - check: function(control, callback, errorMessage) { - if (callback.call(control)) { - return true; - } - control.insert({ - after: new Element("div", {className: 'error'}).update(errorMessage) - }); - return false; - } -}); - -Element.addMethods('form', { - focus: function(form) { - var tofocus, error; - - tofocus = null; - error = form.down('.error'); - if (error) { - tofocus = error.previous('input,textarea'); - } else { - tofocus = form.down('input:not([readonly],[disabled]),textarea:not([readonly][disabled])'); - } - if (tofocus) { - if (error && (typeof tofocus.highlight === "function")) { - tofocus.highlight('#F08080'); - } - tofocus.focus(); - tofocus.select(); - } - }, - - checkEmptyElements: function(form, errorMessage) { - var results = []; - form.select('.required').each(function(elt) { - var id = elt.getAttribute('for'), control = $(id); - if (!control) { - return; - } - if (!control.check(function() { - return !this.value.strip().empty(); - }, errorMessage)) { - results.push(control); - } - }); - return results; - } - -});