mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
45 lines
841 B
TypeScript
45 lines
841 B
TypeScript
import {
|
|
Component, Input
|
|
} from '@angular/core';
|
|
import { TruncatableService } from './truncatable.service';
|
|
|
|
@Component({
|
|
selector: 'ds-truncatable',
|
|
templateUrl: './truncatable.component.html',
|
|
styleUrls: ['./truncatable.component.scss'],
|
|
|
|
})
|
|
export class TruncatableComponent {
|
|
@Input() initialExpand = false;
|
|
@Input() id: string;
|
|
@Input() onHover = false;
|
|
|
|
public constructor(private service: TruncatableService) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
if (this.initialExpand) {
|
|
this.service.expand(this.id);
|
|
} else {
|
|
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);
|
|
}
|
|
|
|
}
|