angular-zxcvbn
Advanced tools
Comparing version 3.1.0 to 3.1.1
{ | ||
"name": "angular-zxcvbn", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "Jose Luis Rivas <me@ghostbar.co>", |
@@ -13,3 +13,3 @@ (function () { | ||
template: '{{ display.crack_times_display }}', | ||
link: function (scope) { | ||
link: function (scope, element, attrs) { | ||
scope.$watch('password', function (newVal) { | ||
@@ -23,3 +23,3 @@ if (angular.isString(newVal)) { | ||
if (scope.data && scope.timeToCrack) | ||
if (('data' in attrs) && scope.timeToCrack) | ||
scope.data = angular.copy(scope.timeToCrack); | ||
@@ -26,0 +26,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";angular.module("zxcvbn",[]).directive("zxcvbn",function(){return{scope:{password:"=",extras:"=?",data:"=?"},restrict:"E",template:"{{ display.crack_times_display }}",link:function(r){r.$watch("password",function(t){angular.isString(t)&&(r.extras?r.timeToCrack=zxcvbn(t,r.extras):r.timeToCrack=zxcvbn(t),r.data&&r.timeToCrack&&(r.data=angular.copy(r.timeToCrack)),r.display=angular.copy(r.timeToCrack))})}}})}(),function(){"use strict";angular.module("zxcvbn").directive("zxcvbn",function(){return{require:"ngModel",restrict:"A",scope:{zxResult:"=?zxcvbn",zxExtras:"=?",zxMinScore:"@?"},link:function(r,t,a,e){r.runZxcvbn=function(){return angular.isUndefined(r.zxPassword)?void console.log("Cant run zxcvbn because the password is not defined in the scope."):void(angular.isDefined(r.zxExtrasArray)&&r.zxExtrasArray.length>0?r.zxResult=zxcvbn(r.zxPassword,r.zxExtrasArray):r.zxResult=zxcvbn(r.zxPassword))},r.isForm=function(r){try{return"FormController"===Object.getPrototypeOf(r).constructor.name}catch(t){return!1}},r.setZxExtrasWatcher=function(){var t=r.zxExtras;angular.isFunction(r.zxExtrasWatcher)&&r.zxExtrasWatcher(),r.zxExtrasWatcher=void 0,angular.isDefined(t)&&(angular.isArray(t)?r.zxArrayWatcher():r.isForm(t)&&r.zxFormWatcher())},r.zxFormWatcher=function(){var t=r.zxExtras;console.assert(r.isForm(t),"zx-extras element is some how not a form."),r.zxExtrasWatcher=r.$watch(function(){var r=[],a=new RegExp("^(?!\\$|__)");for(var e in t)a.test(e)&&t[e].hasOwnProperty("$viewValue")&&-1===e.toLowerCase().indexOf("password")&&r.push(t[e].$viewValue);return r},function(t){r.zxExtrasArray=[];for(var a=0;a<t.length;a++)angular.isString(t[a])&&r.zxExtrasArray.push(t[a]);e.$validate()},!0)},r.zxArrayWatcher=function(){r.zxExtrasWatcher=r.$watch("zxExtras",function(t){r.zxExtrasArray=t,e.$validate()},!0)},r.setZxExtrasWatcher(),e.$validators.passwordStrength=function(t){var a=parseInt(r.zxMinScore);return a=isNaN(a)||0>a||a>4?0:a,r.zxPassword=t,r.runZxcvbn(),a<=r.zxResult.score},a.$observe("zxExtras",function(){r.setZxExtrasWatcher(),e.$validate()}),a.$observe("zxMinScore",function(t){r.zxMinScore=t,e.$validate()})}}})}(); | ||
!function(){"use strict";angular.module("zxcvbn",[]).directive("zxcvbn",function(){return{scope:{password:"=",extras:"=?",data:"=?"},restrict:"E",template:"{{ display.crack_times_display }}",link:function(r,t,a){r.$watch("password",function(t){angular.isString(t)&&(r.extras?r.timeToCrack=zxcvbn(t,r.extras):r.timeToCrack=zxcvbn(t),"data"in a&&r.timeToCrack&&(r.data=angular.copy(r.timeToCrack)),r.display=angular.copy(r.timeToCrack))})}}})}(),function(){"use strict";angular.module("zxcvbn").directive("zxcvbn",function(){return{require:"ngModel",restrict:"A",scope:{zxResult:"=?zxcvbn",zxExtras:"=?",zxMinScore:"@?"},link:function(r,t,a,e){r.runZxcvbn=function(){return angular.isUndefined(r.zxPassword)?void console.log("Cant run zxcvbn because the password is not defined in the scope."):void(angular.isDefined(r.zxExtrasArray)&&r.zxExtrasArray.length>0?r.zxResult=zxcvbn(r.zxPassword,r.zxExtrasArray):r.zxResult=zxcvbn(r.zxPassword))},r.isForm=function(r){try{return"FormController"===Object.getPrototypeOf(r).constructor.name}catch(t){return!1}},r.setZxExtrasWatcher=function(){var t=r.zxExtras;angular.isFunction(r.zxExtrasWatcher)&&r.zxExtrasWatcher(),r.zxExtrasWatcher=void 0,angular.isDefined(t)&&(angular.isArray(t)?r.zxArrayWatcher():r.isForm(t)&&r.zxFormWatcher())},r.zxFormWatcher=function(){var t=r.zxExtras;console.assert(r.isForm(t),"zx-extras element is some how not a form."),r.zxExtrasWatcher=r.$watch(function(){var r=[],a=new RegExp("^(?!\\$|__)");for(var e in t)a.test(e)&&t[e].hasOwnProperty("$viewValue")&&-1===e.toLowerCase().indexOf("password")&&r.push(t[e].$viewValue);return r},function(t){r.zxExtrasArray=[];for(var a=0;a<t.length;a++)angular.isString(t[a])&&r.zxExtrasArray.push(t[a]);e.$validate()},!0)},r.zxArrayWatcher=function(){r.zxExtrasWatcher=r.$watch("zxExtras",function(t){r.zxExtrasArray=t,e.$validate()},!0)},r.setZxExtrasWatcher(),e.$validators.passwordStrength=function(t){var a=parseInt(r.zxMinScore);return a=isNaN(a)||0>a||a>4?0:a,r.zxPassword=t,r.runZxcvbn(),a<=r.zxResult.score},a.$observe("zxExtras",function(){r.setZxExtrasWatcher(),e.$validate()}),a.$observe("zxMinScore",function(t){r.zxMinScore=t,e.$validate()})}}})}(); |
{ | ||
"name": "angular-zxcvbn", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Angular directive for the library zxcvbn", | ||
@@ -5,0 +5,0 @@ "main": "dist/angular-zxcvbn.js", |
@@ -5,3 +5,2 @@ # angular-zxcvbn [![Build Status](https://travis-ci.org/ghostbar/angular-zxcvbn.svg?branch=master)](https://travis-ci.org/ghostbar/angular-zxcvbn) | ||
## Table of Contents | ||
@@ -39,2 +38,4 @@ * [Installation](#installation) | ||
Live plunker: <http://plnkr.co/edit/COTgky?p=preview> | ||
The main way to use the directive is as an attribute alongside the `ng-model` attribute: | ||
@@ -84,4 +85,2 @@ ```html | ||
Live plunker: <http://plnkr.co/edit/COTgky?p=preview> | ||
--- | ||
@@ -88,0 +87,0 @@ ### Element |
@@ -13,3 +13,3 @@ (function () { | ||
template: '{{ display.crack_times_display }}', | ||
link: function (scope) { | ||
link: function (scope, element, attrs) { | ||
scope.$watch('password', function (newVal) { | ||
@@ -23,3 +23,3 @@ if (angular.isString(newVal)) { | ||
if (scope.data && scope.timeToCrack) | ||
if (('data' in attrs) && scope.timeToCrack) | ||
scope.data = angular.copy(scope.timeToCrack); | ||
@@ -26,0 +26,0 @@ |
@@ -40,3 +40,2 @@ 'use strict'; | ||
$rootScope.extras = ['randomness']; | ||
$rootScope.fullData = {}; | ||
$compile('<zxcvbn password="password" extras="extras" data="fullData"></zxcvbn>')($rootScope); | ||
@@ -43,0 +42,0 @@ $rootScope.$digest(); |
41362
727
112