Sha256: 58644bf80379e89536eb716727a5e0457ed4c93aa70e520dea8e9ac7b6b41954

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

(function($){
	$.strength = function(username, password, callback) {
		username = $(username);
		password = $(password);
		var strength = new PasswordStrength();
		callback = callback || $.strength.callback;

		var handler = function(){
			strength.username = $(username).val();
			strength.password = $(this).val();
			strength.test();
			callback(username, password, strength);
		};

		$(username).keydown(handler);
		$(password).keydown(handler);
	};

	$.extend($.strength, {
		callback: function(username, password, strength){
			var img = $(password).next("img.strength");

			if (!img.length) {
				$(password).after("<img class='strength'>");
				img = $("img.strength");
			}

			$(img)
				.removeClass("weak")
				.removeClass("good")
				.removeClass("strong")
				.addClass(strength.status)
				.attr("src", $.strength[strength.status + "Image"]);

			console.debug($.strength[strength.status + "Image"])
		},
		weakImage: "/images/weak.png",
		goodImage: "/images/good.png",
		strongImage: "/images/strong.png"
	});
})(jQuery);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
password_strength-0.1.2 lib/jquery.strength.js
password_strength-0.1.3 lib/jquery.strength.js