diff --git a/bootstrap-switch/bootstrap-switch-tests.ts b/bootstrap-switch/bootstrap-switch-tests.ts new file mode 100644 index 0000000000..542f71ebd4 --- /dev/null +++ b/bootstrap-switch/bootstrap-switch-tests.ts @@ -0,0 +1,25 @@ +/// +/// + +function test_cases() { + $('#switch').bootstrapSwitch(); + + $('#switch').bootstrapSwitch({ + state: false + }); + + $('#switch').bootstrapSwitch({ + state: false, + disabled: true + }); + + //var mySwitch = $('#switch').get(0); + //mySwitch.toggleAnimate(); + + $('#switch').bootstrapSwitch('state', true, true); + + + $('#switch').on('switchChange.bootstrapSwitch', (event) => { + console.log($(event.target).val()); + }); +} \ No newline at end of file diff --git a/bootstrap-switch/bootstrap-switch.d.ts b/bootstrap-switch/bootstrap-switch.d.ts new file mode 100644 index 0000000000..f562f9ef07 --- /dev/null +++ b/bootstrap-switch/bootstrap-switch.d.ts @@ -0,0 +1,102 @@ +// Type definitions for Bootstrap Switch +// Project: http://www.bootstrap-switch.org/ +// Definitions by: John M. Baughman +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * bootstrap-switch - v3.3.2 Copyright (c) 2012-2013 Mattia Larentis + * Available via the Apache license. + * see: http://www.bootstrap-switch.org/ or https://github.com/nostalgiaz/bootstrap-switch for details. + */ + +/// + +declare module BootstrapSwitch { + interface BootstrapSwitchChangeEventObject extends JQueryEventObject { + state: boolean + } + + interface BootstrapSwitchEventObject extends JQueryEventObject { } + + interface BootstrapSwitchOptions { + state?: boolean; + size?: string; + animate?: boolean; + disabled?: boolean; + readonly?: boolean; + indeterminate?: boolean; + invers?: boolean; + radioAllOff?: boolean; + onColor?: string; + offColor?: string; + onText?: string; + offText?: string; + labelText?: string; + handleWidth?: string; + labelWidth?: string; + baseClass?: string; + wrapperClass?: string; + onInit?: any; + onSwitchChange?: any; + } + + interface Switch { + toggleAnimate(): JQuery; + toggleDisabled(): JQuery; + toggleReadonly(): JQuery; + toggleIndeterminate(): JQuery; + toggleInverse(): JQuery; + destroy(): JQuery; + + state(): boolean; + state(value: any): JQuery; + state(value: any, skip: boolean): JQuery; + toggleState(skip?: boolean): JQuery; + radioAllOff(): boolean; + radioAllOff(state: boolean): JQuery; + size(): string; + size(size: string): JQuery; + animate(): boolean; + animate(state: boolean): JQuery; + disabled(): boolean; + disabled(state: boolean): JQuery; + toggleDisabled(): JQuery; + readonly(): boolean; + readonly(state: boolean): JQuery; + toggleReadOnly(): JQuery; + onColor(): string; + onColor(color: string): JQuery; + offColor(): string; + offColor(color: string): JQuery; + onText(): string; + onText(text: string): JQuery; + offText(): string; + offText(text: string): JQuery; + labelText(): string; + labelText(text: string): JQuery; + baseClass(): string; + baseClass(text: string): JQuery; + wrapperClass(): string; + wrapperClass(text: string): JQuery; + } +} + +interface JQuery { + bootstrapSwitch(): JQuery; + bootstrapSwitch(options: BootstrapSwitch.BootstrapSwitchOptions): JQuery; + bootstrapSwitch(method: string): JQuery; + bootstrapSwitch(method: string, param: any): JQuery; + bootstrapSwitch(method: string, param1: any, param2: any): JQuery; + + off(events: "init.bootstrapSwitch", selector?: string, handler?: (eventobject: BootstrapSwitch.BootstrapSwitchEventObject) => any): JQuery; + off(events: "init.bootstrapSwitch", handler?: (eventobject: BootstrapSwitch.BootstrapSwitchEventObject) => any): JQuery; + + off(events: "switchChange.bootstrapSwitch", selector?: string, handler?: (eventobject: BootstrapSwitch.BootstrapSwitchChangeEventObject) => any): JQuery; + off(events: "switchChange.bootstrapSwitch", handler?: (eventobject: BootstrapSwitch.BootstrapSwitchChangeEventObject) => any): JQuery; + + on(events: "init.bootstrapSwitch", selector?: string, handler?: (eventobject: BootstrapSwitch.BootstrapSwitchEventObject) => any): JQuery; + on(events: "init.bootstrapSwitch", handler?: (eventobject: BootstrapSwitch.BootstrapSwitchEventObject) => any): JQuery; + + on(events: "switchChange.bootstrapSwitch", selector?: string, handler?: (eventobject: BootstrapSwitch.BootstrapSwitchChangeEventObject) => any): JQuery; + on(events: "switchChange.bootstrapSwitch", handler?: (eventobject: BootstrapSwitch.BootstrapSwitchChangeEventObject) => any): JQuery; +} \ No newline at end of file