mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
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:
+25
-1
@@ -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);
|
||||
|
||||
Vendored
+3
-2
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user