Skip to content

Commit

Permalink
jquery: add vector skin's collapsibleTabs plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthvp committed Jan 2, 2021
1 parent 6f4e3cc commit a57cf77
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
42 changes: 42 additions & 0 deletions jquery/collapsibleTabs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* 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 {
collapsibleTabs: CollapsibleTabsStatic;
}
interface JQuery {
collapsibleTabs(options: Partial<CollapsibleTabsOptions>): void;
}
}

/** A jQuery plugin that makes collapsible tabs for the Vector skin. */
interface CollapsibleTabsOptions {
/** Optional tab selector. Defaults to `#p-views ul`. */
expandedContainer: string;
/** Optional menu item selector. Defaults to `#p-cactions ul`. */
collapsedContainer: string;
/** Optional selector for tabs that are collapsible. Defaults to `li.collapsible`. */
collapsible: string;
shifting: boolean;
expandedWidth: number;
expandCondition(eleWidth: number): boolean;
collapseCondition(): boolean;
}

interface CollapsibleTabsStatic {
defaults: CollapsibleTabsOptions;
instances: JQuery[];
addData($collapsible: JQuery): void;
getSettings($collapsible: JQuery): CollapsibleTabsOptions;
handleResize(): void;
moveToCollapsed($moving: JQuery): void;
moveToExpanded($moving: JQuery): void;
calculateTabDistance(): number;
}

interface CollapsibleTabs extends CollapsibleTabsStatic, CollapsibleTabsOptions {}

export {}
1 change: 1 addition & 0 deletions jquery/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'jquery';

import './textSelection';
import './collapsibleTabs';
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "types-mediawiki",
"version": "0.5.1",
"version": "0.6.0",
"description": "TypeScript definitions for MediaWiki JS interface",
"types": "index.d.ts",
"scripts": {
Expand Down

0 comments on commit a57cf77

Please sign in to comment.