From 82f84e6176450f23e1a3ccde0ec7f5aca7729b8d Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Fri, 30 Aug 2013 12:13:04 -0500 Subject: [PATCH 1/2] Fix incorrect library name in Ladda definition file --- ladda/ladda.d.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ladda/ladda.d.ts b/ladda/ladda.d.ts index 278f00379c..7b5204ad32 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 @@ -31,5 +31,4 @@ declare module Ladda { function create(button: HTMLElement): ILaddaButton; - function stopAll(): void; -} \ No newline at end of file + function stopAll(): void;} From 40b08478e04dfad66435edbf61b02e63587050a0 Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Fri, 30 Aug 2013 12:16:22 -0500 Subject: [PATCH 2/2] Added additional tests (from project homepage) create() method should accept a parameter of type Element, rather than HTMLElement to work with document.querySelector() --- ladda/ladda-tests.ts | 26 +++++++++++++++++++++++++- ladda/ladda.d.ts | 5 +++-- 2 files changed, 28 insertions(+), 3 deletions(-) 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 7b5204ad32..fc4f43b410 100644 --- a/ladda/ladda.d.ts +++ b/ladda/ladda.d.ts @@ -29,6 +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;} + function stopAll(): void; +}