From cb3aac0525ebd987ccce840ed338687547c993ef Mon Sep 17 00:00:00 2001 From: Edward Townend Date: Mon, 13 Oct 2014 19:34:40 +0100 Subject: [PATCH] Basic support for Foundation - First release to support Zurb Foundation, forked from ablanco/jquery.pwstrength.bootstrap v 1.2.2 - The lack of a built in orange warning state for progress bars is posing a problem, we might have to add it - Basic support for progress bar, though text in progress bar requires extra styling - Verdicts outputted to Foundation .postfix, if existing - Errors outputted to Foundation Error states - Popover not currently supported --- AUTHORS.txt | 1 + CHANGES.md | 129 +--- Gruntfile.js | 3 +- README.md | 44 +- bower.json | 18 +- dist/pwstrength-bootstrap-1.0.0.js | 545 -------------- dist/pwstrength-bootstrap-1.0.0.min.js | 4 - dist/pwstrength-bootstrap-1.0.0.min.map | 1 - dist/pwstrength-bootstrap-1.0.1.js | 545 -------------- dist/pwstrength-bootstrap-1.0.1.min.js | 4 - dist/pwstrength-bootstrap-1.0.1.min.map | 1 - dist/pwstrength-bootstrap-1.0.2.js | 545 -------------- dist/pwstrength-bootstrap-1.0.2.min.js | 4 - dist/pwstrength-bootstrap-1.0.2.min.map | 1 - dist/pwstrength-bootstrap-1.1.0.js | 587 ---------------- dist/pwstrength-bootstrap-1.1.0.min.js | 4 - dist/pwstrength-bootstrap-1.1.0.min.map | 1 - dist/pwstrength-bootstrap-1.1.1.js | 622 ---------------- dist/pwstrength-bootstrap-1.1.1.min.js | 4 - dist/pwstrength-bootstrap-1.1.1.min.map | 1 - dist/pwstrength-bootstrap-1.1.2.js | 629 ----------------- dist/pwstrength-bootstrap-1.1.2.min.js | 4 - dist/pwstrength-bootstrap-1.1.2.min.map | 1 - dist/pwstrength-bootstrap-1.1.3.js | 641 ----------------- dist/pwstrength-bootstrap-1.1.3.min.js | 4 - dist/pwstrength-bootstrap-1.1.3.min.map | 1 - dist/pwstrength-bootstrap-1.1.4.js | 641 ----------------- dist/pwstrength-bootstrap-1.1.4.min.js | 4 - dist/pwstrength-bootstrap-1.1.4.min.map | 1 - dist/pwstrength-bootstrap-1.1.5.js | 654 ----------------- dist/pwstrength-bootstrap-1.1.5.min.js | 4 - dist/pwstrength-bootstrap-1.1.5.min.map | 1 - dist/pwstrength-bootstrap-1.2.0.js | 661 ----------------- dist/pwstrength-bootstrap-1.2.0.min.js | 4 - dist/pwstrength-bootstrap-1.2.0.min.map | 1 - dist/pwstrength-bootstrap-1.2.1.js | 663 ------------------ dist/pwstrength-bootstrap-1.2.1.min.js | 4 - dist/pwstrength-bootstrap-1.2.1.min.map | 1 - dist/pwstrength-bootstrap-1.2.2.min.js | 4 - dist/pwstrength-bootstrap-1.2.2.min.map | 2 +- ....2.2.js => pwstrength-foundation-1.2.3.js} | 80 ++- dist/pwstrength-foundation-1.2.3.min.js | 4 + dist/pwstrength-foundation-1.2.3.min.map | 1 + examples/bootstrap2/bootstrap2.css | 310 -------- examples/bootstrap2/bootstrap2.js | 7 - examples/bootstrap2/index.html | 42 -- examples/bootstrap2/multi.html | 36 - examples/bootstrap2/popover.html | 36 - examples/bootstrap2/rules.html | 45 -- examples/bootstrap3/index.html | 2 +- examples/bootstrap3/popover.html | 2 +- examples/bootstrap3/status.html | 2 +- examples/bootstrap3/zxcvbn.html | 2 +- examples/foundation5/bootstrap3.css | 9 + examples/foundation5/bootstrap3.js | 1 + examples/foundation5/index.html | 58 ++ examples/foundation5/popover.html | 47 ++ examples/foundation5/status.html | 43 ++ examples/foundation5/zxcvbn.html | 66 ++ examples/index.html | 22 +- examples/pwstrength.js | 80 ++- package.json | 12 +- pwstrength-bootstrap.jquery.json | 40 -- pwstrength-foundation.jquery.json | 40 ++ src/methods.js | 16 +- src/options.js | 14 +- src/rules.js | 2 +- src/ui.js | 53 +- 68 files changed, 447 insertions(+), 7614 deletions(-) delete mode 100644 dist/pwstrength-bootstrap-1.0.0.js delete mode 100644 dist/pwstrength-bootstrap-1.0.0.min.js delete mode 100644 dist/pwstrength-bootstrap-1.0.0.min.map delete mode 100644 dist/pwstrength-bootstrap-1.0.1.js delete mode 100644 dist/pwstrength-bootstrap-1.0.1.min.js delete mode 100644 dist/pwstrength-bootstrap-1.0.1.min.map delete mode 100644 dist/pwstrength-bootstrap-1.0.2.js delete mode 100644 dist/pwstrength-bootstrap-1.0.2.min.js delete mode 100644 dist/pwstrength-bootstrap-1.0.2.min.map delete mode 100644 dist/pwstrength-bootstrap-1.1.0.js delete mode 100644 dist/pwstrength-bootstrap-1.1.0.min.js delete mode 100644 dist/pwstrength-bootstrap-1.1.0.min.map delete mode 100644 dist/pwstrength-bootstrap-1.1.1.js delete mode 100644 dist/pwstrength-bootstrap-1.1.1.min.js delete mode 100644 dist/pwstrength-bootstrap-1.1.1.min.map delete mode 100644 dist/pwstrength-bootstrap-1.1.2.js delete mode 100644 dist/pwstrength-bootstrap-1.1.2.min.js delete mode 100644 dist/pwstrength-bootstrap-1.1.2.min.map delete mode 100644 dist/pwstrength-bootstrap-1.1.3.js delete mode 100644 dist/pwstrength-bootstrap-1.1.3.min.js delete mode 100644 dist/pwstrength-bootstrap-1.1.3.min.map delete mode 100644 dist/pwstrength-bootstrap-1.1.4.js delete mode 100644 dist/pwstrength-bootstrap-1.1.4.min.js delete mode 100644 dist/pwstrength-bootstrap-1.1.4.min.map delete mode 100644 dist/pwstrength-bootstrap-1.1.5.js delete mode 100644 dist/pwstrength-bootstrap-1.1.5.min.js delete mode 100644 dist/pwstrength-bootstrap-1.1.5.min.map delete mode 100644 dist/pwstrength-bootstrap-1.2.0.js delete mode 100644 dist/pwstrength-bootstrap-1.2.0.min.js delete mode 100644 dist/pwstrength-bootstrap-1.2.0.min.map delete mode 100644 dist/pwstrength-bootstrap-1.2.1.js delete mode 100644 dist/pwstrength-bootstrap-1.2.1.min.js delete mode 100644 dist/pwstrength-bootstrap-1.2.1.min.map delete mode 100644 dist/pwstrength-bootstrap-1.2.2.min.js rename dist/{pwstrength-bootstrap-1.2.2.js => pwstrength-foundation-1.2.3.js} (91%) create mode 100644 dist/pwstrength-foundation-1.2.3.min.js create mode 100644 dist/pwstrength-foundation-1.2.3.min.map delete mode 100644 examples/bootstrap2/bootstrap2.css delete mode 100644 examples/bootstrap2/bootstrap2.js delete mode 100644 examples/bootstrap2/index.html delete mode 100644 examples/bootstrap2/multi.html delete mode 100644 examples/bootstrap2/popover.html delete mode 100644 examples/bootstrap2/rules.html create mode 100644 examples/foundation5/bootstrap3.css create mode 100644 examples/foundation5/bootstrap3.js create mode 100644 examples/foundation5/index.html create mode 100644 examples/foundation5/popover.html create mode 100644 examples/foundation5/status.html create mode 100644 examples/foundation5/zxcvbn.html delete mode 100644 pwstrength-bootstrap.jquery.json create mode 100644 pwstrength-foundation.jquery.json diff --git a/AUTHORS.txt b/AUTHORS.txt index 4e0ae24..f1d9b07 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -13,3 +13,4 @@ Peter Goes Brent mikemey saparicio +Ed Townend diff --git a/CHANGES.md b/CHANGES.md index 8bb4999..72f4750 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,123 +1,10 @@ # CHANGELOG -## 1.2.2 - -- Every rule can have associated error messages. - -## 1.2.1 - -- Improve documentation. -- Fix typo in alphabetical sequence. -- Use the not minified version of the library in bower as main file. - -## 1.2.0 - -- Listen also to the `change` and `onpaste` events, not only to the `onkeyup`. -- Show the lowest verdict when the score is below zero. -- New option to pass more input fields content to the zxcvbn library. -- Don't show the verdicts inside the popover if they are being showed inside - the progressbar. - -## 1.1.5 - -- Better Bower configuration. -- Pass also the verdict level to the "on key up" event handler. -- Add a basic usage section to the readme. - -## 1.1.4 - -- Bower support. - -## 1.1.3 - -- Pass the score and the verdict to the "on key up" event handler. - -## 1.1.2 - -- Upgrade dev dependencies: grunt plugins and jquery -- Bugfix in sequences lookup -- New tests for sequences lookup - -## 1.1.1 - -- Pass the username field content to the zxcvbn function, so zxcvbn takes it - into consideration when scoring the password. -- Add a debug option, so the score gets printed in the JS console. -- Check reversed sequences too in the sequences rule. -- Fix the popover flickering. - -## 1.1.0 - -- Support zxcvbn for password scoring. -- Support showing the password strength as a validation status in the password - field. -- Support hiding the progress bar, making it optional. -- Support showing the verdicts inside the progress bar. - -## 1.0.2 - -- Bugfix in UI initialization. -- Fix typo in readme. - -## 1.0.1 - -- Separate source file in several smaller files. -- Add Grunt support for creating a bundle and a minified version. -- Add tests for the rules engine, and continuos integration with Travis. - -## 1.0.0 - -- Complete refactor of the code. This is a cleaner version, easier to extend - and mantain. -- Broke backwards compatibility. Bootstrap 3 is the default option now, other - options default values have changed. Options structure has changed too. -- Old tests have been renamed to examples, which is what they really are. Leave - room for real tests. - -## 0.7.0 - -- New rule to check for sequences in the password. It penalizes finding - sequences of consecutive numbers, consecutive characters in the alphabet or - in the qwerty layout. Active by default. - -## 0.6.0 - -- New feature: support showing the verdicts and errors in a Bootstrap popover. -- Hide the verdicts and errors when the input is empty. -- Remove _showVerdictsInitially_ option, is not needed anymore. - -## 0.5.0 - -- Support to activate/deactivate rules using the _rules_ object inside the - _options_ object. -- Two new rules added, deactivated by default. Check for too many character - repetitions, and check for number of character classes used. - -## 0.4.5 - -- Fix error message when the password contains the username. -- Check if the password is an email, and mark as weak. -- Add a _container_ option, it will be used to look for the viewports. - -## 0.4.4 - -- Bad version in plugin manifest. - -## 0.4.3 - -- Change jQuery plugin name to avoid conflict with an existing one. - -## 0.4.2 - -- New option to choose if the verdicts should be displayed before the user - introduces a letter. New default behaviour: don't show them. -- Bugfix with progress bar color and Bootstrap 2. -- Improve code quality. - -## 0.4.1 - -- jQuery plugins registry support. - -## 0.4.0 - -- Bootstrap 3.0.0 support. +## 1.2.3 + +- First release to support Zurb Foundation, forked from ablanco/jquery.pwstrength.bootstrap v 1.2.2 +- The lack of a built in orange warning state for progress bars is posing a problem, we might have to add it +- Basic support for progress bar, though text in progress bar requires extra styling +- Verdicts outputted to Foundation .postfix, if existing +- Errors outputted to Foundation Error states +- Popover not currently supported diff --git a/Gruntfile.js b/Gruntfile.js index 59ab10b..2abff32 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,10 +6,11 @@ module.exports = function (grunt) { var license = '/*!\n' + - '* jQuery Password Strength plugin for Twitter Bootstrap\n' + + '* jQuery Password Strength plugin for Zurb Foundation\n' + '*\n' + '* Copyright (c) 2008-2013 Tane Piper\n' + '* Copyright (c) 2013 Alejandro Blanco\n' + + '* Copyright (c) 2014 Ed Townend\n' + '* Dual licensed under the MIT and GPL licenses.\n' + '*/\n\n' + '(function (jQuery) {\n'; diff --git a/README.md b/README.md index 0fad51a..b4ce70a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# jQuery Password Strength Meter for Twitter Bootstrap +# jQuery Password Strength Meter for Zurb Foundation 5 -[![Build Status](https://travis-ci.org/ablanco/jquery.pwstrength.bootstrap.png?branch=master)](https://travis-ci.org/ablanco/jquery.pwstrength.bootstrap) -[![Code Climate](https://codeclimate.com/github/ablanco/jquery.pwstrength.bootstrap.png)](https://codeclimate.com/github/ablanco/jquery.pwstrength.bootstrap) -[![devDependency Status](https://david-dm.org/ablanco/jquery.pwstrength.bootstrap/dev-status.png)](https://david-dm.org/ablanco/jquery.pwstrength.bootstrap#info=devDependencies) +[![Build Status](https://travis-ci.org/edtownend/jquery.pwstrength.foundation.png?branch=master)](https://travis-ci.org/edtownend/jquery.pwstrength.foundation) +[![Code Climate](https://codeclimate.com/github/edtownend/jquery.pwstrength.foundation.png)](https://codeclimate.com/github/edtownend/jquery.pwstrength.foundation) +[![devDependency Status](https://david-dm.org/edtownend/jquery.pwstrength.foundation/dev-status.png)](https://david-dm.org/edtownend/jquery.pwstrength.foundation#info=devDependencies) -The jQuery Password Strength Meter is a plugin for Twitter Bootstrap that +The jQuery Password Strength Meter is a plugin for Zurb Foundation 5 that provides rulesets for visualy displaying the quality of a users typed in -password. +password. Forked from ablanco/jquery.pwstrength.bootstrap - all I've done is change the outputted syntax Dual licensed under the MIT and GPL licenses. @@ -16,7 +16,7 @@ Dual licensed under the MIT and GPL licenses. ## Requirements * jQuery 1.7 or higher -* Bootstrap 2 or 3 +* Foundation 5 ## How to use it @@ -189,13 +189,6 @@ Let's see the options of each section. ### User Interface -* __bootstrap2__: - - Default: `false` (Boolean) - - Sets if it supports legacy Bootstrap 2 (true) or the current Bootstrap 3 - (false), the progress bar html is different. - * __showProgressBar__: Default: `true` (Boolean) @@ -217,8 +210,9 @@ Let's see the options of each section. Default: `false` (Boolean) - Displays the password strength as a validation status in the password field, - for this to work, the Bootstrap form structure must be followed. + Add a status class (alert, warning, success...) to the selector specified in + ui.viewports.status or the container of the form field. Useful for Foundation + labels. * __spanError__: @@ -264,7 +258,8 @@ Let's see the options of each section. Default: `true` (Boolean) - Determines if the verdicts are displayed or not. + Determines if the verdicts are displayed or not. By default these are shown in + a postfix element, so be sure to layout your markup with a posfix label. * __showVerdictsInsideProgressBar__: @@ -273,13 +268,15 @@ Let's see the options of each section. Determines if the verdicts are displayed inside the progress bar or not. When this setting is active, the verdict viewport is ignored and they won't appear on the popover if it is being showed. Also this option overrides the value of - the _showVerdicts_ one. + the _showVerdicts_ one. Until Foundation supports text inside progress bars, + you're going to have to set the line height yourself to tidy this up. * __showErrors__: - Default: `false` (Boolean) + Default: `true` (Boolean) - Determines if the error list is displayed with the progress bar or not. + Determines if the error list is displayed or not. Shown in the format of + a Foundation error state. * __container__: @@ -296,8 +293,9 @@ Let's see the options of each section. ``` { progress: undefined, - verdict: undefined, - errors: undefined + verdict: '.postfix', + errors: undefined, + status: undefined } ``` @@ -497,5 +495,5 @@ It will check all the source files with [JSLint](http://jslint.com) and run the tests, which are written with [Jasmine](http://jasmine.github.io/). You'll find the tests source code in the `spec` directory. -[Travis](https://travis-ci.org/ablanco/jquery.pwstrength.bootstrap) is being +[Travis](https://travis-ci.org/edtownend/jquery.pwstrength.foundation) is being used for continuos integration. You can check there if the tests are passing. diff --git a/bower.json b/bower.json index 59031da..01d1294 100644 --- a/bower.json +++ b/bower.json @@ -1,22 +1,22 @@ { - "name": "pwstrength-bootstrap", - "version": "1.2.2", - "homepage": "https://github.com/ablanco/jquery.pwstrength.bootstrap", + "name": "pwstrength-foundation", + "version": "1.2.3", + "homepage": "https://github.com/edtownend/jquery.pwstrength.foundation", "authors": [ - "Alejandro Blanco " + "Ed Townend " ], - "description": "jQuery plugin for Twitter Bootstrap that provides rulesets for visualy displaying the quality of a users typed in password.", - "main": "dist/pwstrength-bootstrap-1.2.2.js", + "description": "jQuery plugin for Zurb Foundation 5 that provides rulesets for visualy displaying the quality of a users typed in password.", + "main": "dist/pwstrength-foundation-1.2.2.js", "dependencies": { "jquery": ">=1.7.0", - "bootstrap": ">=2.0.0" + "foundation": ">=2.0.0" }, "moduleType": [ "globals" ], "keywords": [ "jquery", - "bootstrap", + "foundation", "password", "strength", "meter" @@ -32,6 +32,6 @@ "CHANGES.md", "Gruntfile.js", "package.json", - "pwstrength-bootstrap.jquery.json" + "pwstrength-foundation.jquery.json" ] } diff --git a/dist/pwstrength-bootstrap-1.0.0.js b/dist/pwstrength-bootstrap-1.0.0.js deleted file mode 100644 index 4ba160d..0000000 --- a/dist/pwstrength-bootstrap-1.0.0.js +++ /dev/null @@ -1,545 +0,0 @@ -/*! -* jQuery Password Strength plugin for Twitter Bootstrap -* -* Copyright (c) 2008-2013 Tane Piper -* Copyright (c) 2013 Alejandro Blanco -* Dual licensed under the MIT and GPL licenses. -*/ - -(function (jQuery) { -// Source: src/rules.js - - - - -var rulesEngine = {}; - -try { - if (!jQuery && module && module.exports) { - var jQuery = require("jquery"); - } -} catch (ignore) {} - -(function ($, rulesEngine) { - "use strict"; - var validation = {}; - - rulesEngine.forbiddenSequences = [ - "0123456789", "9876543210", "abcdefghijklmnopqrstuvxywz", - "qwertyuiop", "asdfghjkl", "zxcvbnm" - ]; - - validation.wordNotEmail = function (options, word, score) { - if (word.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)) { - options.instances.errors.push(options.ui.spanError(options, "email_as_password")); - return score; - } - }; - - validation.wordLength = function (options, word, score) { - var wordlen = word.length, - lenScore = Math.pow(wordlen, options.rules.raisePower); - if (wordlen < options.common.minChar) { - lenScore = (lenScore + score); - options.instances.errors.push(options.ui.spanError(options, "password_too_short")); - } - return lenScore; - }; - - validation.wordSimilarToUsername = function (options, word, score) { - var username = $(options.common.usernameField).val(); - if (username && word.toLowerCase().match(username.toLowerCase())) { - options.instances.errors.push(options.ui.spanError(options, "same_as_username")); - return score; - } - return false; - }; - - validation.wordTwoCharacterClasses = function (options, word, score) { - if (word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) || - (word.match(/([a-zA-Z])/) && word.match(/([0-9])/)) || - (word.match(/(.[!,@,#,$,%,\^,&,*,?,_,~])/) && word.match(/[a-zA-Z0-9_]/))) { - return score; - } - options.instances.errors.push(options.ui.spanError(options, "two_character_classes")); - return false; - }; - - validation.wordRepetitions = function (options, word, score) { - if (word.match(/(.)\1\1/)) { - options.instances.errors.push(options.ui.spanError(options, "repeated_character")); - return score; - } - return false; - }; - - validation.wordSequences = function (options, word, score) { - var found = false, - j; - if (word.length > 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, sequence) { - for (j = 0; j < (word.length - 3); j += 1) { //iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "The Password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - result = {}; - $container = ui.getContainer(options, $el); - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (!options.ui.showPopover) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
"; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
    ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el, verdictText) { - var placement = "auto top", - html = ""; - - if (options.ui.bootstrap2) { placement = "top"; } - - if (options.ui.showVerdicts && verdictText.length > 0) { - html = "
    " + verdictText + - "
    "; - } - if (options.ui.showErrors) { - html += "
      "; - $.each(options.instances.errors, function (idx, err) { - html += "
    • " + err + "
    • "; - }); - html += "
    "; - } - - $el.popover("destroy"); - $el.popover({ - html: true, - placement: placement, - trigger: "manual", - content: html - }); - $el.popover("show"); - }; - - ui.initUI = function (options, $el) { - if (!options.ui.showPopover) { - ui.initErrorList(options, $el); - ui.initVerdict(options, $el); - } - // The popover can't be initialized here, it requires to be destroyed - // and recreated every time its content changes, because it calculates - // its position based on the size of its content - ui.initProgressBar(options, $el); - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + cssClass); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
  • " + err + "
  • "; - }); - $errors.html(html); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.updateUI = function (options, $el, score) { - var barCss, barPercentage, verdictText; - - barPercentage = ui.percentage(score, options.ui.scores[3]); - if (score <= 0) { - barCss = "danger"; - verdictText = ""; - } else if (score < options.ui.scores[0]) { - barCss = "danger"; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - barCss = "danger"; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - barCss = "warning"; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - barCss = "warning"; - verdictText = options.ui.verdicts[3]; - } else { - barCss = "success"; - verdictText = options.ui.verdicts[4]; - } - - ui.updateProgressBar(options, $el, barCss, barPercentage); - if (options.ui.showPopover) { - // Popover can't be updated, it has to be recreated - ui.initPopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - score; - - options.instances.errors = []; - score = rulesEngine.executeRules(options, word); - ui.updateUI(options, $el, score); - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - ui.initUI(localOptions, $el); - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.0.0.min.js b/dist/pwstrength-bootstrap-1.0.0.min.js deleted file mode 100644 index 9626f50..0000000 --- a/dist/pwstrength-bootstrap-1.0.0.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2013-12-28 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports)var a=require("jquery")}catch(c){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","9876543210","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(a,b){for(f=0;f-1&&(g=!0)}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(c){}var d={};d.common={},d.common.minChar=6,d.common.usernameField="#username",d.common.onLoad=void 0,d.common.onKeyUp=void 0,d.rules={},d.rules.extra={},d.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},d.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},d.rules.raisePower=1.4,d.ui={},d.ui.bootstrap2=!1,d.ui.showPopover=!1,d.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},d.ui.errorMessages={password_too_short:"The Password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},d.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],d.ui.showVerdicts=!0,d.ui.showErrors=!1,d.ui.container=void 0,d.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},d.ui.scores=[14,26,38,50];var e={};!function(a,b){"use strict";b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(e={},d=b.getContainer(a,c),e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showPopover||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict"),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
    ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
      ",a.ui.viewports.errors)},b.initPopover=function(b,c,d){var e="auto top",f="";b.ui.bootstrap2&&(e="top"),b.ui.showVerdicts&&d.length>0&&(f="
      "+d+"
      "),b.ui.showErrors&&(f+="
        ",a.each(b.instances.errors,function(a,b){f+="
      • "+b+"
      • "}),f+="
      "),c.popover("destroy"),c.popover({html:!0,placement:e,trigger:"manual",content:f}),c.popover("show")},b.initUI=function(a,c){a.ui.showPopover||(b.initErrorList(a,c),b.initVerdict(a,c)),b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(c,d,e,f){var g=b.getUIElements(c,d).$progressbar,h=g.find(".progress-bar"),i="progress-";c.ui.bootstrap2&&(h=g.find(".bar"),i=""),a.each(b.possibleProgressBarClasses,function(a,b){h.removeClass(i+"bar-"+b)}),h.addClass(i+"bar-"+e),h.css("width",f+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
    • "+b+"
    • "}),e.html(f)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.updateUI=function(a,c,d){var e,f,g;f=b.percentage(d,a.ui.scores[3]),0>=d?(e="danger",g=""):d 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, sequence) { - for (j = 0; j < (word.length - 3); j += 1) { //iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "The Password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - result = {}; - $container = ui.getContainer(options, $el); - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (!options.ui.showPopover) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
      "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
        ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el, verdictText) { - var placement = "auto top", - html = ""; - - if (options.ui.bootstrap2) { placement = "top"; } - - if (options.ui.showVerdicts && verdictText.length > 0) { - html = "
        " + verdictText + - "
        "; - } - if (options.ui.showErrors) { - html += "
          "; - $.each(options.instances.errors, function (idx, err) { - html += "
        • " + err + "
        • "; - }); - html += "
        "; - } - - $el.popover("destroy"); - $el.popover({ - html: true, - placement: placement, - trigger: "manual", - content: html - }); - $el.popover("show"); - }; - - ui.initUI = function (options, $el) { - if (!options.ui.showPopover) { - ui.initErrorList(options, $el); - ui.initVerdict(options, $el); - } - // The popover can't be initialized here, it requires to be destroyed - // and recreated every time its content changes, because it calculates - // its position based on the size of its content - ui.initProgressBar(options, $el); - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + cssClass); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
      • " + err + "
      • "; - }); - $errors.html(html); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.updateUI = function (options, $el, score) { - var barCss, barPercentage, verdictText; - - barPercentage = ui.percentage(score, options.ui.scores[3]); - if (score <= 0) { - barCss = "danger"; - verdictText = ""; - } else if (score < options.ui.scores[0]) { - barCss = "danger"; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - barCss = "danger"; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - barCss = "warning"; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - barCss = "warning"; - verdictText = options.ui.verdicts[3]; - } else { - barCss = "success"; - verdictText = options.ui.verdicts[4]; - } - - ui.updateProgressBar(options, $el, barCss, barPercentage); - if (options.ui.showPopover) { - // Popover can't be updated, it has to be recreated - ui.initPopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - score; - - options.instances.errors = []; - score = rulesEngine.executeRules(options, word); - ui.updateUI(options, $el, score); - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - ui.initUI(localOptions, $el); - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.0.1.min.js b/dist/pwstrength-bootstrap-1.0.1.min.js deleted file mode 100644 index d154545..0000000 --- a/dist/pwstrength-bootstrap-1.0.1.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2013-12-28 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports)var a=require("jquery")}catch(c){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","9876543210","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(a,b){for(f=0;f-1&&(g=!0)}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(c){}var d={};d.common={},d.common.minChar=6,d.common.usernameField="#username",d.common.onLoad=void 0,d.common.onKeyUp=void 0,d.rules={},d.rules.extra={},d.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},d.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},d.rules.raisePower=1.4,d.ui={},d.ui.bootstrap2=!1,d.ui.showPopover=!1,d.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},d.ui.errorMessages={password_too_short:"The Password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},d.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],d.ui.showVerdicts=!0,d.ui.showErrors=!1,d.ui.container=void 0,d.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},d.ui.scores=[14,26,38,50];var e={};!function(a,b){"use strict";b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(e={},d=b.getContainer(a,c),e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showPopover||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict"),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
        ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
          ",a.ui.viewports.errors)},b.initPopover=function(b,c,d){var e="auto top",f="";b.ui.bootstrap2&&(e="top"),b.ui.showVerdicts&&d.length>0&&(f="
          "+d+"
          "),b.ui.showErrors&&(f+="
            ",a.each(b.instances.errors,function(a,b){f+="
          • "+b+"
          • "}),f+="
          "),c.popover("destroy"),c.popover({html:!0,placement:e,trigger:"manual",content:f}),c.popover("show")},b.initUI=function(a,c){a.ui.showPopover||(b.initErrorList(a,c),b.initVerdict(a,c)),b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(c,d,e,f){var g=b.getUIElements(c,d).$progressbar,h=g.find(".progress-bar"),i="progress-";c.ui.bootstrap2&&(h=g.find(".bar"),i=""),a.each(b.possibleProgressBarClasses,function(a,b){h.removeClass(i+"bar-"+b)}),h.addClass(i+"bar-"+e),h.css("width",f+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
        • "+b+"
        • "}),e.html(f)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.updateUI=function(a,c,d){var e,f,g;f=b.percentage(d,a.ui.scores[3]),0>=d?(e="danger",g=""):d 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, sequence) { - for (j = 0; j < (word.length - 3); j += 1) { //iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "The Password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - result = {}; - $container = ui.getContainer(options, $el); - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (!options.ui.showPopover) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
          "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
            ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el, verdictText) { - var placement = "auto top", - html = ""; - - if (options.ui.bootstrap2) { placement = "top"; } - - if (options.ui.showVerdicts && verdictText.length > 0) { - html = "
            " + verdictText + - "
            "; - } - if (options.ui.showErrors) { - html += "
              "; - $.each(options.instances.errors, function (idx, err) { - html += "
            • " + err + "
            • "; - }); - html += "
            "; - } - - $el.popover("destroy"); - $el.popover({ - html: true, - placement: placement, - trigger: "manual", - content: html - }); - $el.popover("show"); - }; - - ui.initUI = function (options, $el) { - if (!options.ui.showPopover) { - if (options.ui.showErrors) { ui.initErrorList(options, $el); } - if (options.ui.showVerdicts) { ui.initVerdict(options, $el); } - } - // The popover can't be initialized here, it requires to be destroyed - // and recreated every time its content changes, because it calculates - // its position based on the size of its content - ui.initProgressBar(options, $el); - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + cssClass); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
          • " + err + "
          • "; - }); - $errors.html(html); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.updateUI = function (options, $el, score) { - var barCss, barPercentage, verdictText; - - barPercentage = ui.percentage(score, options.ui.scores[3]); - if (score <= 0) { - barCss = "danger"; - verdictText = ""; - } else if (score < options.ui.scores[0]) { - barCss = "danger"; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - barCss = "danger"; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - barCss = "warning"; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - barCss = "warning"; - verdictText = options.ui.verdicts[3]; - } else { - barCss = "success"; - verdictText = options.ui.verdicts[4]; - } - - ui.updateProgressBar(options, $el, barCss, barPercentage); - if (options.ui.showPopover) { - // Popover can't be updated, it has to be recreated - ui.initPopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - score; - - options.instances.errors = []; - score = rulesEngine.executeRules(options, word); - ui.updateUI(options, $el, score); - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - ui.initUI(localOptions, $el); - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.0.2.min.js b/dist/pwstrength-bootstrap-1.0.2.min.js deleted file mode 100644 index f05f40b..0000000 --- a/dist/pwstrength-bootstrap-1.0.2.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2014-01-06 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports)var a=require("jquery")}catch(c){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","9876543210","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(a,b){for(f=0;f-1&&(g=!0)}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(c){}var d={};d.common={},d.common.minChar=6,d.common.usernameField="#username",d.common.onLoad=void 0,d.common.onKeyUp=void 0,d.rules={},d.rules.extra={},d.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},d.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},d.rules.raisePower=1.4,d.ui={},d.ui.bootstrap2=!1,d.ui.showPopover=!1,d.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},d.ui.errorMessages={password_too_short:"The Password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},d.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],d.ui.showVerdicts=!0,d.ui.showErrors=!1,d.ui.container=void 0,d.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},d.ui.scores=[14,26,38,50];var e={};!function(a,b){"use strict";b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(e={},d=b.getContainer(a,c),e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showPopover||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict"),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
            ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
              ",a.ui.viewports.errors)},b.initPopover=function(b,c,d){var e="auto top",f="";b.ui.bootstrap2&&(e="top"),b.ui.showVerdicts&&d.length>0&&(f="
              "+d+"
              "),b.ui.showErrors&&(f+="
                ",a.each(b.instances.errors,function(a,b){f+="
              • "+b+"
              • "}),f+="
              "),c.popover("destroy"),c.popover({html:!0,placement:e,trigger:"manual",content:f}),c.popover("show")},b.initUI=function(a,c){a.ui.showPopover||(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&b.initVerdict(a,c)),b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(c,d,e,f){var g=b.getUIElements(c,d).$progressbar,h=g.find(".progress-bar"),i="progress-";c.ui.bootstrap2&&(h=g.find(".bar"),i=""),a.each(b.possibleProgressBarClasses,function(a,b){h.removeClass(i+"bar-"+b)}),h.addClass(i+"bar-"+e),h.css("width",f+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
            • "+b+"
            • "}),e.html(f)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.updateUI=function(a,c,d){var e,f,g;f=b.percentage(d,a.ui.scores[3]),0>=d?(e="danger",g=""):d 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, sequence) { - for (j = 0; j < (word.length - 3); j += 1) { //iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; -defaultOptions.common.zxcvbn = false; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showProgressBar = true; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.showStatus = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "The Password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - result = {}; - $container = ui.getContainer(options, $el); - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (!options.ui.showPopover) { - if (options.ui.showVerdictsInsideProgressBar) { - result.$verdict = result.$progressbar.find("span.password-verdict"); - } else { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
              "; - if (options.ui.showVerdictsInsideProgressBar) { - progressbar += ""; - } - progressbar += "
              "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el, verdictText) { - var placement = "auto top", - html = ""; - - if (options.ui.bootstrap2) { placement = "top"; } - - if (options.ui.showVerdicts && verdictText.length > 0) { - html = "
                " + verdictText + - "
                "; - } - if (options.ui.showErrors) { - html += "
                  "; - $.each(options.instances.errors, function (idx, err) { - html += "
                • " + err + "
                • "; - }); - html += "
                "; - } - - $el.popover("destroy"); - $el.popover({ - html: true, - placement: placement, - trigger: "manual", - content: html - }); - $el.popover("show"); - }; - - ui.initUI = function (options, $el) { - if (!options.ui.showPopover) { - if (options.ui.showErrors) { ui.initErrorList(options, $el); } - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.initVerdict(options, $el); - } - } - // The popover can't be initialized here, it requires to be destroyed - // and recreated every time its content changes, because it calculates - // its position based on the size of its content - if (options.ui.showProgressBar) { - ui.initProgressBar(options, $el); - } - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
              • " + err + "
              • "; - }); - $errors.html(html); - }; - - ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); - - $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } - $container.removeClass(css); - }); - - cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } - $container.addClass(cssClass); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.updateUI = function (options, $el, score) { - var cssClass, barPercentage, verdictText; - - if (score <= 0) { - cssClass = 0; - verdictText = ""; - } else if (score < options.ui.scores[0]) { - cssClass = 0; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - cssClass = 0; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - cssClass = 1; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - cssClass = 1; - verdictText = options.ui.verdicts[3]; - } else { - cssClass = 2; - verdictText = options.ui.verdicts[4]; - } - - if (options.ui.showProgressBar) { - barPercentage = ui.percentage(score, options.ui.scores[3]); - ui.updateProgressBar(options, $el, cssClass, barPercentage); - } - if (options.ui.showStatus) { - ui.updateFieldStatus(options, $el, cssClass); - } - if (options.ui.showPopover) { - // Popover can't be updated, it has to be recreated - ui.initPopover(options, $el, verdictText); - } else { - if (options.ui.showVerdictsInsideProgressBar || options.ui.showVerdicts) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - score; - - options.instances.errors = []; - if (options.common.zxcvbn) { - score = zxcvbn(word).entropy; - } else { - score = rulesEngine.executeRules(options, word); - } - ui.updateUI(options, $el, score); - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - ui.initUI(localOptions, $el); - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.0.min.js b/dist/pwstrength-bootstrap-1.1.0.min.js deleted file mode 100644 index 3ec49f1..0000000 --- a/dist/pwstrength-bootstrap-1.1.0.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2014-02-02 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports)var a=require("jquery")}catch(c){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","9876543210","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(a,b){for(f=0;f-1&&(g=!0)}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(c){}var d={};d.common={},d.common.minChar=6,d.common.usernameField="#username",d.common.onLoad=void 0,d.common.onKeyUp=void 0,d.common.zxcvbn=!1,d.rules={},d.rules.extra={},d.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},d.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},d.rules.raisePower=1.4,d.ui={},d.ui.bootstrap2=!1,d.ui.showProgressBar=!0,d.ui.showPopover=!1,d.ui.showStatus=!1,d.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},d.ui.errorMessages={password_too_short:"The Password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},d.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],d.ui.showVerdicts=!0,d.ui.showVerdictsInsideProgressBar=!1,d.ui.showErrors=!1,d.ui.container=void 0,d.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},d.ui.scores=[14,26,38,50];var e={};!function(a,b){"use strict";var c=["danger","warning","success"],d=["error","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(e={},d=b.getContainer(a,c),e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showPopover||(e.$verdict=a.ui.showVerdictsInsideProgressBar?e.$progressbar.find("span.password-verdict"):b.findElement(d,a.ui.viewports.verdict,"span.password-verdict"),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                ",c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
                  ",a.ui.viewports.errors)},b.initPopover=function(b,c,d){var e="auto top",f="";b.ui.bootstrap2&&(e="top"),b.ui.showVerdicts&&d.length>0&&(f="
                  "+d+"
                  "),b.ui.showErrors&&(f+="
                    ",a.each(b.instances.errors,function(a,b){f+="
                  • "+b+"
                  • "}),f+="
                  "),c.popover("destroy"),c.popover({html:!0,placement:e,trigger:"manual",content:f}),c.popover("show")},b.initUI=function(a,c){a.ui.showPopover||(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".progress-bar"),j="progress-";d.ui.bootstrap2&&(i=h.find(".bar"),j=""),a.each(b.possibleProgressBarClasses,function(a,b){i.removeClass(j+"bar-"+b)}),i.addClass(j+"bar-"+c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
                • "+b+"
                • "}),e.html(f)},b.updateFieldStatus=function(b,c,e){var f=b.ui.bootstrap2?".control-group":".form-group",g=c.parents(f).first();a.each(d,function(a,c){b.ui.bootstrap2||(c="has-"+c),g.removeClass(c)}),e=d[e],b.ui.bootstrap2||(e="has-"+e),g.addClass(e)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.updateUI=function(a,c,d){var e,f,g;0>=d?(e=0,g=""):d 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, seq) { - var sequences = [seq, seq.split('').reverse().join('')]; - $.each(sequences, function (idx, sequence) { - for (j = 0; j < (word.length - 3); j += 1) { //iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; -defaultOptions.common.zxcvbn = false; -defaultOptions.common.debug = false; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showProgressBar = true; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.showStatus = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "The Password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - $container = ui.getContainer(options, $el); - - result = {}; - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (options.ui.showVerdictsInsideProgressBar) { - result.$verdict = result.$progressbar.find("span.password-verdict"); - } - - if (!options.ui.showPopover) { - if (!options.ui.showVerdictsInsideProgressBar) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
                  "; - if (options.ui.showVerdictsInsideProgressBar) { - progressbar += ""; - } - progressbar += "
                  "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                    ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el) { - $el.popover("destroy"); - $el.popover({ - html: true, - placement: "bottom", - trigger: "manual", - content: " " - }); - }; - - ui.initUI = function (options, $el) { - if (options.ui.showPopover) { - ui.initPopover(options, $el); - } else { - if (options.ui.showErrors) { ui.initErrorList(options, $el); } - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.initVerdict(options, $el); - } - } - if (options.ui.showProgressBar) { - ui.initProgressBar(options, $el); - } - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
                  • " + err + "
                  • "; - }); - $errors.html(html); - }; - - ui.updatePopover = function (options, $el, verdictText) { - var popover = $el.data("bs.popover"), - html = "", - hide = true; - - if (options.ui.showVerdicts && verdictText.length > 0) { - html = "
                    " + verdictText + - "
                    "; - hide = false; - } - if (options.ui.showErrors) { - html += "
                      "; - $.each(options.instances.errors, function (idx, err) { - html += "
                    • " + err + "
                    • "; - hide = false; - }); - html += "
                    "; - } - - if (hide) { - $el.popover("hide"); - return; - } - - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { - $el.find("+ .popover .popover-content").html(html); - } else { - // It's hidden - popover.options.content = html; - $el.popover("show"); - } - }; - - ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); - - $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } - $container.removeClass(css); - }); - - cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } - $container.addClass(cssClass); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.updateUI = function (options, $el, score) { - var cssClass, barPercentage, verdictText; - - if (score <= 0) { - cssClass = 0; - verdictText = ""; - } else if (score < options.ui.scores[0]) { - cssClass = 0; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - cssClass = 0; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - cssClass = 1; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - cssClass = 1; - verdictText = options.ui.verdicts[3]; - } else { - cssClass = 2; - verdictText = options.ui.verdicts[4]; - } - - if (options.ui.showProgressBar) { - barPercentage = ui.percentage(score, options.ui.scores[3]); - ui.updateProgressBar(options, $el, cssClass, barPercentage); - if (options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - } - - if (options.ui.showStatus) { - ui.updateFieldStatus(options, $el, cssClass); - } - - if (options.ui.showPopover) { - ui.updatePopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - username, - score; - - options.instances.errors = []; - if (options.common.zxcvbn) { - username = $(options.common.usernameField).val(); - if (username && username.length > 0) { - score = zxcvbn(word, [username]).entropy; - } else { - score = zxcvbn(word).entropy; - } - } else { - score = rulesEngine.executeRules(options, word); - } - ui.updateUI(options, $el, score); - - if (options.common.debug) { console.log(score); } - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - ui.initUI(localOptions, $el); - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.1.min.js b/dist/pwstrength-bootstrap-1.1.1.min.js deleted file mode 100644 index 06279b4..0000000 --- a/dist/pwstrength-bootstrap-1.1.1.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2014-02-17 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports)var a=require("jquery")}catch(c){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm","!@#$%^&*()_+"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(b,c){var e=[c,c.split("").reverse().join("")];a.each(e,function(a,b){for(f=0;f-1&&(g=!0)})}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(c){}var d={};d.common={},d.common.minChar=6,d.common.usernameField="#username",d.common.onLoad=void 0,d.common.onKeyUp=void 0,d.common.zxcvbn=!1,d.common.debug=!1,d.rules={},d.rules.extra={},d.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},d.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},d.rules.raisePower=1.4,d.ui={},d.ui.bootstrap2=!1,d.ui.showProgressBar=!0,d.ui.showPopover=!1,d.ui.showStatus=!1,d.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},d.ui.errorMessages={password_too_short:"The Password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},d.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],d.ui.showVerdicts=!0,d.ui.showVerdictsInsideProgressBar=!1,d.ui.showErrors=!1,d.ui.container=void 0,d.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},d.ui.scores=[14,26,38,50];var e={};!function(a,b){"use strict";var c=["danger","warning","success"],d=["error","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(d=b.getContainer(a,c),e={},e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showVerdictsInsideProgressBar&&(e.$verdict=e.$progressbar.find("span.password-verdict")),a.ui.showPopover||(a.ui.showVerdictsInsideProgressBar||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict")),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                    ",c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                    ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
                      ",a.ui.viewports.errors)},b.initPopover=function(a,b){b.popover("destroy"),b.popover({html:!0,placement:"bottom",trigger:"manual",content:" "})},b.initUI=function(a,c){a.ui.showPopover?b.initPopover(a,c):(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".progress-bar"),j="progress-";d.ui.bootstrap2&&(i=h.find(".bar"),j=""),a.each(b.possibleProgressBarClasses,function(a,b){i.removeClass(j+"bar-"+b)}),i.addClass(j+"bar-"+c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
                    • "+b+"
                    • "}),e.html(f)},b.updatePopover=function(b,c,d){var e=c.data("bs.popover"),f="",g=!0;return b.ui.showVerdicts&&d.length>0&&(f="
                      "+d+"
                      ",g=!1),b.ui.showErrors&&(f+="
                        ",a.each(b.instances.errors,function(a,b){f+="
                      • "+b+"
                      • ",g=!1}),f+="
                      "),g?(c.popover("hide"),void 0):(b.ui.bootstrap2&&(e=c.data("popover")),e.$arrow&&e.$arrow.parents("body").length>0?c.find("+ .popover .popover-content").html(f):(e.options.content=f,c.popover("show")),void 0)},b.updateFieldStatus=function(b,c,e){var f=b.ui.bootstrap2?".control-group":".form-group",g=c.parents(f).first();a.each(d,function(a,c){b.ui.bootstrap2||(c="has-"+c),g.removeClass(c)}),e=d[e],b.ui.bootstrap2||(e="has-"+e),g.addClass(e)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.updateUI=function(a,c,d){var e,f,g;0>=d?(e=0,g=""):d0?zxcvbn(i,[d]).entropy:zxcvbn(i).entropy):f=b.executeRules(h,i),e.updateUI(h,g,f),h.common.debug&&console.log(f),a.isFunction(h.common.onKeyUp)&&h.common.onKeyUp(c)},c.init=function(b){return this.each(function(c,g){var h=a.extend(!0,{},d),i=a.extend(!0,h,b),j=a(g);i.instances={},j.data("pwstrength-bootstrap",i),j.on("keyup",f),e.initUI(i,j),a.isFunction(i.common.onLoad)&&i.common.onLoad()}),this},c.destroy=function(){this.each(function(b,c){var d=a(c),f=d.data("pwstrength-bootstrap"),g=e.getUIElements(f,d);g.$progressbar.remove(),g.$verdict.remove(),g.$errors.remove(),d.removeData("pwstrength-bootstrap")})},c.forceUpdate=function(){this.each(function(a,b){var c={target:b};f(c)})},c.addRule=function(b,c,d,e){this.each(function(f,g){var h=a(g).data("pwstrength-bootstrap");h.rules.activated[b]=e,h.rules.scores[b]=d,h.rules.extra[b]=c})},g=function(b,c,d){this.each(function(e,f){a(f).data("pwstrength-bootstrap").rules[c][b]=d})},c.changeScore=function(a,b){g.call(this,a,"scores",b)},c.ruleActive=function(a,b){g.call(this,a,"activated",b)},a.fn.pwstrength=function(b){var d;return c[b]?d=c[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?a.error("Method "+b+" does not exist on jQuery.pwstrength-bootstrap"):d=c.init.apply(this,arguments),d}}(a,f)}(jQuery); -//# sourceMappingURL=pwstrength-bootstrap-1.1.1.min.map \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.1.min.map b/dist/pwstrength-bootstrap-1.1.1.min.map deleted file mode 100644 index 1bd8537..0000000 --- a/dist/pwstrength-bootstrap-1.1.1.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pwstrength-bootstrap-1.1.1.min.js","sources":["pwstrength-bootstrap-1.1.1.js"],"names":["jQuery","rulesEngine","module","exports","require","ignore","$","validation","forbiddenSequences","wordNotEmail","options","word","score","match","instances","errors","push","ui","spanError","wordLength","wordlen","length","lenScore","Math","pow","rules","raisePower","common","minChar","wordSimilarToUsername","username","usernameField","val","toLowerCase","wordTwoCharacterClasses","wordRepetitions","wordSequences","j","found","each","idx","seq","sequences","split","reverse","join","sequence","indexOf","substring","wordLowercase","wordUppercase","wordOneNumber","wordThreeNumbers","wordOneSpecialChar","wordTwoSpecialChar","wordUpperLowerCombo","wordLetterNumberCombo","wordLetterNumberCharCombo","executeRules","totalScore","activated","rule","active","result","scores","funct","isFunction","extra","defaultOptions","onLoad","undefined","onKeyUp","zxcvbn","debug","bootstrap2","showProgressBar","showPopover","showStatus","key","text","errorMessages","password_too_short","email_as_password","same_as_username","two_character_classes","repeated_character","sequence_found","verdicts","showVerdicts","showVerdictsInsideProgressBar","showErrors","container","viewports","progress","verdict","barClasses","statusClasses","getContainer","$el","$container","parent","findElement","viewport","cssSelector","find","getUIElements","$progressbar","$verdict","$errors","initProgressBar","progressbar","append","insertAfter","initHelper","html","initVerdict","initErrorList","initPopover","popover","placement","trigger","content","initUI","possibleProgressBarClasses","updateProgressBar","cssClass","percentage","$bar","cssPrefix","value","removeClass","addClass","css","updateVerdict","updateErrors","err","updatePopover","verdictText","data","hide","$arrow","parents","updateFieldStatus","targetClass","first","maximun","floor","updateUI","barPercentage","methods","applyToAll","event","target","entropy","console","log","init","settings","this","el","clonedDefaults","extend","localOptions","on","destroy","elements","remove","removeData","forceUpdate","addRule","name","method","prop","changeScore","call","ruleActive","fn","pwstrength","apply","Array","prototype","slice","arguments","error"],"mappings":";;CAQC,SAAUA,GAMX,GAAIC,KAEJ,KACI,IAAKD,GAAUE,QAAUA,OAAOC,QAC5B,GAAIH,GAASI,QAAQ,UAE3B,MAAOC,KAER,SAAUC,EAAGL,GACV,YACA,IAAIM,KAEJN,GAAYO,oBACR,aAAc,6BAA8B,aAAc,YAC1D,UAAW,gBAGfD,EAAWE,aAAe,SAAUC,EAASC,EAAMC,GAC/C,MAAID,GAAKE,MAAM,iMACXH,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,GAAGC,UAAUR,EAAS,sBACrDE,GAFX,QAMJL,EAAWY,WAAa,SAAUT,EAASC,EAAMC,GAC7C,GAAIQ,GAAUT,EAAKU,OACfC,EAAWC,KAAKC,IAAIJ,EAASV,EAAQe,MAAMC,WAK/C,OAJIN,GAAUV,EAAQiB,OAAOC,UACzBN,GAAuBV,EACvBF,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,GAAGC,UAAUR,EAAS,wBAEzDY,GAGXf,EAAWsB,sBAAwB,SAAUnB,EAASC,EAAMC,GACxD,GAAIkB,GAAWxB,EAAEI,EAAQiB,OAAOI,eAAeC,KAC/C,OAAIF,IAAYnB,EAAKsB,cAAcpB,MAAMiB,EAASG,gBAC9CvB,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO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AQ0D,SACjBpE,EAAIqE,WAAW,2BAIvBlB,EAAQmB,YAAc,WAClBV,KAAKvH,KAAK,SAAUC,EAAKuH,GACrB,GAAIR,IAAUC,OAAQO,EACtBxF,GAAQgF,MAIhBF,EAAQoB,QAAU,SAAUC,EAAMC,EAAQ/J,EAAOkD,GAC7CgG,KAAKvH,KAAK,SAAUC,EAAKuH,GACrB,GAAIrJ,GAAUJ,EAAEyJ,GAAIrB,KAAK,uBAEzBhI,GAAQe,MAAMmC,UAAU8G,GAAQ5G,EAChCpD,EAAQe,MAAMuC,OAAO0G,GAAQ9J,EAC7BF,EAAQe,MAAM0C,MAAMuG,GAAQC,KAIpCrB,EAAa,SAAUzF,EAAM+G,EAAM3C,GAC/B6B,KAAKvH,KAAK,SAAUC,EAAKuH,GACrBzJ,EAAEyJ,GAAIrB,KAAK,wBAAwBjH,MAAMmJ,GAAM/G,GAAQoE,KAI/DoB,EAAQwB,YAAc,SAAUhH,EAAMjD,GAClC0I,EAAWwB,KAAKhB,KAAMjG,EAAM,SAAUjD,IAG1CyI,EAAQ0B,WAAa,SAAUlH,EAAMC,GACjCwF,EAAWwB,KAAKhB,KAAMjG,EAAM,YAAaC,IAG7CxD,EAAE0K,GAAGC,WAAa,SAAUN,GACxB,GAAI5G,EAUJ,OARIsF,GAAQsB,GACR5G,EAASsF,EAAQsB,GAAQO,MAAMpB,KAAMqB,MAAMC,UAAUC,MAAMP,KAAKQ,UAAW,IAClD,gBAAXX,IAAwBA,EAGtCrK,EAAEiL,MAAM,UAAaZ,EAAS,kDAF9B5G,EAASsF,EAAQO,KAAKsB,MAAMpB,KAAMwB,WAK/BvH,IAEb/D,EAAQqJ,IACRrJ"} \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.2.js b/dist/pwstrength-bootstrap-1.1.2.js deleted file mode 100644 index b1d0b33..0000000 --- a/dist/pwstrength-bootstrap-1.1.2.js +++ /dev/null @@ -1,629 +0,0 @@ -/*! -* jQuery Password Strength plugin for Twitter Bootstrap -* -* Copyright (c) 2008-2013 Tane Piper -* Copyright (c) 2013 Alejandro Blanco -* Dual licensed under the MIT and GPL licenses. -*/ - -(function (jQuery) { -// Source: src/rules.js - - - - -var rulesEngine = {}; - -try { - if (!jQuery && module && module.exports) { - var jQuery = require("jquery"), - jsdom = require("jsdom").jsdom; - jQuery = jQuery(jsdom().parentWindow); - } -} catch (ignore) {} - -(function ($, rulesEngine) { - "use strict"; - var validation = {}; - - rulesEngine.forbiddenSequences = [ - "0123456789", "abcdefghijklmnopqrstuvxywz", "qwertyuiop", "asdfghjkl", - "zxcvbnm", "!@#$%^&*()_+" - ]; - - validation.wordNotEmail = function (options, word, score) { - if (word.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)) { - options.instances.errors.push(options.ui.spanError(options, "email_as_password")); - return score; - } - }; - - validation.wordLength = function (options, word, score) { - var wordlen = word.length, - lenScore = Math.pow(wordlen, options.rules.raisePower); - if (wordlen < options.common.minChar) { - lenScore = (lenScore + score); - options.instances.errors.push(options.ui.spanError(options, "password_too_short")); - } - return lenScore; - }; - - validation.wordSimilarToUsername = function (options, word, score) { - var username = $(options.common.usernameField).val(); - if (username && word.toLowerCase().match(username.toLowerCase())) { - options.instances.errors.push(options.ui.spanError(options, "same_as_username")); - return score; - } - return false; - }; - - validation.wordTwoCharacterClasses = function (options, word, score) { - if (word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) || - (word.match(/([a-zA-Z])/) && word.match(/([0-9])/)) || - (word.match(/(.[!,@,#,$,%,\^,&,*,?,_,~])/) && word.match(/[a-zA-Z0-9_]/))) { - return score; - } - options.instances.errors.push(options.ui.spanError(options, "two_character_classes")); - return false; - }; - - validation.wordRepetitions = function (options, word, score) { - if (word.match(/(.)\1\1/)) { - options.instances.errors.push(options.ui.spanError(options, "repeated_character")); - return score; - } - return false; - }; - - validation.wordSequences = function (options, word, score) { - var found = false, - j; - if (word.length > 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, seq) { - var sequences = [seq, seq.split('').reverse().join('')]; - $.each(sequences, function (idx, sequence) { - for (j = 0; j < (word.length - 2); j += 1) { // iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; -defaultOptions.common.zxcvbn = false; -defaultOptions.common.debug = false; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showProgressBar = true; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.showStatus = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "The Password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - $container = ui.getContainer(options, $el); - - result = {}; - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (options.ui.showVerdictsInsideProgressBar) { - result.$verdict = result.$progressbar.find("span.password-verdict"); - } - - if (!options.ui.showPopover) { - if (!options.ui.showVerdictsInsideProgressBar) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
                      "; - if (options.ui.showVerdictsInsideProgressBar) { - progressbar += ""; - } - progressbar += "
                      "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                        ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el) { - $el.popover("destroy"); - $el.popover({ - html: true, - placement: "bottom", - trigger: "manual", - content: " " - }); - }; - - ui.initUI = function (options, $el) { - if (options.ui.showPopover) { - ui.initPopover(options, $el); - } else { - if (options.ui.showErrors) { ui.initErrorList(options, $el); } - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.initVerdict(options, $el); - } - } - if (options.ui.showProgressBar) { - ui.initProgressBar(options, $el); - } - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
                      • " + err + "
                      • "; - }); - $errors.html(html); - }; - - ui.updatePopover = function (options, $el, verdictText) { - var popover = $el.data("bs.popover"), - html = "", - hide = true; - - if (options.ui.showVerdicts && verdictText.length > 0) { - html = "
                        " + verdictText + - "
                        "; - hide = false; - } - if (options.ui.showErrors) { - html += "
                          "; - $.each(options.instances.errors, function (idx, err) { - html += "
                        • " + err + "
                        • "; - hide = false; - }); - html += "
                        "; - } - - if (hide) { - $el.popover("hide"); - return; - } - - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { - $el.find("+ .popover .popover-content").html(html); - } else { - // It's hidden - popover.options.content = html; - $el.popover("show"); - } - }; - - ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); - - $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } - $container.removeClass(css); - }); - - cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } - $container.addClass(cssClass); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.updateUI = function (options, $el, score) { - var cssClass, barPercentage, verdictText; - - if (score <= 0) { - cssClass = 0; - verdictText = ""; - } else if (score < options.ui.scores[0]) { - cssClass = 0; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - cssClass = 0; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - cssClass = 1; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - cssClass = 1; - verdictText = options.ui.verdicts[3]; - } else { - cssClass = 2; - verdictText = options.ui.verdicts[4]; - } - - if (options.ui.showProgressBar) { - barPercentage = ui.percentage(score, options.ui.scores[3]); - ui.updateProgressBar(options, $el, cssClass, barPercentage); - if (options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - } - - if (options.ui.showStatus) { - ui.updateFieldStatus(options, $el, cssClass); - } - - if (options.ui.showPopover) { - ui.updatePopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - username, - score; - - options.instances.errors = []; - if (options.common.zxcvbn) { - username = $(options.common.usernameField).val(); - if (username && username.length > 0) { - score = zxcvbn(word, [username]).entropy; - } else { - score = zxcvbn(word).entropy; - } - } else { - score = rulesEngine.executeRules(options, word); - } - ui.updateUI(options, $el, score); - - if (options.common.debug) { console.log(score); } - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - - ui.initUI(localOptions, $el); - if ($el.val().trim()) { // Not empty, calculate the strength - $el.trigger("keyup"); - } - - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.2.min.js b/dist/pwstrength-bootstrap-1.1.2.min.js deleted file mode 100644 index f919272..0000000 --- a/dist/pwstrength-bootstrap-1.1.2.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2014-04-27 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports){var a=require("jquery"),c=require("jsdom").jsdom;a=a(c().parentWindow)}}catch(d){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm","!@#$%^&*()_+"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(b,c){var e=[c,c.split("").reverse().join("")];a.each(e,function(a,b){for(f=0;f-1&&(g=!0)})}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(d){}var e={};e.common={},e.common.minChar=6,e.common.usernameField="#username",e.common.onLoad=void 0,e.common.onKeyUp=void 0,e.common.zxcvbn=!1,e.common.debug=!1,e.rules={},e.rules.extra={},e.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},e.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},e.rules.raisePower=1.4,e.ui={},e.ui.bootstrap2=!1,e.ui.showProgressBar=!0,e.ui.showPopover=!1,e.ui.showStatus=!1,e.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},e.ui.errorMessages={password_too_short:"The Password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},e.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],e.ui.showVerdicts=!0,e.ui.showVerdictsInsideProgressBar=!1,e.ui.showErrors=!1,e.ui.container=void 0,e.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},e.ui.scores=[14,26,38,50];var f={};!function(a,b){"use strict";var c=["danger","warning","success"],d=["error","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(d=b.getContainer(a,c),e={},e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showVerdictsInsideProgressBar&&(e.$verdict=e.$progressbar.find("span.password-verdict")),a.ui.showPopover||(a.ui.showVerdictsInsideProgressBar||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict")),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                        ",c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                        ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
                          ",a.ui.viewports.errors)},b.initPopover=function(a,b){b.popover("destroy"),b.popover({html:!0,placement:"bottom",trigger:"manual",content:" "})},b.initUI=function(a,c){a.ui.showPopover?b.initPopover(a,c):(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".progress-bar"),j="progress-";d.ui.bootstrap2&&(i=h.find(".bar"),j=""),a.each(b.possibleProgressBarClasses,function(a,b){i.removeClass(j+"bar-"+b)}),i.addClass(j+"bar-"+c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
                        • "+b+"
                        • "}),e.html(f)},b.updatePopover=function(b,c,d){var e=c.data("bs.popover"),f="",g=!0;return b.ui.showVerdicts&&d.length>0&&(f="
                          "+d+"
                          ",g=!1),b.ui.showErrors&&(f+="
                            ",a.each(b.instances.errors,function(a,b){f+="
                          • "+b+"
                          • ",g=!1}),f+="
                          "),g?void c.popover("hide"):(b.ui.bootstrap2&&(e=c.data("popover")),void(e.$arrow&&e.$arrow.parents("body").length>0?c.find("+ .popover .popover-content").html(f):(e.options.content=f,c.popover("show"))))},b.updateFieldStatus=function(b,c,e){var f=b.ui.bootstrap2?".control-group":".form-group",g=c.parents(f).first();a.each(d,function(a,c){b.ui.bootstrap2||(c="has-"+c),g.removeClass(c)}),e=d[e],b.ui.bootstrap2||(e="has-"+e),g.addClass(e)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.updateUI=function(a,c,d){var e,f,g;0>=d?(e=0,g=""):d0?zxcvbn(i,[d]).entropy:zxcvbn(i).entropy):e=b.executeRules(h,i),f.updateUI(h,g,e),h.common.debug&&console.log(e),a.isFunction(h.common.onKeyUp)&&h.common.onKeyUp(c)},c.init=function(b){return this.each(function(c,g){var h=a.extend(!0,{},e),i=a.extend(!0,h,b),j=a(g);i.instances={},j.data("pwstrength-bootstrap",i),j.on("keyup",d),f.initUI(i,j),j.val().trim()&&j.trigger("keyup"),a.isFunction(i.common.onLoad)&&i.common.onLoad()}),this},c.destroy=function(){this.each(function(b,c){var d=a(c),e=d.data("pwstrength-bootstrap"),g=f.getUIElements(e,d);g.$progressbar.remove(),g.$verdict.remove(),g.$errors.remove(),d.removeData("pwstrength-bootstrap")})},c.forceUpdate=function(){this.each(function(a,b){var c={target:b};d(c)})},c.addRule=function(b,c,d,e){this.each(function(f,g){var h=a(g).data("pwstrength-bootstrap");h.rules.activated[b]=e,h.rules.scores[b]=d,h.rules.extra[b]=c})},g=function(b,c,d){this.each(function(e,f){a(f).data("pwstrength-bootstrap").rules[c][b]=d})},c.changeScore=function(a,b){g.call(this,a,"scores",b)},c.ruleActive=function(a,b){g.call(this,a,"activated",b)},a.fn.pwstrength=function(b){var d;return c[b]?d=c[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?a.error("Method "+b+" does not exist on jQuery.pwstrength-bootstrap"):d=c.init.apply(this,arguments),d}}(a,g)}(jQuery); -//# sourceMappingURL=pwstrength-bootstrap-1.1.2.min.map \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.2.min.map b/dist/pwstrength-bootstrap-1.1.2.min.map deleted file mode 100644 index 5f39717..0000000 --- a/dist/pwstrength-bootstrap-1.1.2.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pwstrength-bootstrap-1.1.2.min.js","sources":["pwstrength-bootstrap-1.1.2.js"],"names":["jQuery","rulesEngine","module","exports","require","jsdom","parentWindow","ignore","$","validation","forbiddenSequences","wordNotEmail","options","word","score","match","instances","errors","push","ui","spanError","wordLength","wordlen","length","lenScore","Math","pow","rules","raisePower","common","minChar","wordSimilarToUsername","username","usernameField","val","toLowerCase","wordTwoCharacterClasses","wordRepetitions","wordSequences","j","found","each","idx","seq","sequences","split","reverse","join","sequence","indexOf","substring","wordLowercase","wordUppercase","wordOneNumber","wordThreeNumbers","wordOneSpecialChar","wordTwoSpecialChar","wordUpperLowerCombo","wordLetterNumberCombo","wordLetterNumberCharCombo","executeRules","totalScore","activated","rule","active","result","scores","funct","isFunction","extra","defaultOptions","onLoad","undefined","onKeyUp","zxcvbn","debug","bootstrap2","showProgressBar","showPopover","showStatus","key","text","errorMessages","password_too_short","email_as_password","same_as_username","two_character_classes","repeated_character","sequence_found","verdicts","showVerdicts","showVerdictsInsideProgressBar","showErrors","container","viewports","progress","verdict","barClasses","statusClasses","getContainer","$el","$container","parent","findElement","viewport","cssSelector","find","getUIElements","$progressbar","$verdict","$errors","initProgressBar","progressbar","append","insertAfter","initHelper","html","initVerdict","initErrorList","initPopover","popover","placement","trigger","content","initUI","possibleProgressBarClasses","updateProgressBar","cssClass","percentage","$bar","cssPrefix","value","removeClass","addClass","css","updateVerdict","updateErrors","err","updatePopover","verdictText","data","hide","$arrow","parents","updateFieldStatus","targetClass","first","maximun","floor","updateUI","barPercentage","methods","applyToAll","event","target","entropy","console","log","init","settings","this","el","clonedDefaults","extend","localOptions","on","trim","destroy","elements","remove","removeData","forceUpdate","addRule","name","method","prop","changeScore","call","ruleActive","fn","pwstrength","apply","Array","prototype","slice","arguments","error"],"mappings":";;CAQC,SAAUA,GAMX,GAAIC,KAEJ,KACI,IAAKD,GAAUE,QAAUA,OAAOC,QAAS,CACrC,GAAIH,GAASI,QAAQ,UACjBC,EAAQD,QAAQ,SAASC,KAC7BL,GAASA,EAAOK,IAAQC,eAE9B,MAAOC,KAER,SAAUC,EAAGP,GACV,YACA,IAAIQ,KAEJR,GAAYS,oBACR,aAAc,6BAA8B,aAAc,YAC1D,UAAW,gBAGfD,EAAWE,aAAe,SAAUC,EAASC,EAAMC,GAC/C,MAAID,GAAKE,MAAM,iMACXH,EAA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UnH,EAAMC,GACjCwF,EAAWyB,KAAKjB,KAAMjG,EAAM,YAAaC,IAG7CxD,EAAE2K,GAAGC,WAAa,SAAUN,GACxB,GAAI7G,EAUJ,OARIsF,GAAQuB,GACR7G,EAASsF,EAAQuB,GAAQO,MAAMrB,KAAMsB,MAAMC,UAAUC,MAAMP,KAAKQ,UAAW,IAClD,gBAAXX,IAAwBA,EAGtCtK,EAAEkL,MAAM,UAAaZ,EAAS,kDAF9B7G,EAASsF,EAAQO,KAAKuB,MAAMrB,KAAMyB,WAK/BxH,IAEbjE,EAAQuJ,IACRvJ"} \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.3.js b/dist/pwstrength-bootstrap-1.1.3.js deleted file mode 100644 index ad4f9c0..0000000 --- a/dist/pwstrength-bootstrap-1.1.3.js +++ /dev/null @@ -1,641 +0,0 @@ -/*! -* jQuery Password Strength plugin for Twitter Bootstrap -* -* Copyright (c) 2008-2013 Tane Piper -* Copyright (c) 2013 Alejandro Blanco -* Dual licensed under the MIT and GPL licenses. -*/ - -(function (jQuery) { -// Source: src/rules.js - - - - -var rulesEngine = {}; - -try { - if (!jQuery && module && module.exports) { - var jQuery = require("jquery"), - jsdom = require("jsdom").jsdom; - jQuery = jQuery(jsdom().parentWindow); - } -} catch (ignore) {} - -(function ($, rulesEngine) { - "use strict"; - var validation = {}; - - rulesEngine.forbiddenSequences = [ - "0123456789", "abcdefghijklmnopqrstuvxywz", "qwertyuiop", "asdfghjkl", - "zxcvbnm", "!@#$%^&*()_+" - ]; - - validation.wordNotEmail = function (options, word, score) { - if (word.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)) { - options.instances.errors.push(options.ui.spanError(options, "email_as_password")); - return score; - } - }; - - validation.wordLength = function (options, word, score) { - var wordlen = word.length, - lenScore = Math.pow(wordlen, options.rules.raisePower); - if (wordlen < options.common.minChar) { - lenScore = (lenScore + score); - options.instances.errors.push(options.ui.spanError(options, "password_too_short")); - } - return lenScore; - }; - - validation.wordSimilarToUsername = function (options, word, score) { - var username = $(options.common.usernameField).val(); - if (username && word.toLowerCase().match(username.toLowerCase())) { - options.instances.errors.push(options.ui.spanError(options, "same_as_username")); - return score; - } - return false; - }; - - validation.wordTwoCharacterClasses = function (options, word, score) { - if (word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) || - (word.match(/([a-zA-Z])/) && word.match(/([0-9])/)) || - (word.match(/(.[!,@,#,$,%,\^,&,*,?,_,~])/) && word.match(/[a-zA-Z0-9_]/))) { - return score; - } - options.instances.errors.push(options.ui.spanError(options, "two_character_classes")); - return false; - }; - - validation.wordRepetitions = function (options, word, score) { - if (word.match(/(.)\1\1/)) { - options.instances.errors.push(options.ui.spanError(options, "repeated_character")); - return score; - } - return false; - }; - - validation.wordSequences = function (options, word, score) { - var found = false, - j; - if (word.length > 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, seq) { - var sequences = [seq, seq.split('').reverse().join('')]; - $.each(sequences, function (idx, sequence) { - for (j = 0; j < (word.length - 2); j += 1) { // iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; -defaultOptions.common.zxcvbn = false; -defaultOptions.common.debug = false; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showProgressBar = true; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.showStatus = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "The Password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - $container = ui.getContainer(options, $el); - - result = {}; - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (options.ui.showVerdictsInsideProgressBar) { - result.$verdict = result.$progressbar.find("span.password-verdict"); - } - - if (!options.ui.showPopover) { - if (!options.ui.showVerdictsInsideProgressBar) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
                          "; - if (options.ui.showVerdictsInsideProgressBar) { - progressbar += ""; - } - progressbar += "
                          "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                            ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el) { - $el.popover("destroy"); - $el.popover({ - html: true, - placement: "bottom", - trigger: "manual", - content: " " - }); - }; - - ui.initUI = function (options, $el) { - if (options.ui.showPopover) { - ui.initPopover(options, $el); - } else { - if (options.ui.showErrors) { ui.initErrorList(options, $el); } - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.initVerdict(options, $el); - } - } - if (options.ui.showProgressBar) { - ui.initProgressBar(options, $el); - } - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
                          • " + err + "
                          • "; - }); - $errors.html(html); - }; - - ui.updatePopover = function (options, $el, verdictText) { - var popover = $el.data("bs.popover"), - html = "", - hide = true; - - if (options.ui.showVerdicts && verdictText.length > 0) { - html = "
                            " + verdictText + - "
                            "; - hide = false; - } - if (options.ui.showErrors) { - html += "
                              "; - $.each(options.instances.errors, function (idx, err) { - html += "
                            • " + err + "
                            • "; - hide = false; - }); - html += "
                            "; - } - - if (hide) { - $el.popover("hide"); - return; - } - - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { - $el.find("+ .popover .popover-content").html(html); - } else { - // It's hidden - popover.options.content = html; - $el.popover("show"); - } - }; - - ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); - - $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } - $container.removeClass(css); - }); - - cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } - $container.addClass(cssClass); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.getVerdictAndCssClass = function (options, score) { - var cssClass, verdictText; - - if (score <= 0) { - cssClass = 0; - verdictText = ""; - } else if (score < options.ui.scores[0]) { - cssClass = 0; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - cssClass = 0; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - cssClass = 1; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - cssClass = 1; - verdictText = options.ui.verdicts[3]; - } else { - cssClass = 2; - verdictText = options.ui.verdicts[4]; - } - - return [verdictText, cssClass]; - }; - - ui.updateUI = function (options, $el, score) { - var cssClass, barPercentage, verdictText; - - cssClass = ui.getVerdictAndCssClass(options, score); - verdictText = cssClass[0]; - cssClass = cssClass[1]; - - if (options.ui.showProgressBar) { - barPercentage = ui.percentage(score, options.ui.scores[3]); - ui.updateProgressBar(options, $el, cssClass, barPercentage); - if (options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - } - - if (options.ui.showStatus) { - ui.updateFieldStatus(options, $el, cssClass); - } - - if (options.ui.showPopover) { - ui.updatePopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - username, - verdictText, - score; - - options.instances.errors = []; - if (options.common.zxcvbn) { - username = $(options.common.usernameField).val(); - if (username && username.length > 0) { - score = zxcvbn(word, [username]).entropy; - } else { - score = zxcvbn(word).entropy; - } - } else { - score = rulesEngine.executeRules(options, word); - } - ui.updateUI(options, $el, score); - verdictText = ui.getVerdictAndCssClass(options, score)[0]; - - if (options.common.debug) { console.log(score + ' - ' + verdictText); } - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event, score, verdictText); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - - ui.initUI(localOptions, $el); - if ($el.val().trim()) { // Not empty, calculate the strength - $el.trigger("keyup"); - } - - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.3.min.js b/dist/pwstrength-bootstrap-1.1.3.min.js deleted file mode 100644 index b05b0f8..0000000 --- a/dist/pwstrength-bootstrap-1.1.3.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2014-06-18 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports){var a=require("jquery"),c=require("jsdom").jsdom;a=a(c().parentWindow)}}catch(d){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm","!@#$%^&*()_+"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(b,c){var e=[c,c.split("").reverse().join("")];a.each(e,function(a,b){for(f=0;f-1&&(g=!0)})}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(d){}var e={};e.common={},e.common.minChar=6,e.common.usernameField="#username",e.common.onLoad=void 0,e.common.onKeyUp=void 0,e.common.zxcvbn=!1,e.common.debug=!1,e.rules={},e.rules.extra={},e.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},e.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},e.rules.raisePower=1.4,e.ui={},e.ui.bootstrap2=!1,e.ui.showProgressBar=!0,e.ui.showPopover=!1,e.ui.showStatus=!1,e.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},e.ui.errorMessages={password_too_short:"The Password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},e.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],e.ui.showVerdicts=!0,e.ui.showVerdictsInsideProgressBar=!1,e.ui.showErrors=!1,e.ui.container=void 0,e.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},e.ui.scores=[14,26,38,50];var f={};!function(a,b){"use strict";var c=["danger","warning","success"],d=["error","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(d=b.getContainer(a,c),e={},e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showVerdictsInsideProgressBar&&(e.$verdict=e.$progressbar.find("span.password-verdict")),a.ui.showPopover||(a.ui.showVerdictsInsideProgressBar||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict")),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                            ",c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                            ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
                              ",a.ui.viewports.errors)},b.initPopover=function(a,b){b.popover("destroy"),b.popover({html:!0,placement:"bottom",trigger:"manual",content:" "})},b.initUI=function(a,c){a.ui.showPopover?b.initPopover(a,c):(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".progress-bar"),j="progress-";d.ui.bootstrap2&&(i=h.find(".bar"),j=""),a.each(b.possibleProgressBarClasses,function(a,b){i.removeClass(j+"bar-"+b)}),i.addClass(j+"bar-"+c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
                            • "+b+"
                            • "}),e.html(f)},b.updatePopover=function(b,c,d){var e=c.data("bs.popover"),f="",g=!0;return b.ui.showVerdicts&&d.length>0&&(f="
                              "+d+"
                              ",g=!1),b.ui.showErrors&&(f+="
                                ",a.each(b.instances.errors,function(a,b){f+="
                              • "+b+"
                              • ",g=!1}),f+="
                              "),g?void c.popover("hide"):(b.ui.bootstrap2&&(e=c.data("popover")),void(e.$arrow&&e.$arrow.parents("body").length>0?c.find("+ .popover .popover-content").html(f):(e.options.content=f,c.popover("show"))))},b.updateFieldStatus=function(b,c,e){var f=b.ui.bootstrap2?".control-group":".form-group",g=c.parents(f).first();a.each(d,function(a,c){b.ui.bootstrap2||(c="has-"+c),g.removeClass(c)}),e=d[e],b.ui.bootstrap2||(e="has-"+e),g.addClass(e)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.getVerdictAndCssClass=function(a,b){var c,d;return 0>=b?(c=0,d=""):b0?zxcvbn(j,[d]).entropy:zxcvbn(j).entropy):g=b.executeRules(i,j),f.updateUI(i,h,g),e=f.getVerdictAndCssClass(i,g)[0],i.common.debug&&console.log(g+" - "+e),a.isFunction(i.common.onKeyUp)&&i.common.onKeyUp(c,g,e)},c.init=function(b){return this.each(function(c,g){var h=a.extend(!0,{},e),i=a.extend(!0,h,b),j=a(g);i.instances={},j.data("pwstrength-bootstrap",i),j.on("keyup",d),f.initUI(i,j),j.val().trim()&&j.trigger("keyup"),a.isFunction(i.common.onLoad)&&i.common.onLoad()}),this},c.destroy=function(){this.each(function(b,c){var d=a(c),e=d.data("pwstrength-bootstrap"),g=f.getUIElements(e,d);g.$progressbar.remove(),g.$verdict.remove(),g.$errors.remove(),d.removeData("pwstrength-bootstrap")})},c.forceUpdate=function(){this.each(function(a,b){var c={target:b};d(c)})},c.addRule=function(b,c,d,e){this.each(function(f,g){var h=a(g).data("pwstrength-bootstrap");h.rules.activated[b]=e,h.rules.scores[b]=d,h.rules.extra[b]=c})},g=function(b,c,d){this.each(function(e,f){a(f).data("pwstrength-bootstrap").rules[c][b]=d})},c.changeScore=function(a,b){g.call(this,a,"scores",b)},c.ruleActive=function(a,b){g.call(this,a,"activated",b)},a.fn.pwstrength=function(b){var d;return c[b]?d=c[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?a.error("Method "+b+" does not exist on jQuery.pwstrength-bootstrap"):d=c.init.apply(this,arguments),d}}(a,g)}(jQuery); -//# sourceMappingURL=pwstrength-bootstrap-1.1.3.min.map \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.3.min.map b/dist/pwstrength-bootstrap-1.1.3.min.map deleted file mode 100644 index 8cd49e9..0000000 --- a/dist/pwstrength-bootstrap-1.1.3.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pwstrength-bootstrap-1.1.3.min.js","sources":["pwstrength-bootstrap-1.1.3.js"],"names":["jQuery","rulesEngine","module","exports","require","jsdom","parentWindow","ignore","$","validation","forbiddenSequences","wordNotEmail","options","word","score","match","instances","errors","push","ui","spanError","wordLength","wordlen","length","lenScore","Math","pow","rules","raisePower","common","minChar","wordSimilarToUsername","username","usernameField","val","toLowerCase","wordTwoCharacterClasses","wordRepetitions","wordSequences","j","found","each","idx","seq","sequences","split","reverse","join","sequence","indexOf","substring","wordLowercase","wordUppercase","wordOneNumber","wordThreeNumbers","wordOneSpecialChar","wordTwoSpecialChar","wordUpperLowerCombo","wordLetterNumberCombo","wordLetterNumberCharCombo","executeRules","totalScore","activated","rule","active","result","scores","funct","isFunction","extra","defaultOptions","onLoad","undefined","onKeyUp","zxcvbn","debug","bootstrap2","showProgressBar","showPopover","showStatus","key","text","errorMessages","password_too_short","email_as_password","same_as_username","two_character_classes","repeated_character","sequence_found","verdicts","showVerdicts","showVerdictsInsideProgressBar","showErrors","container","viewports","progress","verdict","barClasses","statusClasses","getContainer","$el","$container","parent","findElement","viewport","cssSelector","find","getUIElements","$progressbar","$verdict","$errors","initProgressBar","progressbar","append","insertAfter","initHelper","html","initVerdict","initErrorList","initPopover","popover","placement","trigger","content","initUI","possibleProgressBarClasses","updateProgressBar","cssClass","percentage","$bar","cssPrefix","value","removeClass","addClass","css","updateVerdict","updateErrors","err","updatePopover","verdictText","data","hide","$arrow","parents","updateFieldStatus","targetClass","first","maximun","floor","getVerdictAndCssClass","updateUI","barPercentage","methods","applyToAll","event","target","entropy","console","log","init","settings","this","el","clonedDefaults","extend","localOptions","on","trim","destroy","elements","remove","removeData","forceUpdate","addRule","name","method","prop","changeScore","call","ruleActive","fn","pwstrength","apply","Array","prototype","slice","arguments","error"],"mappings":";;CAQC,SAAUA,GAMX,GAAIC,KAEJ,KACI,IAAKD,GAAUE,QAAUA,OAAOC,QAAS,CACrC,GAAIH,GAASI,QAAQ,UACjBC,EAAQD,QAAQ,SAASC,KAC7BL,GAASA,EAAOK,IAAQC,eAE9B,MAAOC,KAER,SAAUC,EAAGP,GACV,YACA,IAAIQ,KAEJR,GAAYS,oBACR,aAAc,6BAA8B,aAAc,YAC1D,UAAW,gBAGfD,EAAWE,aAAe,SAAUC,EAASC,EAAMC,GAC/C,MAAID,GAAKE,MAAM,iMACXH,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,GAAGC,UAAUR,EAAS,sBACrDE,GAFX,QAMJL,EAAWY,WAAa,SAAUT,EAASC,EAAMC,GAC7C,GAAIQ,GAAUT,EAAKU,OACfC,EAAWC,KAAKC,IAAIJ,EAASV,EAAQe,MAAMC,WAK/C,OAJIN,GAAUV,EAAQiB,OAAOC,UACzBN,GAAuBV,EACvBF,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,GAAGC,UAAUR,EAAS,wBAEzDY,GAGXf,EAAWsB,sBAAwB,SAAUnB,EAASC,EAAMC,GACxD,GAAIkB,GAAWxB,EAAEI,EAAQiB,OAAOI,eAAeC,KA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EAAQuB,GAAQO,MAAMrB,KAAMsB,MAAMC,UAAUC,MAAMP,KAAKQ,UAAW,IAClD,gBAAXX,IAAwBA,EAGtCvK,EAAEmL,MAAM,UAAaZ,EAAS,kDAF9B9G,EAASuF,EAAQO,KAAKuB,MAAMrB,KAAMyB,WAK/BzH,IAEbjE,EAAQwJ,IACRxJ"} \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.4.js b/dist/pwstrength-bootstrap-1.1.4.js deleted file mode 100644 index ad4f9c0..0000000 --- a/dist/pwstrength-bootstrap-1.1.4.js +++ /dev/null @@ -1,641 +0,0 @@ -/*! -* jQuery Password Strength plugin for Twitter Bootstrap -* -* Copyright (c) 2008-2013 Tane Piper -* Copyright (c) 2013 Alejandro Blanco -* Dual licensed under the MIT and GPL licenses. -*/ - -(function (jQuery) { -// Source: src/rules.js - - - - -var rulesEngine = {}; - -try { - if (!jQuery && module && module.exports) { - var jQuery = require("jquery"), - jsdom = require("jsdom").jsdom; - jQuery = jQuery(jsdom().parentWindow); - } -} catch (ignore) {} - -(function ($, rulesEngine) { - "use strict"; - var validation = {}; - - rulesEngine.forbiddenSequences = [ - "0123456789", "abcdefghijklmnopqrstuvxywz", "qwertyuiop", "asdfghjkl", - "zxcvbnm", "!@#$%^&*()_+" - ]; - - validation.wordNotEmail = function (options, word, score) { - if (word.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)) { - options.instances.errors.push(options.ui.spanError(options, "email_as_password")); - return score; - } - }; - - validation.wordLength = function (options, word, score) { - var wordlen = word.length, - lenScore = Math.pow(wordlen, options.rules.raisePower); - if (wordlen < options.common.minChar) { - lenScore = (lenScore + score); - options.instances.errors.push(options.ui.spanError(options, "password_too_short")); - } - return lenScore; - }; - - validation.wordSimilarToUsername = function (options, word, score) { - var username = $(options.common.usernameField).val(); - if (username && word.toLowerCase().match(username.toLowerCase())) { - options.instances.errors.push(options.ui.spanError(options, "same_as_username")); - return score; - } - return false; - }; - - validation.wordTwoCharacterClasses = function (options, word, score) { - if (word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) || - (word.match(/([a-zA-Z])/) && word.match(/([0-9])/)) || - (word.match(/(.[!,@,#,$,%,\^,&,*,?,_,~])/) && word.match(/[a-zA-Z0-9_]/))) { - return score; - } - options.instances.errors.push(options.ui.spanError(options, "two_character_classes")); - return false; - }; - - validation.wordRepetitions = function (options, word, score) { - if (word.match(/(.)\1\1/)) { - options.instances.errors.push(options.ui.spanError(options, "repeated_character")); - return score; - } - return false; - }; - - validation.wordSequences = function (options, word, score) { - var found = false, - j; - if (word.length > 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, seq) { - var sequences = [seq, seq.split('').reverse().join('')]; - $.each(sequences, function (idx, sequence) { - for (j = 0; j < (word.length - 2); j += 1) { // iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; -defaultOptions.common.zxcvbn = false; -defaultOptions.common.debug = false; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showProgressBar = true; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.showStatus = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "The Password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - $container = ui.getContainer(options, $el); - - result = {}; - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (options.ui.showVerdictsInsideProgressBar) { - result.$verdict = result.$progressbar.find("span.password-verdict"); - } - - if (!options.ui.showPopover) { - if (!options.ui.showVerdictsInsideProgressBar) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
                              "; - if (options.ui.showVerdictsInsideProgressBar) { - progressbar += ""; - } - progressbar += "
                              "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                                ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el) { - $el.popover("destroy"); - $el.popover({ - html: true, - placement: "bottom", - trigger: "manual", - content: " " - }); - }; - - ui.initUI = function (options, $el) { - if (options.ui.showPopover) { - ui.initPopover(options, $el); - } else { - if (options.ui.showErrors) { ui.initErrorList(options, $el); } - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.initVerdict(options, $el); - } - } - if (options.ui.showProgressBar) { - ui.initProgressBar(options, $el); - } - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
                              • " + err + "
                              • "; - }); - $errors.html(html); - }; - - ui.updatePopover = function (options, $el, verdictText) { - var popover = $el.data("bs.popover"), - html = "", - hide = true; - - if (options.ui.showVerdicts && verdictText.length > 0) { - html = "
                                " + verdictText + - "
                                "; - hide = false; - } - if (options.ui.showErrors) { - html += "
                                  "; - $.each(options.instances.errors, function (idx, err) { - html += "
                                • " + err + "
                                • "; - hide = false; - }); - html += "
                                "; - } - - if (hide) { - $el.popover("hide"); - return; - } - - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { - $el.find("+ .popover .popover-content").html(html); - } else { - // It's hidden - popover.options.content = html; - $el.popover("show"); - } - }; - - ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); - - $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } - $container.removeClass(css); - }); - - cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } - $container.addClass(cssClass); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.getVerdictAndCssClass = function (options, score) { - var cssClass, verdictText; - - if (score <= 0) { - cssClass = 0; - verdictText = ""; - } else if (score < options.ui.scores[0]) { - cssClass = 0; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - cssClass = 0; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - cssClass = 1; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - cssClass = 1; - verdictText = options.ui.verdicts[3]; - } else { - cssClass = 2; - verdictText = options.ui.verdicts[4]; - } - - return [verdictText, cssClass]; - }; - - ui.updateUI = function (options, $el, score) { - var cssClass, barPercentage, verdictText; - - cssClass = ui.getVerdictAndCssClass(options, score); - verdictText = cssClass[0]; - cssClass = cssClass[1]; - - if (options.ui.showProgressBar) { - barPercentage = ui.percentage(score, options.ui.scores[3]); - ui.updateProgressBar(options, $el, cssClass, barPercentage); - if (options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - } - - if (options.ui.showStatus) { - ui.updateFieldStatus(options, $el, cssClass); - } - - if (options.ui.showPopover) { - ui.updatePopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - username, - verdictText, - score; - - options.instances.errors = []; - if (options.common.zxcvbn) { - username = $(options.common.usernameField).val(); - if (username && username.length > 0) { - score = zxcvbn(word, [username]).entropy; - } else { - score = zxcvbn(word).entropy; - } - } else { - score = rulesEngine.executeRules(options, word); - } - ui.updateUI(options, $el, score); - verdictText = ui.getVerdictAndCssClass(options, score)[0]; - - if (options.common.debug) { console.log(score + ' - ' + verdictText); } - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event, score, verdictText); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - - ui.initUI(localOptions, $el); - if ($el.val().trim()) { // Not empty, calculate the strength - $el.trigger("keyup"); - } - - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.4.min.js b/dist/pwstrength-bootstrap-1.1.4.min.js deleted file mode 100644 index 6b89067..0000000 --- a/dist/pwstrength-bootstrap-1.1.4.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2014-06-18 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports){var a=require("jquery"),c=require("jsdom").jsdom;a=a(c().parentWindow)}}catch(d){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm","!@#$%^&*()_+"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(b,c){var e=[c,c.split("").reverse().join("")];a.each(e,function(a,b){for(f=0;f-1&&(g=!0)})}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(d){}var e={};e.common={},e.common.minChar=6,e.common.usernameField="#username",e.common.onLoad=void 0,e.common.onKeyUp=void 0,e.common.zxcvbn=!1,e.common.debug=!1,e.rules={},e.rules.extra={},e.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},e.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},e.rules.raisePower=1.4,e.ui={},e.ui.bootstrap2=!1,e.ui.showProgressBar=!0,e.ui.showPopover=!1,e.ui.showStatus=!1,e.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},e.ui.errorMessages={password_too_short:"The Password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},e.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],e.ui.showVerdicts=!0,e.ui.showVerdictsInsideProgressBar=!1,e.ui.showErrors=!1,e.ui.container=void 0,e.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},e.ui.scores=[14,26,38,50];var f={};!function(a,b){"use strict";var c=["danger","warning","success"],d=["error","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(d=b.getContainer(a,c),e={},e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showVerdictsInsideProgressBar&&(e.$verdict=e.$progressbar.find("span.password-verdict")),a.ui.showPopover||(a.ui.showVerdictsInsideProgressBar||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict")),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                                ",c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                                ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
                                  ",a.ui.viewports.errors)},b.initPopover=function(a,b){b.popover("destroy"),b.popover({html:!0,placement:"bottom",trigger:"manual",content:" "})},b.initUI=function(a,c){a.ui.showPopover?b.initPopover(a,c):(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".progress-bar"),j="progress-";d.ui.bootstrap2&&(i=h.find(".bar"),j=""),a.each(b.possibleProgressBarClasses,function(a,b){i.removeClass(j+"bar-"+b)}),i.addClass(j+"bar-"+c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
                                • "+b+"
                                • "}),e.html(f)},b.updatePopover=function(b,c,d){var e=c.data("bs.popover"),f="",g=!0;return b.ui.showVerdicts&&d.length>0&&(f="
                                  "+d+"
                                  ",g=!1),b.ui.showErrors&&(f+="
                                    ",a.each(b.instances.errors,function(a,b){f+="
                                  • "+b+"
                                  • ",g=!1}),f+="
                                  "),g?void c.popover("hide"):(b.ui.bootstrap2&&(e=c.data("popover")),void(e.$arrow&&e.$arrow.parents("body").length>0?c.find("+ .popover .popover-content").html(f):(e.options.content=f,c.popover("show"))))},b.updateFieldStatus=function(b,c,e){var f=b.ui.bootstrap2?".control-group":".form-group",g=c.parents(f).first();a.each(d,function(a,c){b.ui.bootstrap2||(c="has-"+c),g.removeClass(c)}),e=d[e],b.ui.bootstrap2||(e="has-"+e),g.addClass(e)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.getVerdictAndCssClass=function(a,b){var c,d;return 0>=b?(c=0,d=""):b0?zxcvbn(j,[d]).entropy:zxcvbn(j).entropy):g=b.executeRules(i,j),f.updateUI(i,h,g),e=f.getVerdictAndCssClass(i,g)[0],i.common.debug&&console.log(g+" - "+e),a.isFunction(i.common.onKeyUp)&&i.common.onKeyUp(c,g,e)},c.init=function(b){return this.each(function(c,g){var h=a.extend(!0,{},e),i=a.extend(!0,h,b),j=a(g);i.instances={},j.data("pwstrength-bootstrap",i),j.on("keyup",d),f.initUI(i,j),j.val().trim()&&j.trigger("keyup"),a.isFunction(i.common.onLoad)&&i.common.onLoad()}),this},c.destroy=function(){this.each(function(b,c){var d=a(c),e=d.data("pwstrength-bootstrap"),g=f.getUIElements(e,d);g.$progressbar.remove(),g.$verdict.remove(),g.$errors.remove(),d.removeData("pwstrength-bootstrap")})},c.forceUpdate=function(){this.each(function(a,b){var c={target:b};d(c)})},c.addRule=function(b,c,d,e){this.each(function(f,g){var h=a(g).data("pwstrength-bootstrap");h.rules.activated[b]=e,h.rules.scores[b]=d,h.rules.extra[b]=c})},g=function(b,c,d){this.each(function(e,f){a(f).data("pwstrength-bootstrap").rules[c][b]=d})},c.changeScore=function(a,b){g.call(this,a,"scores",b)},c.ruleActive=function(a,b){g.call(this,a,"activated",b)},a.fn.pwstrength=function(b){var d;return c[b]?d=c[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?a.error("Method "+b+" does not exist on jQuery.pwstrength-bootstrap"):d=c.init.apply(this,arguments),d}}(a,g)}(jQuery); -//# sourceMappingURL=pwstrength-bootstrap-1.1.4.min.map \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.4.min.map b/dist/pwstrength-bootstrap-1.1.4.min.map deleted file mode 100644 index 918af67..0000000 --- a/dist/pwstrength-bootstrap-1.1.4.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pwstrength-bootstrap-1.1.4.min.js","sources":["pwstrength-bootstrap-1.1.4.js"],"names":["jQuery","rulesEngine","module","exports","require","jsdom","parentWindow","ignore","$","validation","forbiddenSequences","wordNotEmail","options","word","score","match","instances","errors","push","ui","spanError","wordLength","wordlen","length","lenScore","Math","pow","rules","raisePower","common","minChar","wordSimilarToUsername","username","usernameField","val","toLowerCase","wordTwoCharacterClasses","wordRepetitions","wordSequences","j","found","each","idx","seq","sequences","split","reverse","join","sequence","indexOf","substring","wordLowercase","wordUppercase","wordOneNumber","wordThreeNumbers","wordOneSpecialChar","wordTwoSpecialChar","wordUpperLowerCombo","wordLetterNumberCombo","wordLetterNumberCharCombo","executeRules","totalScore","activated","rule","active","result","scores","funct","isFunction","extra","defaultOptions","onLoad","undefined","onKeyUp","zxcvbn","debug","bootstrap2","showProgressBar","showPopover","showStatus","key","text","errorMessages","password_too_short","email_as_password","same_as_username","two_character_classes","repeated_character","sequence_found","verdicts","showVerdicts","showVerdictsInsideProgressBar","showErrors","container","viewports","progress","verdict","barClasses","statusClasses","getContainer","$el","$container","parent","findElement","viewport","cssSelector","find","getUIElements","$progressbar","$verdict","$errors","initProgressBar","progressbar","append","insertAfter","initHelper","html","initVerdict","initErrorList","initPopover","popover","placement","trigger","content","initUI","possibleProgressBarClasses","updateProgressBar","cssClass","percentage","$bar","cssPrefix","value","removeClass","addClass","css","updateVerdict","updateErrors","err","updatePopover","verdictText","data","hide","$arrow","parents","updateFieldStatus","targetClass","first","maximun","floor","getVerdictAndCssClass","updateUI","barPercentage","methods","applyToAll","event","target","entropy","console","log","init","settings","this","el","clonedDefaults","extend","localOptions","on","trim","destroy","elements","remove","removeData","forceUpdate","addRule","name","method","prop","changeScore","call","ruleActive","fn","pwstrength","apply","Array","prototype","slice","arguments","error"],"mappings":";;CAQC,SAAUA,GAMX,GAAIC,KAEJ,KACI,IAAKD,GAAUE,QAAUA,OAAOC,QAAS,CACrC,GAAIH,GAASI,QAAQ,UACjBC,EAAQD,QAAQ,SAASC,KAC7BL,GAASA,EAAOK,IAAQC,eAE9B,MAAOC,KAER,SAAUC,EAAGP,GACV,YACA,IAAIQ,KAEJR,GAAYS,oBACR,aAAc,6BAA8B,aAAc,YAC1D,UAAW,gBAGfD,EAAWE,aAAe,SAAUC,EAASC,EAAMC,GAC/C,MAAID,GAAKE,MAAM,iMACXH,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,GAAGC,UAAUR,EAAS,sBACrDE,GAFX,QAMJL,EAAWY,WAAa,SAAUT,EAASC,EAAMC,GAC7C,GAAIQ,GAAUT,EAAKU,OACfC,EAAWC,KAAKC,IAAIJ,EAASV,EAAQe,MAAMC,WAK/C,OAJIN,GAAUV,EAAQiB,OAAOC,UACzBN,GAAuBV,EACvBF,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,GAAGC,UAAUR,EAAS,wBAEzDY,GAGXf,EAAWsB,sBAAwB,SAAUnB,EAASC,EAAMC,GACxD,GAAIkB,GAAWxB,EAAEI,EAAQiB,OAAOI,eAAeC,KAC/C,OAAIF,IAAYnB,EAAKsB,cAAcpB,MAAMiB,EAASG,gBAC9CvB,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,GAAGC,UAAUR,EAAS,qBACrDE,IAEJ,GAGXL,EA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uF,EAAQO,KAAKuB,MAAMrB,KAAMyB,WAK/BzH,IAEbjE,EAAQwJ,IACRxJ"} \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.5.js b/dist/pwstrength-bootstrap-1.1.5.js deleted file mode 100644 index a716513..0000000 --- a/dist/pwstrength-bootstrap-1.1.5.js +++ /dev/null @@ -1,654 +0,0 @@ -/*! -* jQuery Password Strength plugin for Twitter Bootstrap -* -* Copyright (c) 2008-2013 Tane Piper -* Copyright (c) 2013 Alejandro Blanco -* Dual licensed under the MIT and GPL licenses. -*/ - -(function (jQuery) { -// Source: src/rules.js - - - - -var rulesEngine = {}; - -try { - if (!jQuery && module && module.exports) { - var jQuery = require("jquery"), - jsdom = require("jsdom").jsdom; - jQuery = jQuery(jsdom().parentWindow); - } -} catch (ignore) {} - -(function ($, rulesEngine) { - "use strict"; - var validation = {}; - - rulesEngine.forbiddenSequences = [ - "0123456789", "abcdefghijklmnopqrstuvxywz", "qwertyuiop", "asdfghjkl", - "zxcvbnm", "!@#$%^&*()_+" - ]; - - validation.wordNotEmail = function (options, word, score) { - if (word.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)) { - options.instances.errors.push(options.ui.spanError(options, "email_as_password")); - return score; - } - }; - - validation.wordLength = function (options, word, score) { - var wordlen = word.length, - lenScore = Math.pow(wordlen, options.rules.raisePower); - if (wordlen < options.common.minChar) { - lenScore = (lenScore + score); - options.instances.errors.push(options.ui.spanError(options, "password_too_short")); - } - return lenScore; - }; - - validation.wordSimilarToUsername = function (options, word, score) { - var username = $(options.common.usernameField).val(); - if (username && word.toLowerCase().match(username.toLowerCase())) { - options.instances.errors.push(options.ui.spanError(options, "same_as_username")); - return score; - } - return false; - }; - - validation.wordTwoCharacterClasses = function (options, word, score) { - if (word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) || - (word.match(/([a-zA-Z])/) && word.match(/([0-9])/)) || - (word.match(/(.[!,@,#,$,%,\^,&,*,?,_,~])/) && word.match(/[a-zA-Z0-9_]/))) { - return score; - } - options.instances.errors.push(options.ui.spanError(options, "two_character_classes")); - return false; - }; - - validation.wordRepetitions = function (options, word, score) { - if (word.match(/(.)\1\1/)) { - options.instances.errors.push(options.ui.spanError(options, "repeated_character")); - return score; - } - return false; - }; - - validation.wordSequences = function (options, word, score) { - var found = false, - j; - if (word.length > 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, seq) { - var sequences = [seq, seq.split('').reverse().join('')]; - $.each(sequences, function (idx, sequence) { - for (j = 0; j < (word.length - 2); j += 1) { // iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; -defaultOptions.common.zxcvbn = false; -defaultOptions.common.debug = false; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showProgressBar = true; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.showStatus = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "The Password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - $container = ui.getContainer(options, $el); - - result = {}; - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (options.ui.showVerdictsInsideProgressBar) { - result.$verdict = result.$progressbar.find("span.password-verdict"); - } - - if (!options.ui.showPopover) { - if (!options.ui.showVerdictsInsideProgressBar) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
                                  "; - if (options.ui.showVerdictsInsideProgressBar) { - progressbar += ""; - } - progressbar += "
                                  "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                                    ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el) { - $el.popover("destroy"); - $el.popover({ - html: true, - placement: "bottom", - trigger: "manual", - content: " " - }); - }; - - ui.initUI = function (options, $el) { - if (options.ui.showPopover) { - ui.initPopover(options, $el); - } else { - if (options.ui.showErrors) { ui.initErrorList(options, $el); } - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.initVerdict(options, $el); - } - } - if (options.ui.showProgressBar) { - ui.initProgressBar(options, $el); - } - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
                                  • " + err + "
                                  • "; - }); - $errors.html(html); - }; - - ui.updatePopover = function (options, $el, verdictText) { - var popover = $el.data("bs.popover"), - html = "", - hide = true; - - if (options.ui.showVerdicts && verdictText.length > 0) { - html = "
                                    " + verdictText + - "
                                    "; - hide = false; - } - if (options.ui.showErrors) { - html += "
                                      "; - $.each(options.instances.errors, function (idx, err) { - html += "
                                    • " + err + "
                                    • "; - hide = false; - }); - html += "
                                    "; - } - - if (hide) { - $el.popover("hide"); - return; - } - - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { - $el.find("+ .popover .popover-content").html(html); - } else { - // It's hidden - popover.options.content = html; - $el.popover("show"); - } - }; - - ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); - - $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } - $container.removeClass(css); - }); - - cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } - $container.addClass(cssClass); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.getVerdictAndCssClass = function (options, score) { - var cssClass, verdictText, level; - - if (score <= 0) { - cssClass = 0; - level = -1; - verdictText = ""; - } else if (score < options.ui.scores[0]) { - cssClass = 0; - level = 0; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - cssClass = 0; - level = 1; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - cssClass = 1; - level = 2; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - cssClass = 1; - level = 3; - verdictText = options.ui.verdicts[3]; - } else { - cssClass = 2; - level = 4; - verdictText = options.ui.verdicts[4]; - } - - return [verdictText, cssClass, level]; - }; - - ui.updateUI = function (options, $el, score) { - var cssClass, barPercentage, verdictText; - - cssClass = ui.getVerdictAndCssClass(options, score); - verdictText = cssClass[0]; - cssClass = cssClass[1]; - - if (options.ui.showProgressBar) { - barPercentage = ui.percentage(score, options.ui.scores[3]); - ui.updateProgressBar(options, $el, cssClass, barPercentage); - if (options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - } - - if (options.ui.showStatus) { - ui.updateFieldStatus(options, $el, cssClass); - } - - if (options.ui.showPopover) { - ui.updatePopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - username, - verdictText, - verdictLevel, - score; - - options.instances.errors = []; - if (options.common.zxcvbn) { - username = $(options.common.usernameField).val(); - if (username && username.length > 0) { - score = zxcvbn(word, [username]).entropy; - } else { - score = zxcvbn(word).entropy; - } - } else { - score = rulesEngine.executeRules(options, word); - } - ui.updateUI(options, $el, score); - verdictText = ui.getVerdictAndCssClass(options, score); - verdictLevel = verdictText[2]; - verdictText = verdictText[0]; - - if (options.common.debug) { console.log(score + ' - ' + verdictText); } - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event, { - score: score, - verdictText: verdictText, - verdictLevel: verdictLevel - }); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - - ui.initUI(localOptions, $el); - if ($el.val().trim()) { // Not empty, calculate the strength - $el.trigger("keyup"); - } - - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.5.min.js b/dist/pwstrength-bootstrap-1.1.5.min.js deleted file mode 100644 index 3ae4f7b..0000000 --- a/dist/pwstrength-bootstrap-1.1.5.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2014-06-21 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports){var a=require("jquery"),c=require("jsdom").jsdom;a=a(c().parentWindow)}}catch(d){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm","!@#$%^&*()_+"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(b,c){var e=[c,c.split("").reverse().join("")];a.each(e,function(a,b){for(f=0;f-1&&(g=!0)})}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(d){}var e={};e.common={},e.common.minChar=6,e.common.usernameField="#username",e.common.onLoad=void 0,e.common.onKeyUp=void 0,e.common.zxcvbn=!1,e.common.debug=!1,e.rules={},e.rules.extra={},e.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},e.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},e.rules.raisePower=1.4,e.ui={},e.ui.bootstrap2=!1,e.ui.showProgressBar=!0,e.ui.showPopover=!1,e.ui.showStatus=!1,e.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},e.ui.errorMessages={password_too_short:"The Password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},e.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],e.ui.showVerdicts=!0,e.ui.showVerdictsInsideProgressBar=!1,e.ui.showErrors=!1,e.ui.container=void 0,e.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},e.ui.scores=[14,26,38,50];var f={};!function(a,b){"use strict";var c=["danger","warning","success"],d=["error","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(d=b.getContainer(a,c),e={},e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showVerdictsInsideProgressBar&&(e.$verdict=e.$progressbar.find("span.password-verdict")),a.ui.showPopover||(a.ui.showVerdictsInsideProgressBar||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict")),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                                    ",c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                                    ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
                                      ",a.ui.viewports.errors)},b.initPopover=function(a,b){b.popover("destroy"),b.popover({html:!0,placement:"bottom",trigger:"manual",content:" "})},b.initUI=function(a,c){a.ui.showPopover?b.initPopover(a,c):(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".progress-bar"),j="progress-";d.ui.bootstrap2&&(i=h.find(".bar"),j=""),a.each(b.possibleProgressBarClasses,function(a,b){i.removeClass(j+"bar-"+b)}),i.addClass(j+"bar-"+c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
                                    • "+b+"
                                    • "}),e.html(f)},b.updatePopover=function(b,c,d){var e=c.data("bs.popover"),f="",g=!0;return b.ui.showVerdicts&&d.length>0&&(f="
                                      "+d+"
                                      ",g=!1),b.ui.showErrors&&(f+="
                                        ",a.each(b.instances.errors,function(a,b){f+="
                                      • "+b+"
                                      • ",g=!1}),f+="
                                      "),g?void c.popover("hide"):(b.ui.bootstrap2&&(e=c.data("popover")),void(e.$arrow&&e.$arrow.parents("body").length>0?c.find("+ .popover .popover-content").html(f):(e.options.content=f,c.popover("show"))))},b.updateFieldStatus=function(b,c,e){var f=b.ui.bootstrap2?".control-group":".form-group",g=c.parents(f).first();a.each(d,function(a,c){b.ui.bootstrap2||(c="has-"+c),g.removeClass(c)}),e=d[e],b.ui.bootstrap2||(e="has-"+e),g.addClass(e)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.getVerdictAndCssClass=function(a,b){var c,d,e;return 0>=b?(c=0,e=-1,d=""):b0?zxcvbn(k,[d]).entropy:zxcvbn(k).entropy):h=b.executeRules(j,k),f.updateUI(j,i,h),e=f.getVerdictAndCssClass(j,h),g=e[2],e=e[0],j.common.debug&&console.log(h+" - "+e),a.isFunction(j.common.onKeyUp)&&j.common.onKeyUp(c,{score:h,verdictText:e,verdictLevel:g})},c.init=function(b){return this.each(function(c,g){var h=a.extend(!0,{},e),i=a.extend(!0,h,b),j=a(g);i.instances={},j.data("pwstrength-bootstrap",i),j.on("keyup",d),f.initUI(i,j),j.val().trim()&&j.trigger("keyup"),a.isFunction(i.common.onLoad)&&i.common.onLoad()}),this},c.destroy=function(){this.each(function(b,c){var d=a(c),e=d.data("pwstrength-bootstrap"),g=f.getUIElements(e,d);g.$progressbar.remove(),g.$verdict.remove(),g.$errors.remove(),d.removeData("pwstrength-bootstrap")})},c.forceUpdate=function(){this.each(function(a,b){var c={target:b};d(c)})},c.addRule=function(b,c,d,e){this.each(function(f,g){var h=a(g).data("pwstrength-bootstrap");h.rules.activated[b]=e,h.rules.scores[b]=d,h.rules.extra[b]=c})},g=function(b,c,d){this.each(function(e,f){a(f).data("pwstrength-bootstrap").rules[c][b]=d})},c.changeScore=function(a,b){g.call(this,a,"scores",b)},c.ruleActive=function(a,b){g.call(this,a,"activated",b)},a.fn.pwstrength=function(b){var d;return c[b]?d=c[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?a.error("Method "+b+" does not exist on jQuery.pwstrength-bootstrap"):d=c.init.apply(this,arguments),d}}(a,g)}(jQuery); -//# sourceMappingURL=pwstrength-bootstrap-1.1.5.min.map \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.1.5.min.map b/dist/pwstrength-bootstrap-1.1.5.min.map deleted file mode 100644 index f899c4b..0000000 --- a/dist/pwstrength-bootstrap-1.1.5.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pwstrength-bootstrap-1.1.5.min.js","sources":["pwstrength-bootstrap-1.1.5.js"],"names":["jQuery","rulesEngine","module","exports","require","jsdom","parentWindow","ignore","$","validation","forbiddenSequences","wordNotEmail","options","word","score","match","instances","errors","push","ui","spanError","wordLength","wordlen","length","lenScore","Math","pow","rules","raisePower","common","minChar","wordSimilarToUsername","username","usernameField","val","toLowerCase","wordTwoCharacterClasses","wordRepetitions","wordSequences","j","found","each","idx","seq","sequences","split","reverse","join","sequence","indexOf","substring","wordLowercase","wordUppercase","wordOneNumber","wordThreeNumbers","wordOneSpecialChar","wordTwoSpecialChar","wordUpperLowerCombo","wordLetterNumberCombo","wordLetterNumberCharCombo","executeRules","totalScore","activated","rule","active","result","scores","funct","isFunction","extra","defaultOptions","onLoad","undefined","onKeyUp","zxcvbn","debug","bootstrap2","showProgressBar","showPopover","showStatus","key","text","errorMessages","password_too_short","email_as_password","same_as_username","two_character_classes","repeated_character","sequence_found","verdicts","showVerdicts","showVerdictsInsideProgressBar","showErrors","container","viewports","progress","verdict","barClasses","statusClasses","getContainer","$el","$container","parent","findElement","viewport","cssSelector","find","getUIElements","$progressbar","$verdict","$errors","initProgressBar","progressbar","append","insertAfter","initHelper","html","initVerdict","initErrorList","initPopover","popover","placement","trigger","content","initUI","possibleProgressBarClasses","updateProgressBar","cssClass","percentage","$bar","cssPrefix","value","removeClass","addClass","css","updateVerdict","updateErrors","err","updatePopover","verdictText","data","hide","$arrow","parents","updateFieldStatus","targetClass","first","maximun","floor","getVerdictAndCssClass","level","updateUI","barPercentage","methods","applyToAll","event","verdictLevel","target","entropy","console","log","init","settings","this","el","clonedDefaults","extend","localOptions","on","trim","destroy","elements","remove","removeData","forceUpdate","addRule","name","method","prop","changeScore","call","ruleActive","fn","pwstrength","apply","Array","prototype","slice","arguments","error"],"mappings":";;CAQC,SAAUA,GAMX,GAAIC,KAEJ,KACI,IAAKD,GAAUE,QAAUA,OAAOC,QAAS,CACrC,GAAIH,GAASI,QAAQ,UACjBC,EAAQD,QAAQ,SAASC,KAC7BL,GAASA,EAAOK,IAAQC,eAE9B,MAAOC,KAER,SAAUC,EAAGP,GACV,YACA,IAAIQ,KAEJR,GAAYS,oBACR,aAAc,6BAA8B,aAAc,YAC1D,UAAW,gBAGfD,EAAWE,aAAe,SAAUC,EAASC,EAAMC,GAC/C,MAAID,GAAKE,MAAM,iMACXH,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,GAAGC,UAAUR,EAAS,sBACrDE,GAFX,QAMJL,EAAWY,WAAa,SAAUT,EAASC,EAAMC,GAC7C,GAAIQ,GAAUT,EAAKU,OACfC,EAAWC,KAAKC,IAAIJ,EAASV,EAAQe,MAAMC,WAK/C,OAJIN,GAAUV,EAAQiB,OAAOC,UACzBN,GAAuBV,EACvBF,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,GAAGC,UAAUR,EAAS,wBAEzDY,GAGXf,EAAWsB,sBAAwB,SAAUnB,EAASC,EAAMC,GACxD,GAAIkB,GAAWxB,EAAEI,EAAQiB,OAAOI,eAAeC,KAC/C,OAAIF,IAAYnB,EAAKsB,cAAcpB,MAAMiB,EAASG,gBAC9CvB,EAAQI,UAAUC,OAAOC,KAAKN,EAAQO,G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D,EAAE8K,GAAGC,WAAa,SAAUN,GACxB,GAAIhH,EAUJ,OARIwF,GAAQwB,GACRhH,EAASwF,EAAQwB,GAAQO,MAAMrB,KAAMsB,MAAMC,UAAUC,MAAMP,KAAKQ,UAAW,IAClD,gBAAXX,IAAwBA,EAGtCzK,EAAEqL,MAAM,UAAaZ,EAAS,kDAF9BhH,EAASwF,EAAQQ,KAAKuB,MAAMrB,KAAMyB,WAK/B3H,IAEbjE,EAAQyJ,IACRzJ"} \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.2.0.js b/dist/pwstrength-bootstrap-1.2.0.js deleted file mode 100644 index cf15d56..0000000 --- a/dist/pwstrength-bootstrap-1.2.0.js +++ /dev/null @@ -1,661 +0,0 @@ -/*! -* jQuery Password Strength plugin for Twitter Bootstrap -* -* Copyright (c) 2008-2013 Tane Piper -* Copyright (c) 2013 Alejandro Blanco -* Dual licensed under the MIT and GPL licenses. -*/ - -(function (jQuery) { -// Source: src/rules.js - - - - -var rulesEngine = {}; - -try { - if (!jQuery && module && module.exports) { - var jQuery = require("jquery"), - jsdom = require("jsdom").jsdom; - jQuery = jQuery(jsdom().parentWindow); - } -} catch (ignore) {} - -(function ($, rulesEngine) { - "use strict"; - var validation = {}; - - rulesEngine.forbiddenSequences = [ - "0123456789", "abcdefghijklmnopqrstuvxywz", "qwertyuiop", "asdfghjkl", - "zxcvbnm", "!@#$%^&*()_+" - ]; - - validation.wordNotEmail = function (options, word, score) { - if (word.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)) { - options.instances.errors.push(options.ui.spanError(options, "email_as_password")); - return score; - } - }; - - validation.wordLength = function (options, word, score) { - var wordlen = word.length, - lenScore = Math.pow(wordlen, options.rules.raisePower); - if (wordlen < options.common.minChar) { - lenScore = (lenScore + score); - options.instances.errors.push(options.ui.spanError(options, "password_too_short")); - } - return lenScore; - }; - - validation.wordSimilarToUsername = function (options, word, score) { - var username = $(options.common.usernameField).val(); - if (username && word.toLowerCase().match(username.toLowerCase())) { - options.instances.errors.push(options.ui.spanError(options, "same_as_username")); - return score; - } - return false; - }; - - validation.wordTwoCharacterClasses = function (options, word, score) { - if (word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) || - (word.match(/([a-zA-Z])/) && word.match(/([0-9])/)) || - (word.match(/(.[!,@,#,$,%,\^,&,*,?,_,~])/) && word.match(/[a-zA-Z0-9_]/))) { - return score; - } - options.instances.errors.push(options.ui.spanError(options, "two_character_classes")); - return false; - }; - - validation.wordRepetitions = function (options, word, score) { - if (word.match(/(.)\1\1/)) { - options.instances.errors.push(options.ui.spanError(options, "repeated_character")); - return score; - } - return false; - }; - - validation.wordSequences = function (options, word, score) { - var found = false, - j; - if (word.length > 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, seq) { - var sequences = [seq, seq.split('').reverse().join('')]; - $.each(sequences, function (idx, sequence) { - for (j = 0; j < (word.length - 2); j += 1) { // iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.userInputs = [ - // Selectors for input fields with user input -]; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; -defaultOptions.common.zxcvbn = false; -defaultOptions.common.debug = false; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showProgressBar = true; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.showStatus = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "Your password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - $container = ui.getContainer(options, $el); - - result = {}; - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (options.ui.showVerdictsInsideProgressBar) { - result.$verdict = result.$progressbar.find("span.password-verdict"); - } - - if (!options.ui.showPopover) { - if (!options.ui.showVerdictsInsideProgressBar) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
                                      "; - if (options.ui.showVerdictsInsideProgressBar) { - progressbar += ""; - } - progressbar += "
                                      "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                                        ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el) { - $el.popover("destroy"); - $el.popover({ - html: true, - placement: "bottom", - trigger: "manual", - content: " " - }); - }; - - ui.initUI = function (options, $el) { - if (options.ui.showPopover) { - ui.initPopover(options, $el); - } else { - if (options.ui.showErrors) { ui.initErrorList(options, $el); } - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.initVerdict(options, $el); - } - } - if (options.ui.showProgressBar) { - ui.initProgressBar(options, $el); - } - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
                                      • " + err + "
                                      • "; - }); - $errors.html(html); - }; - - ui.updatePopover = function (options, $el, verdictText) { - var popover = $el.data("bs.popover"), - html = "", - hide = true; - - if (options.ui.showVerdicts && - !options.ui.showVerdictsInsideProgressBar && - verdictText.length > 0) { - html = "
                                        " + verdictText + - "
                                        "; - hide = false; - } - if (options.ui.showErrors) { - html += "
                                        Errors:
                                          "; - $.each(options.instances.errors, function (idx, err) { - html += "
                                        • " + err + "
                                        • "; - hide = false; - }); - html += "
                                        "; - } - - if (hide) { - $el.popover("hide"); - return; - } - - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { - $el.find("+ .popover .popover-content").html(html); - } else { - // It's hidden - popover.options.content = html; - $el.popover("show"); - } - }; - - ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); - - $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } - $container.removeClass(css); - }); - - cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } - $container.addClass(cssClass); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.getVerdictAndCssClass = function (options, score) { - var cssClass, verdictText, level; - - if (score <= 0) { - cssClass = 0; - level = -1; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[0]) { - cssClass = 0; - level = 0; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - cssClass = 0; - level = 1; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - cssClass = 1; - level = 2; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - cssClass = 1; - level = 3; - verdictText = options.ui.verdicts[3]; - } else { - cssClass = 2; - level = 4; - verdictText = options.ui.verdicts[4]; - } - - return [verdictText, cssClass, level]; - }; - - ui.updateUI = function (options, $el, score) { - var cssClass, barPercentage, verdictText; - - cssClass = ui.getVerdictAndCssClass(options, score); - verdictText = cssClass[0]; - cssClass = cssClass[1]; - - if (options.ui.showProgressBar) { - barPercentage = ui.percentage(score, options.ui.scores[3]); - ui.updateProgressBar(options, $el, cssClass, barPercentage); - if (options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - } - - if (options.ui.showStatus) { - ui.updateFieldStatus(options, $el, cssClass); - } - - if (options.ui.showPopover) { - ui.updatePopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - userInputs, - verdictText, - verdictLevel, - score; - - options.instances.errors = []; - if (options.common.zxcvbn) { - userInputs = []; - $.each(options.common.userInputs, function (idx, selector) { - userInputs.push($(selector).val()); - }); - userInputs.push($(options.common.usernameField).val()); - score = zxcvbn(word, userInputs).entropy; - } else { - score = rulesEngine.executeRules(options, word); - } - ui.updateUI(options, $el, score); - verdictText = ui.getVerdictAndCssClass(options, score); - verdictLevel = verdictText[2]; - verdictText = verdictText[0]; - - if (options.common.debug) { console.log(score + ' - ' + verdictText); } - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event, { - score: score, - verdictText: verdictText, - verdictLevel: verdictLevel - }); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - $el.on("change", onKeyUp); - $el.on("onpaste", onKeyUp); - - ui.initUI(localOptions, $el); - if ($.trim($el.val())) { // Not empty, calculate the strength - $el.trigger("keyup"); - } - - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.2.0.min.js b/dist/pwstrength-bootstrap-1.2.0.min.js deleted file mode 100644 index d29ca68..0000000 --- a/dist/pwstrength-bootstrap-1.2.0.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2014-07-06 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports){var a=require("jquery"),c=require("jsdom").jsdom;a=a(c().parentWindow)}}catch(d){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","abcdefghijklmnopqrstuvxywz","qwertyuiop","asdfghjkl","zxcvbnm","!@#$%^&*()_+"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(b,c){var e=[c,c.split("").reverse().join("")];a.each(e,function(a,b){for(f=0;f-1&&(g=!0)})}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(d){}var e={};e.common={},e.common.minChar=6,e.common.usernameField="#username",e.common.userInputs=[],e.common.onLoad=void 0,e.common.onKeyUp=void 0,e.common.zxcvbn=!1,e.common.debug=!1,e.rules={},e.rules.extra={},e.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},e.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},e.rules.raisePower=1.4,e.ui={},e.ui.bootstrap2=!1,e.ui.showProgressBar=!0,e.ui.showPopover=!1,e.ui.showStatus=!1,e.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},e.ui.errorMessages={password_too_short:"Your password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},e.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],e.ui.showVerdicts=!0,e.ui.showVerdictsInsideProgressBar=!1,e.ui.showErrors=!1,e.ui.container=void 0,e.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},e.ui.scores=[14,26,38,50];var f={};!function(a,b){"use strict";var c=["danger","warning","success"],d=["error","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(d=b.getContainer(a,c),e={},e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showVerdictsInsideProgressBar&&(e.$verdict=e.$progressbar.find("span.password-verdict")),a.ui.showPopover||(a.ui.showVerdictsInsideProgressBar||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict")),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                                        ",c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                                        ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
                                          ",a.ui.viewports.errors)},b.initPopover=function(a,b){b.popover("destroy"),b.popover({html:!0,placement:"bottom",trigger:"manual",content:" "})},b.initUI=function(a,c){a.ui.showPopover?b.initPopover(a,c):(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".progress-bar"),j="progress-";d.ui.bootstrap2&&(i=h.find(".bar"),j=""),a.each(b.possibleProgressBarClasses,function(a,b){i.removeClass(j+"bar-"+b)}),i.addClass(j+"bar-"+c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
                                        • "+b+"
                                        • "}),e.html(f)},b.updatePopover=function(b,c,d){var e=c.data("bs.popover"),f="",g=!0;return b.ui.showVerdicts&&!b.ui.showVerdictsInsideProgressBar&&d.length>0&&(f="
                                          "+d+"
                                          ",g=!1),b.ui.showErrors&&(f+="
                                          Errors:
                                            ",a.each(b.instances.errors,function(a,b){f+="
                                          • "+b+"
                                          • ",g=!1}),f+="
                                          "),g?void c.popover("hide"):(b.ui.bootstrap2&&(e=c.data("popover")),void(e.$arrow&&e.$arrow.parents("body").length>0?c.find("+ .popover .popover-content").html(f):(e.options.content=f,c.popover("show"))))},b.updateFieldStatus=function(b,c,e){var f=b.ui.bootstrap2?".control-group":".form-group",g=c.parents(f).first();a.each(d,function(a,c){b.ui.bootstrap2||(c="has-"+c),g.removeClass(c)}),e=d[e],b.ui.bootstrap2||(e="has-"+e),g.addClass(e)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.getVerdictAndCssClass=function(a,b){var c,d,e;return 0>=b?(c=0,e=-1,d=a.ui.verdicts[0]):b 2) { - $.each(rulesEngine.forbiddenSequences, function (idx, seq) { - var sequences = [seq, seq.split('').reverse().join('')]; - $.each(sequences, function (idx, sequence) { - for (j = 0; j < (word.length - 2); j += 1) { // iterate the word trough a sliding window of size 3: - if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) { - found = true; - } - } - }); - }); - if (found) { - options.instances.errors.push(options.ui.spanError(options, "sequence_found")); - return score; - } - } - return false; - }; - - validation.wordLowercase = function (options, word, score) { - return word.match(/[a-z]/) && score; - }; - - validation.wordUppercase = function (options, word, score) { - return word.match(/[A-Z]/) && score; - }; - - validation.wordOneNumber = function (options, word, score) { - return word.match(/\d+/) && score; - }; - - validation.wordThreeNumbers = function (options, word, score) { - return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score; - }; - - validation.wordOneSpecialChar = function (options, word, score) { - return word.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/) && score; - }; - - validation.wordTwoSpecialChar = function (options, word, score) { - return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score; - }; - - validation.wordUpperLowerCombo = function (options, word, score) { - return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score; - }; - - validation.wordLetterNumberCombo = function (options, word, score) { - return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score; - }; - - validation.wordLetterNumberCharCombo = function (options, word, score) { - return word.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) && score; - }; - - rulesEngine.validation = validation; - - rulesEngine.executeRules = function (options, word) { - var totalScore = 0; - - $.each(options.rules.activated, function (rule, active) { - if (active) { - var score = options.rules.scores[rule], - funct = rulesEngine.validation[rule], - result; - - if (!$.isFunction(funct)) { - funct = options.rules.extra[rule]; - } - - if ($.isFunction(funct)) { - result = funct(options, word, score); - if (result) { - totalScore += result; - } - } - } - }); - - return totalScore; - }; -}(jQuery, rulesEngine)); - -try { - if (module && module.exports) { - module.exports = rulesEngine; - } -} catch (ignore) {} - -// Source: src/options.js - - - - -var defaultOptions = {}; - -defaultOptions.common = {}; -defaultOptions.common.minChar = 6; -defaultOptions.common.usernameField = "#username"; -defaultOptions.common.userInputs = [ - // Selectors for input fields with user input -]; -defaultOptions.common.onLoad = undefined; -defaultOptions.common.onKeyUp = undefined; -defaultOptions.common.zxcvbn = false; -defaultOptions.common.debug = false; - -defaultOptions.rules = {}; -defaultOptions.rules.extra = {}; -defaultOptions.rules.scores = { - wordNotEmail: -100, - wordLength: -50, - wordSimilarToUsername: -100, - wordSequences: -50, - wordTwoCharacterClasses: 2, - wordRepetitions: -25, - wordLowercase: 1, - wordUppercase: 3, - wordOneNumber: 3, - wordThreeNumbers: 5, - wordOneSpecialChar: 3, - wordTwoSpecialChar: 5, - wordUpperLowerCombo: 2, - wordLetterNumberCombo: 2, - wordLetterNumberCharCombo: 2 -}; -defaultOptions.rules.activated = { - wordNotEmail: true, - wordLength: true, - wordSimilarToUsername: true, - wordSequences: true, - wordTwoCharacterClasses: false, - wordRepetitions: false, - wordLowercase: true, - wordUppercase: true, - wordOneNumber: true, - wordThreeNumbers: true, - wordOneSpecialChar: true, - wordTwoSpecialChar: true, - wordUpperLowerCombo: true, - wordLetterNumberCombo: true, - wordLetterNumberCharCombo: true -}; -defaultOptions.rules.raisePower = 1.4; - -defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; -defaultOptions.ui.showProgressBar = true; -defaultOptions.ui.showPopover = false; -defaultOptions.ui.showStatus = false; -defaultOptions.ui.spanError = function (options, key) { - "use strict"; - var text = options.ui.errorMessages[key]; - return '' + text + ''; -}; -defaultOptions.ui.errorMessages = { - password_too_short: "Your password is too short", - email_as_password: "Do not use your email as your password", - same_as_username: "Your password cannot contain your username", - two_character_classes: "Use different character classes", - repeated_character: "Too many repetitions", - sequence_found: "Your password contains sequences" -}; -defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; -defaultOptions.ui.showVerdicts = true; -defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; -defaultOptions.ui.container = undefined; -defaultOptions.ui.viewports = { - progress: undefined, - verdict: undefined, - errors: undefined -}; -defaultOptions.ui.scores = [14, 26, 38, 50]; - -// Source: src/ui.js - - - - -var ui = {}; - -(function ($, ui) { - "use strict"; - - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; - - ui.getContainer = function (options, $el) { - var $container; - - $container = $(options.ui.container); - if (!($container && $container.length === 1)) { - $container = $el.parent(); - } - return $container; - }; - - ui.findElement = function ($container, viewport, cssSelector) { - if (viewport) { - return $container.find(viewport).find(cssSelector); - } - return $container.find(cssSelector); - }; - - ui.getUIElements = function (options, $el) { - var $container, result; - - if (options.instances.viewports) { - return options.instances.viewports; - } - - $container = ui.getContainer(options, $el); - - result = {}; - result.$progressbar = ui.findElement($container, options.ui.viewports.progress, "div.progress"); - if (options.ui.showVerdictsInsideProgressBar) { - result.$verdict = result.$progressbar.find("span.password-verdict"); - } - - if (!options.ui.showPopover) { - if (!options.ui.showVerdictsInsideProgressBar) { - result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); - } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); - } - - options.instances.viewports = result; - return result; - }; - - ui.initProgressBar = function (options, $el) { - var $container = ui.getContainer(options, $el), - progressbar = "
                                          "; - if (options.ui.showVerdictsInsideProgressBar) { - progressbar += ""; - } - progressbar += "
                                          "; - - if (options.ui.viewports.progress) { - $container.find(options.ui.viewports.progress).append(progressbar); - } else { - $(progressbar).insertAfter($el); - } - }; - - ui.initHelper = function (options, $el, html, viewport) { - var $container = ui.getContainer(options, $el); - if (viewport) { - $container.find(viewport).append(html); - } else { - $(html).insertAfter($el); - } - }; - - ui.initVerdict = function (options, $el) { - ui.initHelper(options, $el, "", - options.ui.viewports.verdict); - }; - - ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                                            ", - options.ui.viewports.errors); - }; - - ui.initPopover = function (options, $el) { - $el.popover("destroy"); - $el.popover({ - html: true, - placement: "bottom", - trigger: "manual", - content: " " - }); - }; - - ui.initUI = function (options, $el) { - if (options.ui.showPopover) { - ui.initPopover(options, $el); - } else { - if (options.ui.showErrors) { ui.initErrorList(options, $el); } - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.initVerdict(options, $el); - } - } - if (options.ui.showProgressBar) { - ui.initProgressBar(options, $el); - } - }; - - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; - - ui.updateProgressBar = function (options, $el, cssClass, percentage) { - var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } - - $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); - }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); - $bar.css("width", percentage + '%'); - }; - - ui.updateVerdict = function (options, $el, text) { - var $verdict = ui.getUIElements(options, $el).$verdict; - $verdict.text(text); - }; - - ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, - html = ""; - $.each(options.instances.errors, function (idx, err) { - html += "
                                          • " + err + "
                                          • "; - }); - $errors.html(html); - }; - - ui.updatePopover = function (options, $el, verdictText) { - var popover = $el.data("bs.popover"), - html = "", - hide = true; - - if (options.ui.showVerdicts && - !options.ui.showVerdictsInsideProgressBar && - verdictText.length > 0) { - html = "
                                            " + verdictText + - "
                                            "; - hide = false; - } - if (options.ui.showErrors) { - html += "
                                            Errors:
                                              "; - $.each(options.instances.errors, function (idx, err) { - html += "
                                            • " + err + "
                                            • "; - hide = false; - }); - html += "
                                            "; - } - - if (hide) { - $el.popover("hide"); - return; - } - - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { - $el.find("+ .popover .popover-content").html(html); - } else { - // It's hidden - popover.options.content = html; - $el.popover("show"); - } - }; - - ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); - - $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } - $container.removeClass(css); - }); - - cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } - $container.addClass(cssClass); - }; - - ui.percentage = function (score, maximun) { - var result = Math.floor(100 * score / maximun); - result = result < 0 ? 0 : result; - result = result > 100 ? 100 : result; - return result; - }; - - ui.getVerdictAndCssClass = function (options, score) { - var cssClass, verdictText, level; - - if (score <= 0) { - cssClass = 0; - level = -1; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[0]) { - cssClass = 0; - level = 0; - verdictText = options.ui.verdicts[0]; - } else if (score < options.ui.scores[1]) { - cssClass = 0; - level = 1; - verdictText = options.ui.verdicts[1]; - } else if (score < options.ui.scores[2]) { - cssClass = 1; - level = 2; - verdictText = options.ui.verdicts[2]; - } else if (score < options.ui.scores[3]) { - cssClass = 1; - level = 3; - verdictText = options.ui.verdicts[3]; - } else { - cssClass = 2; - level = 4; - verdictText = options.ui.verdicts[4]; - } - - return [verdictText, cssClass, level]; - }; - - ui.updateUI = function (options, $el, score) { - var cssClass, barPercentage, verdictText; - - cssClass = ui.getVerdictAndCssClass(options, score); - verdictText = cssClass[0]; - cssClass = cssClass[1]; - - if (options.ui.showProgressBar) { - barPercentage = ui.percentage(score, options.ui.scores[3]); - ui.updateProgressBar(options, $el, cssClass, barPercentage); - if (options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - } - - if (options.ui.showStatus) { - ui.updateFieldStatus(options, $el, cssClass); - } - - if (options.ui.showPopover) { - ui.updatePopover(options, $el, verdictText); - } else { - if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) { - ui.updateVerdict(options, $el, verdictText); - } - if (options.ui.showErrors) { - ui.updateErrors(options, $el); - } - } - }; -}(jQuery, ui)); - -// Source: src/methods.js - - - - -var methods = {}; - -(function ($, methods) { - "use strict"; - var onKeyUp, applyToAll; - - onKeyUp = function (event) { - var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), - word = $el.val(), - userInputs, - verdictText, - verdictLevel, - score; - - if (options === undefined) { return; } - - options.instances.errors = []; - if (options.common.zxcvbn) { - userInputs = []; - $.each(options.common.userInputs, function (idx, selector) { - userInputs.push($(selector).val()); - }); - userInputs.push($(options.common.usernameField).val()); - score = zxcvbn(word, userInputs).entropy; - } else { - score = rulesEngine.executeRules(options, word); - } - ui.updateUI(options, $el, score); - verdictText = ui.getVerdictAndCssClass(options, score); - verdictLevel = verdictText[2]; - verdictText = verdictText[0]; - - if (options.common.debug) { console.log(score + ' - ' + verdictText); } - - if ($.isFunction(options.common.onKeyUp)) { - options.common.onKeyUp(event, { - score: score, - verdictText: verdictText, - verdictLevel: verdictLevel - }); - } - }; - - methods.init = function (settings) { - this.each(function (idx, el) { - // Make it deep extend (first param) so it extends too the - // rules and other inside objects - var clonedDefaults = $.extend(true, {}, defaultOptions), - localOptions = $.extend(true, clonedDefaults, settings), - $el = $(el); - - localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); - $el.on("keyup", onKeyUp); - $el.on("change", onKeyUp); - $el.on("onpaste", onKeyUp); - - ui.initUI(localOptions, $el); - if ($.trim($el.val())) { // Not empty, calculate the strength - $el.trigger("keyup"); - } - - if ($.isFunction(localOptions.common.onLoad)) { - localOptions.common.onLoad(); - } - }); - - return this; - }; - - methods.destroy = function () { - this.each(function (idx, el) { - var $el = $(el), - options = $el.data("pwstrength-bootstrap"), - elements = ui.getUIElements(options, $el); - elements.$progressbar.remove(); - elements.$verdict.remove(); - elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); - }); - }; - - methods.forceUpdate = function () { - this.each(function (idx, el) { - var event = { target: el }; - onKeyUp(event); - }); - }; - - methods.addRule = function (name, method, score, active) { - this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); - - options.rules.activated[name] = active; - options.rules.scores[name] = score; - options.rules.extra[name] = method; - }); - }; - - applyToAll = function (rule, prop, value) { - this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; - }); - }; - - methods.changeScore = function (rule, score) { - applyToAll.call(this, rule, "scores", score); - }; - - methods.ruleActive = function (rule, active) { - applyToAll.call(this, rule, "activated", active); - }; - - $.fn.pwstrength = function (method) { - var result; - - if (methods[method]) { - result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === "object" || !method) { - result = methods.init.apply(this, arguments); - } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); - } - - return result; - }; -}(jQuery, methods)); -}(jQuery)); \ No newline at end of file diff --git a/dist/pwstrength-bootstrap-1.2.1.min.js b/dist/pwstrength-bootstrap-1.2.1.min.js deleted file mode 100644 index 71b3f29..0000000 --- a/dist/pwstrength-bootstrap-1.2.1.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* pwstrength-bootstrap 2014-08-24 - GPLv3 & MIT License */ - -!function(a){var b={};try{if(!a&&module&&module.exports){var a=require("jquery"),c=require("jsdom").jsdom;a=a(c().parentWindow)}}catch(d){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","abcdefghijklmnopqrstuvwxyz","qwertyuiop","asdfghjkl","zxcvbnm","!@#$%^&*()_+"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?(a.instances.errors.push(a.ui.spanError(a,"email_as_password")),c):void 0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(b,c){var e=[c,c.split("").reverse().join("")];a.each(e,function(a,b){for(f=0;f-1&&(g=!0)})}),g)?(c.instances.errors.push(c.ui.spanError(c,"sequence_found")),e):!1},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i=c.rules.scores[f],j=b.validation[f];a.isFunction(j)||(j=c.rules.extra[f]),a.isFunction(j)&&(h=j(c,d,i),h&&(e+=h))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(d){}var e={};e.common={},e.common.minChar=6,e.common.usernameField="#username",e.common.userInputs=[],e.common.onLoad=void 0,e.common.onKeyUp=void 0,e.common.zxcvbn=!1,e.common.debug=!1,e.rules={},e.rules.extra={},e.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},e.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},e.rules.raisePower=1.4,e.ui={},e.ui.bootstrap2=!1,e.ui.showProgressBar=!0,e.ui.showPopover=!1,e.ui.showStatus=!1,e.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return''+c+""},e.ui.errorMessages={password_too_short:"Your password is too short",email_as_password:"Do not use your email as your password",same_as_username:"Your password cannot contain your username",two_character_classes:"Use different character classes",repeated_character:"Too many repetitions",sequence_found:"Your password contains sequences"},e.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],e.ui.showVerdicts=!0,e.ui.showVerdictsInsideProgressBar=!1,e.ui.showErrors=!1,e.ui.container=void 0,e.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},e.ui.scores=[14,26,38,50];var f={};!function(a,b){"use strict";var c=["danger","warning","success"],d=["error","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(d=b.getContainer(a,c),e={},e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showVerdictsInsideProgressBar&&(e.$verdict=e.$progressbar.find("span.password-verdict")),a.ui.showPopover||(a.ui.showVerdictsInsideProgressBar||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict")),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                                            ",c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                                            ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
                                              ",a.ui.viewports.errors)},b.initPopover=function(a,b){b.popover("destroy"),b.popover({html:!0,placement:"bottom",trigger:"manual",content:" "})},b.initUI=function(a,c){a.ui.showPopover?b.initPopover(a,c):(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".progress-bar"),j="progress-";d.ui.bootstrap2&&(i=h.find(".bar"),j=""),a.each(b.possibleProgressBarClasses,function(a,b){i.removeClass(j+"bar-"+b)}),i.addClass(j+"bar-"+c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
                                            • "+b+"
                                            • "}),e.html(f)},b.updatePopover=function(b,c,d){var e=c.data("bs.popover"),f="",g=!0;return b.ui.showVerdicts&&!b.ui.showVerdictsInsideProgressBar&&d.length>0&&(f="
                                              "+d+"
                                              ",g=!1),b.ui.showErrors&&(f+="
                                              Errors:
                                                ",a.each(b.instances.errors,function(a,b){f+="
                                              • "+b+"
                                              • ",g=!1}),f+="
                                              "),g?void c.popover("hide"):(b.ui.bootstrap2&&(e=c.data("popover")),void(e.$arrow&&e.$arrow.parents("body").length>0?c.find("+ .popover .popover-content").html(f):(e.options.content=f,c.popover("show"))))},b.updateFieldStatus=function(b,c,e){var f=b.ui.bootstrap2?".control-group":".form-group",g=c.parents(f).first();a.each(d,function(a,c){b.ui.bootstrap2||(c="has-"+c),g.removeClass(c)}),e=d[e],b.ui.bootstrap2||(e="has-"+e),g.addClass(e)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.getVerdictAndCssClass=function(a,b){var c,d,e;return 0>=b?(c=0,e=-1,d=a.ui.verdicts[0]):b2&&(a.each(b.forbiddenSequences,function(b,c){var e=[c,c.split("").reverse().join("")];a.each(e,function(a,b){for(f=0;f-1&&(g=!0)})}),g)?e:0},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i,j=c.rules.scores[f],k=b.validation[f];a.isFunction(k)||(k=c.rules.extra[f]),a.isFunction(k)&&(h=k(c,d,j),h&&(e+=h),(0>h||!a.isNumeric(h)&&!h)&&(i=c.ui.spanError(c,f),i.length>0&&c.instances.errors.push(i)))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(d){}var e={};e.common={},e.common.minChar=6,e.common.usernameField="#username",e.common.userInputs=[],e.common.onLoad=void 0,e.common.onKeyUp=void 0,e.common.zxcvbn=!1,e.common.debug=!1,e.rules={},e.rules.extra={},e.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},e.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},e.rules.raisePower=1.4,e.ui={},e.ui.bootstrap2=!1,e.ui.showProgressBar=!0,e.ui.showPopover=!1,e.ui.showStatus=!1,e.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return c?''+c+"":""},e.ui.errorMessages={wordLength:"Your password is too short",wordNotEmail:"Do not use your email as your password",wordSimilarToUsername:"Your password cannot contain your username",wordTwoCharacterClasses:"Use different character classes",wordRepetitions:"Too many repetitions",wordSequences:"Your password contains sequences"},e.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],e.ui.showVerdicts=!0,e.ui.showVerdictsInsideProgressBar=!1,e.ui.showErrors=!1,e.ui.container=void 0,e.ui.viewports={progress:void 0,verdict:void 0,errors:void 0},e.ui.scores=[14,26,38,50];var f={};!function(a,b){"use strict";var c=["danger","warning","success"],d=["error","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(d=b.getContainer(a,c),e={},e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showVerdictsInsideProgressBar&&(e.$verdict=e.$progressbar.find("span.password-verdict")),a.ui.showPopover||(a.ui.showVerdictsInsideProgressBar||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict")),e.$errors=b.findElement(d,a.ui.viewports.errors,"ul.error-list")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                                              ",c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                                              ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"
                                                ",a.ui.viewports.errors)},b.initPopover=function(a,b){b.popover("destroy"),b.popover({html:!0,placement:"bottom",trigger:"manual",content:" "})},b.initUI=function(a,c){a.ui.showPopover?b.initPopover(a,c):(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["danger","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".progress-bar"),j="progress-";d.ui.bootstrap2&&(i=h.find(".bar"),j=""),a.each(b.possibleProgressBarClasses,function(a,b){i.removeClass(j+"bar-"+b)}),i.addClass(j+"bar-"+c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getUIElements(c,d).$errors,f="";a.each(c.instances.errors,function(a,b){f+="
                                              • "+b+"
                                              • "}),e.html(f)},b.updatePopover=function(b,c,d){var e=c.data("bs.popover"),f="",g=!0;return b.ui.showVerdicts&&!b.ui.showVerdictsInsideProgressBar&&d.length>0&&(f="
                                                "+d+"
                                                ",g=!1),b.ui.showErrors&&(f+="
                                                Errors:
                                                  ",a.each(b.instances.errors,function(a,b){f+="
                                                • "+b+"
                                                • ",g=!1}),f+="
                                                "),g?void c.popover("hide"):(b.ui.bootstrap2&&(e=c.data("popover")),void(e.$arrow&&e.$arrow.parents("body").length>0?c.find("+ .popover .popover-content").html(f):(e.options.content=f,c.popover("show"))))},b.updateFieldStatus=function(b,c,e){var f=b.ui.bootstrap2?".control-group":".form-group",g=c.parents(f).first();a.each(d,function(a,c){b.ui.bootstrap2||(c="has-"+c),g.removeClass(c)}),e=d[e],b.ui.bootstrap2||(e="has-"+e),g.addClass(e)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.getVerdictAndCssClass=function(a,b){var c,d,e;return 0>=b?(c=0,e=-1,d=a.ui.verdicts[0]):b' + text + ''; + // return '' + text + ''; + return text; }; defaultOptions.ui.errorMessages = { wordLength: "Your password is too short", @@ -243,12 +245,13 @@ defaultOptions.ui.errorMessages = { defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; defaultOptions.ui.showVerdicts = true; defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; +defaultOptions.ui.showErrors = true; defaultOptions.ui.container = undefined; defaultOptions.ui.viewports = { progress: undefined, - verdict: undefined, - errors: undefined + verdict: '.postfix', + errors: undefined, + status: undefined }; defaultOptions.ui.scores = [14, 26, 38, 50]; @@ -262,8 +265,8 @@ var ui = {}; (function ($, ui) { "use strict"; - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; + var barClasses = ["alert", "success", "success"], + statusClasses = ["alert", "warning", "success"]; ui.getContainer = function (options, $el) { var $container; @@ -301,7 +304,7 @@ var ui = {}; if (!options.ui.showVerdictsInsideProgressBar) { result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); + result.$errors = ui.findElement($container, options.ui.viewports.errors, ".error"); } options.instances.viewports = result; @@ -310,12 +313,7 @@ var ui = {}; ui.initProgressBar = function (options, $el) { var $container = ui.getContainer(options, $el), - progressbar = "
                                                "; + progressbar = "
                                                "; if (options.ui.showVerdictsInsideProgressBar) { progressbar += ""; } @@ -343,7 +341,7 @@ var ui = {}; }; ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                                                  ", + ui.initHelper(options, $el, "", options.ui.viewports.errors); }; @@ -371,22 +369,16 @@ var ui = {}; } }; - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; + ui.possibleProgressBarClasses = ["alert", "warning", "success"]; ui.updateProgressBar = function (options, $el, cssClass, percentage) { var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } + $bar = $progressbar.find(".meter"); $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); + $progressbar.removeClass(value); }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); + $progressbar.addClass(barClasses[cssClass]); $bar.css("width", percentage + '%'); }; @@ -396,11 +388,21 @@ var ui = {}; }; ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, + var $container = ui.getContainer(options, $el), + $errors = ui.getUIElements(options, $el).$errors, html = ""; $.each(options.instances.errors, function (idx, err) { - html += "
                                                • " + err + "
                                                • "; + html += err + "
                                                  "; }); + + if (html !== "") { + $container.addClass('error'); + $errors.show(); + } else { + $container.removeClass('error'); + $errors.hide(); + } + $errors.html(html); }; @@ -430,8 +432,6 @@ var ui = {}; return; } - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { $el.find("+ .popover .popover-content").html(html); } else { @@ -442,16 +442,14 @@ var ui = {}; }; ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); + + var $container = options.ui.viewports.status ? $(options.ui.viewports.status) : ui.getContainer(options, $el); $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } $container.removeClass(css); }); cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } $container.addClass(cssClass); }; @@ -539,7 +537,7 @@ var methods = {}; onKeyUp = function (event) { var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), + options = $el.data("pwstrength-foundation"), word = $el.val(), userInputs, verdictText, @@ -584,7 +582,7 @@ var methods = {}; $el = $(el); localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); + $el.data("pwstrength-foundation", localOptions); $el.on("keyup", onKeyUp); $el.on("change", onKeyUp); $el.on("onpaste", onKeyUp); @@ -605,12 +603,12 @@ var methods = {}; methods.destroy = function () { this.each(function (idx, el) { var $el = $(el), - options = $el.data("pwstrength-bootstrap"), + options = $el.data("pwstrength-foundation"), elements = ui.getUIElements(options, $el); elements.$progressbar.remove(); elements.$verdict.remove(); elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); + $el.removeData("pwstrength-foundation"); }); }; @@ -623,7 +621,7 @@ var methods = {}; methods.addRule = function (name, method, score, active) { this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); + var options = $(el).data("pwstrength-foundation"); options.rules.activated[name] = active; options.rules.scores[name] = score; @@ -633,7 +631,7 @@ var methods = {}; applyToAll = function (rule, prop, value) { this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; + $(el).data("pwstrength-foundation").rules[prop][rule] = value; }); }; @@ -653,7 +651,7 @@ var methods = {}; } else if (typeof method === "object" || !method) { result = methods.init.apply(this, arguments); } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); + $.error("Method " + method + " does not exist on jQuery.pwstrength-foundation"); } return result; diff --git a/dist/pwstrength-foundation-1.2.3.min.js b/dist/pwstrength-foundation-1.2.3.min.js new file mode 100644 index 0000000..aba6490 --- /dev/null +++ b/dist/pwstrength-foundation-1.2.3.min.js @@ -0,0 +1,4 @@ +/* pwstrength-foundation 2014-10-13 - GPLv3 & MIT License */ + +!function(a){var b={};try{if(!a&&module&&module.exports){var a=require("jquery"),c=require("jsdom").jsdom;a=a(c().parentWindow)}}catch(d){}!function(a,b){"use strict";var c={};b.forbiddenSequences=["0123456789","abcdefghijklmnopqrstuvwxyz","qwertyuiop","asdfghjkl","zxcvbnm","!@#$%^&*()_+"],c.wordNotEmail=function(a,b,c){return b.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i)?c:0},c.wordLength=function(a,b,c){var d=b.length,e=Math.pow(d,a.rules.raisePower);return d2&&(a.each(b.forbiddenSequences,function(b,c){var e=[c,c.split("").reverse().join("")];a.each(e,function(a,b){for(f=0;f-1&&(g=!0)})}),g)?e:0},c.wordLowercase=function(a,b,c){return b.match(/[a-z]/)&&c},c.wordUppercase=function(a,b,c){return b.match(/[A-Z]/)&&c},c.wordOneNumber=function(a,b,c){return b.match(/\d+/)&&c},c.wordThreeNumbers=function(a,b,c){return b.match(/(.*[0-9].*[0-9].*[0-9])/)&&c},c.wordOneSpecialChar=function(a,b,c){return b.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&c},c.wordTwoSpecialChar=function(a,b,c){return b.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&c},c.wordUpperLowerCombo=function(a,b,c){return b.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&c},c.wordLetterNumberCombo=function(a,b,c){return b.match(/([a-zA-Z])/)&&b.match(/([0-9])/)&&c},c.wordLetterNumberCharCombo=function(a,b,c){return b.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&c},b.validation=c,b.executeRules=function(c,d){var e=0;return a.each(c.rules.activated,function(f,g){if(g){var h,i,j=c.rules.scores[f],k=b.validation[f];a.isFunction(k)||(k=c.rules.extra[f]),a.isFunction(k)&&(h=k(c,d,j),h&&(e+=h),(0>h||!a.isNumeric(h)&&!h)&&(i=c.ui.spanError(c,f),i.length>0&&c.instances.errors.push(i)))}}),e}}(a,b);try{module&&module.exports&&(module.exports=b)}catch(d){}var e={};e.common={},e.common.minChar=6,e.common.usernameField="#username",e.common.userInputs=[],e.common.onLoad=void 0,e.common.onKeyUp=void 0,e.common.zxcvbn=!1,e.common.debug=!1,e.rules={},e.rules.extra={},e.rules.scores={wordNotEmail:-100,wordLength:-50,wordSimilarToUsername:-100,wordSequences:-50,wordTwoCharacterClasses:2,wordRepetitions:-25,wordLowercase:1,wordUppercase:3,wordOneNumber:3,wordThreeNumbers:5,wordOneSpecialChar:3,wordTwoSpecialChar:5,wordUpperLowerCombo:2,wordLetterNumberCombo:2,wordLetterNumberCharCombo:2},e.rules.activated={wordNotEmail:!0,wordLength:!0,wordSimilarToUsername:!0,wordSequences:!0,wordTwoCharacterClasses:!1,wordRepetitions:!1,wordLowercase:!0,wordUppercase:!0,wordOneNumber:!0,wordThreeNumbers:!0,wordOneSpecialChar:!0,wordTwoSpecialChar:!0,wordUpperLowerCombo:!0,wordLetterNumberCombo:!0,wordLetterNumberCharCombo:!0},e.rules.raisePower=1.4,e.ui={},e.ui.showProgressBar=!0,e.ui.showPopover=!1,e.ui.showStatus=!1,e.ui.spanError=function(a,b){"use strict";var c=a.ui.errorMessages[b];return c?c:""},e.ui.errorMessages={wordLength:"Your password is too short",wordNotEmail:"Do not use your email as your password",wordSimilarToUsername:"Your password cannot contain your username",wordTwoCharacterClasses:"Use different character classes",wordRepetitions:"Too many repetitions",wordSequences:"Your password contains sequences"},e.ui.verdicts=["Weak","Normal","Medium","Strong","Very Strong"],e.ui.showVerdicts=!0,e.ui.showVerdictsInsideProgressBar=!1,e.ui.showErrors=!0,e.ui.container=void 0,e.ui.viewports={progress:void 0,verdict:".postfix",errors:void 0,status:void 0},e.ui.scores=[14,26,38,50];var f={};!function(a,b){"use strict";var c=["alert","success","success"],d=["alert","warning","success"];b.getContainer=function(b,c){var d;return d=a(b.ui.container),d&&1===d.length||(d=c.parent()),d},b.findElement=function(a,b,c){return b?a.find(b).find(c):a.find(c)},b.getUIElements=function(a,c){var d,e;return a.instances.viewports?a.instances.viewports:(d=b.getContainer(a,c),e={},e.$progressbar=b.findElement(d,a.ui.viewports.progress,"div.progress"),a.ui.showVerdictsInsideProgressBar&&(e.$verdict=e.$progressbar.find("span.password-verdict")),a.ui.showPopover||(a.ui.showVerdictsInsideProgressBar||(e.$verdict=b.findElement(d,a.ui.viewports.verdict,"span.password-verdict")),e.$errors=b.findElement(d,a.ui.viewports.errors,".error")),a.instances.viewports=e,e)},b.initProgressBar=function(c,d){var e=b.getContainer(c,d),f="
                                                  ";c.ui.showVerdictsInsideProgressBar&&(f+=""),f+="
                                                  ",c.ui.viewports.progress?e.find(c.ui.viewports.progress).append(f):a(f).insertAfter(d)},b.initHelper=function(c,d,e,f){var g=b.getContainer(c,d);f?g.find(f).append(e):a(e).insertAfter(d)},b.initVerdict=function(a,c){b.initHelper(a,c,"",a.ui.viewports.verdict)},b.initErrorList=function(a,c){b.initHelper(a,c,"",a.ui.viewports.errors)},b.initPopover=function(a,b){b.popover("destroy"),b.popover({html:!0,placement:"bottom",trigger:"manual",content:" "})},b.initUI=function(a,c){a.ui.showPopover?b.initPopover(a,c):(a.ui.showErrors&&b.initErrorList(a,c),a.ui.showVerdicts&&!a.ui.showVerdictsInsideProgressBar&&b.initVerdict(a,c)),a.ui.showProgressBar&&b.initProgressBar(a,c)},b.possibleProgressBarClasses=["alert","warning","success"],b.updateProgressBar=function(d,e,f,g){var h=b.getUIElements(d,e).$progressbar,i=h.find(".meter");a.each(b.possibleProgressBarClasses,function(a,b){h.removeClass(b)}),h.addClass(c[f]),i.css("width",g+"%")},b.updateVerdict=function(a,c,d){var e=b.getUIElements(a,c).$verdict;e.text(d)},b.updateErrors=function(c,d){var e=b.getContainer(c,d),f=b.getUIElements(c,d).$errors,g="";a.each(c.instances.errors,function(a,b){g+=b+"
                                                  "}),""!==g?(e.addClass("error"),f.show()):(e.removeClass("error"),f.hide()),f.html(g)},b.updatePopover=function(b,c,d){var e=c.data("bs.popover"),f="",g=!0;return b.ui.showVerdicts&&!b.ui.showVerdictsInsideProgressBar&&d.length>0&&(f="
                                                  "+d+"
                                                  ",g=!1),b.ui.showErrors&&(f+="
                                                  Errors:
                                                    ",a.each(b.instances.errors,function(a,b){f+="
                                                  • "+b+"
                                                  • ",g=!1}),f+="
                                                  "),g?void c.popover("hide"):void(e.$arrow&&e.$arrow.parents("body").length>0?c.find("+ .popover .popover-content").html(f):(e.options.content=f,c.popover("show")))},b.updateFieldStatus=function(c,e,f){var g=c.ui.viewports.status?a(c.ui.viewports.status):b.getContainer(c,e);a.each(d,function(a,b){g.removeClass(b)}),f=d[f],g.addClass(f)},b.percentage=function(a,b){var c=Math.floor(100*a/b);return c=0>c?0:c,c=c>100?100:c},b.getVerdictAndCssClass=function(a,b){var c,d,e;return 0>=b?(c=0,e=-1,d=a.ui.verdicts[0]):bli,ol.inline>li{display:inline-block;*display:inline;*zoom:1;padding-left:5px;padding-right:5px;} -dl{margin-bottom:20px;} -dt,dd{line-height:20px;} -dt{font-weight:bold;} -dd{margin-left:10px;} -.dl-horizontal{*zoom:1;}.dl-horizontal:before,.dl-horizontal:after{display:table;content:"";line-height:0;} -.dl-horizontal:after{clear:both;} -.dl-horizontal dt{float:left;width:160px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;} -.dl-horizontal dd{margin-left:180px;} -hr{margin:20px 0;border:0;border-top:1px solid #eeeeee;border-bottom:1px solid #ffffff;} -abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #999999;} -abbr.initialism{font-size:90%;text-transform:uppercase;} -blockquote{padding:0 0 0 15px;margin:0 0 20px;border-left:5px solid #eeeeee;}blockquote p{margin-bottom:0;font-size:17.5px;font-weight:300;line-height:1.25;} -blockquote small{display:block;line-height:20px;color:#999999;}blockquote small:before{content:'\2014 \00A0';} -blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eeeeee;border-left:0;}blockquote.pull-right p,blockquote.pull-right small{text-align:right;} -blockquote.pull-right small:before{content:'';} -blockquote.pull-right small:after{content:'\00A0 \2014';} -q:before,q:after,blockquote:before,blockquote:after{content:"";} -address{display:block;margin-bottom:20px;font-style:normal;line-height:20px;} -form{margin:0 0 20px;} -fieldset{padding:0;margin:0;border:0;} -legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:40px;color:#333333;border:0;border-bottom:1px solid #e5e5e5;}legend small{font-size:15px;color:#999999;} -label,input,button,select,textarea{font-size:14px;font-weight:normal;line-height:20px;} -input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;} -label{display:block;margin-bottom:5px;} -select,textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{display:inline-block;height:20px;padding:4px 6px;margin-bottom:10px;font-size:14px;line-height:20px;color:#555555;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;vertical-align:middle;} -input,textarea,.uneditable-input{width:206px;} -textarea{height:auto;} -textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{background-color:#ffffff;border:1px solid #cccccc;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-webkit-transition:border linear .2s, box-shadow linear .2s;-moz-transition:border linear .2s, box-shadow linear .2s;-o-transition:border linear .2s, box-shadow linear .2s;transition:border linear .2s, box-shadow linear .2s;}textarea:focus,input[type="text"]:focus,input[type="password"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="date"]:focus,input[type="month"]:focus,input[type="time"]:focus,input[type="week"]:focus,input[type="number"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="color"]:focus,.uneditable-input:focus{border-color:rgba(82, 168, 236, 0.8);outline:0;outline:thin dotted \9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6);} -input[type="radio"],input[type="checkbox"]{margin:4px 0 0;*margin-top:0;margin-top:1px \9;line-height:normal;} -input[type="file"],input[type="image"],input[type="submit"],input[type="reset"],input[type="button"],input[type="radio"],input[type="checkbox"]{width:auto;} -select,input[type="file"]{height:30px;*margin-top:4px;line-height:30px;} -select{width:220px;border:1px solid #cccccc;background-color:#ffffff;} -select[multiple],select[size]{height:auto;} -select:focus,input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px;} -.uneditable-input,.uneditable-textarea{color:#999999;background-color:#fcfcfc;border-color:#cccccc;-webkit-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.025);-moz-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.025);box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.025);cursor:not-allowed;} -.uneditable-input{overflow:hidden;white-space:nowrap;} -.uneditable-textarea{width:auto;height:auto;} -input:-moz-placeholder,textarea:-moz-placeholder{color:#999999;} -input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#999999;} -input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#999999;} -.radio,.checkbox{min-height:20px;padding-left:20px;} -.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-20px;} -.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px;} -.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle;} -.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px;} -.input-mini{width:60px;} -.input-small{width:90px;} -.input-medium{width:150px;} -.input-large{width:210px;} -.input-xlarge{width:270px;} -.input-xxlarge{width:530px;} -input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"]{float:none;margin-left:0;} -.input-append input[class*="span"],.input-append .uneditable-input[class*="span"],.input-prepend input[class*="span"],.input-prepend .uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"],.row-fluid .input-prepend [class*="span"],.row-fluid .input-append [class*="span"]{display:inline-block;} -input,textarea,.uneditable-input{margin-left:0;} -.controls-row [class*="span"]+[class*="span"]{margin-left:20px;} -input.span12,textarea.span12,.uneditable-input.span12{width:926px;} -input.span11,textarea.span11,.uneditable-input.span11{width:846px;} -input.span10,textarea.span10,.uneditable-input.span10{width:766px;} -input.span9,textarea.span9,.uneditable-input.span9{width:686px;} -input.span8,textarea.span8,.uneditable-input.span8{width:606px;} -input.span7,textarea.span7,.uneditable-input.span7{width:526px;} -input.span6,textarea.span6,.uneditable-input.span6{width:446px;} -input.span5,textarea.span5,.uneditable-input.span5{width:366px;} -input.span4,textarea.span4,.uneditable-input.span4{width:286px;} -input.span3,textarea.span3,.uneditable-input.span3{width:206px;} -input.span2,textarea.span2,.uneditable-input.span2{width:126px;} -input.span1,textarea.span1,.uneditable-input.span1{width:46px;} -.controls-row{*zoom:1;}.controls-row:before,.controls-row:after{display:table;content:"";line-height:0;} -.controls-row:after{clear:both;} -.controls-row [class*="span"],.row-fluid .controls-row [class*="span"]{float:left;} -.controls-row .checkbox[class*="span"],.controls-row .radio[class*="span"]{padding-top:5px;} -input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#eeeeee;} -input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"][readonly],input[type="checkbox"][readonly]{background-color:transparent;} -.control-group.warning .control-label,.control-group.warning .help-block,.control-group.warning .help-inline{color:#c09853;} -.control-group.warning .checkbox,.control-group.warning .radio,.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853;} -.control-group.warning input,.control-group.warning select,.control-group.warning textarea{border-color:#c09853;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);}.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #dbc59e;-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #dbc59e;box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #dbc59e;} -.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853;} -.control-group.error .control-label,.control-group.error .help-block,.control-group.error .help-inline{color:#b94a48;} -.control-group.error .checkbox,.control-group.error .radio,.control-group.error input,.control-group.error select,.control-group.error textarea{color:#b94a48;} -.control-group.error input,.control-group.error select,.control-group.error textarea{border-color:#b94a48;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);}.control-group.error input:focus,.control-group.error select:focus,.control-group.error textarea:focus{border-color:#953b39;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #d59392;-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #d59392;box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #d59392;} -.control-group.error .input-prepend .add-on,.control-group.error .input-append .add-on{color:#b94a48;background-color:#f2dede;border-color:#b94a48;} -.control-group.success .control-label,.control-group.success .help-block,.control-group.success .help-inline{color:#468847;} -.control-group.success .checkbox,.control-group.success .radio,.control-group.success input,.control-group.success select,.control-group.success textarea{color:#468847;} -.control-group.success input,.control-group.success select,.control-group.success textarea{border-color:#468847;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);}.control-group.success input:focus,.control-group.success select:focus,.control-group.success textarea:focus{border-color:#356635;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #7aba7b;-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #7aba7b;box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #7aba7b;} -.control-group.success .input-prepend .add-on,.control-group.success .input-append .add-on{color:#468847;background-color:#dff0d8;border-color:#468847;} -.control-group.info .control-label,.control-group.info .help-block,.control-group.info .help-inline{color:#3a87ad;} -.control-group.info .checkbox,.control-group.info .radio,.control-group.info input,.control-group.info select,.control-group.info textarea{color:#3a87ad;} -.control-group.info input,.control-group.info select,.control-group.info textarea{border-color:#3a87ad;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);}.control-group.info input:focus,.control-group.info select:focus,.control-group.info textarea:focus{border-color:#2d6987;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #7ab5d3;-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #7ab5d3;box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 6px #7ab5d3;} -.control-group.info .input-prepend .add-on,.control-group.info .input-append .add-on{color:#3a87ad;background-color:#d9edf7;border-color:#3a87ad;} -input:focus:invalid,textarea:focus:invalid,select:focus:invalid{color:#b94a48;border-color:#ee5f5b;}input:focus:invalid:focus,textarea:focus:invalid:focus,select:focus:invalid:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7;} -.form-actions{padding:19px 20px 20px;margin-top:20px;margin-bottom:20px;background-color:#f5f5f5;border-top:1px solid #e5e5e5;*zoom:1;}.form-actions:before,.form-actions:after{display:table;content:"";line-height:0;} -.form-actions:after{clear:both;} -.help-block,.help-inline{color:#595959;} -.help-block{display:block;margin-bottom:10px;} -.help-inline{display:inline-block;*display:inline;*zoom:1;vertical-align:middle;padding-left:5px;} -.input-append,.input-prepend{display:inline-block;margin-bottom:10px;vertical-align:middle;font-size:0;white-space:nowrap;}.input-append input,.input-prepend input,.input-append select,.input-prepend select,.input-append .uneditable-input,.input-prepend .uneditable-input,.input-append .dropdown-menu,.input-prepend .dropdown-menu,.input-append .popover,.input-prepend .popover{font-size:14px;} -.input-append input,.input-prepend input,.input-append select,.input-prepend select,.input-append .uneditable-input,.input-prepend .uneditable-input{position:relative;margin-bottom:0;*margin-left:0;vertical-align:top;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0;}.input-append input:focus,.input-prepend input:focus,.input-append select:focus,.input-prepend select:focus,.input-append .uneditable-input:focus,.input-prepend .uneditable-input:focus{z-index:2;} -.input-append .add-on,.input-prepend .add-on{display:inline-block;width:auto;height:20px;min-width:16px;padding:4px 5px;font-size:14px;font-weight:normal;line-height:20px;text-align:center;text-shadow:0 1px 0 #ffffff;background-color:#eeeeee;border:1px solid #ccc;} -.input-append .add-on,.input-prepend .add-on,.input-append .btn,.input-prepend .btn,.input-append .btn-group>.dropdown-toggle,.input-prepend .btn-group>.dropdown-toggle{vertical-align:top;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;} -.input-append .active,.input-prepend .active{background-color:#a9dba9;border-color:#46a546;} -.input-prepend .add-on,.input-prepend .btn{margin-right:-1px;} -.input-prepend .add-on:first-child,.input-prepend .btn:first-child{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px;} -.input-append input,.input-append select,.input-append .uneditable-input{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px;}.input-append input+.btn-group .btn:last-child,.input-append select+.btn-group .btn:last-child,.input-append .uneditable-input+.btn-group .btn:last-child{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0;} -.input-append .add-on,.input-append .btn,.input-append .btn-group{margin-left:-1px;} -.input-append .add-on:last-child,.input-append .btn:last-child,.input-append .btn-group:last-child>.dropdown-toggle{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0;} -.input-prepend.input-append input,.input-prepend.input-append select,.input-prepend.input-append .uneditable-input{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}.input-prepend.input-append input+.btn-group .btn,.input-prepend.input-append select+.btn-group .btn,.input-prepend.input-append .uneditable-input+.btn-group .btn{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0;} -.input-prepend.input-append .add-on:first-child,.input-prepend.input-append .btn:first-child{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px;} -.input-prepend.input-append .add-on:last-child,.input-prepend.input-append .btn:last-child{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0;} -.input-prepend.input-append .btn-group:first-child{margin-left:0;} -input.search-query{padding-right:14px;padding-right:4px \9;padding-left:14px;padding-left:4px \9;margin-bottom:0;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px;} -.form-search .input-append .search-query,.form-search .input-prepend .search-query{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;} -.form-search .input-append .search-query{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px;} -.form-search .input-append .btn{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0;} -.form-search .input-prepend .search-query{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0;} -.form-search .input-prepend .btn{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px;} -.form-search input,.form-inline input,.form-horizontal input,.form-search textarea,.form-inline textarea,.form-horizontal textarea,.form-search select,.form-inline select,.form-horizontal select,.form-search .help-inline,.form-inline .help-inline,.form-horizontal .help-inline,.form-search .uneditable-input,.form-inline .uneditable-input,.form-horizontal .uneditable-input,.form-search .input-prepend,.form-inline .input-prepend,.form-horizontal .input-prepend,.form-search .input-append,.form-inline .input-append,.form-horizontal .input-append{display:inline-block;*display:inline;*zoom:1;margin-bottom:0;vertical-align:middle;} -.form-search .hide,.form-inline .hide,.form-horizontal .hide{display:none;} -.form-search label,.form-inline label,.form-search .btn-group,.form-inline .btn-group{display:inline-block;} -.form-search .input-append,.form-inline .input-append,.form-search .input-prepend,.form-inline .input-prepend{margin-bottom:0;} -.form-search .radio,.form-search .checkbox,.form-inline .radio,.form-inline .checkbox{padding-left:0;margin-bottom:0;vertical-align:middle;} -.form-search .radio input[type="radio"],.form-search .checkbox input[type="checkbox"],.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:left;margin-right:3px;margin-left:0;} -.control-group{margin-bottom:10px;} -legend+.control-group{margin-top:20px;-webkit-margin-top-collapse:separate;} -.form-horizontal .control-group{margin-bottom:20px;*zoom:1;}.form-horizontal .control-group:before,.form-horizontal .control-group:after{display:table;content:"";line-height:0;} -.form-horizontal .control-group:after{clear:both;} -.form-horizontal .control-label{float:left;width:160px;padding-top:5px;text-align:right;} -.form-horizontal .controls{*display:inline-block;*padding-left:20px;margin-left:180px;*margin-left:0;}.form-horizontal .controls:first-child{*padding-left:180px;} -.form-horizontal .help-block{margin-bottom:0;} -.form-horizontal input+.help-block,.form-horizontal select+.help-block,.form-horizontal textarea+.help-block,.form-horizontal .uneditable-input+.help-block,.form-horizontal .input-prepend+.help-block,.form-horizontal .input-append+.help-block{margin-top:10px;} -.form-horizontal .form-actions{padding-left:180px;} -@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0;} to{background-position:0 0;}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0;} to{background-position:0 0;}}@-ms-keyframes progress-bar-stripes{from{background-position:40px 0;} to{background-position:0 0;}}@-o-keyframes progress-bar-stripes{from{background-position:0 0;} to{background-position:40px 0;}}@keyframes progress-bar-stripes{from{background-position:40px 0;} to{background-position:0 0;}}.progress{overflow:hidden;height:20px;margin-bottom:20px;background-color:#f7f7f7;background-image:-moz-linear-gradient(top, #f5f5f5, #f9f9f9);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));background-image:-webkit-linear-gradient(top, #f5f5f5, #f9f9f9);background-image:-o-linear-gradient(top, #f5f5f5, #f9f9f9);background-image:linear-gradient(to bottom, #f5f5f5, #f9f9f9);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);-moz-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;} -.progress .bar{width:0%;height:100%;color:#ffffff;float:left;font-size:12px;text-align:center;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);background-color:#0e90d2;background-image:-moz-linear-gradient(top, #149bdf, #0480be);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be));background-image:-webkit-linear-gradient(top, #149bdf, #0480be);background-image:-o-linear-gradient(top, #149bdf, #0480be);background-image:linear-gradient(to bottom, #149bdf, #0480be);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf', endColorstr='#ff0480be', GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);-moz-box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:width 0.6s ease;-moz-transition:width 0.6s ease;-o-transition:width 0.6s ease;transition:width 0.6s ease;} -.progress .bar+.bar{-webkit-box-shadow:inset 1px 0 0 rgba(0,0,0,.15), inset 0 -1px 0 rgba(0,0,0,.15);-moz-box-shadow:inset 1px 0 0 rgba(0,0,0,.15), inset 0 -1px 0 rgba(0,0,0,.15);box-shadow:inset 1px 0 0 rgba(0,0,0,.15), inset 0 -1px 0 rgba(0,0,0,.15);} -.progress-striped .bar{background-color:#149bdf;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));background-image:-webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);-webkit-background-size:40px 40px;-moz-background-size:40px 40px;-o-background-size:40px 40px;background-size:40px 40px;} -.progress.active .bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite;} -.progress-danger .bar,.progress .bar-danger{background-color:#dd514c;background-image:-moz-linear-gradient(top, #ee5f5b, #c43c35);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35));background-image:-webkit-linear-gradient(top, #ee5f5b, #c43c35);background-image:-o-linear-gradient(top, #ee5f5b, #c43c35);background-image:linear-gradient(to bottom, #ee5f5b, #c43c35);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffc43c35', GradientType=0);} -.progress-danger.progress-striped .bar,.progress-striped .bar-danger{background-color:#ee5f5b;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));background-image:-webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);} -.progress-success .bar,.progress .bar-success{background-color:#5eb95e;background-image:-moz-linear-gradient(top, #62c462, #57a957);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957));background-image:-webkit-linear-gradient(top, #62c462, #57a957);background-image:-o-linear-gradient(top, #62c462, #57a957);background-image:linear-gradient(to bottom, #62c462, #57a957);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff57a957', GradientType=0);} -.progress-success.progress-striped .bar,.progress-striped .bar-success{background-color:#62c462;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));background-image:-webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);} -.progress-info .bar,.progress .bar-info{background-color:#4bb1cf;background-image:-moz-linear-gradient(top, #5bc0de, #339bb9);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9));background-image:-webkit-linear-gradient(top, #5bc0de, #339bb9);background-image:-o-linear-gradient(top, #5bc0de, #339bb9);background-image:linear-gradient(to bottom, #5bc0de, #339bb9);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff339bb9', GradientType=0);} -.progress-info.progress-striped .bar,.progress-striped .bar-info{background-color:#5bc0de;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));background-image:-webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);} -.progress-warning .bar,.progress .bar-warning{background-color:#faa732;background-image:-moz-linear-gradient(top, #fbb450, #f89406);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));background-image:-webkit-linear-gradient(top, #fbb450, #f89406);background-image:-o-linear-gradient(top, #fbb450, #f89406);background-image:linear-gradient(to bottom, #fbb450, #f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);} -.progress-warning.progress-striped .bar,.progress-striped .bar-warning{background-color:#fbb450;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));background-image:-webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);} -.popover{position:absolute;top:0;left:0;z-index:1010;display:none;max-width:276px;padding:1px;text-align:left;background-color:#ffffff;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0, 0, 0, 0.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 5px 10px rgba(0, 0, 0, 0.2);box-shadow:0 5px 10px rgba(0, 0, 0, 0.2);white-space:normal;}.popover.top{margin-top:-10px;} -.popover.right{margin-left:10px;} -.popover.bottom{margin-top:10px;} -.popover.left{margin-left:-10px;} -.popover-title{margin:0;padding:8px 14px;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0;}.popover-title:empty{display:none;} -.popover-content{padding:9px 14px;} -.popover .arrow,.popover .arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid;} -.popover .arrow{border-width:11px;} -.popover .arrow:after{border-width:10px;content:"";} -.popover.top .arrow{left:50%;margin-left:-11px;border-bottom-width:0;border-top-color:#999;border-top-color:rgba(0, 0, 0, 0.25);bottom:-11px;}.popover.top .arrow:after{bottom:1px;margin-left:-10px;border-bottom-width:0;border-top-color:#ffffff;} -.popover.right .arrow{top:50%;left:-11px;margin-top:-11px;border-left-width:0;border-right-color:#999;border-right-color:rgba(0, 0, 0, 0.25);}.popover.right .arrow:after{left:1px;bottom:-10px;border-left-width:0;border-right-color:#ffffff;} -.popover.bottom .arrow{left:50%;margin-left:-11px;border-top-width:0;border-bottom-color:#999;border-bottom-color:rgba(0, 0, 0, 0.25);top:-11px;}.popover.bottom .arrow:after{top:1px;margin-left:-10px;border-top-width:0;border-bottom-color:#ffffff;} -.popover.left .arrow{top:50%;right:-11px;margin-top:-11px;border-right-width:0;border-left-color:#999;border-left-color:rgba(0, 0, 0, 0.25);}.popover.left .arrow:after{right:1px;border-right-width:0;border-left-color:#ffffff;bottom:-10px;} -.pull-right{float:right;} -.pull-left{float:left;} -.hide{display:none;} -.show{display:block;} -.invisible{visibility:hidden;} -.affix{position:fixed;} -.fade{opacity:0;-webkit-transition:opacity 0.15s linear;-moz-transition:opacity 0.15s linear;-o-transition:opacity 0.15s linear;transition:opacity 0.15s linear;}.fade.in{opacity:1;} -.collapse{position:relative;height:0;overflow:hidden;-webkit-transition:height 0.35s ease;-moz-transition:height 0.35s ease;-o-transition:height 0.35s ease;transition:height 0.35s ease;}.collapse.in{height:auto;} diff --git a/examples/bootstrap2/bootstrap2.js b/examples/bootstrap2/bootstrap2.js deleted file mode 100644 index 604a790..0000000 --- a/examples/bootstrap2/bootstrap2.js +++ /dev/null @@ -1,7 +0,0 @@ -/** -* Bootstrap.js by @fat & @mdo -* plugins: bootstrap-transition.js, bootstrap-tooltip.js, bootstrap-popover.js -* Copyright 2013 Twitter, Inc. -* http://www.apache.org/licenses/LICENSE-2.0.txt -*/ -!function(a){a(function(){a.support.transition=function(){var a=function(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},c;for(c in b)if(a.style[c]!==undefined)return b[c]}();return a&&{end:a}}()})}(window.jQuery),!function(a){var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f,g,h,i;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,g=this.options.trigger.split(" ");for(i=g.length;i--;)h=g[i],h=="click"?this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this)):h!="manual"&&(e=h=="hover"?"mouseenter":"focus",f=h=="hover"?"mouseleave":"blur",this.$element.on(e+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f+"."+this.type,this.options.selector,a.proxy(this.leave,this)));this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){return b=a.extend({},a.fn[this.type].defaults,this.$element.data(),b),b.delay&&typeof b.delay=="number"&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){var c=a.fn[this.type].defaults,d={},e;this._options&&a.each(this._options,function(a,b){c[a]!=b&&(d[a]=b)},this),e=a(b.currentTarget)[this.type](d).data(this.type);if(!e.options.delay||!e.options.delay.show)return e.show();clearTimeout(this.timeout),e.hoverState="in",this.timeout=setTimeout(function(){e.hoverState=="in"&&e.show()},e.options.delay.show)},leave:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);this.timeout&&clearTimeout(this.timeout);if(!c.options.delay||!c.options.delay.hide)return c.hide();c.hoverState="out",this.timeout=setTimeout(function(){c.hoverState=="out"&&c.hide()},c.options.delay.hide)},show:function(){var b,c,d,e,f,g,h=a.Event("show");if(this.hasContent()&&this.enabled){this.$element.trigger(h);if(h.isDefaultPrevented())return;b=this.tip(),this.setContent(),this.options.animation&&b.addClass("fade"),f=typeof this.options.placement=="function"?this.options.placement.call(this,b[0],this.$element[0]):this.options.placement,b.detach().css({top:0,left:0,display:"block"}),this.options.container?b.appendTo(this.options.container):b.insertAfter(this.$element),c=this.getPosition(),d=b[0].offsetWidth,e=b[0].offsetHeight;switch(f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}this.applyPlacement(g,f),this.$element.trigger("shown")}},applyPlacement:function(a,b){var c=this.tip(),d=c[0].offsetWidth,e=c[0].offsetHeight,f,g,h,i;c.offset(a).addClass(b).addClass("in"),f=c[0].offsetWidth,g=c[0].offsetHeight,b=="top"&&g!=e&&(a.top=a.top+e-g,i=!0),b=="bottom"||b=="top"?(h=0,a.left<0&&(h=a.left*-2,a.left=0,c.offset(a),f=c[0].offsetWidth,g=c[0].offsetHeight),this.replaceArrow(h-d+f,f,"left")):this.replaceArrow(g-e,g,"top"),i&&c.offset(a)},replaceArrow:function(a,b,c){this.arrow().css(c,a?50*(1-a/b)+"%":"")},setContent:function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},hide:function(){function e(){var b=setTimeout(function(){c.off(a.support.transition.end).detach()},500);c.one(a.support.transition.end,function(){clearTimeout(b),c.detach()})}var b=this,c=this.tip(),d=a.Event("hide");this.$element.trigger(d);if(d.isDefaultPrevented())return;return c.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?e():c.detach(),this.$element.trigger("hidden"),this},fixTitle:function(){var a=this.$element;(a.attr("title")||typeof a.attr("data-original-title")!="string")&&a.attr("data-original-title",a.attr("title")||"").attr("title","")},hasContent:function(){return this.getTitle()},getPosition:function(){var b=this.$element[0];return a.extend({},typeof b.getBoundingClientRect=="function"?b.getBoundingClientRect():{width:b.offsetWidth,height:b.offsetHeight},this.$element.offset())},getTitle:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||(typeof c.title=="function"?c.title.call(b[0]):c.title),a},tip:function(){return this.$tip=this.$tip||a(this.options.template)},arrow:function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(b){var c=b?a(b.currentTarget)[this.type](this._options).data(this.type):this;c.tip().hasClass("in")?c.hide():c.show()},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}};var c=a.fn.tooltip;a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("tooltip"),f=typeof c=="object"&&c;e||d.data("tooltip",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'
                                                  ',trigger:"hover focus",title:"",delay:0,html:!1,container:!1},a.fn.tooltip.noConflict=function(){return a.fn.tooltip=c,this}}(window.jQuery),!function(a){var b=function(a,b){this.init("popover",a,b)};b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype,{constructor:b,setContent:function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content")[this.options.html?"html":"text"](c),a.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var a,b=this.$element,c=this.options;return a=(typeof c.content=="function"?c.content.call(b[0]):c.content)||b.attr("data-content"),a},tip:function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}});var c=a.fn.popover;a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("popover"),f=typeof c=="object"&&c;e||d.data("popover",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.defaults=a.extend({},a.fn.tooltip.defaults,{placement:"right",trigger:"click",content:"",template:'

                                                  '}),a.fn.popover.noConflict=function(){return a.fn.popover=c,this}}(window.jQuery) \ No newline at end of file diff --git a/examples/bootstrap2/index.html b/examples/bootstrap2/index.html deleted file mode 100644 index 542dc01..0000000 --- a/examples/bootstrap2/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - Bootstrap 2 Password Strength Meter Example - - - -
                                                  -

                                                  Bootstrap 2 Password Strength Meter Example

                                                  -
                                                  -
                                                  - Please type in your password - User: -
                                                  - Pass: -
                                                  -
                                                  -
                                                  -
                                                  -

                                                  Go back

                                                  -
                                                  - - - - - - diff --git a/examples/bootstrap2/multi.html b/examples/bootstrap2/multi.html deleted file mode 100644 index e807dd1..0000000 --- a/examples/bootstrap2/multi.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - Bootstrap 2 Password Strength Meter Example - Multiple inputs - - - -
                                                  -

                                                  Bootstrap 2 Password Strength Meter Example - Multiple inputs

                                                  -
                                                  - User:
                                                  -
                                                  - Please type in your first password - Pass: -
                                                  - -
                                                  - Please type in your second password - Pass: -
                                                  -
                                                  -

                                                  Go back

                                                  -
                                                  - - - - - - diff --git a/examples/bootstrap2/popover.html b/examples/bootstrap2/popover.html deleted file mode 100644 index 57c110f..0000000 --- a/examples/bootstrap2/popover.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - Bootstrap 2 Password Strength Meter Example - Popover - - - -
                                                  -

                                                  Bootstrap 2 Password Strength Meter Example - Popover

                                                  -
                                                  -
                                                  - Please type in your password - User:
                                                  - Pass: -
                                                  -
                                                  -

                                                  Go back

                                                  -
                                                  - - - - - - - diff --git a/examples/bootstrap2/rules.html b/examples/bootstrap2/rules.html deleted file mode 100644 index 61adde6..0000000 --- a/examples/bootstrap2/rules.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - Bootstrap 2 Password Strength Meter Example - Custom Rules - - - -
                                                  -

                                                  Bootstrap 2 Password Strength Meter Example - Custom Rules

                                                  -
                                                  -
                                                  - Please type in your password - User:
                                                  - Pass: -
                                                  -
                                                  -

                                                  The words "password", "3141592" and "yeah" have been blocked by the - custom rules. So if the password contains one of the blocked words, - then the password will be marked as weak.

                                                  -

                                                  Go back

                                                  -
                                                  - - - - - - diff --git a/examples/bootstrap3/index.html b/examples/bootstrap3/index.html index ea88d35..a1e97bc 100644 --- a/examples/bootstrap3/index.html +++ b/examples/bootstrap3/index.html @@ -26,7 +26,7 @@

                                                  Bootstrap 3 Password Strength Meter Example

                                                  Go back

                                                  - + + + + + + + + diff --git a/examples/foundation5/popover.html b/examples/foundation5/popover.html new file mode 100644 index 0000000..ed6d63b --- /dev/null +++ b/examples/foundation5/popover.html @@ -0,0 +1,47 @@ + + + + Foundation 5 Password Strength Meter Example - Popover + + + +
                                                  +

                                                  Foundation 5 Password Strength Meter Example - Popover

                                                  +
                                                  +
                                                  +
                                                  +
                                                  + + + + +
                                                  +
                                                  +
                                                  +
                                                  +

                                                  Go back

                                                  +
                                                  + + + + + + + diff --git a/examples/foundation5/status.html b/examples/foundation5/status.html new file mode 100644 index 0000000..4dbf2db --- /dev/null +++ b/examples/foundation5/status.html @@ -0,0 +1,43 @@ + + + + Foundation 5 Password Strength Meter Example - Status + + + +
                                                  +

                                                  Foundation 5 Password Strength Meter Example - Status

                                                  +
                                                  +
                                                  +
                                                  +
                                                  + + +
                                                  + +
                                                  +
                                                  +
                                                  +

                                                  Go back

                                                  +
                                                  + + + + + + diff --git a/examples/foundation5/zxcvbn.html b/examples/foundation5/zxcvbn.html new file mode 100644 index 0000000..898eec1 --- /dev/null +++ b/examples/foundation5/zxcvbn.html @@ -0,0 +1,66 @@ + + + + Foundation 5 Password Strength Meter Example - zxcvbn + + + +
                                                  +

                                                  Foundation 5 Password Strength Meter Example - zxcvbn

                                                  +
                                                  +
                                                  +
                                                  +
                                                  + + +
                                                  +
                                                  + + +
                                                  +
                                                  + + +
                                                  +
                                                  + + +
                                                  +
                                                  +
                                                  + +
                                                  +
                                                  +
                                                  +
                                                  +
                                                  +
                                                  +

                                                  Go back

                                                  +
                                                  + + + + + + + diff --git a/examples/index.html b/examples/index.html index a2cb5ce..bf39bc7 100644 --- a/examples/index.html +++ b/examples/index.html @@ -1,29 +1,21 @@ - jQuery Password Strength Meter for Twitter Bootstrap Examples - + jQuery Password Strength Meter for Zurb Foundation Examples +
                                                  -

                                                  jQuery Password Strength Meter for Twitter Bootstrap

                                                  +

                                                  jQuery Password Strength Meter for Zurb Foundation

                                                  Examples

                                                  This examples expect the example directory to be serverd as root, all the path are written based on that assumption.

                                                  -

                                                  Bootstrap 3

                                                    -
                                                  1. Basic usage
                                                  2. -
                                                  3. Show verdict and errors in a popover
                                                  4. -
                                                  5. Use zxcvbn to calculate the password strength
                                                  6. -
                                                  7. Show the password strength as a status in the field
                                                  8. -
                                                  -

                                                  Bootstrap 2

                                                  -
                                                    -
                                                  1. Basic usage
                                                  2. -
                                                  3. Multiple password inputs in one page
                                                  4. -
                                                  5. Adding custom rules
                                                  6. -
                                                  7. Show verdict and errors in a popover
                                                  8. +
                                                  9. Basic usage
                                                  10. +
                                                  11. Show verdict and errors in a popover
                                                  12. +
                                                  13. Use zxcvbn to calculate the password strength
                                                  14. +
                                                  15. Show the password strength as a status in the field
                                                  diff --git a/examples/pwstrength.js b/examples/pwstrength.js index d40d200..b8b8f9c 100644 --- a/examples/pwstrength.js +++ b/examples/pwstrength.js @@ -1,8 +1,9 @@ /*! -* jQuery Password Strength plugin for Twitter Bootstrap +* jQuery Password Strength plugin for Zurb Foundation * * Copyright (c) 2008-2013 Tane Piper * Copyright (c) 2013 Alejandro Blanco +* Copyright (c) 2014 Ed Townend * Dual licensed under the MIT and GPL licenses. */ @@ -222,7 +223,7 @@ defaultOptions.rules.activated = { defaultOptions.rules.raisePower = 1.4; defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; +// defaultOptions.ui.bootstrap2 = false; defaultOptions.ui.showProgressBar = true; defaultOptions.ui.showPopover = false; defaultOptions.ui.showStatus = false; @@ -230,7 +231,8 @@ defaultOptions.ui.spanError = function (options, key) { "use strict"; var text = options.ui.errorMessages[key]; if (!text) { return ''; } - return '' + text + ''; + // return '' + text + ''; + return text; }; defaultOptions.ui.errorMessages = { wordLength: "Your password is too short", @@ -243,12 +245,13 @@ defaultOptions.ui.errorMessages = { defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; defaultOptions.ui.showVerdicts = true; defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; +defaultOptions.ui.showErrors = true; defaultOptions.ui.container = undefined; defaultOptions.ui.viewports = { progress: undefined, - verdict: undefined, - errors: undefined + verdict: '.postfix', + errors: undefined, + status: undefined }; defaultOptions.ui.scores = [14, 26, 38, 50]; @@ -262,8 +265,8 @@ var ui = {}; (function ($, ui) { "use strict"; - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; + var barClasses = ["alert", "success", "success"], + statusClasses = ["alert", "warning", "success"]; ui.getContainer = function (options, $el) { var $container; @@ -301,7 +304,7 @@ var ui = {}; if (!options.ui.showVerdictsInsideProgressBar) { result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); + result.$errors = ui.findElement($container, options.ui.viewports.errors, ".error"); } options.instances.viewports = result; @@ -310,12 +313,7 @@ var ui = {}; ui.initProgressBar = function (options, $el) { var $container = ui.getContainer(options, $el), - progressbar = "
                                                  "; + progressbar = "
                                                  "; if (options.ui.showVerdictsInsideProgressBar) { progressbar += ""; } @@ -343,7 +341,7 @@ var ui = {}; }; ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                                                    ", + ui.initHelper(options, $el, "", options.ui.viewports.errors); }; @@ -371,22 +369,16 @@ var ui = {}; } }; - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; + ui.possibleProgressBarClasses = ["alert", "warning", "success"]; ui.updateProgressBar = function (options, $el, cssClass, percentage) { var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } + $bar = $progressbar.find(".meter"); $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); + $progressbar.removeClass(value); }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); + $progressbar.addClass(barClasses[cssClass]); $bar.css("width", percentage + '%'); }; @@ -396,11 +388,21 @@ var ui = {}; }; ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, + var $container = ui.getContainer(options, $el), + $errors = ui.getUIElements(options, $el).$errors, html = ""; $.each(options.instances.errors, function (idx, err) { - html += "
                                                  • " + err + "
                                                  • "; + html += err + "
                                                    "; }); + + if (html !== "") { + $container.addClass('error'); + $errors.show(); + } else { + $container.removeClass('error'); + $errors.hide(); + } + $errors.html(html); }; @@ -430,8 +432,6 @@ var ui = {}; return; } - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { $el.find("+ .popover .popover-content").html(html); } else { @@ -442,16 +442,14 @@ var ui = {}; }; ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); + + var $container = options.ui.viewports.status ? $(options.ui.viewports.status) : ui.getContainer(options, $el); $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } $container.removeClass(css); }); cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } $container.addClass(cssClass); }; @@ -539,7 +537,7 @@ var methods = {}; onKeyUp = function (event) { var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), + options = $el.data("pwstrength-foundation"), word = $el.val(), userInputs, verdictText, @@ -584,7 +582,7 @@ var methods = {}; $el = $(el); localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); + $el.data("pwstrength-foundation", localOptions); $el.on("keyup", onKeyUp); $el.on("change", onKeyUp); $el.on("onpaste", onKeyUp); @@ -605,12 +603,12 @@ var methods = {}; methods.destroy = function () { this.each(function (idx, el) { var $el = $(el), - options = $el.data("pwstrength-bootstrap"), + options = $el.data("pwstrength-foundation"), elements = ui.getUIElements(options, $el); elements.$progressbar.remove(); elements.$verdict.remove(); elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); + $el.removeData("pwstrength-foundation"); }); }; @@ -623,7 +621,7 @@ var methods = {}; methods.addRule = function (name, method, score, active) { this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); + var options = $(el).data("pwstrength-foundation"); options.rules.activated[name] = active; options.rules.scores[name] = score; @@ -633,7 +631,7 @@ var methods = {}; applyToAll = function (rule, prop, value) { this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; + $(el).data("pwstrength-foundation").rules[prop][rule] = value; }); }; @@ -653,7 +651,7 @@ var methods = {}; } else if (typeof method === "object" || !method) { result = methods.init.apply(this, arguments); } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); + $.error("Method " + method + " does not exist on jQuery.pwstrength-foundation"); } return result; diff --git a/package.json b/package.json index f00ed0c..7509895 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,18 @@ { - "name": "pwstrength-bootstrap", - "version": "1.2.2", - "author": "Alejandro Blanco ", + "name": "pwstrength-foundation", + "version": "1.2.3", + "author": "Ed Townend ", "repository": { "type": "git", - "url": "https://github.com/ablanco/jquery.pwstrength.bootstrap" + "url": "https://github.com/edtownend/jquery.pwstrength.foundation" }, "licenses" : [ { "type" : "GPL v3", - "url" : "https://raw.github.com/ablanco/jquery.pwstrength.bootstrap/master/GPL-LICENSE.txt" + "url" : "https://raw.github.com/edtownend/jquery.pwstrength.foundation/master/GPL-LICENSE.txt" }, { "type": "MIT", - "url": "https://raw.github.com/ablanco/jquery.pwstrength.bootstrap/master/MIT-LICENSE.txt" + "url": "https://raw.github.com/edtownend/jquery.pwstrength.foundation/master/MIT-LICENSE.txt" } ], "scripts": { diff --git a/pwstrength-bootstrap.jquery.json b/pwstrength-bootstrap.jquery.json deleted file mode 100644 index af1631c..0000000 --- a/pwstrength-bootstrap.jquery.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "pwstrength-bootstrap", - "title": "jQuery Password Strength Meter for Twitter Bootstrap", - "description": "jQuery plugin for Twitter Bootstrap that provides rulesets for visualy displaying the quality of a users typed in password.", - "keywords": [ - "bootstrap", - "password", - "strength", - "meter" - ], - "version": "1.2.2", - "author": { - "name": "Alejandro Blanco other contributors", - "url": "https://github.com/ablanco/jquery.pwstrength.bootstrap/blob/1.2.2/AUTHORS.txt" - }, - "maintainers": [ - { - "name": "Alejandro Blanco", - "email": "alejandro.b.e@gmail.com", - "url": "http://mensab.com" - } - ], - "licenses": [ - { - "type": "GPLv3", - "url": "https://github.com/ablanco/jquery.pwstrength.bootstrap/blob/1.2.2/GPL-LICENSE.txt" - }, - { - "type": "MIT", - "url": "https://github.com/ablanco/jquery.pwstrength.bootstrap/blob/1.2.2/MIT-LICENSE.txt" - } - ], - "bugs": "https://github.com/ablanco/jquery.pwstrength.bootstrap/issues", - "homepage": "https://github.com/ablanco/jquery.pwstrength.bootstrap", - "docs": "https://github.com/ablanco/jquery.pwstrength.bootstrap/blob/1.2.2/README.md", - "download": "https://github.com/ablanco/jquery.pwstrength.bootstrap/releases", - "dependencies": { - "jquery": ">=1.7" - } -} diff --git a/pwstrength-foundation.jquery.json b/pwstrength-foundation.jquery.json new file mode 100644 index 0000000..5df8609 --- /dev/null +++ b/pwstrength-foundation.jquery.json @@ -0,0 +1,40 @@ +{ + "name": "pwstrength-foundation", + "title": "jQuery Password Strength Meter for Zurb Foundation 5", + "description": "jQuery plugin for Zurb Foundation 5 that provides rulesets for visualy displaying the quality of a users typed in password.", + "keywords": [ + "foundation", + "password", + "strength", + "meter" + ], + "version": "1.2.3", + "author": { + "name": "Ed Townend, Alejandro Blanco other contributors", + "url": "https://github.com/edtownend/jquery.pwstrength.foundation/blob/1.2.3/AUTHORS.txt" + }, + "maintainers": [ + { + "name": "Alejandro Blanco", + "email": "alejandro.b.e@gmail.com", + "url": "http://mensab.com" + } + ], + "licenses": [ + { + "type": "GPLv3", + "url": "https://github.com/edtownend/jquery.pwstrength.foundation/blob/1.2.3/GPL-LICENSE.txt" + }, + { + "type": "MIT", + "url": "https://github.com/edtownend/jquery.pwstrength.foundation/blob/1.2.3/MIT-LICENSE.txt" + } + ], + "bugs": "https://github.com/edtownend/jquery.pwstrength.foundation/issues", + "homepage": "https://github.com/edtownend/jquery.pwstrength.foundation", + "docs": "https://github.com/edtownend/jquery.pwstrength.foundation/blob/1.2.3/README.md", + "download": "https://github.com/edtownend/jquery.pwstrength.foundation/releases", + "dependencies": { + "jquery": ">=1.7" + } +} diff --git a/src/methods.js b/src/methods.js index 48c9ad8..36af8a5 100644 --- a/src/methods.js +++ b/src/methods.js @@ -2,7 +2,7 @@ /*global jQuery, ui, rulesEngine, defaultOptions, zxcvbn, console */ /* -* jQuery Password Strength plugin for Twitter Bootstrap +* jQuery Password Strength plugin for Zurb Foundation * * Copyright (c) 2008-2013 Tane Piper * Copyright (c) 2013 Alejandro Blanco @@ -17,7 +17,7 @@ var methods = {}; onKeyUp = function (event) { var $el = $(event.target), - options = $el.data("pwstrength-bootstrap"), + options = $el.data("pwstrength-foundation"), word = $el.val(), userInputs, verdictText, @@ -62,7 +62,7 @@ var methods = {}; $el = $(el); localOptions.instances = {}; - $el.data("pwstrength-bootstrap", localOptions); + $el.data("pwstrength-foundation", localOptions); $el.on("keyup", onKeyUp); $el.on("change", onKeyUp); $el.on("onpaste", onKeyUp); @@ -83,12 +83,12 @@ var methods = {}; methods.destroy = function () { this.each(function (idx, el) { var $el = $(el), - options = $el.data("pwstrength-bootstrap"), + options = $el.data("pwstrength-foundation"), elements = ui.getUIElements(options, $el); elements.$progressbar.remove(); elements.$verdict.remove(); elements.$errors.remove(); - $el.removeData("pwstrength-bootstrap"); + $el.removeData("pwstrength-foundation"); }); }; @@ -101,7 +101,7 @@ var methods = {}; methods.addRule = function (name, method, score, active) { this.each(function (idx, el) { - var options = $(el).data("pwstrength-bootstrap"); + var options = $(el).data("pwstrength-foundation"); options.rules.activated[name] = active; options.rules.scores[name] = score; @@ -111,7 +111,7 @@ var methods = {}; applyToAll = function (rule, prop, value) { this.each(function (idx, el) { - $(el).data("pwstrength-bootstrap").rules[prop][rule] = value; + $(el).data("pwstrength-foundation").rules[prop][rule] = value; }); }; @@ -131,7 +131,7 @@ var methods = {}; } else if (typeof method === "object" || !method) { result = methods.init.apply(this, arguments); } else { - $.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap"); + $.error("Method " + method + " does not exist on jQuery.pwstrength-foundation"); } return result; diff --git a/src/options.js b/src/options.js index 470e101..1e1feda 100644 --- a/src/options.js +++ b/src/options.js @@ -2,7 +2,7 @@ /*global */ /* -* jQuery Password Strength plugin for Twitter Bootstrap +* jQuery Password Strength plugin for Zurb Foundation * * Copyright (c) 2008-2013 Tane Piper * Copyright (c) 2013 Alejandro Blanco @@ -61,7 +61,7 @@ defaultOptions.rules.activated = { defaultOptions.rules.raisePower = 1.4; defaultOptions.ui = {}; -defaultOptions.ui.bootstrap2 = false; +// defaultOptions.ui.bootstrap2 = false; defaultOptions.ui.showProgressBar = true; defaultOptions.ui.showPopover = false; defaultOptions.ui.showStatus = false; @@ -69,7 +69,8 @@ defaultOptions.ui.spanError = function (options, key) { "use strict"; var text = options.ui.errorMessages[key]; if (!text) { return ''; } - return '' + text + ''; + // return '' + text + ''; + return text; }; defaultOptions.ui.errorMessages = { wordLength: "Your password is too short", @@ -82,11 +83,12 @@ defaultOptions.ui.errorMessages = { defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"]; defaultOptions.ui.showVerdicts = true; defaultOptions.ui.showVerdictsInsideProgressBar = false; -defaultOptions.ui.showErrors = false; +defaultOptions.ui.showErrors = true; defaultOptions.ui.container = undefined; defaultOptions.ui.viewports = { progress: undefined, - verdict: undefined, - errors: undefined + verdict: '.postfix', + errors: undefined, + status: undefined }; defaultOptions.ui.scores = [14, 26, 38, 50]; diff --git a/src/rules.js b/src/rules.js index dc749e8..38b01ea 100644 --- a/src/rules.js +++ b/src/rules.js @@ -2,7 +2,7 @@ /*global jQuery: true, module, require */ /* -* jQuery Password Strength plugin for Twitter Bootstrap +* jQuery Password Strength plugin for Zurb Foundation * * Copyright (c) 2008-2013 Tane Piper * Copyright (c) 2013 Alejandro Blanco diff --git a/src/ui.js b/src/ui.js index 8dec9f8..625ae9a 100644 --- a/src/ui.js +++ b/src/ui.js @@ -2,7 +2,7 @@ /*global jQuery */ /* -* jQuery Password Strength plugin for Twitter Bootstrap +* jQuery Password Strength plugin for Zurb Foundation * * Copyright (c) 2008-2013 Tane Piper * Copyright (c) 2013 Alejandro Blanco @@ -14,8 +14,8 @@ var ui = {}; (function ($, ui) { "use strict"; - var barClasses = ["danger", "warning", "success"], - statusClasses = ["error", "warning", "success"]; + var barClasses = ["alert", "success", "success"], + statusClasses = ["alert", "warning", "success"]; ui.getContainer = function (options, $el) { var $container; @@ -53,7 +53,7 @@ var ui = {}; if (!options.ui.showVerdictsInsideProgressBar) { result.$verdict = ui.findElement($container, options.ui.viewports.verdict, "span.password-verdict"); } - result.$errors = ui.findElement($container, options.ui.viewports.errors, "ul.error-list"); + result.$errors = ui.findElement($container, options.ui.viewports.errors, ".error"); } options.instances.viewports = result; @@ -62,12 +62,7 @@ var ui = {}; ui.initProgressBar = function (options, $el) { var $container = ui.getContainer(options, $el), - progressbar = "
                                                    "; + progressbar = "
                                                    "; if (options.ui.showVerdictsInsideProgressBar) { progressbar += ""; } @@ -95,7 +90,7 @@ var ui = {}; }; ui.initErrorList = function (options, $el) { - ui.initHelper(options, $el, "
                                                      ", + ui.initHelper(options, $el, "", options.ui.viewports.errors); }; @@ -123,22 +118,16 @@ var ui = {}; } }; - ui.possibleProgressBarClasses = ["danger", "warning", "success"]; + ui.possibleProgressBarClasses = ["alert", "warning", "success"]; ui.updateProgressBar = function (options, $el, cssClass, percentage) { var $progressbar = ui.getUIElements(options, $el).$progressbar, - $bar = $progressbar.find(".progress-bar"), - cssPrefix = "progress-"; - - if (options.ui.bootstrap2) { - $bar = $progressbar.find(".bar"); - cssPrefix = ""; - } + $bar = $progressbar.find(".meter"); $.each(ui.possibleProgressBarClasses, function (idx, value) { - $bar.removeClass(cssPrefix + "bar-" + value); + $progressbar.removeClass(value); }); - $bar.addClass(cssPrefix + "bar-" + barClasses[cssClass]); + $progressbar.addClass(barClasses[cssClass]); $bar.css("width", percentage + '%'); }; @@ -148,11 +137,21 @@ var ui = {}; }; ui.updateErrors = function (options, $el) { - var $errors = ui.getUIElements(options, $el).$errors, + var $container = ui.getContainer(options, $el), + $errors = ui.getUIElements(options, $el).$errors, html = ""; $.each(options.instances.errors, function (idx, err) { - html += "
                                                    • " + err + "
                                                    • "; + html += err + "
                                                      "; }); + + if (html !== "") { + $container.addClass('error'); + $errors.show(); + } else { + $container.removeClass('error'); + $errors.hide(); + } + $errors.html(html); }; @@ -182,8 +181,6 @@ var ui = {}; return; } - if (options.ui.bootstrap2) { popover = $el.data("popover"); } - if (popover.$arrow && popover.$arrow.parents("body").length > 0) { $el.find("+ .popover .popover-content").html(html); } else { @@ -194,16 +191,14 @@ var ui = {}; }; ui.updateFieldStatus = function (options, $el, cssClass) { - var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group", - $container = $el.parents(targetClass).first(); + + var $container = options.ui.viewports.status ? $(options.ui.viewports.status) : ui.getContainer(options, $el); $.each(statusClasses, function (idx, css) { - if (!options.ui.bootstrap2) { css = "has-" + css; } $container.removeClass(css); }); cssClass = statusClasses[cssClass]; - if (!options.ui.bootstrap2) { cssClass = "has-" + cssClass; } $container.addClass(cssClass); };