From 5b4c1f883233a0018dbec1010d6da3e87b83bc3d Mon Sep 17 00:00:00 2001 From: Andrea Briganti Date: Wed, 24 May 2017 16:25:53 +0200 Subject: [PATCH] Add jquery-match-height typings --- types/jquery-match-height/index.d.ts | 29 +++++++++++++++ .../jquery-match-height-tests.ts | 36 +++++++++++++++++++ types/jquery-match-height/tsconfig.json | 23 ++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 types/jquery-match-height/index.d.ts create mode 100644 types/jquery-match-height/jquery-match-height-tests.ts create mode 100644 types/jquery-match-height/tsconfig.json diff --git a/types/jquery-match-height/index.d.ts b/types/jquery-match-height/index.d.ts new file mode 100644 index 0000000000..e17cb841c0 --- /dev/null +++ b/types/jquery-match-height/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for jquery-match-height v0.7.2 +// Project: https://github.com/liabru/jquery-match-height +// Definitions by: Andrea Briganti +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +// We cannot add the jQuery.fn definitions of the plugin until this +// issue is resolved +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12685 + +declare namespace JQueryMatchHeight { + interface Options { + byRow?: boolean, + property?: string, + target?: string, + remove?: boolean + } +} + +interface JQuery { + /** + * Set all selected elements to the height of the tallest. + * If the items are on multiple rows, the items of each row will be set to the tallest of that row. + * + * @param options + */ + matchHeight(options?: JQueryMatchHeight.Options): JQuery; +} diff --git a/types/jquery-match-height/jquery-match-height-tests.ts b/types/jquery-match-height/jquery-match-height-tests.ts new file mode 100644 index 0000000000..3adc5936a7 --- /dev/null +++ b/types/jquery-match-height/jquery-match-height-tests.ts @@ -0,0 +1,36 @@ +/* from documentation at https://github.com/liabru/jquery-match-height */ + +$(document).ready(() => { + $(".containers").matchHeight(); + $(".containers").matchHeight({ + byRow: true, + property: "height", + target: null, + remove: true} + ); +}); + +$.fn.matchHeight._update(); + +$.fn.matchHeight._rows($('.containers')); + +$('.containers').matchHeight({ remove: true }); + +$.fn.matchHeight._beforeUpdate = function(event: any, groups: any) { + // do something before any updates are applied +}; + +$.fn.matchHeight._afterUpdate = function(event: any, groups: any) { + // do something after all updates are applied +}; + +let elements = $('.containers'); +let options = {byRow: true}; + +$.fn.matchHeight._apply(elements, options); + +$.fn.matchHeight._throttle = 80; + +$.fn.matchHeight._maintainScroll = true; + +$.fn.matchHeight._groups diff --git a/types/jquery-match-height/tsconfig.json b/types/jquery-match-height/tsconfig.json new file mode 100644 index 0000000000..f90e113f27 --- /dev/null +++ b/types/jquery-match-height/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery-match-height-tests.ts" + ] +}