Page MenuHomePhabricator

generalize function switchPrefTab() (previously tabbedprefs())
Open, LowPublicFeature


Author: alistrius

Hello, it should be convenient to use tabbed navigation troughout the meta space (not on main namespace). There is already function tabbedprefs() which do the work in wikibits.js, but it catche only <fieldsets> in <div id='preferences'>

If it's possible to put the div in the wikitext, it doesn't work for fieldset since it's illegal out of <form> elements.

So i suggest it should be able to catch

<dl class="tabbed">
<dd>Content for Foo</dd>
<dd>Content for Bar</dd>

and make tabs from it

here is the code i suggest (not tested)

function tabbedprefs() { // nename in maketabs() ?

if (!wgNamespaceNumber) return; // in on mainspace return (or not ?)

var prefform = document.getElementById('tabbed');
if (!prefform || !document.createElement) {


if (prefform.nodeName.toLowerCase() == 'a') {

		return; // Occasional IE problem

prefform.className = prefform.className + 'jsprefs';
var sections = [];
var childrenTitles = prefform.childNodes.getElementsByTagName('dt');

var childrenContent = prefform.childNodes.getElementsByTagName('dd');
if (childrenTitles.length != childrenContent.length) return; //if there is not the same number on dt and dd

var seci = 0;
for (var i = 0; i < childrenTitles.length; i++) {

		if (childrenTitles[i].nodeName.toLowerCase() == 'dt') { // == 'fieldset';
			childrenTitles[i].id = 'prefsection-' + seci;
			childrenTitles[i].className = 'prefsection';
			if (is_opera || is_khtml) {
				childrenTitles[i].className = 'prefsection operaprefsection';
			var legends = childrenTitles[i].nodeValue; //.getElementsByTagName('legend');
			sections[seci] = {};
			legends[0].className = 'mainLegend';
			if (legends[0] && legends[0].firstChild.nodeValue) {
				sections[seci].text = childrenContent[i].firstChild.nodeValue; //not sure of [i] or [seci]
			} else {
				sections[seci].text = '# ' + seci;
			sections[seci].secid = childrenContent[i].id;
			if (sections.length != 1) {
				childrenContent[i].style.display = 'none';
			} else {
				var selectedid = childrenContent[i].id;

var toc = document.createElement('ul'); = 'preftoc';
toc.selectedid = selectedid;
for (i = 0; i < sections.length; i++) {

		var li = document.createElement('li');
		if (i === 0) {
			li.className = 'selected';
		var a = document.createElement('a');
		a.href = '#' + sections[i].secid;
		a.onmousedown = a.onclick = uncoversection;
		a.secid = sections[i].secid;

prefform.parentNode.insertBefore(toc, prefform.parentNode.childNodes[0]);
document.getElementById('prefsubmit').id = 'prefcontrol';

quick link to the original code

Version: unspecified
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:06 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz12610.
bzimport added a subscriber: Unknown Object (MLST).

alistrius wrote:

correction, it should better catter catch <h2 class=tab> in <div class="tabbed">, since <dd> in not optimal for have a lot of content, and may not be semanticaly correct in some cases (we cannot anticipate the usage of these tabs and what will people put in the dd's)

(In reply to italvet from comment #0)

There is already function tabbedprefs() which do the work in wikibits.js

That file is located at but there is no function tabbedprefs() anymore nowadays.

I also grep'ed the MediaWiki core codebase and could not find any "tabbedprefs" match.

Hence closing this as obsolete nowadays - using INVALID as I cannot find anything that matches better.

For the records: Might die at some point, see bug 33836 and dependencies, plus

@Andre, the code is in resources/src/mediawiki.special/mediawiki.special.preferences.js now.

Ah, thanks, DJ! Still wondering how to rephrase the summary of this ticket, as it's not "tabbedprefs" anymore...

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.