Moved some of the functionality from mediawiki.legacy.prefs into mediawiki.specials.preferences.
This commit is contained in:
parent
519173c0e4
commit
2896d1c83c
4 changed files with 45 additions and 80 deletions
|
|
@ -51,8 +51,9 @@ class SpecialPreferences extends SpecialPage {
|
|||
$this->showResetForm();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$wgOut->addModules( 'mediawiki.legacy.prefs' );
|
||||
$wgOut->addModuleScripts( 'mediawiki.specials.preferences' );
|
||||
|
||||
if ( $wgRequest->getCheck( 'success' ) ) {
|
||||
$wgOut->wrapWikiMsg(
|
||||
|
|
|
|||
|
|
@ -304,6 +304,9 @@ return array(
|
|||
'scripts' => 'resources/mediawiki/mediawiki.js',
|
||||
'debugScripts' => 'resources/mediawiki/mediawiki.log.js',
|
||||
) ),
|
||||
'mediawiki.specials.preferences' => new ResourceLoaderFileModule( array(
|
||||
'scripts' => 'resources/mediawiki/mediawiki.specials.preferences.js',
|
||||
) ),
|
||||
|
||||
/* MediaWiki Legacy */
|
||||
|
||||
|
|
|
|||
40
resources/mediawiki/mediawiki.specials.preferences.js
Normal file
40
resources/mediawiki/mediawiki.specials.preferences.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* JavaScript for Special:Preferences
|
||||
*/
|
||||
|
||||
$( '#prefsubmit' ).attr( 'id', 'prefcontrol' ).end()
|
||||
$( '#preferences' )
|
||||
.addClass( 'jsprefs' )
|
||||
.before( $( '<ul id="preftoc"></ul>' ) )
|
||||
.find( '> fieldset' )
|
||||
.hide()
|
||||
.addClass( 'prefsection' )
|
||||
.find( '> legend' )
|
||||
.addClass( 'mainLegend' )
|
||||
.each( function( i ) {
|
||||
$(this).parent().attr( 'id', 'prefsection-' + i );
|
||||
if ( i === 0 ) {
|
||||
$(this).parent().show();
|
||||
}
|
||||
$( '#preftoc' ).append(
|
||||
$( '<li></li>' )
|
||||
.addClass( i === 0 ? 'selected' : null )
|
||||
.append(
|
||||
$( '<a></a>')
|
||||
.text( $(this).text() )
|
||||
.attr( 'href', '#prefsection-' + i )
|
||||
.mousedown( function( e ) {
|
||||
$(this).parent().parent().find( 'li' ).removeClass( 'selected' );
|
||||
$(this).parent().addClass( 'selected' );
|
||||
e.preventDefault();
|
||||
return false;
|
||||
} )
|
||||
.click( function( e ) {
|
||||
$( '#preferences > fieldset' ).hide();
|
||||
$( '#prefsection-' + i ).show();
|
||||
e.preventDefault();
|
||||
return false;
|
||||
} )
|
||||
)
|
||||
);
|
||||
} );
|
||||
|
|
@ -1,81 +1,3 @@
|
|||
// generate toc from prefs form, fold sections
|
||||
// XXX: needs testing on IE/Mac and safari
|
||||
// more comments to follow
|
||||
window.tabbedprefs = function() {
|
||||
var prefform = document.getElementById( 'preferences' );
|
||||
if ( !prefform || !document.createElement ) {
|
||||
return;
|
||||
}
|
||||
if ( prefform.nodeName.toLowerCase() == 'a' ) {
|
||||
return; // Occasional IE problem
|
||||
}
|
||||
prefform.className = prefform.className + 'jsprefs';
|
||||
var sections = [];
|
||||
var children = prefform.childNodes;
|
||||
var seci = 0;
|
||||
for ( var i = 0; i < children.length; i++ ) {
|
||||
if ( children[i].nodeName.toLowerCase() == 'fieldset' ) {
|
||||
children[i].id = 'prefsection-' + seci;
|
||||
children[i].className = 'prefsection';
|
||||
if ( is_opera ) {
|
||||
children[i].className = 'prefsection operaprefsection';
|
||||
}
|
||||
var legends = children[i].getElementsByTagName('legend');
|
||||
sections[seci] = {};
|
||||
if ( legends[0] ) {
|
||||
legends[0].className = 'mainLegend';
|
||||
}
|
||||
if ( legends[0] && legends[0].firstChild.nodeValue ) {
|
||||
sections[seci].text = legends[0].firstChild.nodeValue;
|
||||
} else {
|
||||
sections[seci].text = '# ' + seci;
|
||||
}
|
||||
sections[seci].secid = children[i].id;
|
||||
seci++;
|
||||
if ( sections.length != 1 ) {
|
||||
children[i].style.display = 'none';
|
||||
} else {
|
||||
var selectedid = children[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';
|
||||
}
|
||||
|
||||
window.uncoversection = function() {
|
||||
var oldsecid = this.parentNode.parentNode.selectedid;
|
||||
var newsec = document.getElementById( this.secid );
|
||||
if ( oldsecid != this.secid ) {
|
||||
var ul = document.getElementById( 'preftoc' );
|
||||
document.getElementById( oldsecid ).style.display = 'none';
|
||||
newsec.style.display = 'block';
|
||||
ul.selectedid = this.secid;
|
||||
var lis = ul.getElementsByTagName( 'li' );
|
||||
for ( var i = 0; i< lis.length; i++ ) {
|
||||
lis[i].className = '';
|
||||
}
|
||||
this.parentNode.className = 'selected';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Timezone stuff
|
||||
// tz in format [+-]HHMM
|
||||
window.checkTimezone = function( tz, msg ) {
|
||||
|
|
@ -214,4 +136,3 @@ window.updateTimezoneSelection = function( force_offset ) {
|
|||
}
|
||||
|
||||
addOnloadHook( timezoneSetup );
|
||||
addOnloadHook( tabbedprefs );
|
||||
|
|
|
|||
Loading…
Reference in a new issue