Animated progression bar, better colors.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 4 May 2008 10:13:27 +0000 (12:13 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 4 May 2008 10:16:49 +0000 (12:16 +0200)
WARNING: requires jQuery 1.2, upgrade your jQuery if you're still on a previous version.

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

index eed1687..8876425 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -115,10 +115,13 @@ include/banana/banana.inc.php:
 ## jquery
 ##
 
-jquery: htdocs/javascript/jquery.js htdocs/javascript/jquery.autocomplete.js
+jquery: htdocs/javascript/jquery.js htdocs/javascript/jquery.autocomplete.js htdocs/javascript/jquery.color.js
 htdocs/javascript/jquery.js:
        wget http://jquery.com/src/jquery-latest.pack.js -O $@ -q || ($(RM) $@; exit 1)
 
+htdocs/javascript/jquery.color.js:
+       wget http://plugins.jquery.com/files/jquery.color.js.txt -O $@ -q || ($(RM) $@; exit 1)
+
 ################################################################################
 
 .PHONY: build dist clean wiki build-wiki banana htdocs/images/banana htdocs/css/banana.css include/banana/banana.inc.php
index 84ace48..c25725f 100644 (file)
@@ -323,12 +323,30 @@ function checkPassword(box) {
     } else if (prop < 0) {
         prop = 0;
     }
-    ok = (prop >= 60);
-    $("#passwords_measure").width(prop + "%").css("background-color", ok ? "green" : "red");
+    if (prop >= 60) {
+        if (prop == 100) {
+            color = "#47f";
+        } else {
+            color = "#4f4";
+        }
+        ok = true;
+    } else if (prop >= 40) {
+        color = "#ff4";
+        ok = false;
+    } else {
+        color = "#f20";
+        ok = false;
+    }
+    $("#passwords_measure")
+        .stop()
+        .animate({ width: prop + "%",
+                   backgroundColor: color
+                 }, 750);
+    var submitButton = $(":submit[@name='" + passwordprompt_submit + "']");
     if (ok) {
-        $(":submit[@name='" + passwordprompt_submit + "']").removeAttr("disabled");
+        submitButton.removeAttr("disabled");
     } else {
-        $(":submit[@name='" + passwordprompt_submit + "']").attr("disabled", "disabled");
+        submitButton.attr("disabled", "disabled");
     }
 }
 
index 1f90d09..87dabf5 100644 (file)
@@ -34,6 +34,7 @@ function smarty_compiler_checkpasswd($tag_attrs, &$compiler)
     }
 
     return '?><script type="text/javascript" src="javascript/jquery.js" ></script>
+              <script type="text/javascript" src="javascript/jquery.color.js" ></script>
               <script type="text/javascript">//<![CDATA[
                 var passwordprompt_name = '.  $prompt . ';
                 var passwordprompt_submit = ' . $submit . ';