{"version":3,"file":"primeng-password.js","sources":["../../src/app/components/password/password.ts","../../src/app/components/password/primeng-password.ts"],"sourcesContent":["import {NgModule,Directive,ElementRef,HostListener,Input,OnDestroy,DoCheck,NgZone} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler, ConnectedOverlayScrollHandler} from 'primeng/dom';\n\n@Directive({\n selector: '[pPassword]',\n host: {\n '[class.p-inputtext]': 'true',\n '[class.p-component]': 'true',\n '[class.p-filled]': 'filled'\n }\n})\nexport class Password implements OnDestroy,DoCheck {\n\n @Input() promptLabel: string = 'Enter a password';\n\n @Input() weakLabel: string = 'Weak';\n\n @Input() mediumLabel: string = 'Medium';\n\n @Input() strongLabel: string = 'Strong';\n\n @Input() feedback: boolean = true;\n\n @Input() set showPassword(show: boolean) {\n this.el.nativeElement.type = show ? 'text' : 'password';\n }\n\n panel: HTMLDivElement;\n\n meter: any;\n\n info: any;\n\n filled: boolean;\n\n scrollHandler: any;\n\n documentResizeListener: any;\n\n constructor(public el: ElementRef, public zone: NgZone) {}\n\n ngDoCheck() {\n this.updateFilledState();\n }\n\n @HostListener('input', ['$event'])\n onInput(e) {\n this.updateFilledState();\n }\n\n updateFilledState() {\n this.filled = this.el.nativeElement.value && this.el.nativeElement.value.length;\n }\n\n createPanel() {\n this.panel = document.createElement('div');\n this.panel.className = 'p-password-panel p-component p-password-panel-overlay p-connected-overlay';\n this.meter = document.createElement('div');\n this.meter.className = 'p-password-meter';\n this.info = document.createElement('div');\n this.info.className = 'p-password-info';\n this.info.textContent = this.promptLabel;\n this.panel.appendChild(this.meter);\n this.panel.appendChild(this.info);\n this.panel.style.minWidth = DomHandler.getOuterWidth(this.el.nativeElement) + 'px';\n document.body.appendChild(this.panel);\n }\n\n showOverlay() {\n if (this.feedback) {\n if (!this.panel) {\n this.createPanel();\n }\n\n this.panel.style.zIndex = String(++DomHandler.zindex);\n this.panel.style.display = 'block';\n this.zone.runOutsideAngular(() => {\n\n setTimeout(() => {\n DomHandler.addClass(this.panel, 'p-connected-overlay-visible');\n this.bindScrollListener();\n this.bindDocumentResizeListener();\n }, 1);\n });\n DomHandler.absolutePosition(this.panel, this.el.nativeElement);\n }\n }\n\n hideOverlay() {\n if (this.feedback && this.panel) {\n DomHandler.addClass(this.panel, 'p-connected-overlay-hidden');\n DomHandler.removeClass(this.panel, 'p-connected-overlay-visible');\n this.unbindScrollListener();\n this.unbindDocumentResizeListener();\n\n this.zone.runOutsideAngular(() => {\n setTimeout(() => {\n this.ngOnDestroy();\n }, 150);\n });\n }\n }\n\n @HostListener('focus')\n onFocus() {\n this.showOverlay();\n }\n\n @HostListener('blur')\n onBlur() {\n this.hideOverlay();\n }\n\n @HostListener('keyup', ['$event'])\n onKeyup(e) {\n if (this.feedback) {\n let value = e.target.value,\n label = null,\n meterPos = null;\n\n if (value.length === 0) {\n label = this.promptLabel;\n meterPos = '0px 0px';\n }\n else {\n var score = this.testStrength(value);\n\n if (score < 30) {\n label = this.weakLabel;\n meterPos = '0px -10px';\n }\n else if (score >= 30 && score < 80) {\n label = this.mediumLabel;\n meterPos = '0px -20px';\n }\n else if (score >= 80) {\n label = this.strongLabel;\n meterPos = '0px -30px';\n }\n }\n\n if (!this.panel || !DomHandler.hasClass(this.panel, 'p-connected-overlay-visible')) {\n this.showOverlay();\n }\n\n this.meter.style.backgroundPosition = meterPos;\n this.info.textContent = label;\n }\n }\n\n testStrength(str: string) {\n let grade: number = 0;\n let val: RegExpMatchArray;\n\n val = str.match('[0-9]');\n grade += this.normalize(val ? val.length : 1/4, 1) * 25;\n\n val = str.match('[a-zA-Z]');\n grade += this.normalize(val ? val.length : 1/2, 3) * 10;\n\n val = str.match('[!@#$%^&*?_~.,;=]');\n grade += this.normalize(val ? val.length : 1/6, 1) * 35;\n\n val = str.match('[A-Z]');\n grade += this.normalize(val ? val.length : 1/6, 1) * 30;\n\n grade *= str.length / 8;\n\n return grade > 100 ? 100 : grade;\n }\n\n normalize(x, y) {\n let diff = x - y;\n\n if (diff <= 0)\n return x / y;\n else\n return 1 + 0.5 * (x / (x + y/4));\n }\n\n get disabled(): boolean {\n return this.el.nativeElement.disabled;\n }\n\n bindScrollListener() {\n if (!this.scrollHandler) {\n this.scrollHandler = new ConnectedOverlayScrollHandler(this.el.nativeElement, () => {\n if (DomHandler.hasClass(this.panel, 'p-connected-overlay-visible')) {\n this.hideOverlay();\n }\n });\n }\n\n this.scrollHandler.bindScrollListener();\n }\n\n unbindScrollListener() {\n if (this.scrollHandler) {\n this.scrollHandler.unbindScrollListener();\n }\n }\n\n bindDocumentResizeListener() {\n this.documentResizeListener = this.onWindowResize.bind(this);\n window.addEventListener('resize', this.documentResizeListener);\n }\n\n unbindDocumentResizeListener() {\n if (this.documentResizeListener) {\n window.removeEventListener('resize', this.documentResizeListener);\n this.documentResizeListener = null;\n }\n }\n\n onWindowResize() {\n this.hideOverlay();\n }\n\n ngOnDestroy() {\n if (this.panel) {\n if (this.scrollHandler) {\n this.scrollHandler.destroy();\n this.scrollHandler = null;\n }\n\n this.unbindDocumentResizeListener();\n\n document.body.removeChild(this.panel);\n this.panel = null;\n this.meter = null;\n this.info = null;\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Password],\n declarations: [Password]\n})\nexport class PasswordModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAYa,QAAQ;IA4BjB,YAAmB,EAAc,EAAS,IAAY;QAAnC,OAAE,GAAF,EAAE,CAAY;QAAS,SAAI,GAAJ,IAAI,CAAQ;QA1B7C,gBAAW,GAAW,kBAAkB,CAAC;QAEzC,cAAS,GAAW,MAAM,CAAC;QAE3B,gBAAW,GAAW,QAAQ,CAAC;QAE/B,gBAAW,GAAW,QAAQ,CAAC;QAE/B,aAAQ,GAAY,IAAI,CAAC;KAkBwB;IAhB1D,IAAa,YAAY,CAAC,IAAa;QACnC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,GAAG,IAAI,GAAG,MAAM,G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