Last modified: 2014-08-04 13:18:02 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T14610, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 12610 - generalize function switchPrefTab() (previously tabbedprefs())
generalize function switchPrefTab() (previously tabbedprefs())
Status: REOPENED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-01-13 16:29 UTC by italvet
Modified: 2014-08-04 13:18 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description italvet 2008-01-13 16:29:04 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
Comment 1 italvet 2008-01-13 16:52:44 UTC
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)
Comment 2 Andre Klapper 2014-06-16 22:22:10 UTC
(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
Comment 3 Derk-Jan Hartman 2014-06-16 22:26:11 UTC
@andre, the code is in resources/src/mediawiki.special/mediawiki.special.preferences.js  now.
Comment 4 Andre Klapper 2014-06-16 23:22:32 UTC
Ah, thanks, DJ!  Still wondering how to rephrase the summary of this ticket, as it's not "tabbedprefs" anymore...

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links