summaryrefslogtreecommitdiff
path: root/skins/common/prefs.js
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
committerPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
commit9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch)
tree46d1a0dee7febef5c2d57a9f7b972be16a163b3d /skins/common/prefs.js
parent78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff)
update to MediaWiki 1.17.0
Diffstat (limited to 'skins/common/prefs.js')
-rw-r--r--skins/common/prefs.js111
1 files changed, 16 insertions, 95 deletions
diff --git a/skins/common/prefs.js b/skins/common/prefs.js
index ca55632c..1eb8e5bf 100644
--- a/skins/common/prefs.js
+++ b/skins/common/prefs.js
@@ -1,84 +1,6 @@
-// generate toc from prefs form, fold sections
-// XXX: needs testing on IE/Mac and safari
-// more comments to follow
-function tabbedprefs() {
- 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';
-}
-
-function uncoversection() {
- 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
-function checkTimezone( tz, msg ) {
+window.checkTimezone = function( tz, msg ) {
var localclock = new Date();
// returns negative offset from GMT in minutes
var tzRaw = localclock.getTimezoneOffset();
@@ -89,11 +11,11 @@ function checkTimezone( tz, msg ) {
var junk = msg.split('$1');
document.write( junk[0] + 'UTC' + tzString + junk[1] );
}
-}
+};
-function timezoneSetup() {
- var tzSelect = document.getElementById( 'mw-input-timecorrection' );
- var tzTextbox = document.getElementById( 'mw-input-timecorrection-other' );
+window.timezoneSetup = function() {
+ var tzSelect = document.getElementById( 'mw-input-wptimecorrection' );
+ var tzTextbox = document.getElementById( 'mw-input-wptimecorrection-other' );
if ( tzSelect && tzTextbox ) {
addHandler( tzSelect, 'change', function( e ) { updateTimezoneSelection( false ); } );
@@ -101,11 +23,11 @@ function timezoneSetup() {
}
updateTimezoneSelection( false );
-}
+};
// in [-]HH:MM format...
// won't yet work with non-even tzs
-function fetchTimezone() {
+window.fetchTimezone = function() {
// FIXME: work around Safari bug
var localclock = new Date();
// returns negative offset from GMT in minutes
@@ -115,26 +37,26 @@ function fetchTimezone() {
var tzString = ( ( tzRaw >= 0 ) ? '-' : '' ) + ( ( tzHour < 10 ) ? '0' : '' ) + tzHour +
':' + ( ( tzMin < 10 ) ? '0' : '' ) + tzMin;
return tzString;
-}
+};
-function guessTimezone() {
- var textbox = document.getElementById( 'mw-input-timecorrection-other' );
- var selector = document.getElementById( 'mw-input-timecorrection' );
+window.guessTimezone = function() {
+ var textbox = document.getElementById( 'mw-input-wptimecorrection-other' );
+ var selector = document.getElementById( 'mw-input-wptimecorrection' );
selector.value = 'other';
textbox.value = fetchTimezone();
textbox.disabled = false; // The changed handler doesn't trip, obviously.
updateTimezoneSelection( true );
-}
+};
-function updateTimezoneSelection( force_offset ) {
- var selector = document.getElementById( 'mw-input-timecorrection' );
+window.updateTimezoneSelection = function( force_offset ) {
+ var selector = document.getElementById( 'mw-input-wptimecorrection' );
if ( selector.value == 'guess' ) {
return guessTimezone();
}
- var textbox = document.getElementById( 'mw-input-timecorrection-other' );
+ var textbox = document.getElementById( 'mw-input-wptimecorrection-other' );
var localtimeHolder = document.getElementById( 'wpLocalTime' );
var servertime = document.getElementsByName( 'wpServerTime' )[0].value;
var minDiff = 0;
@@ -211,7 +133,6 @@ function updateTimezoneSelection( force_offset ) {
}
textbox.value = hour + ':' + min;
}
-}
+};
addOnloadHook( timezoneSetup );
-addOnloadHook( tabbedprefs );