Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 67x 67x 67x 142x 67x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import {
Component,
ElementRef,
EventEmitter,
forwardRef,
HostBinding,
HostListener,
Input,
NgZone,
Output
} from '@angular/core';
import { AutofocusDirective } from '../../../directive/autofocus.directive';
import { ConfigService } from '../../../service/config.service';
import { Store } from '../../../store/store';
import { MdComponent } from '../../md/md.component';
@Component({
selector: 'app-todo-item',
templateUrl: './item.component.html',
styleUrls: ['./item.component.scss'],
host: { 'class': 'todo-item' },
imports: [
AutofocusDirective,
forwardRef(() => MdComponent),
]
})
export class TodoItemComponent {
@HostBinding('class.unlocked')
unlocked = false;
@Input()
pressToUnlock = false;
@Input()
plugins: string[] = [];
@Input()
origin = '';
@Output()
update = new EventEmitter<{ text: string, checked: boolean }>();
checked = false;
editing = false;
text = '';
hovering = false;
private _line = '';
constructor(
private store: Store,
public config: ConfigService,
private el: ElementRef,
private zone: NgZone,
) { }
get local() {
return this.origin === this.store.account.origin;
}
@Input()
set line(value: string) {
this._line = value;
if (value) {
this.checked = !!/^[\s-]*\[([\sxX]*)]/.exec(value)?.[1]?.trim() || false;
this.text = this._line.replace(/^[\s-]*\[[\sxX]*]\s*/g, '');
} else {
this.checked = false;
this.text = '';
}
}
@HostListener('touchend', ['$event'])
touchend(e: TouchEvent) {
this.zone.run(() => this.unlocked = false);
}
@HostListener('press', ['$event'])
unlock(event: any) {
if (!this.config.mobile) return;
this.unlocked = true;
this.el.nativeElement.scrollIntoView({ block: 'nearest', inline: 'center', behavior: 'smooth' });
if ('vibrate' in navigator) navigator.vibrate([2, 32, 4]);
}
toggle() {
this.checked = !this.checked;
this.update.next({ text: this.text, checked: this.checked });
}
edit() {
this.update.next({ text: this.text, checked: this.checked });
this.editing = false;
}
}
|