More configuration.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 3 May 2008 21:51:14 +0000 (23:51 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 3 May 2008 21:59:10 +0000 (23:59 +0200)
* can change the submit button name
* auto-disable the submit button at startup

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
htdocs/javascript/xorg.js
plugins/compiler.checkpasswd.php

index 7cb2fe3..84ace48 100644 (file)
@@ -326,9 +326,9 @@ function checkPassword(box) {
     ok = (prop >= 60);
     $("#passwords_measure").width(prop + "%").css("background-color", ok ? "green" : "red");
     if (ok) {
-        $(":submit").removeAttr("disabled");
+        $(":submit[@name='" + passwordprompt_submit + "']").removeAttr("disabled");
     } else {
-        $(":submit").attr("disabled", "disabled");
+        $(":submit[@name='" + passwordprompt_submit + "']").attr("disabled", "disabled");
     }
 }
 
index dbfbc71..1f90d09 100644 (file)
@@ -26,13 +26,21 @@ function smarty_compiler_checkpasswd($tag_attrs, &$compiler)
     if (!isset($width)) {
       $width = '250px';
     }
-    if (!isset($id)) {
-      $id = "newpassword";
+    if (!isset($prompt)) {
+      $prompt = "'nouveau'";
+    }
+    if (!isset($submit)) {
+      $submit = "'submitn'";
     }
 
     return '?><script type="text/javascript" src="javascript/jquery.js" ></script>
               <script type="text/javascript">//<![CDATA[
-                $(":input[@name=' . $id . ']").keyup(function(event) { checkPassword(event.target); });
+                var passwordprompt_name = '.  $prompt . ';
+                var passwordprompt_submit = ' . $submit . ';
+                $(":input[@name=' . $prompt . ']").keyup(function(event) { checkPassword(event.target); });
+                $(document).ready(function() {
+                  $(":submit[@name=' . $submit . ']").attr("disabled", "disabled");
+                });
               //]]></script>
               <div style="border: 1px solid white; width: ' . $width . '; height: 7px; background-color: #444">
                 <div id="passwords_measure" style="height: 100%; background-color: red; width: 0px"></div>