|
|
@ -14,7 +14,16 @@ |
|
|
/// limitations under the License.
|
|
|
/// limitations under the License.
|
|
|
///
|
|
|
///
|
|
|
|
|
|
|
|
|
import { Component, forwardRef, Input, OnInit, Renderer2, ViewContainerRef, ViewEncapsulation } from '@angular/core'; |
|
|
import { |
|
|
|
|
|
ChangeDetectorRef, |
|
|
|
|
|
Component, |
|
|
|
|
|
forwardRef, |
|
|
|
|
|
Input, |
|
|
|
|
|
OnInit, |
|
|
|
|
|
Renderer2, |
|
|
|
|
|
ViewContainerRef, |
|
|
|
|
|
ViewEncapsulation |
|
|
|
|
|
} from '@angular/core'; |
|
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; |
|
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; |
|
|
import { |
|
|
import { |
|
|
BackgroundSettings, |
|
|
BackgroundSettings, |
|
|
@ -30,6 +39,7 @@ import { |
|
|
} from '@home/components/widget/lib/settings/common/background-settings-panel.component'; |
|
|
} from '@home/components/widget/lib/settings/common/background-settings-panel.component'; |
|
|
import { Observable, of } from 'rxjs'; |
|
|
import { Observable, of } from 'rxjs'; |
|
|
import { ImagePipe } from '@shared/pipe/image.pipe'; |
|
|
import { ImagePipe } from '@shared/pipe/image.pipe'; |
|
|
|
|
|
import { DomSanitizer } from '@angular/platform-browser'; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'tb-background-settings', |
|
|
selector: 'tb-background-settings', |
|
|
@ -47,7 +57,7 @@ import { ImagePipe } from '@shared/pipe/image.pipe'; |
|
|
export class BackgroundSettingsComponent implements OnInit, ControlValueAccessor { |
|
|
export class BackgroundSettingsComponent implements OnInit, ControlValueAccessor { |
|
|
|
|
|
|
|
|
@Input() |
|
|
@Input() |
|
|
disabled: boolean; |
|
|
disabled = false; |
|
|
|
|
|
|
|
|
backgroundType = BackgroundType; |
|
|
backgroundType = BackgroundType; |
|
|
|
|
|
|
|
|
@ -60,9 +70,11 @@ export class BackgroundSettingsComponent implements OnInit, ControlValueAccessor |
|
|
private propagateChange = null; |
|
|
private propagateChange = null; |
|
|
|
|
|
|
|
|
constructor(private imagePipe: ImagePipe, |
|
|
constructor(private imagePipe: ImagePipe, |
|
|
|
|
|
private sanitizer: DomSanitizer, |
|
|
private popoverService: TbPopoverService, |
|
|
private popoverService: TbPopoverService, |
|
|
private renderer: Renderer2, |
|
|
private renderer: Renderer2, |
|
|
private viewContainerRef: ViewContainerRef) {} |
|
|
private viewContainerRef: ViewContainerRef, |
|
|
|
|
|
private cd: ChangeDetectorRef) {} |
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
ngOnInit(): void { |
|
|
} |
|
|
} |
|
|
@ -75,8 +87,10 @@ export class BackgroundSettingsComponent implements OnInit, ControlValueAccessor |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setDisabledState(isDisabled: boolean): void { |
|
|
setDisabledState(isDisabled: boolean): void { |
|
|
this.disabled = isDisabled; |
|
|
if (this.disabled !== isDisabled) { |
|
|
this.updateBackgroundStyle(); |
|
|
this.disabled = isDisabled; |
|
|
|
|
|
this.updateBackgroundStyle(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
writeValue(value: BackgroundSettings): void { |
|
|
writeValue(value: BackgroundSettings): void { |
|
|
@ -112,12 +126,13 @@ export class BackgroundSettingsComponent implements OnInit, ControlValueAccessor |
|
|
|
|
|
|
|
|
private updateBackgroundStyle() { |
|
|
private updateBackgroundStyle() { |
|
|
if (!this.disabled) { |
|
|
if (!this.disabled) { |
|
|
this.backgroundStyle$ = backgroundStyle(this.modelValue, this.imagePipe); |
|
|
this.backgroundStyle$ = backgroundStyle(this.modelValue, this.imagePipe, this.sanitizer, true); |
|
|
this.overlayStyle = overlayStyle(this.modelValue.overlay); |
|
|
this.overlayStyle = overlayStyle(this.modelValue.overlay); |
|
|
} else { |
|
|
} else { |
|
|
this.backgroundStyle$ = of({}); |
|
|
this.backgroundStyle$ = of({}); |
|
|
this.overlayStyle = {}; |
|
|
this.overlayStyle = {}; |
|
|
} |
|
|
} |
|
|
|
|
|
this.cd.markForCheck(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|