diff --git a/README.md b/README.md index c37d7e5..7fb43f3 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,9 @@ Configuration The path and the title of the different strength categories can be configured with the first parameter of `.strengthify`. +The inputs property is an array of words to add to zxcvbn's dictionary +or a function that returns the array to use. + Default: ```JSON @@ -52,7 +55,8 @@ Default: "So-so", "Good", "Perfect" - ] + ], + "inputs": [] } ``` diff --git a/jquery.strengthify.js b/jquery.strengthify.js index 21f5fa8..0be04ad 100644 --- a/jquery.strengthify.js +++ b/jquery.strengthify.js @@ -41,7 +41,8 @@ 'So-so', 'Good', 'Perfect' - ] + ], + inputs: [] }, options = $.extend(defaults, paramOptions); @@ -58,12 +59,12 @@ dataType: 'script', url: options.zxcvbn }).done(function() { - me.bind('keyup input', function() { - var password = $(this).val(), - // hide strengthigy if no input is provided + function update() { + var password = me.val(), + // hide strengthify if no input is provided opacity = (password === '') ? 0 : 1, // calculate result - result = zxcvbn(password), + result = zxcvbn(password, typeof options.inputs === 'function' ? options.inputs() : options.inputs), css = '', // cache jQuery selections $container = $('.strengthify-container'), @@ -125,7 +126,11 @@ $container.css('width', 0); } - }); + }; + me.bind('keyup input', update); + if (me.val()) { + update(); + } }); return me; diff --git a/strengthify.css b/strengthify.css index 9340270..041e9aa 100644 --- a/strengthify.css +++ b/strengthify.css @@ -6,6 +6,10 @@ * Copyright (c) 2013 Morris Jobke */ +.strengthify-wrapper { + position: relative; +} + .strengthify-wrapper > * { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0);