angular2-promise-buttons
Version:
Chilled loading buttons for angular
63 lines (62 loc) • 2.33 kB
TypeScript
import { AfterContentInit, ElementRef, OnDestroy } from '@angular/core';
import { PromiseBtnConfig } from './promise-btn-config';
import * as i0 from "@angular/core";
export declare class PromiseBtnDirective implements OnDestroy, AfterContentInit {
cfg: PromiseBtnConfig;
minDurationTimeout: number;
isMinDurationTimeoutDone: boolean;
isPromiseDone: boolean;
btnEl: HTMLElement;
promise: any;
set isDisabledFromTheOutsideSetter(v: boolean);
isDisabledFromTheOutside: boolean;
private _fakePromiseResolve;
constructor(el: ElementRef, cfg: PromiseBtnConfig);
set promiseBtn(passedValue: any);
ngAfterContentInit(): void;
ngOnDestroy(): void;
createPromiseFromBoolean(val: boolean): Promise<any>;
/**
* Initializes all html and event handlers
*/
prepareBtnEl(btnEl: HTMLElement): void;
/**
* Checks if all required parameters are there and inits the promise handler
*/
checkAndInitPromiseHandler(btnEl: HTMLElement): void;
/**
* Helper FN to add class
*/
addLoadingClass(el: any): void;
/**
* Helper FN to remove classes
*/
removeLoadingClass(el: any): void;
/**
* Handles everything to be triggered when the button is set
* to loading state.
*/
initLoadingState(btnEl: HTMLElement): void;
/**
* Handles everything to be triggered when loading is finished
*/
cancelLoadingStateIfPromiseAndMinDurationDone(btnEl: HTMLElement): void;
disableBtn(btnEl: HTMLElement): void;
enableBtn(btnEl: HTMLElement): void;
/**
* Initializes a watcher for the promise. Also takes
* this.cfg.minDuration into account if given.
*/
initPromiseHandler(btnEl: HTMLElement): void;
/**
* $compile and append the spinner template to the button.
*/
appendSpinnerTpl(btnEl: HTMLElement): void;
/**
* Limit loading state to show only for the currently clicked button.
* Executed only if this.cfg.handleCurrentBtnOnly is set
*/
handleCurrentBtnOnly(): boolean;
static ɵfac: i0.ɵɵFactoryDeclaration<PromiseBtnDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<PromiseBtnDirective, "[promiseBtn]", never, { "isDisabledFromTheOutsideSetter": "disabled"; "promiseBtn": "promiseBtn"; }, {}, never>;
}