1 | import { Component, HostBinding, Input, Optional } from '@angular/core';
|
---|
2 | import { DomSanitizer } from '@angular/platform-browser';
|
---|
3 | import { counter } from '@fortawesome/fontawesome-svg-core';
|
---|
4 | import { faWarnIfParentNotExist } from '../shared/errors/warn-if-parent-not-exist';
|
---|
5 | import { FaLayersComponent } from './layers.component';
|
---|
6 | export class FaLayersCounterComponent {
|
---|
7 | constructor(parent, sanitizer) {
|
---|
8 | this.parent = parent;
|
---|
9 | this.sanitizer = sanitizer;
|
---|
10 | this.classes = [];
|
---|
11 | faWarnIfParentNotExist(this.parent, 'FaLayersComponent', this.constructor.name);
|
---|
12 | }
|
---|
13 | ngOnChanges(changes) {
|
---|
14 | if (changes) {
|
---|
15 | const params = this.buildParams();
|
---|
16 | this.updateContent(params);
|
---|
17 | }
|
---|
18 | }
|
---|
19 | buildParams() {
|
---|
20 | return {
|
---|
21 | title: this.title,
|
---|
22 | classes: this.classes,
|
---|
23 | styles: this.styles,
|
---|
24 | };
|
---|
25 | }
|
---|
26 | updateContent(params) {
|
---|
27 | this.renderedHTML = this.sanitizer.bypassSecurityTrustHtml(counter(this.content || '', params).html.join(''));
|
---|
28 | }
|
---|
29 | }
|
---|
30 | FaLayersCounterComponent.decorators = [
|
---|
31 | { type: Component, args: [{
|
---|
32 | selector: 'fa-layers-counter',
|
---|
33 | template: '',
|
---|
34 | host: {
|
---|
35 | class: 'ng-fa-layers-counter',
|
---|
36 | }
|
---|
37 | },] }
|
---|
38 | ];
|
---|
39 | FaLayersCounterComponent.ctorParameters = () => [
|
---|
40 | { type: FaLayersComponent, decorators: [{ type: Optional }] },
|
---|
41 | { type: DomSanitizer }
|
---|
42 | ];
|
---|
43 | FaLayersCounterComponent.propDecorators = {
|
---|
44 | content: [{ type: Input }],
|
---|
45 | title: [{ type: Input }],
|
---|
46 | styles: [{ type: Input }],
|
---|
47 | classes: [{ type: Input }],
|
---|
48 | renderedHTML: [{ type: HostBinding, args: ['innerHTML',] }]
|
---|
49 | };
|
---|
50 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