diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-11-16 13:11:00 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-11-16 13:11:00 +0300 |
commit | 981481c37d650ac5ced81f42411f6bcc166784ed (patch) | |
tree | 0193aa9290697adb2fe5f51b201c02bb6116dedf | |
parent | 2bc38873152025a281da9f8b04190a680d0cbad2 (diff) | |
parent | 9421827f13b584ba659bb448ca4e7b36b4cc5d52 (diff) |
Merge pull request #8 from MorrisJobke/MorrisJobke-patch-3
Switch to tooltip and also update on scroll of parent
-rw-r--r-- | jquery.strengthify.js | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/jquery.strengthify.js b/jquery.strengthify.js index 2db00a5..80fcf96 100644 --- a/jquery.strengthify.js +++ b/jquery.strengthify.js @@ -1,15 +1,15 @@ /** * Strengthify - show the weakness of a password (uses zxcvbn for this) - * https://github.com/kabum/strengthify + * https://github.com/MorrisJobke/strengthify * * Version: 0.4.1 - * Author: Morris Jobke (github.com/kabum) + * Author: Morris Jobke (github.com/MorrisJobke) * * License: * * The MIT License (MIT) * - * Copyright (c) 2013 Morris Jobke <morris.jobke@gmail.com> + * Copyright (c) 2013-2015 Morris Jobke <morris.jobke@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -43,23 +43,9 @@ 'Perfect' ] }, - options = $.extend(defaults, paramOptions); - - // add elements - $('.strengthify-wrapper') - .append('<div class="strengthify-bg" />') - .append('<div class="strengthify-container" />') - .append('<div class="strengthify-separator" style="left: 25%" />') - .append('<div class="strengthify-separator" style="left: 50%" />') - .append('<div class="strengthify-separator" style="left: 75%" />'); - - $.ajax({ - cache: true, - dataType: 'script', - url: options.zxcvbn - }).done(function() { - me.bind('keyup input change', function() { - var password = $(this).val(), + options = $.extend(defaults, paramOptions), + drawStrengthify = function() { + var password = $(me).val(), // hide strengthigy if no input is provided opacity = (password === '') ? 0 : 1, // calculate result @@ -125,7 +111,24 @@ $container.css('width', 0); } - }); + }; + + // add elements + $('.strengthify-wrapper') + .append('<div class="strengthify-bg" />') + .append('<div class="strengthify-container" />') + .append('<div class="strengthify-separator" style="left: 25%" />') + .append('<div class="strengthify-separator" style="left: 50%" />') + .append('<div class="strengthify-separator" style="left: 75%" />'); + + me.parents().on('scroll', drawStrengthify); + + $.ajax({ + cache: true, + dataType: 'script', + url: options.zxcvbn + }).done(function() { + me.bind('keyup input change', drawStrengthify); }); return me; |