mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
input verbatim directive
This commit is contained in:
parent
10b9e9c2d6
commit
df1649bac1
37
src/angular/directives/input-verbatim.directive.ts
Normal file
37
src/angular/directives/input-verbatim.directive.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import {
|
||||
Directive,
|
||||
ElementRef,
|
||||
Input,
|
||||
Renderer2,
|
||||
} from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[appInputVerbatim]',
|
||||
})
|
||||
export class InputVerbatimDirective {
|
||||
@Input() set appInputVerbatim(condition: boolean | string) {
|
||||
this.disableComplete = condition === '' || condition === true;
|
||||
}
|
||||
|
||||
private disableComplete: boolean;
|
||||
|
||||
constructor(private el: ElementRef, private renderer: Renderer2) { }
|
||||
|
||||
ngOnInit() {
|
||||
if (this.disableComplete && !this.el.nativeElement.hasAttribute('autocomplete')) {
|
||||
this.renderer.setAttribute(this.el.nativeElement, 'autocomplete', 'nope');
|
||||
}
|
||||
if (!this.el.nativeElement.hasAttribute('autocapitalize')) {
|
||||
this.renderer.setAttribute(this.el.nativeElement, 'autocapitalize', 'none');
|
||||
}
|
||||
if (!this.el.nativeElement.hasAttribute('autocorrect')) {
|
||||
this.renderer.setAttribute(this.el.nativeElement, 'autocorrect', 'none');
|
||||
}
|
||||
if (!this.el.nativeElement.hasAttribute('spellcheck')) {
|
||||
this.renderer.setAttribute(this.el.nativeElement, 'spellcheck', 'false');
|
||||
}
|
||||
if (!this.el.nativeElement.hasAttribute('inputmode')) {
|
||||
this.renderer.setAttribute(this.el.nativeElement, 'inputmode', 'verbatim');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user