mirror of
https://github.com/StarCitizenTools/mediawiki-extensions-TabberNeue.git
synced 2024-11-24 00:13:28 +00:00
feat: add TabberNeueUseLegacyTabIds config option (#184)
Also fix the issue where disabling TabberNeueEnableAnimation didn't actually work --------- Co-authored-by: Jayden Bailey <jaydenkieran@gmail.com>
This commit is contained in:
parent
dcacc42442
commit
1b60511ae7
|
@ -44,7 +44,8 @@
|
||||||
"config": {
|
"config": {
|
||||||
"enableAnimation": "TabberNeueEnableAnimation",
|
"enableAnimation": "TabberNeueEnableAnimation",
|
||||||
"parseTabName": "TabberNeueParseTabName",
|
"parseTabName": "TabberNeueParseTabName",
|
||||||
"updateLocationOnTabChange": "TabberNeueUpdateLocationOnTabChange"
|
"updateLocationOnTabChange": "TabberNeueUpdateLocationOnTabChange",
|
||||||
|
"useLegacyTabIds": "TabberNeueUseLegacyTabIds"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ext.tabberNeue/Hash.js",
|
"ext.tabberNeue/Hash.js",
|
||||||
|
@ -162,6 +163,11 @@
|
||||||
"value": true,
|
"value": true,
|
||||||
"description": "If enabled, when a tab is selected, the URL displayed on the browser changes. Opening this URL makes that tab initially selected.",
|
"description": "If enabled, when a tab is selected, the URL displayed on the browser changes. Opening this URL makes that tab initially selected.",
|
||||||
"public": true
|
"public": true
|
||||||
|
},
|
||||||
|
"TabberNeueUseLegacyTabIds": {
|
||||||
|
"value": false,
|
||||||
|
"description": "If enabled, tab IDs will not be prepended with \"tabber-\". This provides better compatibility with the old Tabber extension, but will cause issues if there are headings with the same name as an existing tab.",
|
||||||
|
"public": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Hooks": {
|
"Hooks": {
|
||||||
|
|
|
@ -49,10 +49,14 @@ class Hash {
|
||||||
* Builds a unique hash based on the provided title text.
|
* Builds a unique hash based on the provided title text.
|
||||||
*
|
*
|
||||||
* @param {string} titleText - The title text to generate the hash from.
|
* @param {string} titleText - The title text to generate the hash from.
|
||||||
|
* @param {boolean} useLegacyTabIds - Whether to use the legacy tab ID format.
|
||||||
* @return {string} - A unique hash created from the title text.
|
* @return {string} - A unique hash created from the title text.
|
||||||
*/
|
*/
|
||||||
static build( titleText ) {
|
static build( titleText, useLegacyTabIds ) {
|
||||||
let hash = `tabber-${ mw.util.escapeIdForAttribute( titleText ) }`;
|
let hash = mw.util.escapeIdForAttribute( titleText );
|
||||||
|
if ( !useLegacyTabIds ) {
|
||||||
|
hash = `tabber-${ hash }`;
|
||||||
|
}
|
||||||
|
|
||||||
if ( Hash.exists( hash ) ) {
|
if ( Hash.exists( hash ) ) {
|
||||||
hash = Hash.makeUnique( hash );
|
hash = Hash.makeUnique( hash );
|
||||||
|
|
|
@ -544,11 +544,13 @@ class TabberBuilder {
|
||||||
|
|
||||||
let tabId;
|
let tabId;
|
||||||
if ( config.parseTabName ) {
|
if ( config.parseTabName ) {
|
||||||
tabId = Hash.build( Util.extractTextFromHtml( titleAttr ) );
|
tabId = Util.extractTextFromHtml( titleAttr );
|
||||||
} else {
|
} else {
|
||||||
tabId = Hash.build( titleAttr );
|
tabId = titleAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tabId = Hash.build( tabId, config.useLegacyTabIds );
|
||||||
|
|
||||||
this.setTabpanelAttributes( tabpanel, tabId );
|
this.setTabpanelAttributes( tabpanel, tabId );
|
||||||
|
|
||||||
return this.createTab( titleAttr, tabId );
|
return this.createTab( titleAttr, tabId );
|
||||||
|
|
Loading…
Reference in a new issue