diff --git a/ladda/ladda-tests.ts b/ladda/ladda-tests.ts index 24956950c..710407de6 100644 --- a/ladda/ladda-tests.ts +++ b/ladda/ladda-tests.ts @@ -12,6 +12,9 @@ var l = Ladda.create(document.querySelector('.my-button')); // Start loading l.start(); +// Start loading after a delay +l.startAfter(300); + // Will display a progress bar for 50% of the button width l.setProgress(0.5); @@ -24,6 +27,9 @@ l.toggle(); // Check the current state l.isLoading(); +// Remove the element +l.remove(); + // Test bind Ladda.bind('button.ladda-button', { timeout: 42, callback: btn => alert('Clicked!!!') }); Ladda.bind('button.ladda-button'); diff --git a/ladda/ladda.d.ts b/ladda/ladda.d.ts index fc4f43b41..b464a31c5 100644 --- a/ladda/ladda.d.ts +++ b/ladda/ladda.d.ts @@ -1,35 +1,36 @@ -// Type definitions for Ladda 0.7.0 +// Type definitions for Ladda 0.9.4 // Project: https://github.com/hakimel/Ladda // Definitions by: Danil Flores // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module Ladda { - - interface ILaddaButton { - start(): ILaddaButton; - - stop(): ILaddaButton; - - toggle(): ILaddaButton; - - setProgress(progress: number): ILaddaButton; - - enable(): ILaddaButton; - - disable(): ILaddaButton; - - isLoading(): boolean; - } - - interface ILaddaOptions { - timeout?: number; - callback?: (instance: ILaddaButton) => void; - } - - function bind(target: HTMLElement, options?: ILaddaOptions): void; - function bind(cssSelector: string, options?: ILaddaOptions): void; - - function create(button: Element): ILaddaButton; - - function stopAll(): void; +interface ILaddaButton { + start(): ILaddaButton; + startAfter(delay: number): ILaddaButton + stop(): ILaddaButton; + toggle(): ILaddaButton; + setProgress(progress: number): ILaddaButton; + enable(): ILaddaButton; + disable(): ILaddaButton; + isLoading(): boolean; + remove(): void; +} + +interface ILaddaOptions { + timeout?: number; + callback?: (instance: ILaddaButton) => void; +} + +interface ILadda { + bind(target: HTMLElement, options?: ILaddaOptions): void; + bind(cssSelector: string, options?: ILaddaOptions): void; + + create(button: Element): ILaddaButton; + + stopAll(): void; +} + +declare var Ladda: ILadda; + +declare module "ladda" { + export = Ladda; }