mirror of
https://github.com/StarCitizenTools/mediawiki-extensions-TabberNeue.git
synced 2024-11-13 18:37:00 +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": {
|
||||
"enableAnimation": "TabberNeueEnableAnimation",
|
||||
"parseTabName": "TabberNeueParseTabName",
|
||||
"updateLocationOnTabChange": "TabberNeueUpdateLocationOnTabChange"
|
||||
"updateLocationOnTabChange": "TabberNeueUpdateLocationOnTabChange",
|
||||
"useLegacyTabIds": "TabberNeueUseLegacyTabIds"
|
||||
}
|
||||
},
|
||||
"ext.tabberNeue/Hash.js",
|
||||
|
@ -162,6 +163,11 @@
|
|||
"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.",
|
||||
"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": {
|
||||
|
|
|
@ -49,10 +49,14 @@ class Hash {
|
|||
* Builds a unique hash based on the provided title text.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
static build( titleText ) {
|
||||
let hash = `tabber-${ mw.util.escapeIdForAttribute( titleText ) }`;
|
||||
static build( titleText, useLegacyTabIds ) {
|
||||
let hash = mw.util.escapeIdForAttribute( titleText );
|
||||
if ( !useLegacyTabIds ) {
|
||||
hash = `tabber-${ hash }`;
|
||||
}
|
||||
|
||||
if ( Hash.exists( hash ) ) {
|
||||
hash = Hash.makeUnique( hash );
|
||||
|
|
|
@ -544,11 +544,13 @@ class TabberBuilder {
|
|||
|
||||
let tabId;
|
||||
if ( config.parseTabName ) {
|
||||
tabId = Hash.build( Util.extractTextFromHtml( titleAttr ) );
|
||||
tabId = Util.extractTextFromHtml( titleAttr );
|
||||
} else {
|
||||
tabId = Hash.build( titleAttr );
|
||||
tabId = titleAttr;
|
||||
}
|
||||
|
||||
tabId = Hash.build( tabId, config.useLegacyTabIds );
|
||||
|
||||
this.setTabpanelAttributes( tabpanel, tabId );
|
||||
|
||||
return this.createTab( titleAttr, tabId );
|
||||
|
|
Loading…
Reference in a new issue