minhur / bootstrap-toggle

Bootstrap Toggle is a highly flexible Bootstrap plugin that converts checkboxes into toggles
http://www.bootstraptoggle.com
MIT License
1.48k stars 440 forks source link

Typescript definition file #203

Open ArthurBorsboom opened 5 years ago

ArthurBorsboom commented 5 years ago

While searching for a Typescript definition file for bootstrap toggle, I have found a beginning on stackoverflow, which I have extended for my use cases. The defintion file is far from complete, however it is a nice start.

I would like to share it here, so hopefully someone can pick it up and extend it, to make it publicly available.

Filename: index.d.ts

interface BootstrapToggleOptions {
    on?: string;
    off?: string;
    onstyle?: OnOffStyle;
    offstyle?: OnOffStyle;
    size?: Size;
    width?: number;
    height?: number;
}

type BootstrapToggleMethods = "destroy" | "on" | "off" | "toggle" | "enable" | "disable";
type OnOffStyle = "default" | "primary" | "success" | "info" | "warning" | "danger";
type Size = "large" | "normal" | "small" | "mini";

interface JQuery {
    bootstrapToggle(): JQuery;
    bootstrapToggle( options?: BootstrapToggleOptions ): JQuery;
    bootstrapToggle( method?: BootstrapToggleMethods ): JQuery;
}