diff --git a/README.md b/README.md index f059ec8..1beea25 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ let namespaces = mw.config.get("pageTriageNamespaces") as number[]; ### MediaWiki API parameters -This package also provides typings for API request parameters for the [MediaWiki Action API](https://www.mediawiki.org/wiki/API:Main_page). API endpoints defined in MediaWiki core and by a number of common extensions (the ones enabled on English Wikipedia) are covered. These aren't exported to the global scope, however. For usage, you need to import them. For example: +This package also provides typings for API request parameters for the [MediaWiki Action API](https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page). API endpoints defined in MediaWiki core and by a number of common extensions (the ones enabled on English Wikipedia) are covered. These aren't exported to the global scope, however. For usage, you need to import them. For example: ```ts import type { ApiEditPageParams, ApiParseParams } from "types-mediawiki/api_params"; diff --git a/jquery/client.d.ts b/jquery/client.d.ts index 152e6e6..1f03fba 100644 --- a/jquery/client.d.ts +++ b/jquery/client.d.ts @@ -1,9 +1,9 @@ declare global { interface JQueryStatic { /** - * User-agent detection + * User-agent detection. * - * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/jQuery.client + * @see https://doc.wikimedia.org/jquery-client/master/jQuery.client.html */ client: Client; } @@ -27,19 +27,6 @@ interface Client { * } * ``` * - * Example: - * - * ```js - * if ( $.client.profile().layout == 'gecko' ) { - * // This will only run in Gecko browsers, such as Mozilla Firefox. - * } - * - * var profile = $.client.profile(); - * if ( profile.layout == 'gecko' && profile.platform == 'linux' ) { - * // This will only run in Gecko browsers on Linux. - * } - * ``` - * * Recognised browser names: * * - `android` (legacy Android browser, prior to Chrome Mobile) @@ -76,10 +63,21 @@ interface Client { * - `solaris` (untested) * - `win` * + * @example + * ```js + * if ( $.client.profile().layout == 'gecko' ) { + * // This will only run in Gecko browsers, such as Mozilla Firefox. + * } + * + * var profile = $.client.profile(); + * if ( profile.layout == 'gecko' && profile.platform == 'linux' ) { + * // This will only run in Gecko browsers on Linux. + * } + * ``` * @param {ClientNavigator} [nav] An object with a 'userAgent' and 'platform' property. * Defaults to the global `navigator` object. * @returns {ClientProfile} The client object - * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/jQuery.client-method-profile + * @see https://doc.wikimedia.org/jquery-client/master/jQuery.client.html#.profile */ profile(nav?: ClientNavigator): ClientProfile; @@ -124,14 +122,14 @@ interface Client { * @param {boolean} [exactMatchOnly=false] Only return true if the browser is matched, * otherwise returns true if the browser is not found. * @returns {boolean} The current browser is in the support map - * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/jQuery.client-method-test + * @see https://doc.wikimedia.org/jquery-client/master/jQuery.client.html#.test */ test(map: ClientSupportMap, profile?: ClientProfile, exactMatchOnly?: boolean): boolean; } export interface ClientNavigator { - userAgent: string; platform: string; + userAgent: string; } type ClientProfileName = @@ -159,9 +157,9 @@ type ClientSupportMap = | Record<"ltr" | "rtl", UndirectedClientSupportMap>; interface ClientProfile { - name: ClientProfileName; layout: "edge" | "gecko" | "khtml" | "presto" | "trident" | "webkit"; layoutVersion: number; + name: ClientProfileName; platform: "ipad" | "iphone" | "linux" | "mac" | "solaris" | "win"; version: string; versionBase: string; diff --git a/jquery/collapsibleTabs.d.ts b/jquery/collapsibleTabs.d.ts index b218fdf..4a2af39 100644 --- a/jquery/collapsibleTabs.d.ts +++ b/jquery/collapsibleTabs.d.ts @@ -1,26 +1,27 @@ -/** - * CollapsibleTabsPlugin used in MediaWiki vector skin - * Copied from https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/skins/Vector/+/master/resources/CollapsibleTabsPlugin.d.ts - */ - declare global { interface JQueryStatic { + /** + * CollapsibleTabsPlugin used in MediaWiki vector skin + * Copied from {@link https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/skins/Vector/+/master/resources/CollapsibleTabsPlugin.d.ts} + */ collapsibleTabs: CollapsibleTabsStatic; } interface JQuery { + /** + * CollapsibleTabsPlugin used in MediaWiki vector skin + * Copied from {@link https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/skins/Vector/+/master/resources/CollapsibleTabsPlugin.d.ts} + */ collapsibleTabs(options: Partial): void; } } /** * A jQuery plugin that makes collapsible tabs for the Vector skin. + * + * @see https://doc.wikimedia.org/mediawiki-skins-Vector/master/js/js/CollapsibleTabsOptions.html */ interface CollapsibleTabsOptions { - /** - * Optional tab selector. Defaults to `#p-views ul`. - */ - expandedContainer: string; /** * Optional menu item selector. Defaults to `#p-cactions ul`. */ @@ -29,12 +30,16 @@ interface CollapsibleTabsOptions { * Optional selector for tabs that are collapsible. Defaults to `li.collapsible`. */ collapsible: string; - shifting: boolean; + /** + * Optional tab selector. Defaults to `#p-views ul`. + */ + expandedContainer: string; expandedWidth: number; - - expandCondition(eleWidth: number): boolean; + shifting: boolean; collapseCondition(): boolean; + + expandCondition(eleWidth: number): boolean; } interface CollapsibleTabsStatic { @@ -43,6 +48,8 @@ interface CollapsibleTabsStatic { addData($collapsible: JQuery): void; + calculateTabDistance(): number; + getSettings($collapsible: JQuery): CollapsibleTabsOptions; handleResize(): void; @@ -50,8 +57,6 @@ interface CollapsibleTabsStatic { moveToCollapsed($moving: JQuery): void; moveToExpanded($moving: JQuery): void; - - calculateTabDistance(): number; } interface CollapsibleTabs extends CollapsibleTabsStatic, CollapsibleTabsOptions {} diff --git a/jquery/colorUtil.d.ts b/jquery/colorUtil.d.ts index c71783a..84d1941 100644 --- a/jquery/colorUtil.d.ts +++ b/jquery/colorUtil.d.ts @@ -1,5 +1,9 @@ declare global { interface JQueryStatic { + /** + * @deprecated Removed since 1.41. + * @see https://doc.wikimedia.org/mediawiki-core/REL1_40/js/#!/api/jQuery.colorUtil + */ colorUtil: ColorUtil; } } @@ -7,50 +11,57 @@ declare global { type Color = [number, number, number]; interface ColorUtil { - /** - * Parse CSS color strings looking for color tuples - * - * Based on highlightFade by Blair Mitchelmore - * - * - * @param {Color|string} color - * @returns {Color} - */ - getRGB(color: string | T): T; - /** * Named color map * * Based on Interface by Stefan Petre - * + * {@link http://interface.eyecon.ro/} + * + * @see https://doc.wikimedia.org/mediawiki-core/REL1_40/js/#!/api/jQuery.colorUtil-property-colors */ colors: Record; /** - * Convert an RGB color value to HSL. + * Get a brighter or darker rgb() value string. * - * Conversion formula based on - * + * Usage: * - * Adapted from . + * ```js + * $.colorUtil.getColorBrightness( 'red', +0.1 ); + * // > "rgb(255,50,50)" + * $.colorUtil.getColorBrightness( 'rgb(200,50,50)', -0.2 ); + * // > "rgb(118,29,29)" + * ``` * - * Assumes `r`, `g`, and `b` are contained in the set `[0, 255]` and - * returns `h`, `s`, and `l` in the set `[0, 1]`. + * @param {Color|string} currentColor Current value in css + * @param {number} mod Wanted brightness modification between -1 and 1 + * @returns {string} Like `'rgb(r,g,b)'` + * @see https://doc.wikimedia.org/mediawiki-core/REL1_40/js/#!/api/jQuery.colorUtil-method-getColorBrightness + */ + getColorBrightness( + currentColor: string | Color, + mod: number + ): `rgb(${number},${number},${number})`; + + /** + * Parse CSS color strings looking for color tuples * - * @param {number} r The red color value - * @param {number} g The green color value - * @param {number} b The blue color value - * @returns {Color} The HSL representation + * Based on highlightFade by Blair Mitchelmore + * {@link http://jquery.offput.ca/highlightFade/} + * + * @param {Color|string} color + * @returns {Color} + * @see https://doc.wikimedia.org/mediawiki-core/REL1_40/js/#!/api/jQuery.colorUtil-method-getRGB */ - rgbToHsl(r: number, g: number, b: number): Color; + getRGB(color: string | T): T; /** * Convert an HSL color value to RGB. * * Conversion formula based on - * + * {@link http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript} * - * Adapted from . + * Adapted from {@link https://en.wikipedia.org/wiki/HSL_color_space}. * * Assumes `h`, `s`, and `l` are contained in the set `[0, 1]` and * returns `r`, `g`, and `b` in the set `[0, 255]`. @@ -59,29 +70,28 @@ interface ColorUtil { * @param {number} s The saturation * @param {number} l The lightness * @returns {Color} The RGB representation + * @see https://doc.wikimedia.org/mediawiki-core/REL1_40/js/#!/api/jQuery.colorUtil-method-hslToRgb */ hslToRgb(h: number, s: number, l: number): Color; /** - * Get a brighter or darker rgb() value string. + * Convert an RGB color value to HSL. * - * Usage: + * Conversion formula based on + * {@link http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript} * - * ```js - * $.colorUtil.getColorBrightness( 'red', +0.1 ); - * // > "rgb(255,50,50)" - * $.colorUtil.getColorBrightness( 'rgb(200,50,50)', -0.2 ); - * // > "rgb(118,29,29)" - * ``` + * Adapted from {@link https://en.wikipedia.org/wiki/HSL_color_space}. * - * @param {Color|string} currentColor Current value in css - * @param {number} mod Wanted brightness modification between -1 and 1 - * @returns {string} Like `'rgb(r,g,b)'` + * Assumes `r`, `g`, and `b` are contained in the set `[0, 255]` and + * returns `h`, `s`, and `l` in the set `[0, 1]`. + * + * @param {number} r The red color value + * @param {number} g The green color value + * @param {number} b The blue color value + * @returns {Color} The HSL representation + * @see https://doc.wikimedia.org/mediawiki-core/REL1_40/js/#!/api/jQuery.colorUtil-method-rgbToHsl */ - getColorBrightness( - currentColor: string | Color, - mod: number - ): `rgb(${number},${number},${number})`; + rgbToHsl(r: number, g: number, b: number): Color; } export {}; diff --git a/jquery/confirmable.d.ts b/jquery/confirmable.d.ts index bc44d43..20843b9 100644 --- a/jquery/confirmable.d.ts +++ b/jquery/confirmable.d.ts @@ -1,101 +1,123 @@ declare global { interface JQuery { + /** + * Enable inline confirmation for given clickable element (like `` or `