www-thermferm/jqwidgets/jqxpasswordinput.js

Sat, 25 Apr 2020 20:31:31 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 25 Apr 2020 20:31:31 +0200
changeset 605
e00f8ff4de9a
parent 511
2d1d43c3a2c2
child 617
b216f9d4b917
permissions
-rw-r--r--

Version 0.9.8. Added extra path to the fonts for Debian buster. Changed the PID to work on Proportional on Measurement. Added loops so that it looks like the PID is running at 100 mSec intervals.

117
7119ea8a5225 Initial setup of wqwidgets
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*
511
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
2 jQWidgets v4.5.2 (2017-May)
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
3 Copyright (c) 2011-2017 jQWidgets.
117
7119ea8a5225 Initial setup of wqwidgets
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 License: http://jqwidgets.com/license/
511
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
5 */
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
6 !function(a){"use strict";a.jqx.jqxWidget("jqxPasswordInput","",{}),a.extend(a.jqx._jqxPasswordInput.prototype,{defineInstance:function(){var b={width:null,height:null,disabled:!1,rtl:!1,placeHolder:null,showStrength:!1,showStrengthPosition:"right",maxLength:null,minLength:null,showPasswordIcon:!0,strengthTypeRenderer:null,passwordStrength:null,changeType:null,localization:{passwordStrengthString:"Password strength",tooShort:"Too short",weak:"Weak",fair:"Fair",good:"Good",strong:"Strong",showPasswordString:"Show Password"},strengthColors:{tooShort:"rgb(170, 0, 51)",weak:"rgb(170, 0, 51)",fair:"rgb(255, 204, 51)",good:"rgb(45, 152, 243)",strong:"rgb(118, 194, 97)"}};return this===a.jqx._jqxPasswordInput.prototype?b:(a.extend(!0,this,b),b)},createInstance:function(){var a=this;a._inDOM=document.body.contains(a.element),a.render()},render:function(){var b=this,c=a.jqx.browser.browser,d=a.jqx.browser.version;this._browserCheck="msie"!=c||"7.0"!=d&&"8.0"!=d,this.widgetID=b.element.id;var e="Invalid input type. Please set the type attribute of the input element to password.";if("password"!=this.element.getAttribute("type"))throw e;b._hidden=!0,b._setTheme(),b._setAttributes(),b._showPassword(),b._showStrength(),a.jqx.utilities.resize(this.host,function(){if(!b._inDOM){var a=b.element.parentNode;return b.element.nextSibling?a.insertBefore(b.icon,b.element.nextSibling):a.appendChild(b.icon),void(b._inDOM=!0)}b.element===document.activeElement&&(b._positionIcon(),b.showStrength&&b.host.jqxTooltip("close"))})},refresh:function(b){var c=this;b||(c.removeHandler(c.host,"change.passwordinput"+c.widgetID),c.removeHandler(c.host,"focus.passwordinput"+c.widgetID),c.removeHandler(c.host,"blur.passwordinput"+c.widgetID),c.removeHandler(c.host,"click.passwordinput"+c.widgetID),c.removeHandler(c.host,"keyup.passwordinput"+c.widgetID),c.removeHandler(c.icon,"mousedown.passwordinput"+c.widgetID),c.removeHandler(a(document),"mouseup.passwordinput"+c.widgetID),c.removeHandler(a(document),"mousedown.passwordinput"+c.widgetID),c._setAttributes(),c._setTheme(),c._showPassword(),c._showStrength())},val:function(b){var c=this,d=c.element.value,e="placeholder"in c.element;if(a.isEmptyObject(b)&&""!==b)return e||d!==c.placeHolder||(d=""),d;if(!e||b!==d){if(!e){if(""===b)return void(d!==c.placeHolder&&(c.element.value=c.placeHolder,c.element.setAttribute("type","text")));c.element.setAttribute("type","password")}c.element.value=b,c.showStrength===!0&&c._evaluateStrength()}},propertyChangedHandler:function(b,c,d,e){return"theme"===c?void a.jqx.utilities.setTheme(d,e,b.host):"disabled"==c?void(b.disabled?(b.element.setAttribute("disabled","disabled"),b.element.className+=" "+b.toThemeProperty("jqx-fill-state-disabled")):(b.host.removeAttr("disabled"),b.host.removeClass(b.toThemeProperty("jqx-fill-state-disabled")))):void("placeHolder"==c?this._browserCheck&&("placeholder"in this.element?b.element.setAttribute("placeholder",b.placeHolder):""===b.element.value?(b.element.setAttribute("type","text"),b.element.value=e):b.element.value==d&&(b.element.value=e)):this.refresh())},resize:function(a,b){this.width=a,this.height=b,this.element.style.width=this._toPx(a),this.element.style.height=this._toPx(b)},_setAttributes:function(){var a=this,b=a.element;b.style.width=a._toPx(a.width),b.style.height=a._toPx(a.height),a.maxLength&&b.setAttribute("maxlength",a.maxLength),a.minLength&&b.setAttribute("minLength",a.minLength),a.placeHolder&&a._browserCheck&&("placeholder"in a.element?b.setAttribute("placeholder",a.placeHolder):""===b.value&&(b.setAttribute("type","text"),b.value=a.placeHolder)),a.disabled?(b.setAttribute("disabled","disabled"),b.className+=" "+this.toThemeProperty("jqx-fill-state-disabled")):(b.removeAttribute("disabled"),a.host.removeClass(a.toThemeProperty("jqx-fill-state-disabled")));var c=!1;a.addHandler(b,"change.passwordinput"+a.widgetID,function(b){c||(b.preventDefault(),b.stopPropagation(),c=!0,a._raiseEvent(),c=!1)}),a.addHandler(b,"click.passwordinput"+a.widgetID,function(){a.showPasswordIcon&&a.icon&&(a.icon.style.display="inline",a._positionIcon())}),a.interval=null,a.addHandler(b,"keydown.passwordinput"+a.widgetID,function(){if(a.changeType="keyboard",a.showPasswordIcon&&a.icon){a.interval&&clearInterval(a.interval);var b=0;a.interval=setInterval(function(){"none"!=a.icon.style.display?(a._positionIcon(),b++,b>5&&clearInterval(a.interval)):clearInterval(a.interval)},100)}}),a.addHandler(b,"focus.passwordinput"+a.widgetID,function(){if(a._focused=!0,b.className+=" "+a.toThemeProperty("jqx-fill-state-focus"),!a.placeHolder||!a._browserCheck||"placeholder"in a.element||b.value!=a.placeHolder||(b.value="",a._hidden&&b.setAttribute("type","password")),a.val().length>0&&a.showStrength){var c=a.host.jqxTooltip("content");c&&a.host.jqxTooltip("open")}a.showPasswordIcon&&a.icon&&(a.icon.style.display="inline",a._positionIcon())}),a.addHandler(b,"blur.passwordinput"+a.widgetID,function(){a._focused=!1,a.host.removeClass(a.toThemeProperty("jqx-fill-state-focus")),!a.placeHolder||!a._browserCheck||"placeholder"in a.element||""!==b.value||(a.element.value=a.placeHolder,a.element.setAttribute("type","text")),a.showPasswordIcon&&a._browserCheck&&(a.rtl===!1?a.host.removeClass(a.toThemeProperty("jqx-passwordinput-password-icon-ltr")):a.host.removeClass(a.toThemeProperty("jqx-passwordinput-password-icon-rtl"))),a.showStrength&&a.host.jqxTooltip("close"),a.showPasswordIcon&&a.icon&&(a.icon.style.display="none")})},destroy:function(){this.host.jqxTooltip&&this.host.jqxTooltip("destroy"),this.host.remove()},_setTheme:function(){var a=this,b="jqx-widget jqx-widget-content jqx-input jqx-rc-all";a.rtl?(b+=" jqx-rtl",a.element.style.direction="rtl"):(a.host.removeClass(a.toThemeProperty("jqx-rtl")),a.element.style.direction="ltr"),a.element.className+=" "+a.toThemeProperty(b)},_showPassword:function(){if(this.showPasswordIcon&&this._browserCheck){var b=this,c=document.createElement("span"),d=".passwordinput"+b.widgetID;c.setAttribute("tabindex",-1),c.setAttribute("hasfocus",!1),c.setAttribute("title",b.localization.showPasswordString),c.style.position="absolute",c.style.display="none",c.className=b.toThemeProperty("jqx-passwordinput-password-icon");var e=b.element.parentNode;e&&(b.element.nextSibling?e.insertBefore(c,b.element.nextSibling):e.appendChild(c)),b.icon=c,b._positionIcon();var f=function(){b.element.setAttribute("type","password"),b._hidden=!0},g=function(){b._hidden===!1?f():b._hidden&&(b.element.setAttribute("type","text"),b._hidden=!1)},h=a.jqx.mobile.isTouchDevice();h?b.addHandler(b.icon,"mousedown"+d,function(){return g(),!1}):(b.addHandler(b.icon,"mousedown"+d,function(){return g(),!1}),b.addHandler(a(document),"mouseup"+d,function(){return f(),!1}),b.addHandler(a(document),"mousedown"+d,function(){b._focused&&f()}))}},_positionIcon:function(){var b=this.host.offset(),c=this.element.offsetWidth,d=this.element.offsetHeight,e=a(this.icon);this.rtl?e.offset({top:parseInt(b.top+d/2-5,10),left:b.left+2}):e.offset({top:parseInt(b.top+d/2-5,10),left:b.left+c-18})},_showStrength:function(){var a=this;if(a.showStrength){if(!a.host.jqxTooltip)throw new Error("jqxPasswordInput: Missing reference to jqxtooltip.js");var b,c=a.widgetID+"Strength",d=c+"Value",e=c+"Indicator";if(a.strengthTypeRenderer){var f=a.element.value;"placeholder"in a.element||!a._browserCheck||f!=a.placeHolder||(f=""),a._countCharacters();var g=a.localization.tooShort,h=a.strengthTypeRenderer(f,{letters:a.letters,numbers:a.numbers,specialKeys:a.specials},g);b=h}else b='<div style="width: 220px;"><div><span style="font-weight: bold;">'+a.localization.passwordStrengthString+': </span><span id="'+d+'"></span></div><div id="'+e+'"></div></div>';if(a.host.jqxTooltip({theme:a.theme,position:a.showStrengthPosition,content:b,trigger:"none",autoHide:!1,rtl:a.rtl}),!a.strengthTypeRenderer){var i=document.getElementById(e);document.getElementById(d).innerHTML=a.localization.tooShort,i.className+=" jqx-passwordinput-password-strength-inicator",i.style.backgroundColor=a.strengthColors.tooShort,a.rtl===!1?i.style.float="left":i.style.float="right"}a._checkStrength()}},_checkStrength:function(){var a=this;a.addHandler(a.host,"keyup.passwordinput"+a.widgetID,function(){a._evaluateStrength()})},_raiseEvent:function(){var b=new a.Event("change");b.args={type:this.changeType},this.changeType=null,b.owner=this;var c=this.host.trigger(b);return c},_evaluateStrength:function(){var b=this,c=b.element.value,d=c.length;if(b._countCharacters(),d>0&&b.showStrength){var e=!b.host.jqxTooltip("opened");e&&b.host.jqxTooltip("open")}var f,g=b.letters+b.numbers+2*b.specials+b.letters*b.numbers/2+d;f=d<8?b.localization.tooShort:g<20?b.localization.weak:g<30?b.localization.fair:g<40?b.localization.good:b.localization.strong;var h;if(b.strengthTypeRenderer)h=b.strengthTypeRenderer(c,{letters:b.letters,numbers:b.numbers,specialKeys:b.specials},f),b.host.jqxTooltip({content:h});else{b.passwordStrength&&(h=b.passwordStrength(c,{letters:b.letters,numbers:b.numbers,specialKeys:b.specials},f),a.each(b.localization,function(){var a=this;if(h==a)return f=h,!1})),document.getElementById(b.widgetID+"StrengthValue").innerHTML=f;var i,j,k=document.getElementById(b.widgetID+"StrengthIndicator");switch(f){case b.localization.tooShort:i="20%",j=b.strengthColors.tooShort;break;case b.localization.weak:i="40%",j=b.strengthColors.weak;break;case b.localization.fair:i="60%",j=b.strengthColors.fair;break;case b.localization.good:i="80%",j=b.strengthColors.good;break;case b.localization.strong:i="100%",j=b.strengthColors.strong}k.style.width=i,k.style.backgroundColor=j}},_countCharacters:function(){var a=this;a.letters=0,a.numbers=0,a.specials=0;for(var b="<>@!#$%^&*()_+[]{}?:;|'\"\\,./~`-=",c=a.element.value,d=c.length,e=0;e<d;e++){var f=c.charAt(e),g=c.charCodeAt(e);g>64&&g<91||g>96&&g<123||g>127&&g<155||g>159&&g<166?a.letters+=1:isNaN(f)!==!1?b.indexOf(f)==-1||(a.specials+=1):a.numbers+=1}},_toPx:function(a){return"number"==typeof a?a+"px":a}})}(jqxBaseFramework);
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
7

mercurial