From 5a16e42cf05724be51732369870dd3a5a4bc29c7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 4 Apr 2018 14:19:09 -0400 Subject: [PATCH] move box row directive for sharing --- jslib | 2 +- src/app/app.module.ts | 2 +- src/app/directives/box-row.directive.ts | 49 ------------------------- 3 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 src/app/directives/box-row.directive.ts diff --git a/jslib b/jslib index bb8cf89788..f673bd62d7 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit bb8cf8978860b68d9f8011b0da0cb8588e729b37 +Subproject commit f673bd62d7abb773fa5a6abfb5307b7c3feca59b diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8328e22c06..28394a5409 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -29,7 +29,7 @@ import { TwoFactorComponent } from './accounts/two-factor.component'; import { ApiActionDirective } from 'jslib/angular/directives/api-action.directive'; import { AutofocusDirective } from 'jslib/angular/directives/autofocus.directive'; import { BlurClickDirective } from 'jslib/angular/directives/blur-click.directive'; -import { BoxRowDirective } from './directives/box-row.directive'; +import { BoxRowDirective } from 'jslib/angular/directives/box-row.directive'; import { FallbackSrcDirective } from 'jslib/angular/directives/fallback-src.directive'; import { StopClickDirective } from 'jslib/angular/directives/stop-click.directive'; import { StopPropDirective } from 'jslib/angular/directives/stop-prop.directive'; diff --git a/src/app/directives/box-row.directive.ts b/src/app/directives/box-row.directive.ts deleted file mode 100644 index 241a5b3f82..0000000000 --- a/src/app/directives/box-row.directive.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { - Directive, - ElementRef, - HostListener, - OnInit, -} from '@angular/core'; - -@Directive({ - selector: '[appBoxRow]', -}) -export class BoxRowDirective implements OnInit { - el: HTMLElement = null; - formEls: NodeListOf; - - constructor(private elRef: ElementRef) { - this.el = elRef.nativeElement; - } - - ngOnInit(): void { - this.formEls = this.el.querySelectorAll('input:not([type="hidden"]), select, textarea'); - this.formEls.forEach((formEl) => { - formEl.addEventListener('focus', (event: Event) => { - this.el.classList.add('active'); - }, false); - - formEl.addEventListener('blur', (event: Event) => { - this.el.classList.remove('active'); - }, false); - }); - } - - @HostListener('click', ['$event']) onClick(event: Event) { - if (event.target !== this.el) { - return; - } - - if (this.formEls.length > 0) { - const formEl = (this.formEls[0] as HTMLElement); - if (formEl.tagName.toLowerCase() === 'input') { - const inputEl = (formEl as HTMLInputElement); - if (inputEl.type != null && inputEl.type.toLowerCase() === 'checkbox') { - inputEl.click(); - return; - } - } - formEl.focus(); - } - } -}