@evan.network/ui-angular-core
Version:
The angular-core operates as an global and central library for the evan.network Angular 5 frontend development. Using this project you will be able to to the following things:
332 lines (331 loc) • 11.8 kB
TypeScript
import { Logger } from 'bcc';
import { OnDestroy, // '@angular/core';
Platform } from 'angular-libs';
import { SingletonService } from './singleton-service';
/**************************************************************************************************/
/**
* Utility service for the whole angular core module
*
* @class Injectable EvanUtilService
*/
export declare class EvanUtilService implements OnDestroy {
private platform;
private singleton;
/**
* array of functions, that should be called, when the browser was resized
*/
private resizeFunctions;
/**
* function that handles the window resize
*/
private resizingFunction;
/**
* add & remove temporary dynamic styles
*/
private styles;
/**
* function that handles the window resize
*/
private watchScreenSize;
/**
* is devMode enabled?
*/
devMode: boolean;
/**
* is browser width greater than 1500?
*/
isXXL: boolean;
/**
* is browser width greater than 1200?
*/
isXL: boolean;
/**
* is browser width greater than 992?
*/
isLG: boolean;
/**
* is browser width greater than 768?
*/
isMD: boolean;
/**
* is browser width greater than 576?
*/
isSM: boolean;
/**
* current window size
*/
screenSize: number;
/**
* BCC logger instance
*/
logger: Logger;
/**
* Create a singleton service instance. Start screen size watching. Prefill
* dev ens variables
*/
constructor(platform: Platform, singleton: SingletonService);
/**
* remove listeners for resizing functions
*/
ngOnDestroy(): void;
/**
* Prefill localStorage dev environment variables.
*
* @param {boolean} full check if all internal variables should
* enrolled too
*/
fillDevEnvVariables(full?: boolean): void;
/**
* Add a temporary css style to the document head. E.g. it is used to style an image within an
* alert dialog.
*
* @param {string} name Name for the style. Style is available under class :
* evan-img-${name}
* @param {string} css css definition
*
* Usage:
*
* this.utils.addTemporaryStyle(trimmedName, `
* .evan-temporary-${trimmedName} {
* min-width: 257px;
* }
* `);
*/
addTemporaryStyle(name: string, css: string): void;
/**
* Remove a temporary style sheet from the dom.
*
* @param name Name for the style. Style is available under ID : evan-img-${name}
*/
removeTemporaryImageStyle(name: string): void;
/**
* Check if we are on a mobile device (no matter if ionic app or browser).
*
* @return {boolean} True if mobile, False otherwise.
*/
isMobile(): boolean;
/**
* Check if cordova is available
*
* @return {boolean} True if native mobile, False otherwise.
*/
isNativeMobile(): boolean;
/**
* check if we are on a ios mobile device (no matter if ionic app or browser).
*
* @return {boolean} True if mobile ios, False otherwise.
*/
isMobileIOS(): boolean;
/**
* check if we are on a android mobile device (no matter if ionic app or browser).
*
* @return {boolean} True if mobile android, False otherwise.
*/
isMobileAndroid(): boolean;
/**
* Promise wrapper for setTimeout.
*
* @param {number} ms Milliseconds to wait
* @return {Promise<void>} solved when setTimeout callback is called
*/
timeout(ms?: number): Promise<void>;
/**
* Promise wrapper for setimmediate
*
* @return {Promise<void>} solved when setImmediate callback is called
*/
immediate(): Promise<void>;
/**
* Remove duplicate values from an array.
*
* @param {Array<any>} a Input Array
* @return {Array<any>} the unique array
*/
uniqueArray(a: Array<any>): Array<any>;
/**
* Registers and window resize watcher
*
* @param {Function} callback callback is called when size has changed
* @return {Function} Function to unsubscribe
*/
windowSize(callback: Function): Promise<Function>;
/**
* emits a window.dispatchEvent
*
* @param {string} name even name
* @param {any} data data to send
*/
sendEvent(name: string, data?: any): void;
/**
* runs window.addEventListener and func is called when event was triggered
*
* @param {string} name event name
* @param {Function} func function that is called on event occurence
* @return {Function} Function to unsubscribe
*/
onEvent(name: string, func: any): () => void;
/**
* Runs JSON.parse(JSON.stringify(obj)) to make an maximum deep copy. Be
* aware: dont apply recursive objects!
*
* @param {any} obj object that should be cloned
* @return {any} cloned object
*/
deepCopy(obj: any): any;
/**
* Searches relative to an element an parent element with a specific element
* class
*
* @param {Element} $element reference element
* @param {string} className class name that should be searched
* @return {Element} parent element that should be searched
*/
getParentByClassName(element: any, className: string): Element;
/**
* Gets the full offset top of an element relative to an container
*
* @param {Element} $parent Parent container where the offset of the
* child should be get
* @param {Element} $element Element to retrieve offset top from
* @param {number} offsetTop last offset top for recursive function
* @return {number} offset
*/
getOffsetTop($parent: Element, $element: any, offsetTop?: number): number;
/**
* Scroll a container horizontal / vertical smooth to a specific position
*
* @param {Element} $container element that should be scrolled
* @param {string} direction horizontal / vertical
* @param {number} scrollTo position to scroll to
* @param {number} maxTurns max turns to break animation (max. 200px)
* @param {Number} scrollRange amount of pixels that should be scrolled each timeout
*/
scrollTo($container: any, direction: string, scrollTo: number, maxTurns?: number, scrollRange?: number): void;
/**
* Scrolls the suggestions container upwards
*
* @param {Element} $container $container that should be scrolled
* @param {number} scrollTo where the container should be scrolled to
* @param {number} maxTurns max turns to break animation (max. 200px)
* @param {Number} scrollRange amount of pixels that should be scrolled each timeout
*/
scrollUp($container: Element, scrollTo: number, maxTurns?: number, scrollRange?: number): void;
/**
* Scrolls the suggestions container downwards.
*
* @param {Element} $container $container that should be scrolled
* @param {number} scrollTo where the container should be scrolled to
* @param {number} maxTurns max turns to break animation (max. 200px)
* @param {Number} scrollRange amount of pixels that should be scrolled each timeout
*/
scrollDown($container: any, scrollTo: any, maxTurns?: number, scrollRange?: number): void;
/**
* Scrolls the suggestions container to the right.
*
* @param {Element} $container $container that should be scrolled
* @param {number} scrollTo where the container should be scrolled to
* @param {number} maxTurns max turns to break animation (max. 200px)
* @param {Number} scrollRange amount of pixels that should be scrolled each timeout
*/
scrollRight($container: any, scrollTo: any, maxTurns?: number, scrollRange?: number): void;
/**
* Scrolls the suggestions container to the left.
*
* @param {Element} $container $container that should be scrolled
* @param {number} scrollTo where the container should be scrolled to
* @param {number} maxTurns max turns to break animation (max. 200px)
* @param {Number} scrollRange amount of pixels that should be scrolled each timeout
*/
scrollLeft($container: any, scrollTo: any, maxTurns?: number, scrollRange?: number): void;
/**
* Generates an uid.
*
* @return {string} uuid (257bed80-d18a-1a70-5e9b-fb4d3afa8915)
*/
generateID(): string;
/**
* Using BCC log function to handle a generalized loggin mechanism.
*
* @param {string} message message to log
* @param {string} level level to log the message with
*/
log(message: string, level: string): void;
/**
* Check if the user enabled developer mode within profile configuration.
*
* @return {boolean} True if developer mode, False otherwise.
*/
isDeveloperMode(): boolean;
/**
* Check if the user enabled notifications on the mobile devices
*
* @return {boolean} True if notifications enabled, false otherwise.
*/
notificationsEnabled(): boolean;
/**
* Checks if currently the evan-dapps-domain is enabled.
*
* @return {string} the defined domain.
*/
getDevDomain(): any;
/**
* Transforms an Exception into an loggable string format. Returns the string if the exception is
* only a string.
*
* @param {any} ex Exception / string
* @return {string} Transformed exception
*/
getErrorLog(ex: any): string;
/**
* generates a ISO standard string from a date object
*
* @param {object} date generated date object
* @return {string} the iso string
*/
toIsoString(date: any): string;
/**
* Shows the loading of a ref detached component
*
* @param {any} context this of the component
*/
showLoading(context: any): void;
/**
* Hides the loading of a ref detached component.
*
* @param {any} context this of the component
*/
hideLoading(context: any): void;
/**
* Gets the color theme.
*
* @return {string} the current color theme
*/
getColorTheme(): any;
/**
* Adds the current color theme class to the body.
*
* @param {string} colorTheme the color theme name (e.g. light)
*/
activateColorTheme(colorTheme: string): void;
/**
* Stops the browser event bubbling for a dom event (click, hover, ...).
*
* @param {any} $event the interaction event
* @return {boolean} false to break everything
*/
stopEventBubbling($event?: any): boolean;
/**
* Checks if a form property is touched and invalid.
*
* @param {any} form the form that should be checked
* @param {string} paramName name of the form property that should be checked
* @return {boolean} true if touched and invalid, else false
*/
showError(form: any, paramName: string): any;
/**
* Run detectChanges directly and after and timeout again, to update select fields.
*
* @param {any} ref the component element ref
*/
detectTimeout(ref: any): void;
}