diff --git a/ladda/ladda-tests.ts b/ladda/ladda-tests.ts index 9707534cce..24956950cb 100644 --- a/ladda/ladda-tests.ts +++ b/ladda/ladda-tests.ts @@ -1,5 +1,29 @@ /// +// Automatically trigger the loading animation on click +Ladda.bind('input[type=submit]'); + +// Same as the above but automatically stops after two seconds +Ladda.bind('input[type=submit]', { timeout: 2000 }); + +// Create a new instance of ladda for the specified button +var l = Ladda.create(document.querySelector('.my-button')); + +// Start loading +l.start(); + +// Will display a progress bar for 50% of the button width +l.setProgress(0.5); + +// Stop loading +l.stop(); + +// Toggle between loading/not loading states +l.toggle(); + +// Check the current state +l.isLoading(); + // Test bind Ladda.bind('button.ladda-button', { timeout: 42, callback: btn => alert('Clicked!!!') }); Ladda.bind('button.ladda-button'); @@ -17,4 +41,4 @@ var laddaBtn = Ladda.create(btnElement); laddaBtn.start().stop().toggle().setProgress(42).enable().disable().start(); // Test isLoading -console.assert(laddaBtn.isLoading() === true); \ No newline at end of file +console.assert(laddaBtn.isLoading() === true); diff --git a/ladda/ladda.d.ts b/ladda/ladda.d.ts index 278f00379c..fc4f43b410 100644 --- a/ladda/ladda.d.ts +++ b/ladda/ladda.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jStorage 0.4.0 +// Type definitions for Ladda 0.7.0 // Project: https://github.com/hakimel/Ladda // Definitions by: Danil Flores // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -29,7 +29,7 @@ declare module Ladda { function bind(target: HTMLElement, options?: ILaddaOptions): void; function bind(cssSelector: string, options?: ILaddaOptions): void; - function create(button: HTMLElement): ILaddaButton; + function create(button: Element): ILaddaButton; function stopAll(): void; -} \ No newline at end of file +}