Merge pull request #16768 from leonard-thieu/jquerystatic-fn

[jquery] Define type for JQueryStatic.fn
This commit is contained in:
John Reilly
2017-06-02 10:54:06 +01:00
committed by GitHub
6 changed files with 56 additions and 19 deletions

View File

@@ -5,9 +5,24 @@
/// <reference types="jquery"/>
// We cannot add the jQuery.fn definitions of the plugin until this
// issue is resolved
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12685
interface JQueryMatchHeight {
_throttle: number;
_maintainScroll: boolean;
_groups: any[];
/**
* 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
*/
(options?: JQueryMatchHeight.Options): JQuery;
_update(): void;
_rows($item: JQuery): any[];
_beforeUpdate(event: JQueryEventObject, groups: any[]): any;
_afterUpdate(event: JQueryEventObject, groups: any[]): any;
_apply(elements: any, options: any): void;
}
declare namespace JQueryMatchHeight {
interface Options {
@@ -19,11 +34,5 @@ declare namespace JQueryMatchHeight {
}
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;
matchHeight: JQueryMatchHeight;
}

View File

@@ -16,12 +16,12 @@ $.fn.matchHeight._rows($('.containers'));
$('.containers').matchHeight({ remove: true });
// tslint:disable-next-line no-used-variable
$.fn.matchHeight._beforeUpdate = (event: any, groups: any) => {
$.fn.matchHeight._beforeUpdate = (event, groups) => {
// do something before any updates are applied
};
// tslint:disable-next-line no-used-variable
$.fn.matchHeight._afterUpdate = (event: any, groups: any) => {
$.fn.matchHeight._afterUpdate = (event, groups) => {
// do something after all updates are applied
};

View File

@@ -259,7 +259,7 @@ $('#s6').cycle({
}
});
$.fn.cycle.transitions.pinch = function ($cont, $slides, opts) {
$.fn.cycle.transitions['pinch'] = function ($cont, $slides, opts) {
var $el = $($slides[0]);
var w = $el.width();
var h = $el.height();

View File

@@ -1,6 +1,26 @@
// Type definitions for jQuery 1.10.x / 2.0.x
// Type definitions for jQuery 2.0
// Project: http://jquery.com/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Christian Hoffmeister <https://github.com/choffmeister>, Steve Fenton <https://github.com/Steve-Fenton>, Diullei Gomes <https://github.com/Diullei>, Tass Iliopoulos <https://github.com/tasoili>, Jason Swearingen <https://github.com/jasons-novaleaf>, Sean Hill <https://github.com/seanski>, Guus Goossens <https://github.com/Guuz>, Kelly Summerlin <https://github.com/ksummerlin>, Basarat Ali Syed <https://github.com/basarat>, Nicholas Wolverson <https://github.com/nwolverson>, Derek Cicerone <https://github.com/derekcicerone>, Andrew Gaspar <https://github.com/AndrewGaspar>, Seikichi Kondo <https://github.com/seikichi>, Benjamin Jackman <https://github.com/benjaminjackman>, Poul Sorensen <https://github.com/s093294>, Josh Strobl <https://github.com/JoshStrobl>, John Reilly <https://github.com/johnnyreilly/>, Dick van den Brink <https://github.com/DickvdBrink>, Thomas Schulz <https://github.com/King2500>
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Christian Hoffmeister <https://github.com/choffmeister>
// Steve Fenton <https://github.com/Steve-Fenton>
// Diullei Gomes <https://github.com/Diullei>
// Tass Iliopoulos <https://github.com/tasoili>
// Jason Swearingen <https://github.com/jasons-novaleaf>
// Sean Hill <https://github.com/seanski>
// Guus Goossens <https://github.com/Guuz>
// Kelly Summerlin <https://github.com/ksummerlin>
// Basarat Ali Syed <https://github.com/basarat>
// Nicholas Wolverson <https://github.com/nwolverson>
// Derek Cicerone <https://github.com/derekcicerone>
// Andrew Gaspar <https://github.com/AndrewGaspar>
// Seikichi Kondo <https://github.com/seikichi>
// Benjamin Jackman <https://github.com/benjaminjackman>
// Poul Sorensen <https://github.com/s093294>
// Josh Strobl <https://github.com/JoshStrobl>
// John Reilly <https://github.com/johnnyreilly/>
// Dick van den Brink <https://github.com/DickvdBrink>
// Thomas Schulz <https://github.com/King2500>
// Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
@@ -1146,7 +1166,7 @@ interface JQueryStatic {
error(message: any): JQuery;
expr: any;
fn: any; //TODO: Decide how we want to type this
readonly fn: JQuery;
isReady: boolean;
@@ -3781,6 +3801,14 @@ interface JQuery {
* @see {@link https://api.jquery.com/queue/#queue-queueName-callback}
*/
queue(queueName: string, callback: Function): JQuery;
/**
* Merge the contents of an object onto the jQuery prototype to provide new jQuery instance methods.
*
* @param object An object to merge onto the jQuery prototype.
* @see {@link https://api.jquery.com/jQuery.fn.extend/#jQuery-fn-extend-object}
*/
extend(object: { [method: string]: (...args: any[]) => any; }): JQuery;
}
declare module "jquery" {
export = $;

View File

@@ -403,7 +403,7 @@ function test_form_specifyingValidationRules() {
function test_form_addCustomRule() {
const user = { adminLevel: 1 };
$.fn.form.settings.rules.adminLevel = (value: any, adminLevel: number) => {
$.fn.form.settings.rules!['adminLevel'] = (value: any, adminLevel: number) => {
return (user.adminLevel >= adminLevel);
};
$('.ui.form').form({

View File

@@ -1,5 +1,5 @@
///<reference types="knockout" />
///<reference types="jquery" />
/// <reference types="knockout" />
/// <reference types="jquery" />
import * as angular from 'angular';
import * as ng from 'angular';