From ccb835b2b49d12a6ed8ccc39775ed28b49e2314f Mon Sep 17 00:00:00 2001 From: VorobeY1326 Date: Fri, 20 May 2016 20:25:55 +0500 Subject: [PATCH 1/7] Definitions for jquery.tooltipster 3.3.0 --- jquery.tooltipster/jquery.tooltipster.d.ts | 41 ++++++++++++++++------ 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/jquery.tooltipster/jquery.tooltipster.d.ts b/jquery.tooltipster/jquery.tooltipster.d.ts index a4df0a36e3..13260f15fe 100644 --- a/jquery.tooltipster/jquery.tooltipster.d.ts +++ b/jquery.tooltipster/jquery.tooltipster.d.ts @@ -1,6 +1,6 @@ -// Type definitions for jQuery Tooltipster 3.0.5 +// Type definitions for jQuery Tooltipster 3.3.0 // Project: https://github.com/iamceege/tooltipster -// Definitions by: Patrick Magee +// Definitions by: Patrick Magee , Dmitry Pesterev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -21,14 +21,13 @@ interface JQueryTooltipsterOptions { */ arrowColor?: any; /** - * If autoClose is set to false, the tooltip will never close unless you call the 'close' method yourself. Default: true + * If autoClose is set to false, the tooltip will never close unless you call the 'hide' method yourself. Default: true */ autoClose?: boolean; /** * If set, this will override the content of the tooltip. Default: null - * @type string, jQuery object */ - content?: any; + content?: string | JQuery; /** * If the content of the tooltip is provided as a string, it is displayed as plain text by default. If this content should actually be interpreted as HTML, set this option to true. Default: false */ @@ -38,15 +37,19 @@ interface JQueryTooltipsterOptions { */ contentCloning?: boolean; /** + * Tooltipster logs notices into the console when you're doing something you ideally shouldn't be doing. Set to false to disable logging. Default: true + */ + debug?: boolean; + /** * Delay how long it takes (in milliseconds) for the tooltip to start animating in. Default: 200 */ delay?: number; /** - * Set a fixed width for the tooltip. The tooltip will always be a consistent width - no matter your content size. Default: 0 (auto width) + * Set a minimum width for the tooltip. Default: 0 (auto width) */ - fixedWidth?: number; + minWidth?: number; /** - * Set a max width for the tooltip. If the tooltip ends up being smaller than the set max width, the tooltip's width will be set automatically. Default: 0 (no max width) + * Set a maximum width for the tooltip. Default: null (no max width) */ maxWidth?: number; /** @@ -66,10 +69,13 @@ interface JQueryTooltipsterOptions { */ functionAfter?: (origin) => void; /** - * If using the iconDesktop or iconTouch options, this sets the content for your icon. Default: '(?)' - * @type string, jQuery object + * If true, the tooltip will close if its origin is clicked. This option only applies when 'trigger' is 'hover' and 'autoClose' is false. Default: false */ - icon?: any; + hideOnClick?: boolean; + /** + * If using the iconDesktop or iconTouch options, this sets the content for your icon. Default: '(?)' + */ + icon?: string | JQuery; /** * If you provide a jQuery object to the 'icon' option, this sets if it is a clone of this object that should actually be used. Default: true */ @@ -95,6 +101,10 @@ interface JQueryTooltipsterOptions { */ interactiveTolerance?: number; /** + * Allows you to put multiple tooltips on a single element. Read further instructions down this page. Default: false + */ + multiple?: boolean; + /** * Offsets the tooltip (in pixels) farther left/right from the origin. Default: 0 */ offsetX?: number; @@ -116,6 +126,15 @@ interface JQueryTooltipsterOptions { */ positionTracker?: boolean; /** + * Called after the tooltip has been repositioned by the position tracker (if enabled). Default: A function that will close the tooltip if the trigger is 'hover' and autoClose is false. + */ + positionTrackerCallback?: (origin) => void; + /** + * Specify if a TITLE attribute should be restored on the HTML element after a call to the 'destroy' method. This attribute may be omitted, or be restored with the value that existed before Tooltipster was initialized, or be restored with the stringified value of the current content. Note: in case of multiple tooltips on a single element, only the last destroyed tooltip may trigger a restoration. Default: 'current' + * 'none', 'previous' or 'current' + */ + restoration?: string; + /** * Set the speed of the animation. Default: 350 */ speed?: number; From da38d0569abda73fd1b8b6d768781059433adbf2 Mon Sep 17 00:00:00 2001 From: VorobeY1326 Date: Fri, 20 May 2016 20:26:56 +0500 Subject: [PATCH 2/7] Updated tests to test type union in content --- jquery.tooltipster/jquery.tooltipster-tests.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jquery.tooltipster/jquery.tooltipster-tests.ts b/jquery.tooltipster/jquery.tooltipster-tests.ts index 8a8f29acae..df5ec17e51 100644 --- a/jquery.tooltipster/jquery.tooltipster-tests.ts +++ b/jquery.tooltipster/jquery.tooltipster-tests.ts @@ -2,7 +2,7 @@ // Type definition tests for jQuery Tooltipster 3.0.5 // Project: https://github.com/iamceege/tooltipster -// Definitions by: Patrick Magee +// Definitions by: Patrick Magee , Dmitry Pesterev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Tests taken from the getting started section of the Tooltipster website @@ -13,6 +13,10 @@ $(document).ready(function () { $('#my-tooltip').tooltipster({ content: $(' This text is in bold case !') }); + + $('#my-tooltip').tooltipster({ + content: 'string test' + }); }); @@ -191,4 +195,4 @@ $(document).ready(function () { }); }); -$('#my-special-tooltip').tooltipster('content', 'My new content'); \ No newline at end of file +$('#my-special-tooltip').tooltipster('content', 'My new content'); From 15e410b756322c505802ab2b006cda295d808ccb Mon Sep 17 00:00:00 2001 From: VorobeY1326 Date: Fri, 20 May 2016 20:27:34 +0500 Subject: [PATCH 3/7] Version --- jquery.tooltipster/jquery.tooltipster-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.tooltipster/jquery.tooltipster-tests.ts b/jquery.tooltipster/jquery.tooltipster-tests.ts index df5ec17e51..21a5446c12 100644 --- a/jquery.tooltipster/jquery.tooltipster-tests.ts +++ b/jquery.tooltipster/jquery.tooltipster-tests.ts @@ -1,6 +1,6 @@ /// -// Type definition tests for jQuery Tooltipster 3.0.5 +// Type definition tests for jQuery Tooltipster 3.3.0 // Project: https://github.com/iamceege/tooltipster // Definitions by: Patrick Magee , Dmitry Pesterev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 0055a7b7589ee0fe2d1770b7ad0150c7e009da96 Mon Sep 17 00:00:00 2001 From: VorobeY1326 Date: Tue, 7 Feb 2017 19:24:55 +0500 Subject: [PATCH 4/7] Definition for dropkickjs library --- dropkickjs/dropkickjs-tests.ts | 91 ++++++++++++++++++++++++++++++++++ dropkickjs/index.d.ts | 52 +++++++++++++++++++ dropkickjs/tsconfig.json | 20 ++++++++ dropkickjs/tslint.json | 1 + 4 files changed, 164 insertions(+) create mode 100644 dropkickjs/dropkickjs-tests.ts create mode 100644 dropkickjs/index.d.ts create mode 100644 dropkickjs/tsconfig.json create mode 100644 dropkickjs/tslint.json diff --git a/dropkickjs/dropkickjs-tests.ts b/dropkickjs/dropkickjs-tests.ts new file mode 100644 index 0000000000..af46b43c02 --- /dev/null +++ b/dropkickjs/dropkickjs-tests.ts @@ -0,0 +1,91 @@ +/// + +//constructor +var constructorNoOptions = new Dropkick('#my-select'); +var constructorNoOptions2 = new Dropkick(new HTMLSelectElement()); +var constructorOptions = new Dropkick('#my-select', {}); +var constructorOptions2 = new Dropkick(new HTMLSelectElement(), {}); + +//options +var options : DropkickOptions = { + disabled: true, + form: new HTMLFormElement(), + length: 1, + mobile: true, + multiple: true, + options: ['test'], + selectedIndex: 0, + selectedOptions: ['test'], + value: 'test', + change() { }, + close() { }, + open() { }, + initialize: () => { } +} +var withFullOptions = new Dropkick('#test', options); + +var dk = new Dropkick('#test'); + +//fields (same as options) +var o1 = dk.disabled; +var o2 = dk.form; +var o3 = dk.length; +var o4 = dk.mobile; +var o5 = dk.multiple; +var o6 = dk.options; +var o7 = dk.selectedIndex; +var o8 = dk.selectedOptions; +var o9 = dk.value; + +//methods +dk.add('new'); +dk.add(new HTMLSelectElement()); +dk.add('new', 'old'); +dk.add('new', 1); + +dk.disable(); +dk.disable(false); +dk.disable(4, true); +dk.disable(4); + +dk.dispose(); + +dk.focus(); + +dk.hide(4); +dk.hide(4, false); + +var node = dk.item(4); + +dk.open(); + +dk.refresh(); + +dk.remove(4); + +dk.reset(); +dk.reset(true); + +var words = dk.search("qwer", "fuzzy"); + +var node2 = dk.select(4); +var node3 = dk.select("AL"); +var node4 = dk.select(4, true); + +var node5 = dk.selectOne(4); +var node6 = dk.selectOne(4, true); + +//real life example +var fieldValue = ''; +var selectOptions : DropkickOptions = { + open(this: Dropkick) { + const optionsList = (this).data.elem.lastChild; //undocumented but useful data field + if (optionsList.scrollWidth > optionsList.offsetWidth) { + optionsList.style.width = optionsList.scrollWidth + 25 + 'px'; + } + }, + change: () => { + fieldValue = select.value; + } +}; +var select = new Dropkick('#select', options); \ No newline at end of file diff --git a/dropkickjs/index.d.ts b/dropkickjs/index.d.ts new file mode 100644 index 0000000000..80818ff789 --- /dev/null +++ b/dropkickjs/index.d.ts @@ -0,0 +1,52 @@ +// Type definitions for dropkickjs v2.1.9 +// Project: http://dropkickjs.com/ +// Definitions by Dmitry Pesterev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface DropkickOptions { + disabled?: boolean; + form?: Node; + length?: number; + mobile?: boolean; + multiple?: boolean; + options?: Array; + selectedIndex?: number; + selectedOptions?: Array; + value?: string; + + change?: () => void; + close?: () => void; + initialize?: () => void; + open?: () => void; +} + +declare class Dropkick { + constructor(id: string, options?: DropkickOptions); + constructor(element: HTMLElement, options?: DropkickOptions); + + add(value: string | Node, before?: number | string): void; + close(): void; + disable(disabled?: boolean): void; + disable(index: number, disabled?: boolean): void; + dispose(): void; + focus(): void; + hide(index: number, hidden?: boolean): void; + item(index: number): Node; + open(): void; + refresh(): void; + remove(index: number): void; + reset(clear?: boolean): void; + search(string: string, mode?: string): Array; + select(element: number|string, selectDisabled?: boolean): Node; + selectOne(element: number, selectDisabled?: boolean): Node; + + disabled: boolean; + form: Node; + length: number; + mobile: boolean; + multiple: boolean; + options: Array; + selectedIndex: number; + selectedOptions: Array; + value: string; +} \ No newline at end of file diff --git a/dropkickjs/tsconfig.json b/dropkickjs/tsconfig.json new file mode 100644 index 0000000000..e0699ecf5c --- /dev/null +++ b/dropkickjs/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "dropkickjs-tests.ts" + ] +} \ No newline at end of file diff --git a/dropkickjs/tslint.json b/dropkickjs/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/dropkickjs/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From e6d4014e92ddca6cdf9c50a30de4cb754a743d79 Mon Sep 17 00:00:00 2001 From: VorobeY1326 Date: Tue, 7 Feb 2017 19:40:38 +0500 Subject: [PATCH 5/7] Header fix --- dropkickjs/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dropkickjs/index.d.ts b/dropkickjs/index.d.ts index 80818ff789..1884749629 100644 --- a/dropkickjs/index.d.ts +++ b/dropkickjs/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for dropkickjs v2.1.9 // Project: http://dropkickjs.com/ -// Definitions by Dmitry Pesterev +// Definitions by: Dmitry Pesterev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface DropkickOptions { From 59dc6f0c84c28bcebe2b5016eb58f940e7c73f88 Mon Sep 17 00:00:00 2001 From: VorobeY1326 Date: Tue, 7 Feb 2017 19:46:40 +0500 Subject: [PATCH 6/7] Fixed tslint warnings --- dropkickjs/index.d.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dropkickjs/index.d.ts b/dropkickjs/index.d.ts index 1884749629..8af96c1a57 100644 --- a/dropkickjs/index.d.ts +++ b/dropkickjs/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for dropkickjs v2.1.9 +// Type definitions for dropkickjs v2.1 // Project: http://dropkickjs.com/ // Definitions by: Dmitry Pesterev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -9,9 +9,9 @@ interface DropkickOptions { length?: number; mobile?: boolean; multiple?: boolean; - options?: Array; + options?: string[]; selectedIndex?: number; - selectedOptions?: Array; + selectedOptions?: string[]; value?: string; change?: () => void; @@ -21,8 +21,7 @@ interface DropkickOptions { } declare class Dropkick { - constructor(id: string, options?: DropkickOptions); - constructor(element: HTMLElement, options?: DropkickOptions); + constructor(id: string|HTMLElement, options?: DropkickOptions); add(value: string | Node, before?: number | string): void; close(): void; @@ -36,7 +35,7 @@ declare class Dropkick { refresh(): void; remove(index: number): void; reset(clear?: boolean): void; - search(string: string, mode?: string): Array; + search(string: string, mode?: string): string[]; select(element: number|string, selectDisabled?: boolean): Node; selectOne(element: number, selectDisabled?: boolean): Node; @@ -45,8 +44,8 @@ declare class Dropkick { length: number; mobile: boolean; multiple: boolean; - options: Array; + options: string[]; selectedIndex: number; - selectedOptions: Array; + selectedOptions: string[]; value: string; } \ No newline at end of file From 723a4cdf203a7326e70e921b704ee57c57bf83ac Mon Sep 17 00:00:00 2001 From: VorobeY1326 Date: Tue, 7 Feb 2017 19:49:58 +0500 Subject: [PATCH 7/7] And now tslint will pass --- dropkickjs/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dropkickjs/index.d.ts b/dropkickjs/index.d.ts index 8af96c1a57..1e0a4f4acf 100644 --- a/dropkickjs/index.d.ts +++ b/dropkickjs/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for dropkickjs v2.1 +// Type definitions for dropkickjs 2.1 // Project: http://dropkickjs.com/ // Definitions by: Dmitry Pesterev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped