From de99248c4078f3646316e3d09dfa9fe999bbd97d Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 4 May 2008 12:13:27 +0200 Subject: [PATCH] Animated progression bar, better colors. WARNING: requires jQuery 1.2, upgrade your jQuery if you're still on a previous version. Signed-off-by: Florent Bruneau --- Makefile | 5 ++++- htdocs/javascript/xorg.js | 26 ++++++++++++++++++++++---- plugins/compiler.checkpasswd.php | 1 + 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index eed1687..8876425 100644 --- 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 diff --git a/htdocs/javascript/xorg.js b/htdocs/javascript/xorg.js index 84ace48..c25725f 100644 --- a/htdocs/javascript/xorg.js +++ b/htdocs/javascript/xorg.js @@ -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"); } } diff --git a/plugins/compiler.checkpasswd.php b/plugins/compiler.checkpasswd.php index 1f90d09..87dabf5 100644 --- a/plugins/compiler.checkpasswd.php +++ b/plugins/compiler.checkpasswd.php @@ -34,6 +34,7 @@ function smarty_compiler_checkpasswd($tag_attrs, &$compiler) } return '?> +