Skip to content

Instantly share code, notes, and snippets.

@Bezhok
Last active August 18, 2018 12:01
Show Gist options
  • Save Bezhok/f9b160a7d43d516ae2f3a9620d665fd2 to your computer and use it in GitHub Desktop.
Save Bezhok/f9b160a7d43d516ae2f3a9620d665fd2 to your computer and use it in GitHub Desktop.
/*! Pass*Field v1.1.13 | (c) 2015 Antelle | https://github.com/antelle/passfield/blob/master/MIT-LICENSE.txt */
!function(a,b,c){"use strict";var d=c.PassField=c.PassField||{};d.Config=d.Config||{},d.Config.locales={en:{lower:!0,msg:{pass:"password",and:"and",showPass:"Show password",hidePass:"Hide password",genPass:"Random password",passTooShort:"password is too short (min. length: {})",noCharType:"password must contain {}",digits:"digits",letters:"letters",lettersUp:"letters in UPPER case",symbols:"symbols",inBlackList:"password is in list of top used passwords",passRequired:"password is required",equalTo:"password is equal to login",repeat:"password consists of repeating characters",badChars:"password contains bad characters: “{}”",weakWarn:"weak",invalidPassWarn:"*",weakTitle:"This password is weak",generateMsg:"To generate a strong password, click {} button."}},de:{lower:!1,msg:{pass:"Passwort",and:"und",showPass:"Passwort anzeigen",hidePass:"Passwort verbergen",genPass:"Zufallspasswort",passTooShort:"Passwort ist zu kurz (Mindestlänge: {})",noCharType:"Passwort muss {} enthalten",digits:"Ziffern",letters:"Buchstaben",lettersUp:"Buchstaben in GROSSSCHRIFT",symbols:"Symbole",inBlackList:"Passwort steht auf der Liste der beliebtesten Passwörter",passRequired:"Passwort wird benötigt",equalTo:"Passwort ist wie Anmeldung",repeat:"Passwort besteht aus sich wiederholenden Zeichen",badChars:"Passwort enthält ungültige Zeichen: “{}”",weakWarn:"Schwach",invalidPassWarn:"*",weakTitle:"Dieses Passwort ist schwach",generateMsg:"Klicken Sie auf den {}-Button, um ein starkes Passwort zu generieren."}},fr:{lower:!0,msg:{pass:"mot de passe",and:"et",showPass:"Montrer le mot de passe",hidePass:"Cacher le mot de passe",genPass:"Mot de passe aléatoire",passTooShort:"le mot de passe est trop court (min. longueur: {})",noCharType:"le mot de passe doit contenir des {}",digits:"chiffres",letters:"lettres",lettersUp:"lettres en MAJUSCULES",symbols:"symboles",inBlackList:"le mot de passe est dans la liste des plus utilisés",passRequired:"le mot de passe est requis",equalTo:"le mot de passe est le même que l'identifiant",repeat:"le mot de passe est une répétition de caractères",badChars:"le mot de passe contient des caractères incorrects: “{}”",weakWarn:"faible",invalidPassWarn:"*",weakTitle:"Ce mot de passe est faible",generateMsg:"Pour créer un mot de passe fort cliquez sur le bouton {}."}},it:{lower:!1,msg:{pass:"password",and:"e",showPass:"Mostra password",hidePass:"Nascondi password",genPass:"Password casuale",passTooShort:"la password è troppo breve (lunghezza min.: {})",noCharType:"la password deve contenere {}",digits:"numeri",letters:"lettere",lettersUp:"lettere in MAIUSCOLO",symbols:"simboli",inBlackList:"la password è nella lista delle password più usate",passRequired:"è necessaria una password",equalTo:"la password è uguale al login",repeat:"la password è composta da caratteri che si ripetono",badChars:"la password contiene caratteri non accettati: “{}”",weakWarn:"debole",invalidPassWarn:"*",weakTitle:"Questa password è debole",generateMsg:"Per generare una password forte, clicca sul tasto {}."}},nl:{lower:!0,msg:{pass:"wachtwoord",and:"en",showPass:"Toon wachtwoord",hidePass:"Verberg wachtwoord",genPass:"Willekeurig wachtwoord",passTooShort:"Wachtwoord is te kort (min. lengte: {})",noCharType:"wachtwoord moet {} bevatten",digits:"cijfers",letters:"letters",lettersUp:"hoofdletters",symbols:"symbolen",inBlackList:"wachtwoord is in de lijst meest gebruikte wachtwoorden",passRequired:"wachtwoord is verplicht",equalTo:"wachtwoord is hetzelfde als login",repeat:"wachtwoord bestaat uit herhaalde karakters",badChars:"wachtwoord bevat verboden karakters: “{}”",weakWarn:"zwak",invalidPassWarn:"*",weakTitle:"Dit wachtwoord is zwak",generateMsg:"Klik {} om een sterk wachtwoord te genereren."}},ru:{lower:!0,msg:{pass:"пароль",and:"и",showPass:"Показать пароль",hidePass:"Скрыть пароль",genPass:"Случайный пароль",passTooShort:"пароль слишком короткий (мин. длина: {})",noCharType:"в пароле должны быть {}",digits:"цифры",letters:"буквы",lettersUp:"буквы в ВЕРХНЕМ регистре",symbols:"символы",inBlackList:"этот пароль часто используется в Интернете",passRequired:"пароль обязателен",equalTo:"пароль совпадает с логином",repeat:"пароль состоит из повторяющихся символов",badChars:"в пароле есть недопустимые символы: «{}»",weakWarn:"слабый",invalidPassWarn:"*",weakTitle:"Пароль слабый, его легко взломать",generateMsg:"Чтобы сгенерировать пароль, нажмите кнопку {}."}},ua:{lower:!0,msg:{pass:"пароль",and:"i",showPass:"Показати пароль",hidePass:"Сховати пароль",genPass:"Випадковий пароль",passTooShort:"пароль є занадто коротким (мiн. довжина: {})",noCharType:"пароль повинен містити {}",digits:"цифри",letters:"букви",lettersUp:"букви у ВЕРХНЬОМУ регістрі",symbols:"cимволи",inBlackList:"пароль входить до списку паролей, що використовуються найчастіше",passRequired:"пароль є обов'язковим",equalTo:"пароль та логін однакові",repeat:"пароль містить повторювані символи",badChars:"пароль містить неприпустимі символи: «{}»",weakWarn:"слабкий",invalidPassWarn:"*",weakTitle:"Цей пароль є слабким",generateMsg:"Щоб ​​створити надійний пароль, натисніть кнопку {}."}},es:{lower:!0,msg:{pass:"contraseña",and:"y",showPass:"Mostrar contraseña",hidePass:"Ocultar contraseña",genPass:"Contraseña aleatoria",passTooShort:"contraseña demasiado corta (longitud mín.: {})",noCharType:"la contraseña debe contener {}",digits:"dígitos",letters:"letras",lettersUp:"letras en MAYÚSCULAS",symbols:"símbolos",inBlackList:"la contraseña está en la lista de las contraseñas más usadas",passRequired:"se requiere contraseña",equalTo:"la contraseña es igual al inicio de sesión",repeat:"la contraseña tiene caracteres repetidos",badChars:"la contraseña contiene caracteres no permitidos: “{}”",weakWarn:"débil",invalidPassWarn:"*",weakTitle:"Esta contraseña es débil",generateMsg:"Para generar una contraseña segura, haga clic en el botón de {}."}},el:{lower:!0,msg:{pass:"πρόσβασης",and:"και",showPass:"Προβολή κωδικού πρόσβασης",hidePass:"Απόκρυψη κωδικού πρόσβασης",genPass:"Τυχαίος κωδικός πρόσβασης",passTooShort:"ο κωδικός πρόσβασης είναι πολύ μικρός (ελάχιστο μήκος: {})",noCharType:"ο κωδικός πρόσβασης πρέπει να περιέχει {}",digits:"ψηφία",letters:"λατινικά γράμματα",lettersUp:"λατινικά γράμματα με ΚΕΦΑΛΑΙΑ",symbols:"σύμβολα",inBlackList:"ο κωδικός πρόσβασης βρίσκεται σε κατάλογο δημοφιλέστερων κωδικών",passRequired:"απαιτείται κωδικός πρόσβασης",equalTo:"ο κωδικός είναι όμοιος με το όνομα χρήστη",repeat:"ο κωδικός αποτελείται από επαναλαμβανόμενους χαρακτήρες",badChars:"ο κωδικός περιέχει μη επιτρεπτούς χαρακτήρες: “{}”",weakWarn:"αδύναμος",invalidPassWarn:"*",weakTitle:"Αυτός ο κωδικός πρόσβασης είναι αδύναμος",generateMsg:"Για να δημιουργήσετε δυνατό κωδικό πρόσβασης, κάντε κλικ στο κουμπί {}."}},pt:{lower:!0,msg:{pass:"senha",and:"e",showPass:"Mostrar senha",hidePass:"Ocultar senha",genPass:"Senha aleatória",passTooShort:"senha muito curta (tamanho mínimo: {})",noCharType:"Senha deve conter {}",digits:"dígito",letters:"letras",lettersUp:"letras maiúsculas",symbols:"símbolos",inBlackList:"senha está na lista das senhas mais usadas",passRequired:"senha é obrigatória",equalTo:"senha igual ao login",repeat:"senha consiste em uma repetição de caracteres",badChars:"senha tem caracteres inválidos: “{}”",weakWarn:"fraca",invalidPassWarn:"*",weakTitle:"Esta senha é fraca",generateMsg:"Para gerar uma senha forte, clique no botão {}."}}}}(window.jQuery,document,window),function(a,b,c,d){"use strict";var e=c.PassField=c.PassField||{};e.CharTypes={DIGIT:"digits",LETTER:"letters",LETTER_UP:"lettersUp",SYMBOL:"symbols",UNKNOWN:"unknown"},e.CheckModes={MODERATE:0,STRICT:1},e.Config={defaults:{pattern:"abcdef12",acceptRate:.8,allowEmpty:!0,isMasked:!0,showToggle:!0,showGenerate:!0,showWarn:!0,showTip:!0,tipPopoverStyle:{},strengthCheckTimeout:500,validationCallback:null,blackList:[],locale:"",localeMsg:{},warnMsgClassName:"help-inline form-control-static",errorWrapClassName:"error",allowAnyChars:!0,checkMode:e.CheckModes.MODERATE,chars:{digits:"1234567890",letters:"abcdefghijklmnopqrstuvwxyzßабвгедёжзийклмнопрстуфхцчшщъыьэюяґєåäâáàãéèêëíìîїóòôõöüúùûýñçøåæþðαβγδεζηθικλμνξοπρσςτυφχψω",lettersUp:"ABCDEFGHIJKLMNOPQRSTUVWXYZАБВГЕДЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯҐЄÅÄÂÁÀÃÉÈÊËÍÌÎЇÓÒÔÕÖÜÚÙÛÝÑÇØÅÆÞÐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ",symbols:"@#$%^&*()-_=+[]{};:<>/?!"},events:{generated:null,switched:null},nonMatchField:null,length:{min:null,max:null},maskBtn:{textMasked:"abc",textUnmasked:"&bull;&bull;&bull;",className:!1,classMasked:!1,classUnmasked:!1}},locales:e.Config?e.Config.locales:{},blackList:["password","123456","12345678","abc123","qwerty","monkey","letmein","dragon","111111","baseball","iloveyou","trustno1","1234567","sunshine","master","123123","welcome","shadow","ashley","football","jesus","michael","ninja","mustang","password1","p@ssw0rd","miss","root","secret"],generationChars:{digits:"1234567890",letters:"abcdefghijklmnopqrstuvwxyz",lettersUp:"ABCDEFGHIJKLMNOPQRSTUVWXYZ"},dataAttr:"PassField.Field"},e.Field=function(g,h){function i(a){j(),k()&&(l(),n(),C(),o(),E(),N(Da.isMasked,!1),Q(),ua(e.Config.dataAttr,a))}function j(){Da.blackList=(Da.blackList||[]).concat(e.Config.blackList)}function k(){return"string"==typeof g&&(g=b.getElementById(g)),Ca.mainInput=g,!!Ca.mainInput}function l(){var a="en",b=Da.locale;!b&&navigator.language&&(b=navigator.language.replace(/\-.*/g,"")),b&&(va=Ba.locales[b]),va&&(va=f.extend({},Ba.locales[a],va)),va||(va=f.extend({},Ba.locales[a])),Da.localeMsg&&f.extend(va.msg,Da.localeMsg)}function m(a){Ca.mainInput.value=a,Ca.clearInput&&(Ca.clearInput.value=a),H()}function n(){wa=Ca.mainInput.id,wa||(wa="i"+Math.round(1e5*Math.random()),Ca.mainInput.id=wa)}function o(){var a=ia(Ca.mainInput);a.top+=la(Ca.mainInput,"marginTop"),p(),q(),r(),s(),t(),u(),v(a),w(a),x(),setTimeout(y,0)}function p(){Ca.wrapper=Ca.mainInput.parentNode,qa(Ca.wrapper,"wrap"),Aa.hasInlineBlock||qa(Ca.wrapper,"wrap-no-ib"),"static"===ka(Ca.wrapper,"position")&&(Ca.wrapper.style.position="relative")}function q(){Da.length&&Da.length.max&&Ca.mainInput.setAttribute("maxLength",Da.length.max.toString())}function r(){if(!Aa.changeType){Ca.clearInput=ca("input",{type:"text",id:"txt-clear",className:"txt-clear",value:Ca.mainInput.value},{display:"none"});var a=Ca.mainInput.className;a&&qa(Ca.clearInput,a,!0);var b=Ca.mainInput.style.cssText;b&&(Ca.clearInput.style.cssText=b),f.each(["maxLength","size","placeholder"],function(a){var b=Ca.mainInput.getAttribute(a);b&&Ca.clearInput.setAttribute(a,b)}),ma(Ca.mainInput,Ca.clearInput)}qa(Ca.mainInput,"txt-pass")}function s(){if(Da.showWarn){Ca.warnMsg=ca("p",{id:"warn",className:"warn"},{margin:"0 0 0 3px"}),qa(Ca.warnMsg,"empty"),Da.warnMsgClassName&&qa(Ca.warnMsg,Da.warnMsgClassName,!0);var a=Ca.clearInput||Ca.mainInput;sa(g.parentNode,Sa,!0)&&(a=a.parentNode),ma(a,Ca.warnMsg)}}function t(){if(Da.showToggle){var a=ka(Ca.mainInput,"z-index");Ca.maskBtn=ca("div",{id:"btn-mask",className:"btn-mask",title:va.msg.showPass},{position:"absolute",margin:"0",padding:"0","z-index":a?a+1:null}),qa(Ca.maskBtn,"btn"),Da.maskBtn.className&&qa(Ca.maskBtn,Da.maskBtn.className,!0),Da.maskBtn.classMasked&&qa(Ca.maskBtn,Da.maskBtn.classMasked,!0),oa(Ca.maskBtn,Da.maskBtn.textMasked),na(Ca.mainInput,Ca.maskBtn)}}function u(){if(Da.showGenerate){var a=ka(Ca.mainInput,"z-index");Ca.genBtn=ca("div",{id:"btn-gen",className:"btn-gen",title:va.msg.genPass},{position:"absolute",margin:"0",padding:"0","z-index":a?a+1:null}),qa(Ca.genBtn,"btn"),na(Ca.mainInput,Ca.genBtn),Ca.genBtnInner=ca("div",{id:"btn-gen-i",className:"btn-gen-i",title:va.msg.genPass}),Ca.genBtn.appendChild(Ca.genBtnInner)}}function v(b){if(Da.showTip)if(Da.tipPopoverStyle&&a&&"function"==typeof a.fn.popover)a(Ca.mainInput).popover(f.extend({title:null,placement:Da.tipPopoverStyle.placement||function(b,d){var e=a(d).position().top-a(c).scrollTop(),f=a(c).height()-e;return f>300||f>e?"bottom":"top"},animation:!1},Da.tipPopoverStyle,{trigger:"manual",html:!0,content:function(){return Ma}}));else{Ca.tip=ca("div",{id:"tip",className:"tip"},{position:"absolute",margin:"0",padding:"0",width:b.width+"px"}),na(Ca.mainInput,Ca.tip);var d=ca("div",{id:"tip-arr-wrap",className:"tip-arr-wrap"});Ca.tip.appendChild(d),d.appendChild(ca("div",{id:"tip-arr",className:"tip-arr"})),d.appendChild(ca("div",{id:"tip-arr-in",className:"tip-arr-in"})),Ca.tipBody=ca("div",{id:"tip-body",className:"tip-body"}),Ca.tip.appendChild(Ca.tipBody)}}function w(a){if(Aa.placeholders)!Ca.mainInput.getAttribute("placeholder")&&Ca.mainInput.getAttribute("data-placeholder")&&Ca.mainInput.setAttribute("placeholder",Ca.mainInput.getAttribute("data-placeholder"));else{var b=Ca.mainInput.getAttribute("placeholder")||Ca.mainInput.getAttribute("data-placeholder");b&&(Ca.placeholder=ca("div",{id:"placeholder",className:"placeholder"},{position:"absolute",margin:"0",padding:"0",height:a.height+"px",lineHeight:a.height+"px"}),oa(Ca.placeholder,b),na(Ca.mainInput,Ca.placeholder))}}function x(){Aa.passSymbol&&(Ca.passLengthChecker=ca("div",{id:"len"},{position:"absolute",height:ka(Ca.mainInput,"height"),top:"-10000px",left:"-10000px",display:"block",color:"transparent",border:"none"}),na(Ca.mainInput,Ca.passLengthChecker),setTimeout(function(){f.each(["marginLeft","fontFamily","fontSize","fontWeight","fontStyle","fontVariant"],function(a){var b=ka(Ca.mainInput,a);b&&(Ca.passLengthChecker.style[a]=b)})},50))}function y(){A(),B();var a=ia(D()),b=z();Ca.maskBtn&&"none"!==Ca.maskBtn.style.display&&(b+=la(Ca.maskBtn,"width"),ja(Ca.maskBtn,{top:a.top,left:a.left+a.width-b,height:a.height})),Ca.genBtn&&"none"!==Ca.genBtn.style.display&&(b+=la(Ca.genBtn,"width"),ja(Ca.genBtn,{top:a.top,left:a.left+a.width-b,height:a.height}),Ca.genBtnInner.style.marginTop=Math.max(0,Math.round((a.height-19)/2))+"px"),Ca.placeholder&&"none"!==Ca.placeholder.style.display&&ja(Ca.placeholder,{top:a.top,left:a.left+7,height:a.height}),Ca.tip&&"none"!==Ca.tip.style.display&&ja(Ca.tip,{left:a.left,top:a.top+a.height,width:a.width})}function z(){var a=la(D(),"paddingRight");return Math.max(Pa,a)}function A(){Ca.genBtn&&(Ca.genBtn.style.display=Ha||Ia&&!Ja?"block":"block"),Ca.maskBtn&&(Ca.maskBtn.style.display=Ha||Ia&&!Ka?"block":"block")}function B(){if(Da.showTip)if(Ca.tip)Ca.tip.style.display=Fa&&Ia?"block":"none";else if(Fa&&Ia){if(!La||Ma!==La){var b=a(Ca.mainInput).data("popover")||a(Ca.mainInput).data("bs.popover"),c=b.options,d=c.animation;La&&(c.animation=!1);var e=D().offsetWidth-2,f=b.$tip;f?f.width(e):b.options.template&&(b.options.template=b.options.template.replace('class="popover"','class="popover" style="width: '+e+'px"')),Ca.clearInput&&(b.$element=a(D())),a(Ca.mainInput).popover("show"),La=Ma,c.animation=d}}else La&&(La=null,a(Ca.mainInput).popover("hide"))}function C(){var a=!0,c=!0,d=b.createElement("input");"placeholder"in d||(a=!1),d.setAttribute("style","position:absolute;left:-10000px;top:-10000px;"),b.body.appendChild(d);try{d.setAttribute("type","password")}catch(e){c=!1}b.body.removeChild(d);var f=b.createElement("div");f.setAttribute("style","display:inline-block"),f.style.paddingLeft=f.style.width="1px",b.body.appendChild(f);var g=2===f.offsetWidth,h="inline-block"===ka(f,"display");b.body.removeChild(f);var i=navigator.userAgent.indexOf("AppleWebKit")>=0||navigator.userAgent.indexOf("Opera")>=0||navigator.userAgent.indexOf("Firefox")>=0&&navigator.platform.indexOf("Mac")>=0?"•":"●";Aa={placeholders:a,changeType:c,boxModel:g,hasInlineBlock:h,passSymbol:i}}function D(){return Ea?Ca.mainInput:Ca.clearInput||Ca.mainInput}function E(){if(f.each(Ca.clearInput?[Ca.mainInput,Ca.clearInput]:[Ca.mainInput],function(a){f.attachEvent(a,"onkeyup",H),f.attachEvent(a,"onfocus",K),f.attachEvent(a,"onblur",L),f.attachEvent(a,"onmouseover",G),f.attachEvent(a,"onmouseout",G),Ca.placeholder&&f.attachEvent(a,"onkeydown",J)}),f.attachEvent(c,"onresize",y),Ca.maskBtn&&(f.attachEvent(Ca.maskBtn,"onclick",function(){N()}),f.attachEvent(Ca.maskBtn,"onmouseover",G),f.attachEvent(Ca.maskBtn,"onmouseout",G)),Ca.genBtn&&(f.attachEvent(Ca.genBtn,"onclick",function(){R()}),f.attachEvent(Ca.genBtn,"onmouseover",G),f.attachEvent(Ca.genBtn,"onmouseout",G)),Ca.placeholder&&f.attachEvent(Ca.placeholder,"onclick",F),Da.nonMatchField){var a=pa(Da.nonMatchField);a&&f.attachEvent(a,"onkeyup",M)}}function F(){D().focus()}function G(a){var b="mouseover"===a.type,c=a.relatedTarget?a.relatedTarget:b?a.fromElement:a.toElement;(!c||!c.id||0!==c.id.indexOf(Na+"btn")&&c!==Ca.mainInput&&c!==Ca.clearInput)&&(Ha=b,y())}function H(a){var b,c=a?a.which||a.keyCode:null,d=c===Ra||c===Qa;b=Ca.clearInput?Ea?Ca.clearInput.value=Ca.mainInput.value:Ca.mainInput.value=Ca.clearInput.value:Ca.mainInput.value,Da.strengthCheckTimeout>0&&!Fa&&!d?(xa&&clearTimeout(xa),xa=setTimeout(S,Da.strengthCheckTimeout)):S(),Ca.placeholder&&!b&&(Ca.placeholder.style.display="block"),I()}function I(){if(Ca.passLengthChecker){var a=D().value;Ea&&(a=a.replace(/./g,Aa.passSymbol)),oa(Ca.passLengthChecker,a);var b=Ca.passLengthChecker.offsetWidth;b+=la(Ca.mainInput,"paddingLeft");var c=0,d=0,e=ha(D()),f=e.width,g=!1,h=z();if(Ca.maskBtn){c=la(Ca.maskBtn,"width");var i=f-c-h,j=b>i;Ka!==j&&(g=!0,Ka=j)}if(Ca.genBtn){d=la(Ca.genBtn,"width");var k=f-c-d-h,l=b>k;Ja!==l&&(g=!0,Ja=l)}g&&y()}}function J(){Ca.placeholder&&(Ca.placeholder.style.display="none")}function K(){ya&&(clearTimeout(ya),ya=null),za&&(clearTimeout(za),za=null),Ia=!0,y()}function L(){ya=setTimeout(function(){ya=null,Ia=!1,y(),Da.isMasked&&!za&&(za=setTimeout(function(){za=null,N(!0,!1)},1500))},100)}function M(){Fa&&S()}function N(a,b){b===d&&(b=!0);var c=a!==Ea;if(a=a===d?!Ea:!!a,Aa.changeType){var e=D(),g=O(e);e.setAttribute("type",a?"password":"text"),b&&(P(e,g),e.focus())}else{var h=ka(D(),"display")||"block",i=a?Ca.clearInput:Ca.mainInput,j=a?Ca.mainInput:Ca.clearInput;Ea!==a&&f.each(["paddingRight","width","backgroundImage","backgroundPosition","backgroundRepeat","backgroundAttachment","border"],function(a){var b=i.style[a];b&&(j.style[a]=b)});var k=O(i);j.style.display=h,i.style.display="none",j.value=i.value,b&&(P(j,k),j.focus()),Ca.mainInput.nextSibling!==Ca.clearInput&&ma(Ca.mainInput,Ca.clearInput)}Ca.maskBtn&&(oa(Ca.maskBtn,a?Da.maskBtn.textMasked:Da.maskBtn.textUnmasked),a?(Da.maskBtn.classUnmasked&&ra(Ca.maskBtn,Da.maskBtn.classUnmasked,!0),Da.maskBtn.classMasked&&qa(Ca.maskBtn,Da.maskBtn.classMasked,!0)):(Da.maskBtn.classMasked&&ra(Ca.maskBtn,Da.maskBtn.classMasked,!0),Da.maskBtn.classUnmasked&&qa(Ca.maskBtn,Da.maskBtn.classUnmasked,!0)),Ca.maskBtn.title=a?va.msg.showPass:va.msg.hidePass),Ea=a,I(),y(),c&&ta("switched",Ea)}function O(a){return"number"==typeof a.selectionStart&&"number"==typeof a.selectionEnd?{start:a.selectionStart,end:a.selectionEnd}:null}function P(a,b){b&&"number"==typeof a.selectionStart&&"number"==typeof a.selectionEnd&&(a.selectionStart=b.start,a.selectionEnd=b.end)}function Q(){("function"==typeof Ca.mainInput.hasAttribute&&Ca.mainInput.hasAttribute("autofocus")||Ca.mainInput.getAttribute("autofocus"))&&(Ca.mainInput.focus(),K())}function R(){var a=$();Ca.mainInput.value=a,Ca.clearInput&&(Ca.clearInput.value=a),ta("generated",a),N(!1),xa&&(clearTimeout(xa),xa=null),S(),Ca.placeholder&&(Ca.placeholder.style.display="none")}function S(){xa&&(clearTimeout(xa),xa=null);var a=D().value,b=T(a);if(0===a.length)b={strength:Da.allowEmpty?0:null,messages:[va.msg.passRequired]};else{!Da.allowAnyChars&&b.charTypes[e.CharTypes.UNKNOWN]&&(b={strength:null,messages:[va.msg.badChars.replace("{}",b.charTypes[e.CharTypes.UNKNOWN])]}),delete b.charTypes;var c=!1;f.each(Da.blackList,function(b){return b===a?(c=!0,!1):!0}),c&&(b={strength:0,messages:[va.msg.inBlackList]}),a&&a===X()&&(b={strength:0,messages:[va.msg.equalTo]})}if("function"==typeof Da.validationCallback){var d,g,h=Da.validationCallback(Ca.mainInput,b);h&&h.messages&&f.isArray(h.messages)&&(d=h.messages),h&&Object.prototype.hasOwnProperty.call(h,"strength")&&("number"==typeof h.strength||null===h.strength)&&(g=h.strength),d&&d.length?(b.messages=d,b.strength=g):g&&g>b.strength&&(b.strength=g)}return 0===a.length&&Da.allowEmpty?(W(),Ga={strength:0},!0):null===b.strength||b.strength<Da.acceptRate?(V(b.strength,b.messages),!1):(W(),Ga={strength:b.strength},!0)}function T(a){var b=_(Da.pattern,e.CharTypes.SYMBOL),c=_(a,Da.allowAnyChars?e.CharTypes.SYMBOL:e.CharTypes.UNKNOWN),d=[],g=0;f.each(b,function(a){if(g++,!c[a]){var b=va.msg[a];if(a===e.CharTypes.SYMBOL){var f=4,h=Da.chars[a];h.length>f&&(h=h.substring(0,f)),b=b+" ("+h+")"}d.push(b)}});var h=1-d.length/g;if(d.length&&(d=[U(d)]),Da.checkMode===e.CheckModes.MODERATE){var i=0;f.each(c,function(a){b[a]||i++}),h+=i/g}var j=Da.pattern.length,k=a.length/j-1;if(Da.length&&Da.length.min&&a.length<Da.length.min&&(k=-10,Da.length.min>j&&(j=Da.length.min)),0>k?(h+=k,d.push(va.msg.passTooShort.replace("{}",j.toString()))):Da.checkMode===e.CheckModes.MODERATE&&(h+=k/g),a.length>2){for(var l=a.charAt(0),m=!0,n=0;n<a.length;n++)if(a.charAt(n)!==l){m=!1;break}m&&(h=0,d=[va.msg.repeat])}return 0>h&&(h=0),h>1&&(h=1),{strength:h,messages:d,charTypes:c}}function U(a){for(var b=a[0],c=1;c<a.length;c++)b+=c===a.length-1?" "+va.msg.and+" ":", ",b+=a[c];return va.msg.noCharType.replace("{}",b)}function V(a,b){var c="",d="";if(null===a)c=va.msg.invalidPassWarn,d=b[0].charAt(0).toUpperCase()+b[0].substring(1);else if(c=va.msg.weakWarn,d="",b)for(var e=0;e<b.length;e++){var f=b[e].charAt(0);0===e?(d+=va.msg.weakTitle+": ",va.lower&&(f=f.toLowerCase())):(d+="<br/>",f=f.toUpperCase()),d+=f+b[e].substring(1),d&&"."!==d.charAt(d.length-1)&&(d+=".")}if(d&&"."!==d.charAt(d.length-1)&&(d+="."),Ga={strength:a,message:d},Ca.warnMsg&&(oa(Ca.warnMsg,c),Ca.warnMsg.title=d,Da.errorWrapClassName&&qa(Ca.wrapper,Da.errorWrapClassName,!0),c?ra(Ca.warnMsg,"empty"):qa(Ca.warnMsg,"empty")),Da.showTip){var g=d;Ca.genBtn&&(g+="<br/>"+va.msg.generateMsg.replace("{}",'<div class="'+ba("btn-gen-help")+'"></div>')),Ma=g,Ca.tipBody&&oa(Ca.tipBody,g)}Fa=!0,y()}function W(){Ca.warnMsg&&(oa(Ca.warnMsg,""),Ca.warnMsg.title="",Da.errorWrapClassName&&ra(Ca.wrapper,Da.errorWrapClassName,!0),qa(Ca.warnMsg,"empty")),Ma=null,Fa=!1,y()}function X(){if(!Da.nonMatchField)return null;var a=pa(Da.nonMatchField);return a?a.value:null}function Y(){return Ga?Ga.message:null}function Z(){return Ga?Ga.strength:-1}function $(){var a="",b=_(Da.pattern,e.CharTypes.SYMBOL),c=[];return f.each(b,function(a,b){for(var d=0;d<b.length;d++)c.push(a)}),c.sort(function(){return.7-Math.random()}),f.each(c,function(b){var c=Ba.generationChars[b];c?Da.chars[b]&&Da.chars[b].indexOf(c)<0&&(c=Da.chars[b]):c=Da.chars[b],a+=f.selectRandom(c)}),a}function _(a,b){for(var c={},d=0;d<a.length;d++){var e=a.charAt(d),g=b;f.each(Da.chars,function(a,b){return b.indexOf(e)>=0?(g=a,!1):!0}),c[g]=(c[g]||"")+e}return c}function aa(a){return Na+a+"-"+wa}function ba(a){return Na+a}function ca(a,b,c){return b.id&&(b.id=aa(b.id)),b.className&&(b.className=ba(b.className)),f.newEl(a,b,c)}function da(a){try{return a.getBoundingClientRect()}catch(b){return{top:0,left:0}}}function ea(a){var b=a.ownerDocument;if(!b)return{top:0,left:0};var d=da(a);return{top:d.top+(c.pageYOffset||0)-(b.documentElement.clientTop||0),left:d.left+(c.pageXOffset||0)-(b.documentElement.clientLeft||0)}}function fa(a){var c;try{c=a.offsetParent}catch(d){}for(c||(c=b.documentElement);c&&"html"!==c.nodeName.toLowerCase()&&"static"===ka(c,"position");)c=c.offsetParent;return c||b.documentElement}function ga(a){var b,c={top:0,left:0};if("fixed"===ka(a,"position"))b=da(a);else{var d=fa(a);b=ea(a),"html"!==d.nodeName.toLowerCase()&&(c=ea(d)),c.top+=la(d,"borderTopWidth"),c.left+=la(d,"borderLeftWidth")}return{top:b.top-c.top-la(a,"marginTop"),left:b.left-c.left-la(a,"marginLeft")}}function ha(a){return{width:a.offsetWidth,height:a.offsetHeight}}function ia(a){return f.extend(ea(a),ha(a))}function ja(a,b){if(b.height&&!isNaN(b.height)&&(a.style.height=b.height+"px",a.style.lineHeight=b.height+"px"),b.width&&!isNaN(b.width)&&(a.style.width=b.width+"px"),b.top||b.left){if("none"===ka(a,"display"))return a.style.top=b.top+"px",void(a.style.left=b.left+"px");var c,d,e;if(e=ea(a),d=ka(a,"top")||0,c=ka(a,"left")||0,(d+c+"").indexOf("auto")>-1){var f=ga(a);d=f.top,c=f.left}else d=parseFloat(d)||0,c=parseFloat(c)||0;b.top&&(a.style.top=b.top-e.top+d+"px"),b.left&&(a.style.left=b.left-e.left+c+"px")}}function ka(a,b){var d="function"==typeof c.getComputedStyle?c.getComputedStyle(a,null):a.currentStyle;return d?d[b]:null}function la(a,b){var c=ka(a,b);if(!c)return 0;var d=parseFloat(c);return isNaN(d)?0:d}function ma(a,b){a.parentNode&&a.parentNode.insertBefore(b,a.nextSibling)}function na(a,b){a.parentNode&&a.parentNode.insertBefore(b,a)}function oa(a,c){try{a.innerHTML=c}catch(d){var e=b.createElement("c");for(e.innerHTML=c;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(e)}}function pa(a){return"string"==typeof a?b.getElementById(a):a.jquery?a[0]:a}function qa(a,b,c){sa(a,b,c)||(a.className=a.className+(a.className?" ":"")+(c===!0?b:ba(b)))}function ra(a,b,c){sa(a,b,c)&&(a.className=(" "+a.className+" ").replace((c===!0?b:ba(b))+" ","").replace(/^\s+|\s+$/g,""))}function sa(a,b,c){return b=" "+(c===!0?b:ba(b))+" ",(" "+a.className+" ").replace(/[\n\t]/g," ").indexOf(b)>-1}function ta(b,c){if(a)try{a(Ca.mainInput).trigger(Oa+b,c)}catch(d){}if(Da.events&&"function"==typeof Da.events[b])try{Da.events[b].call(Ca.mainInput,c)}catch(d){}}function ua(b,c){a&&a(Ca.mainInput).data(b,c)}var va,wa,xa,ya,za,Aa,Ba=e.Config,Ca={},Da=f.extend({},Ba.defaults,h),Ea=!0,Fa=!1,Ga=null,Ha=!1,Ia=!1,Ja=!1,Ka=!1,La=!1,Ma=null,Na="a_pf-",Oa="pass:",Pa=5,Qa=46,Ra=8,Sa="input-group";this.toggleMasking=function(a){N(a)},this.setPass=m,this.validatePass=S,this.getPassValidationMessage=Y,this.getPassStrength=Z,i(this)};var f={};f.extend=function(){for(var a=arguments,b=1;b<a.length;b++)f.each(a[b],function(b,c){f.isArray(a[0][b])||f.isArray(c)?a[0][b]=a[0][b]?a[0][b].concat(c||[]):c:f.isElement(c)?a[0][b]=c:"object"==typeof a[0][b]&&"object"==typeof c&&null!==c?a[0][b]=f.extend({},a[0][b],c):"object"==typeof c&&null!==c?a[0][b]=f.extend({},c):a[0][b]=c});return a[0]},f.newEl=function(a,c,d){var e=b.createElement(a);return c&&f.each(c,function(a,b){b&&(e[a]=b)}),d&&f.each(d,function(a,b){b&&(e.style[a]=b)}),e},f.attachEvent=function(a,b,d){var e=a[b];a[b]=function(a){a||(a=c.event),d(a),"function"==typeof e&&e(a)}},f.each=function(a,b){if(f.isArray(a)){for(var c=0;c<a.length;c++)if(b(a[c])===!1)return}else for(var d in a)if(Object.prototype.hasOwnProperty.call(a,d)&&b(d,a[d])===!1)return},f.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},f.isElement=function(b){if(!b)return!1;try{return b instanceof HTMLElement||a&&b instanceof a}catch(c){return"object"==typeof b&&b.nodeType||b.jquery}},f.selectRandom=function(a){var b=Math.floor(Math.random()*a.length);return f.isArray(a)?a[b]:a.charAt(b)},f.contains=function(a,b){if(!a)return!1;var c=!1;return f.each(a,function(a){return a===b?(c=!0,!1):!0}),c},a&&(a.fn.passField=function(a){return this.each(function(){new e.Field(this,a)})},a.fn.togglePassMasking=function(b){return this.each(function(){var c=a(this).data(e.Config.dataAttr);c&&c.toggleMasking(b)})},a.fn.setPass=function(b){return this.each(function(){var c=a(this).data(e.Config.dataAttr);c&&c.setPass(b)})},a.fn.validatePass=function(){var b=!0;return this.each(function(){var c=a(this).data(e.Config.dataAttr);c&&!c.validatePass()&&(b=!1)}),b},a.fn.getPassValidationMessage=function(){var a=this.first();if(a){var b=a.data(e.Config.dataAttr);if(b)return b.getPassValidationMessage()}return null},a.fn.getPassStrength=function(){var a=this.first();if(a){var b=a.data(e.Config.dataAttr);if(b)return b.getPassStrength()}return null}),a&&a.validator&&a.validator.addMethod("passfield",function(b,c){return a(c).validatePass()},function(b,c){return a(c).getPassValidationMessage()})}(window.jQuery,document,window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment