1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-13 10:14:18 +01:00

move box row directive for sharing

This commit is contained in:
Kyle Spearrin 2018-04-04 14:19:09 -04:00
parent 1674ef202d
commit 5a16e42cf0
3 changed files with 2 additions and 51 deletions

2
jslib

@ -1 +1 @@
Subproject commit bb8cf8978860b68d9f8011b0da0cb8588e729b37 Subproject commit f673bd62d7abb773fa5a6abfb5307b7c3feca59b

View File

@ -29,7 +29,7 @@ import { TwoFactorComponent } from './accounts/two-factor.component';
import { ApiActionDirective } from 'jslib/angular/directives/api-action.directive'; import { ApiActionDirective } from 'jslib/angular/directives/api-action.directive';
import { AutofocusDirective } from 'jslib/angular/directives/autofocus.directive'; import { AutofocusDirective } from 'jslib/angular/directives/autofocus.directive';
import { BlurClickDirective } from 'jslib/angular/directives/blur-click.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 { FallbackSrcDirective } from 'jslib/angular/directives/fallback-src.directive';
import { StopClickDirective } from 'jslib/angular/directives/stop-click.directive'; import { StopClickDirective } from 'jslib/angular/directives/stop-click.directive';
import { StopPropDirective } from 'jslib/angular/directives/stop-prop.directive'; import { StopPropDirective } from 'jslib/angular/directives/stop-prop.directive';

View File

@ -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<Element>;
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();
}
}
}