]> dev.renevier.net Git - syj.git/blob - public/js/newpwd.js
js strict mode in development files
[syj.git] / public / js / newpwd.js
1 /*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
2     and is published under the AGPL license. */
3
4 "use strict";
5
6 function insertErrorBefore(elt, messageError) {
7     var message = new Element("div", {className: 'error'}).update(messageError);
8     elt.insert({before: message});
9 }
10
11 document.observe("dom:loaded", function() {
12     var errors, tofocus;
13
14     errors = $$('.error');
15     tofocus = null;
16     if (errors.length) {
17         tofocus = $('newpwd_email');
18     } else {
19         tofocus = $$('form input:not([readonly],[disabled])')[0];
20     }
21     if (tofocus) {
22         tofocus.activate();
23     }
24
25     $("newpwdform").observe('submit', function(evt) {
26         $$('.error').invoke('remove');
27         if ($('newpwd_email').value.strip().empty()) {
28             insertErrorBefore($('newpwdform').select('table')[0], SyjStrings.notEmptyField);
29             $('newpwd_email').highlight('#F08080').activate();
30             evt.stop();
31         }
32     });
33
34 });