From 573f32b362f4639928485d66feb1c0721109716b Mon Sep 17 00:00:00 2001 From: YuanHu Date: Tue, 27 Mar 2018 17:24:38 +0800 Subject: Include paletx core Include paletx core to WF Designer UI. Issue-ID: SDC-1130,SDC-1131 Change-Id: I9a2591e022b5ff118cccbbc839796be19d70df84 Signed-off-by: YuanHu --- .../app/paletx/core/overlay/overlay-container.ts | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 sdc-workflow-designer-ui/src/app/paletx/core/overlay/overlay-container.ts (limited to 'sdc-workflow-designer-ui/src/app/paletx/core/overlay/overlay-container.ts') diff --git a/sdc-workflow-designer-ui/src/app/paletx/core/overlay/overlay-container.ts b/sdc-workflow-designer-ui/src/app/paletx/core/overlay/overlay-container.ts new file mode 100644 index 00000000..fbb37c7e --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/paletx/core/overlay/overlay-container.ts @@ -0,0 +1,83 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +/* tslint:disable:array-type member-access variable-name typedef + only-arrow-functions directive-class-suffix component-class-suffix + component-selector*/ +import {Injectable, Optional, SkipSelf} from '@angular/core'; + + +/** + * The OverlayContainer is the container in which all overlays will load. + * It should be provided in the root component to ensure it is properly shared. + */ +@Injectable() +export class OverlayContainer { + protected _containerElement: HTMLElement; + + private _themeClass: string; + + /** + * Base theme to be applied to all overlay-based components. + */ + get themeClass(): string { + return this._themeClass; + } + set themeClass(value: string) { + if (this._containerElement) { + this._containerElement.classList.remove(this._themeClass); + + if (value) { + this._containerElement.classList.add(value); + } + } + + this._themeClass = value; + } + + /** + * This method returns the overlay container element. It will lazily + * create the element the first time it is called to facilitate using + * the container in non-browser environments. + * @returns the container element + */ + getContainerElement(): HTMLElement { + if (!this._containerElement) { + this._createContainer(); + } + return this._containerElement; + } + + /** + * Create the overlay container element, which is simply a div + * with the 'cdk-overlay-container' class on the document body. + */ + protected _createContainer(): void { + const container = document.createElement('div'); + container.classList.add('nz-overlay-container'); + + if (this._themeClass) { + container.classList.add(this._themeClass); + } + + document.body.appendChild(container); + this._containerElement = container; + } +} + +export function OVERLAY_CONTAINER_PROVIDER_FACTORY( + parentContainer: OverlayContainer) { + return parentContainer || new OverlayContainer(); +} + +export const OVERLAY_CONTAINER_PROVIDER = { + // If there is already an OverlayContainer available, use that. Otherwise, + // provide a new one. + provide: OverlayContainer, + deps: [[new Optional(), new SkipSelf(), OverlayContainer]], + useFactory: OVERLAY_CONTAINER_PROVIDER_FACTORY +}; -- cgit 1.2.3-korg