From b2d61996c7a050a65bf43be42dc9ca5bf985b06f Mon Sep 17 00:00:00 2001 From: Paul Gaske Date: Wed, 25 Jun 2014 12:58:04 +1000 Subject: [PATCH] Added types for the jQuery.prettyPhoto project: https://github.com/scaron/prettyphoto --- CONTRIBUTORS.md | 1 + .../jquery.prettyphoto-tests.ts | 34 ++ jquery.prettyphoto/jquery.prettyphoto.d.ts | 290 ++++++++++++++++++ 3 files changed, 325 insertions(+) create mode 100644 jquery.prettyphoto/jquery.prettyphoto-tests.ts create mode 100644 jquery.prettyphoto/jquery.prettyphoto.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1d32f8c2fd..ae430f57d1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -162,6 +162,7 @@ All definitions files include a header with the author and editors, so at some p * [jQuery.pjax](https://github.com/defunkt/jquery-pjax) (by [Junle Li](https://github.com/lijunle)) * [jQuery.pnotify](http://sciactive.github.io/pnotify/) (by [David Sichau](https://github.com/DavidSichau/)) * [jQuery.postMessage](http://benalman.com/projects/jquery-postmessage-plugin/) (by [Junle Li](https://github.com/lijunle)) +* [jQuery.prettyphoto](https://github.com/scaron/prettyphoto) (by [Paul Gaske](https://github.com/pgaske)) * [jQuery.scrollTo](https://github.com/flesler/jquery.scrollTo) (by [Neil Stalker](https://github.com/nestalk/)) * [jQuery.simplePagination](https://github.com/flaviusmatis/simplePagination.js) (by [Natan Vivo](https://github.com/nvivo/)) * [jquery.superLink](http://james.padolsey.com/demos/plugins/jQuery/superLink/superlink.jquery.js) (by [Blake Niemyjski](https://github.com/niemyjski)) diff --git a/jquery.prettyphoto/jquery.prettyphoto-tests.ts b/jquery.prettyphoto/jquery.prettyphoto-tests.ts new file mode 100644 index 0000000000..1cf3b40a89 --- /dev/null +++ b/jquery.prettyphoto/jquery.prettyphoto-tests.ts @@ -0,0 +1,34 @@ +// Tests for prettyPhoto library + +/// +/// + +// JQUERY + +$('#id').prettyPhoto(); + +$('#id').prettyPhoto({ animation_speed: 'fast' }); + +// JQUERYSTATIC + +$.prettyPhoto.changeGalleryPage('next'); + +$.prettyPhoto.changeGalleryPage('previous'); + +$.prettyPhoto.changePage('next'); + +$.prettyPhoto.changePage('previous'); + +$.prettyPhoto.close(); + +$.prettyPhoto.open(); + +$.prettyPhoto.open('test.jpg', 'title', 'description'); + +$.prettyPhoto.open(['test1.jpg', 'test2.jpg'], ['title1', 'title2'], ['description1', 'description2']); + +$.prettyPhoto.startSlideshow(); + +$.prettyPhoto.stopSlideshow(); + +$.prettyPhoto.version; diff --git a/jquery.prettyphoto/jquery.prettyphoto.d.ts b/jquery.prettyphoto/jquery.prettyphoto.d.ts new file mode 100644 index 0000000000..f60de3b390 --- /dev/null +++ b/jquery.prettyphoto/jquery.prettyphoto.d.ts @@ -0,0 +1,290 @@ +// Type definitions for jQuery prettyPhoto 3.1.5 +// Project: https://github.com/scaron/prettyphoto +// Definitions by: pgaske +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module scaron_prettyPhoto { + /** + * Pretty photo settings + */ + interface PrettyPhotoSettings { + /** + * the attribute tag to use for prettyPhoto hooks. For HTML5, use "data-rel" or similar. + * @default 'rel' + */ + hook?: string; + + /** + * fast/slow/normal + * @default 'fast' + */ + animation_speed?: string; + + + ajaxcallback?: () => void; + + /** + * false OR interval time in ms + * @default 5000 + */ + slideshow?: any; + + /** + * true/false + * @default false + */ + autoplay_slideshow?: boolean; + + /** + * Value between 0 and 1 + * @default 0.80 + */ + opacity?: number; + + /** + * true/false + * @default true + */ + show_title?: boolean; + + /** + * Resize the photos bigger than viewport. true/false + * @default true + */ + allow_resize?: boolean; + + /** + * Allow the user to expand a resized image. true/false + * @default true + */ + allow_expand?: boolean; + + /** + * Pixels + * @default 500 + */ + default_width?: number; + + /** + * Pixels + * @default 344 + */ + default_height?: number; + + /** + * The separator for the gallery counter 1 "of" 2 + * @default '/' + */ + counter_separator_label?: string; + + /** + * light_rounded / dark_rounded / light_square / dark_square / facebook + * @default 'pp_default' + */ + theme?: string; + + /** + * The padding on each side of the picture + * @default 20 + */ + horizontal_padding?: number; + + /** + * Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto + * @default false + */ + hideflash?: boolean; + + /** + * Set the flash wmode attribute + * @default 'opaque' + */ + wmode?: string; + + /** + * Automatically start videos: True/False + * @default true + */ + autoplay?: boolean; + + /** + * If set to true, only the close button will close the window + * @default false + */ + modal?: boolean; + + /** + * Allow prettyPhoto to update the url to enable deeplinking. + * @default true + */ + deeplinking?: boolean; + + /** + * If set to true, a gallery will overlay the fullscreen image on mouse over + * @default true + */ + overlay_gallery?: boolean; + + /** + * Maximum number of pictures in the overlay gallery + * @default 30 + */ + overlay_gallery_max?: number; + + /** + * Set to false if you open forms inside prettyPhoto + * @default true + */ + keyboard_shortcuts?: boolean; + + /** + * Called everytime an item is shown/changed + * @default function () { } + */ + changepicturecallback?: () => void; + + /** + * Called when prettyPhoto is closed + * @default function () { } + */ + callback?: () => void; + + /** + * @default true + */ + ie6_fallback?: boolean; + + /** + * Markup for pretty photo + * @default omitted for brevity + */ + markup?: string; + + /** + * Markup for pretty photo gallery + * @default omitted for brevity + */ + gallery_markup?: string; + + /** + * Markup for image + * @default '' + */ + image_markup?: string; + + /** + * Markup for flash + * @default '' + */ + flash_markup?: string; + + /** + * Markup for quicktime + * @default '' + */ + quicktime_markup?: string; + + /** + * Markup for iframe + * @default '' + */ + iframe_markup?: string; + + /** + * @default '
{content}
' + */ + inline_markup?: string; + + /** + * @default '' + */ + custom_markup?: string; + + /** + * Markup for social tools, set to html or false to disable + * @default '' + */ + social_tools?: any; + } + + interface moduleJQuery { + /** + * Initialises prettyPhoto + */ + (): JQuery; + + /** + * Initialises prettyPhoto specificying overrides for the defaults + * @param pp_settings custom prettyPhoto settings + */ + (pp_settings: PrettyPhotoSettings): JQuery; + } + + interface moduleJQueryStatic { + /** + * prettyPhoto version number + */ + version: string; + + /** + * Opens the prettyPhoto modal box. + * Note: Always returns false. + */ + open(): boolean; + + /** + * Opens the prettyPhoto modal box. + * Note: Always returns false. + * @param image {String} Full path to the image to be open, can also be an array containing full images paths. + * @param title {String} The title to be displayed with the picture, can also be an array containing all the titles. + * @param description {String} The description to be displayed with the picture, can also be an array containing all the descriptions. + */ + open(image: string, title: string, description: string): boolean; + + /** + * Opens the prettyPhoto modal box. + * Note: Always returns false. + * @param image {Array} Full path to the image to be open, can also be an array containing full images paths. + * @param title {Array} The title to be displayed with the picture, can also be an array containing all the titles. + * @param description {Array} The description to be displayed with the picture, can also be an array containing all the descriptions. + */ + open(images: string[], titles: string[], descriptions: string[]): boolean; + + /** + * Change page in the prettyPhoto modal box + * @param direction {String} Direction of the paging, previous or next. + */ + changePage(direction: string): void; + + /** + * Change gallery page in the prettyPhoto modal box + * @param direction {String} Direction of the paging, previous or next. + */ + changeGalleryPage(direction: string): void; + + /** + * Start the slideshow... + */ + startSlideshow(): void; + + /** + * Stop the slideshow... + */ + stopSlideshow(): void; + + /** + * Closes prettyPhoto. + */ + close(): void; + } +} + +interface JQuery { + prettyPhoto: scaron_prettyPhoto.moduleJQuery; +} + +interface JQueryStatic { + prettyPhoto: scaron_prettyPhoto.moduleJQueryStatic; +} \ No newline at end of file