From 4f2e203405a9dfa0d914d81b714981a758488628 Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Fri, 9 Jan 2015 14:32:41 -0600 Subject: [PATCH 1/2] Add jquery.tipsy --- jquery.tipsy/jquery.tipsy-tests.ts | 32 ++++++++++++++++++++++++++ jquery.tipsy/jquery.tipsy.d.ts | 36 ++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 jquery.tipsy/jquery.tipsy-tests.ts create mode 100644 jquery.tipsy/jquery.tipsy.d.ts diff --git a/jquery.tipsy/jquery.tipsy-tests.ts b/jquery.tipsy/jquery.tipsy-tests.ts new file mode 100644 index 000000000..384e34a21 --- /dev/null +++ b/jquery.tipsy/jquery.tipsy-tests.ts @@ -0,0 +1,32 @@ +/// +/// + +// basic +$('#example-1').tipsy(); + +// code snippets from http://onehackoranother.com/projects/jquery/tipsy/ +$('#foo').tipsy({gravity: 'n'}); // nw | n | ne | w | e | sw | s | se + +$('#foo').tipsy({gravity: $.fn.tipsy.autoNS}); + +$('#example-fade').tipsy({fade: true}); + +$('#example-custom-attribute').tipsy({title: 'id'}); + +$('#example-callback').tipsy({title: function() { return this.getAttribute('original-title').toUpperCase(); } }); + +$('#example-fallback').tipsy({fallback: "Where's my tooltip yo'?" }); + +$('#example-html').tipsy({html: true }); + +$('#example-delay').tipsy({delayIn: 500, delayOut: 1000}); + +$(function() { + $('#focus-example [title]').tipsy({trigger: 'focus', gravity: 'w'}); +}); + +function onclickExample1() { $("#manual-example a[rel=tipsy]").tipsy("show"); return false; } +function onclickExample2() { $("#manual-example a[rel=tipsy]").tipsy("hide"); return false; } +$('#manual-example a[rel=tipsy]').tipsy({trigger: 'manual'}); + +$('a.live-tipsy').tipsy({live: true}); \ No newline at end of file diff --git a/jquery.tipsy/jquery.tipsy.d.ts b/jquery.tipsy/jquery.tipsy.d.ts new file mode 100644 index 000000000..097f7ece8 --- /dev/null +++ b/jquery.tipsy/jquery.tipsy.d.ts @@ -0,0 +1,36 @@ +// Type definitions for jQuery.tipsy +// Project: http://onehackoranother.com/projects/jquery/tipsy/ +// https://github.com/jaz303/tipsy +// Definitions by: Brian Dukes +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface JQuery { + tipsy: JQueryTipsy.Tipsy; +} + + +declare module JQueryTipsy { + interface Tipsy { + (options?: Options): JQuery; + autoNS: () => string; + autoWE: () => string; + autoSWSE: () => string; + autoNWNE: () => string; + } + + interface Options { + delayIn?: number; + delayOut?: number; + fade?: boolean; + fallback?: string; + gravity?: any; // string or () => string + html?: boolean; + live?: boolean; + offset?: number; + opacity?: number; + title?: any; // string or () => string + trigger?: string; + } +} From d5baa434baf3acbaf5bec0a342b038f920a11034 Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Fri, 9 Jan 2015 14:47:20 -0600 Subject: [PATCH 2/2] Add JSDoc to jquery.tipsy --- jquery.tipsy/jquery.tipsy.d.ts | 95 +++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 12 deletions(-) diff --git a/jquery.tipsy/jquery.tipsy.d.ts b/jquery.tipsy/jquery.tipsy.d.ts index 097f7ece8..d586eefbd 100644 --- a/jquery.tipsy/jquery.tipsy.d.ts +++ b/jquery.tipsy/jquery.tipsy.d.ts @@ -1,36 +1,107 @@ // Type definitions for jQuery.tipsy // Project: http://onehackoranother.com/projects/jquery/tipsy/ -// https://github.com/jaz303/tipsy // Definitions by: Brian Dukes // Definitions: https://github.com/borisyankov/DefinitelyTyped /// interface JQuery { + /** + * initialize tipsy plugin + */ tipsy: JQueryTipsy.Tipsy; } - -declare module JQueryTipsy { - interface Tipsy { - (options?: Options): JQuery; - autoNS: () => string; - autoWE: () => string; - autoSWSE: () => string; - autoNWNE: () => string; - } - +declare module JQueryTipsy { interface Options { + /** + * delay before showing tooltip (ms) + * + * default: 0 + */ delayIn?: number; + /** + * delay before hiding tooltip (ms) + * + * default: 0 + */ delayOut?: number; + /** + * fade tooltips in/out? + * + * default: false + */ fade?: boolean; + /** + * fallback text to use when no tooltip text + * + * default: '' + */ fallback?: string; + /** + * gravity + * + * default: 'n' + */ gravity?: any; // string or () => string + /** + * is tooltip content HTML? + * + * default: false + */ html?: boolean; + /** + * use live event support? + * + * default: false + */ live?: boolean; + /** + * pixel offset of tooltip from element + * + * default: 0 + */ offset?: number; + /** + * opacity of tooltip + * + * default: 0.8 + */ opacity?: number; + /** + * attribute/callback containing tooltip text + * + * default: 'title' + */ title?: any; // string or () => string + /** + * how tooltip is triggered - hover | focus | manual + * + * default: 'hover' + */ trigger?: string; - } + } + + interface Tipsy { + /** + * initialize tipsy plugin + */ + (options?: Options): JQuery; + /** + * determine gravity either to North or South automatically based on the element's location in the viewport + */ + autoNS: () => string; + /** + * determine gravity either to West or East automatically based on the element's location in the viewport + */ + autoWE: () => string; + /** + * determine gravity either to Southwest or Southeast automatically based on the element's location in the viewport + */ + autoSWSE: () => string; + /** + * determine gravity either to Northwest or Northeast automatically based on the element's location in the viewport + */ + autoNWNE: () => string; + } }