Debian Codegraph @

skins/Vector/resources/skins.vector.js/menuTabs.js

raw symbols SCIP
1 const
2 TABS_SELECTOR = '.vector-menu-tabs',
3 LIST_ITEM_JS_SELECTOR = '.mw-list-item-js',
4 NO_ICON_CLASS = 'vector-tab-noicon';
5
6 /**
7 * T320691: Add a `.vector-tab-noicon` class to any tabbed menu item that is
8 * added by a gadget so that the menu item has the correct padding and margin.
9 *
10 * @param {HTMLElement} item
11 */
12 function addNoIconClass( item ) {
13 item.classList.add( NO_ICON_CLASS );
14 }
15
16 function init() {
17 // Enhance previously added items.
18 Array.prototype.forEach.call(
19 document.querySelectorAll( TABS_SELECTOR + ' ' + LIST_ITEM_JS_SELECTOR ),
20 addNoIconClass
21 );
22
23 mw.hook( 'util.addPortletLink' ).add(
24 /**
25 * @param {HTMLElement} item
26 */
27 ( item ) => {
28 // Check if this menu item belongs to a tabs menu.
29 if ( item.closest( TABS_SELECTOR ) ) {
30 addNoIconClass( item );
31 }
32 } );
33 }
34
35 module.exports = init;