46063: working CSS truncation, but were switching to JS again...

This commit is contained in:
Lotte Hofstede
2018-01-24 15:22:31 +01:00
parent 136edddbdd
commit 1b0fc45b6d
20 changed files with 262 additions and 132 deletions

View File

@@ -9,34 +9,34 @@ import { TruncatableService } from './truncatable.service';
styleUrls: ['./truncatable.component.scss']
})
export class TruncatableComponent {
@Input() minLines: number;
@Input() maxLines: number;
@Input() initialExpand = false;
@Input() id: string;
@Input() content;
private lines: number;
@Input() onHover = false;
public constructor(private service: TruncatableService) {
}
ngOnInit() {
if (this.initialExpand) {
this.service.toggle(this.id);
}
this.setLines();
}
public toggleCollapse() {
this.service.toggle(this.id);
this.setLines();
}
private setLines() {
if (this.service.isCollapsed(this.id)) {
this.lines = this.minLines;
this.service.expand(this.id);
} else {
this.lines = this.maxLines;
this.service.collapse(this.id);
}
}
public hoverCollapse() {
if (this.onHover) {
this.service.collapse(this.id);
}
}
public hoverExpand() {
if (this.onHover) {
this.service.expand(this.id);
}
}
public toggle() {
this.service.toggle(this.id);
}
}