diff --git a/README.md b/README.md index 3cfeba4d1..2943452fd 100755 --- a/README.md +++ b/README.md @@ -126,8 +126,9 @@ List of Definitions * [KoLite](https://github.com/CodeSeven/kolite) (by [Boris Yankov](https://github.com/borisyankov)) * [Leaflet](https://github.com/Leaflet/Leaflet) (by [Vladimir](https://github.com/rgripper)) * [Libxmljs](https://github.com/polotek/libxmljs) (by [François de Campredon](https://github.com/fdecampredon)) +* [ladda](https://github.com/hakimel/Ladda) (by [Danil Flores](https://github.com/dflor003)) * [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder)) -* [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone] (https://github.com/vbortone)) +* [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone)) * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) * [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/)) * [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) diff --git a/ladda/ladda-tests.ts b/ladda/ladda-tests.ts new file mode 100644 index 000000000..9707534cc --- /dev/null +++ b/ladda/ladda-tests.ts @@ -0,0 +1,20 @@ +/// + +// Test bind +Ladda.bind('button.ladda-button', { timeout: 42, callback: btn => alert('Clicked!!!') }); +Ladda.bind('button.ladda-button'); +Ladda.bind(document.createElement('button'), {}); +Ladda.bind(document.createElement('button')); + +// Test stop all +Ladda.stopAll(); + +// Test create +var btnElement = document.createElement('button'); +var laddaBtn = Ladda.create(btnElement); + +// Test operations via chaining +laddaBtn.start().stop().toggle().setProgress(42).enable().disable().start(); + +// Test isLoading +console.assert(laddaBtn.isLoading() === true); \ No newline at end of file diff --git a/ladda/ladda.d.ts b/ladda/ladda.d.ts new file mode 100644 index 000000000..278f00379 --- /dev/null +++ b/ladda/ladda.d.ts @@ -0,0 +1,35 @@ +// Type definitions for jStorage 0.4.0 +// Project: https://github.com/hakimel/Ladda +// Definitions by: Danil Flores +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Ladda { + + interface ILaddaButton { + start(): ILaddaButton; + + stop(): ILaddaButton; + + toggle(): ILaddaButton; + + setProgress(progress: number): ILaddaButton; + + enable(): ILaddaButton; + + disable(): ILaddaButton; + + isLoading(): boolean; + } + + interface ILaddaOptions { + timeout?: number; + callback?: (instance: ILaddaButton) => void; + } + + function bind(target: HTMLElement, options?: ILaddaOptions): void; + function bind(cssSelector: string, options?: ILaddaOptions): void; + + function create(button: HTMLElement): ILaddaButton; + + function stopAll(): void; +} \ No newline at end of file