Adding Definitions for Ladda jQuery Plugin 0.9.4

This commit is contained in:
Michael Lee
2015-01-12 22:55:34 -06:00
parent 0605ebbdbd
commit 195fcbd17c
2 changed files with 59 additions and 1 deletions

View File

@@ -48,3 +48,30 @@ laddaBtn.start().stop().toggle().setProgress(42).enable().disable().start();
// Test isLoading
console.assert(laddaBtn.isLoading() === true);
//Test jQuery plugin Support
// Automatically trigger the loading animation on click
$('input[type=submit]').ladda('bind');
// Same as the above but automatically stops after two seconds
$('input[type=submit]').ladda('bind', { timeout: 2000 });
// Create a new instance of ladda for the specified button
var ljq = $('.my-button').ladda();
// Start loading
ljq.ladda('start');
// Will display a progress bar for 50% of the button width
ljq.ladda('setProgress', 0.5);
// Stop loading
ljq.ladda('stop');
// Toggle between loading/not loading states
ljq.ladda('toggle');
// Check the current state
ljq.ladda('isLoading');
$.ladda('stopAll');

33
ladda/ladda.d.ts vendored
View File

@@ -1,8 +1,10 @@
// Type definitions for Ladda 0.9.4
// Project: https://github.com/hakimel/Ladda
// Definitions by: Danil Flores <https://github.com/dflor003/>
// Definitions by: Danil Flores <https://github.com/dflor003/>, Michael Lee <https://github.com/leemicw>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
interface ILaddaButton {
start(): ILaddaButton;
startAfter(delay: number): ILaddaButton
@@ -34,3 +36,32 @@ declare var Ladda: ILadda;
declare module "ladda" {
export = Ladda;
}
interface JQuery {
/**
* Creates a new instance of ladda for the selected button
*/
ladda(): JQuery;
/**
* The action controls or checks the state of the ladda button.
* Possible actions are 'start', 'stop', 'toggle', 'stopAll'
* Possible check 'isLoading'
*/
ladda(action: string): JQuery;
/**
* When the action is 'setProgress' you can pass a number between
* 0 and 1 for the options to represent the progress. For example .5 would be 50%
* When the action is 'bind' you can pass an object with a property
* called timeout with the timeout value in milliseconds.
* For example { timeout: 2000 }
*/
ladda(action: string, options: any): JQuery;
}
interface JQueryStatic {
ladda(action: string): JQuery;
}