Last modified: 2014-08-04 13:18:02 UTC
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"> <dt>Foo</dt> <dd>Content for Foo</dd> <dt>Bar</ct> <dd>Content for Bar</dd> </dl> 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) { return; } 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; seci++; if (sections.length != 1) { childrenContent[i].style.display = 'none'; } else { var selectedid = childrenContent[i].id; } } } var toc = document.createElement('ul'); toc.id = '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.appendChild(document.createTextNode(sections[i].text)); a.secid = sections[i].secid; li.appendChild(a); toc.appendChild(li); } prefform.parentNode.insertBefore(toc, prefform.parentNode.childNodes[0]); document.getElementById('prefsubmit').id = 'prefcontrol'; } ----- quick link to the original code http://en.wikipedia.org/skins-1.5/common/wikibits.js
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 https://git.wikimedia.org/raw/mediawiki%2Fcore.git/HEAD/skins%2Fcommon%2Fwikibits.js 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 https://www.mediawiki.org/wiki/ResourceLoader/JavaScript_Deprecations
@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...