From fb7832af29088554efd2414ad83fb776c4d8eabd Mon Sep 17 00:00:00 2001 From: Albin Sunnanbo Date: Mon, 6 Apr 2015 22:59:23 +0200 Subject: [PATCH 1/2] Add TypeScript definitions and tests for Bootstrap TouchSpin (http://www.virtuosoft.eu/code/bootstrap-touchspin/) --- .../jquery.bootstrap-touchspin-tests.ts | 68 +++++++++ .../jquery.bootstrap-touchspin.d.ts | 130 ++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts create mode 100644 jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts diff --git a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts b/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts new file mode 100644 index 000000000..436b98416 --- /dev/null +++ b/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts @@ -0,0 +1,68 @@ +/// +/// + +$(function () { + // Example 1 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo1']").TouchSpin({ + min: 0, + max: 100, + step: 0.1, + decimals: 2, + boostat: 5, + maxboostedstep: 10, + postfix: '%' + }); + + // Example 2 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo2']").TouchSpin({ + min: -1000000000, + max: 1000000000, + stepinterval: 50, + maxboostedstep: 10000000, + prefix: '$' + }); + + // Example 3 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo_vertical']").TouchSpin({ + verticalbuttons: true + }); + + // Example 4 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo_vertical2']").TouchSpin({ + verticalbuttons: true, + verticalupclass: 'glyphicon glyphicon-plus', + verticaldownclass: 'glyphicon glyphicon-minus' + }); + + // Example 5 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo3']").TouchSpin(); + + // Example 6 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo3_21']").TouchSpin({ + initval: 40 + }); + + // Example 7 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo4']").TouchSpin({ + postfix: "a button", + postfix_extraclass: "btn btn-default" + }); + + // Example 8 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo4_2']").TouchSpin({ + postfix: "a button", + postfix_extraclass: "btn btn-default" + }); + + // Example 9 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo5']").TouchSpin({ + prefix: "pre", + postfix: "post" + }); + + // Example 10 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ + $("input[name='demo6']").TouchSpin({ + buttondown_class: "btn btn-link", + buttonup_class: "btn btn-link" + }); +}); \ No newline at end of file diff --git a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts b/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts new file mode 100644 index 000000000..2dcf62884 --- /dev/null +++ b/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts @@ -0,0 +1,130 @@ +// Type definitions for Bootstrap TouchSpin +// Project: http://www.virtuosoft.eu/code/bootstrap-touchspin/ +// Definitions by: Albin Sunnanbo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** + * TouchSpinOptions. All options are optional + */ +interface TouchSpinOptions { + /** + * Applied when no explicit value is set on the input with the value attribute. + * Empty string means that the value remains empty on initialization. + */ + initval?: number | string; + + /** + * Minimum value. + */ + min?: number; + + /** + * Maximum value. + */ + max?: number; + + /** + * Incremental/decremental step on up/down change. + */ + step?: number; + + /** + * How to force the value to be divisible by step value: 'none' | 'round' | 'floor' | 'ceil' + */ + forcestepdivisibility?: string; + + /** + * Number of decimal points. + */ + decimals?: number; + + /** + * Refresh rate of the spinner in milliseconds. + */ + stepinterval?: number; + + /** + * Time in milliseconds before the spinner starts to spin. + */ + stepintervaldelay?: number; + + /** + * Enables the traditional up/down buttons. + */ + verticalbuttons?: boolean; + + /** + * Class of the up button with vertical buttons mode enabled. + */ + verticalupclass?: string; + + /** + * Class of the down button with vertical buttons mode enabled. + */ + verticaldownclass?: string; + + /** + * Text before the input. + */ + prefix?: string; + + /** + * Text after the input. + */ + postfix?: string; + + /** + * Extra class(es) for prefix. + */ + prefix_extraclass?: string; + + /** + * Extra class(es) for postfix. + */ + postfix_extraclass?: string; + + /** + * If enabled, the the spinner is continually becoming faster as holding the button. + */ + booster?: boolean; + + /** + * Boost at every nth step. + */ + boostat?: number; + + /** + * Maximum step when boosted. + */ + maxboostedstep?: number | boolean; + + /** + * Enables the mouse wheel to change the value of the input. + */ + mousewheel?: boolean; + + /** + * Class(es) of down button. + */ + buttondown_class?: string; + + /** + * Class(es) of up button. + */ + buttonup_class?: string; +} + +interface JQuery { + /** + * Initialize TouchSpin + */ + TouchSpin(): JQuery; + + /** + * Inialize TouchSpin with options + * @param options a TouchSpinOptions object with one or more options + */ + TouchSpin(options: TouchSpinOptions): JQuery; +} From c156c4545fa7aeca27bb25455b6d34d0497f2d57 Mon Sep 17 00:00:00 2001 From: Albin Sunnanbo Date: Sun, 12 Apr 2015 08:05:52 +0200 Subject: [PATCH 2/2] Add TypeScript definitions and tests for Bootstrap TouchSpin (http://www.virtuosoft.eu/code/bootstrap-touchspin/) - Rename to bootstrap-touchspin as suggested in https://github.com/borisyankov/DefinitelyTyped/pull/4054#issuecomment-90607707 --- .../bootstrap-touchspin-tests.ts | 2 +- .../bootstrap-touchspin.d.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts => bootstrap-touchspin/bootstrap-touchspin-tests.ts (97%) rename jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts => bootstrap-touchspin/bootstrap-touchspin.d.ts (100%) diff --git a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts b/bootstrap-touchspin/bootstrap-touchspin-tests.ts similarity index 97% rename from jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts rename to bootstrap-touchspin/bootstrap-touchspin-tests.ts index 436b98416..552c26f52 100644 --- a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin-tests.ts +++ b/bootstrap-touchspin/bootstrap-touchspin-tests.ts @@ -1,5 +1,5 @@ /// -/// +/// $(function () { // Example 1 from http://www.virtuosoft.eu/code/bootstrap-touchspin/ diff --git a/jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts b/bootstrap-touchspin/bootstrap-touchspin.d.ts similarity index 100% rename from jquery.bootstrap-touchspin/jquery.bootstrap-touchspin.d.ts rename to bootstrap-touchspin/bootstrap-touchspin.d.ts