Added additional tests (from project homepage)

create() method should accept a parameter of type Element, rather than HTMLElement to work with document.querySelector()
This commit is contained in:
Theodore Brown
2013-08-30 12:16:22 -05:00
parent 82f84e6176
commit 40b08478e0
2 changed files with 28 additions and 3 deletions
+25 -1
View File
@@ -1,5 +1,29 @@
/// <reference path="ladda.d.ts" />
// 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);
console.assert(laddaBtn.isLoading() === true);
+3 -2
View File
@@ -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;
}