bower update for jquery.strengthify 0.4.1
This commit is contained in:
parent
1b2e60b53d
commit
698e47a7af
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "strengthify",
|
"name": "strengthify",
|
||||||
|
"version": "0.4.1",
|
||||||
"homepage": "https://github.com/MorrisJobke/strengthify",
|
"homepage": "https://github.com/MorrisJobke/strengthify",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Morris Jobke <hey@morrisjobke.de>"
|
"Morris Jobke <hey@morrisjobke.de>"
|
||||||
|
@ -7,13 +8,13 @@
|
||||||
"description": "Combine jQuery and zxcvbn to create a password strength meter.",
|
"description": "Combine jQuery and zxcvbn to create a password strength meter.",
|
||||||
"main": "jquery.strengthify.js",
|
"main": "jquery.strengthify.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"_release": "f1dd3eaf28",
|
"_release": "0.4.1",
|
||||||
"_resolution": {
|
"_resolution": {
|
||||||
"type": "branch",
|
"type": "version",
|
||||||
"branch": "master",
|
"tag": "0.4.1",
|
||||||
"commit": "f1dd3eaf289be559885325a6585f6dd6ae2fa8c3"
|
"commit": "fe9d1c80156d3fcdd16434ebc789007d045c1d1f"
|
||||||
},
|
},
|
||||||
"_source": "git://github.com/MorrisJobke/strengthify.git",
|
"_source": "git://github.com/MorrisJobke/strengthify.git",
|
||||||
"_target": "*",
|
"_target": "0.4.1",
|
||||||
"_originalSource": "strengthify"
|
"_originalSource": "strengthify"
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
* Strengthify - show the weakness of a password (uses zxcvbn for this)
|
* Strengthify - show the weakness of a password (uses zxcvbn for this)
|
||||||
* https://github.com/kabum/strengthify
|
* https://github.com/kabum/strengthify
|
||||||
*
|
*
|
||||||
* Version: 0.3
|
* Version: 0.4.1
|
||||||
* Author: Morris Jobke (github.com/kabum)
|
* Author: Morris Jobke (github.com/kabum)
|
||||||
*
|
*
|
||||||
* License:
|
* License:
|
||||||
|
@ -29,22 +29,21 @@
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* global jQuery */
|
||||||
(function ($) {
|
(function ($) {
|
||||||
$.fn.strengthify = function(options) {
|
$.fn.strengthify = function(paramOptions) {
|
||||||
var me = this
|
var me = this,
|
||||||
|
defaults = {
|
||||||
var defaults = {
|
zxcvbn: 'zxcvbn/zxcvbn.js',
|
||||||
zxcvbn: 'zxcvbn/zxcvbn.js',
|
titles: [
|
||||||
titles: [
|
'Weakest',
|
||||||
'Weakest',
|
'Weak',
|
||||||
'Weak',
|
'So-so',
|
||||||
'So-so',
|
'Good',
|
||||||
'Good',
|
'Perfect'
|
||||||
'Perfect'
|
]
|
||||||
]
|
},
|
||||||
}
|
options = $.extend(defaults, paramOptions);
|
||||||
|
|
||||||
var options = $.extend(defaults, options)
|
|
||||||
|
|
||||||
// add elements
|
// add elements
|
||||||
$('.strengthify-wrapper')
|
$('.strengthify-wrapper')
|
||||||
|
@ -52,9 +51,7 @@
|
||||||
.append('<div class="strengthify-container" />')
|
.append('<div class="strengthify-container" />')
|
||||||
.append('<div class="strengthify-separator" style="left: 25%" />')
|
.append('<div class="strengthify-separator" style="left: 25%" />')
|
||||||
.append('<div class="strengthify-separator" style="left: 50%" />')
|
.append('<div class="strengthify-separator" style="left: 50%" />')
|
||||||
.append('<div class="strengthify-separator" style="left: 75%" />')
|
.append('<div class="strengthify-separator" style="left: 75%" />');
|
||||||
|
|
||||||
var oldDisplayState = $('.strengthify-wrapper').css('display')
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
cache: true,
|
cache: true,
|
||||||
|
@ -62,22 +59,24 @@
|
||||||
url: options.zxcvbn
|
url: options.zxcvbn
|
||||||
}).done(function() {
|
}).done(function() {
|
||||||
me.bind('keyup input', function() {
|
me.bind('keyup input', function() {
|
||||||
var password = $(this).val()
|
var password = $(this).val(),
|
||||||
|
// hide strengthigy if no input is provided
|
||||||
|
opacity = (password === '') ? 0 : 1,
|
||||||
|
// calculate result
|
||||||
|
result = zxcvbn(password),
|
||||||
|
css = '',
|
||||||
|
// cache jQuery selections
|
||||||
|
$container = $('.strengthify-container'),
|
||||||
|
$wrapper = $('.strengthify-wrapper');
|
||||||
|
|
||||||
// hide strengthigy if no input is provided
|
$wrapper.children().css(
|
||||||
var opacity = (password === '') ? 0 : 1
|
|
||||||
$('.strengthify-wrapper').children().css(
|
|
||||||
'opacity',
|
'opacity',
|
||||||
opacity
|
opacity
|
||||||
).css(
|
).css(
|
||||||
'-ms-filter',
|
'-ms-filter',
|
||||||
'"progid:DXImageTransform.Microsoft.Alpha(Opacity=' + opacity * 100 + ')"'
|
'"progid:DXImageTransform.Microsoft.Alpha(Opacity=' + opacity * 100 + ')"'
|
||||||
)
|
);
|
||||||
|
|
||||||
// calculate result
|
|
||||||
var result = zxcvbn(password)
|
|
||||||
|
|
||||||
var css = ''
|
|
||||||
// style strengthify bar
|
// style strengthify bar
|
||||||
// possible scores: 0-4
|
// possible scores: 0-4
|
||||||
switch(result.score) {
|
switch(result.score) {
|
||||||
|
@ -94,16 +93,18 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.strengthify-container').attr('class', css + ' strengthify-container')
|
$container
|
||||||
// possible scores: 0-4
|
.attr('class', css + ' strengthify-container')
|
||||||
$('.strengthify-container').css(
|
// possible scores: 0-4
|
||||||
'width',
|
.css(
|
||||||
// if score is '0' it will be changed to '1' to
|
'width',
|
||||||
// not hide strengthify if the password is extremely weak
|
// if score is '0' it will be changed to '1' to
|
||||||
((result.score == 0 ? 1 : result.score) * 25) + '%'
|
// not hide strengthify if the password is extremely weak
|
||||||
)
|
((result.score === 0 ? 1 : result.score) * 25) + '%'
|
||||||
|
);
|
||||||
|
|
||||||
// set a title for the wrapper
|
// set a title for the wrapper
|
||||||
$('.strengthify-wrapper').attr(
|
$wrapper.attr(
|
||||||
'title',
|
'title',
|
||||||
options.titles[result.score]
|
options.titles[result.score]
|
||||||
).tipsy({
|
).tipsy({
|
||||||
|
@ -111,23 +112,23 @@
|
||||||
opacity: opacity
|
opacity: opacity
|
||||||
}).tipsy(
|
}).tipsy(
|
||||||
'show'
|
'show'
|
||||||
)
|
);
|
||||||
|
|
||||||
if(opacity === 0) {
|
if(opacity === 0) {
|
||||||
$('.strengthify-wrapper').tipsy(
|
$wrapper.tipsy(
|
||||||
'hide'
|
'hide'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset state for empty string password
|
// reset state for empty string password
|
||||||
if(password === '') {
|
if(password === '') {
|
||||||
$('.strengthify-container').css('width', 0)
|
$container.css('width', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
return me
|
return me;
|
||||||
};
|
};
|
||||||
|
|
||||||
}(jQuery))
|
}(jQuery));
|
||||||
|
|
Loading…
Reference in New Issue