Index: trunk/phase3/skins/common/prefs.js |
— | — | @@ -1,81 +1,3 @@ |
2 | | -// generate toc from prefs form, fold sections |
3 | | -// XXX: needs testing on IE/Mac and safari |
4 | | -// more comments to follow |
5 | | -window.tabbedprefs = function() { |
6 | | - var prefform = document.getElementById( 'preferences' ); |
7 | | - if ( !prefform || !document.createElement ) { |
8 | | - return; |
9 | | - } |
10 | | - if ( prefform.nodeName.toLowerCase() == 'a' ) { |
11 | | - return; // Occasional IE problem |
12 | | - } |
13 | | - prefform.className = prefform.className + 'jsprefs'; |
14 | | - var sections = []; |
15 | | - var children = prefform.childNodes; |
16 | | - var seci = 0; |
17 | | - for ( var i = 0; i < children.length; i++ ) { |
18 | | - if ( children[i].nodeName.toLowerCase() == 'fieldset' ) { |
19 | | - children[i].id = 'prefsection-' + seci; |
20 | | - children[i].className = 'prefsection'; |
21 | | - if ( is_opera ) { |
22 | | - children[i].className = 'prefsection operaprefsection'; |
23 | | - } |
24 | | - var legends = children[i].getElementsByTagName('legend'); |
25 | | - sections[seci] = {}; |
26 | | - if ( legends[0] ) { |
27 | | - legends[0].className = 'mainLegend'; |
28 | | - } |
29 | | - if ( legends[0] && legends[0].firstChild.nodeValue ) { |
30 | | - sections[seci].text = legends[0].firstChild.nodeValue; |
31 | | - } else { |
32 | | - sections[seci].text = '# ' + seci; |
33 | | - } |
34 | | - sections[seci].secid = children[i].id; |
35 | | - seci++; |
36 | | - if ( sections.length != 1 ) { |
37 | | - children[i].style.display = 'none'; |
38 | | - } else { |
39 | | - var selectedid = children[i].id; |
40 | | - } |
41 | | - } |
42 | | - } |
43 | | - var toc = document.createElement( 'ul' ); |
44 | | - toc.id = 'preftoc'; |
45 | | - toc.selectedid = selectedid; |
46 | | - for ( i = 0; i < sections.length; i++ ) { |
47 | | - var li = document.createElement( 'li' ); |
48 | | - if ( i === 0 ) { |
49 | | - li.className = 'selected'; |
50 | | - } |
51 | | - var a = document.createElement( 'a' ); |
52 | | - a.href = '#' + sections[i].secid; |
53 | | - a.onmousedown = a.onclick = uncoversection; |
54 | | - a.appendChild( document.createTextNode( sections[i].text ) ); |
55 | | - a.secid = sections[i].secid; |
56 | | - li.appendChild( a ); |
57 | | - toc.appendChild( li ); |
58 | | - } |
59 | | - prefform.parentNode.insertBefore( toc, prefform.parentNode.childNodes[0] ); |
60 | | - document.getElementById( 'prefsubmit' ).id = 'prefcontrol'; |
61 | | -} |
62 | | - |
63 | | -window.uncoversection = function() { |
64 | | - var oldsecid = this.parentNode.parentNode.selectedid; |
65 | | - var newsec = document.getElementById( this.secid ); |
66 | | - if ( oldsecid != this.secid ) { |
67 | | - var ul = document.getElementById( 'preftoc' ); |
68 | | - document.getElementById( oldsecid ).style.display = 'none'; |
69 | | - newsec.style.display = 'block'; |
70 | | - ul.selectedid = this.secid; |
71 | | - var lis = ul.getElementsByTagName( 'li' ); |
72 | | - for ( var i = 0; i< lis.length; i++ ) { |
73 | | - lis[i].className = ''; |
74 | | - } |
75 | | - this.parentNode.className = 'selected'; |
76 | | - } |
77 | | - return false; |
78 | | -} |
79 | | - |
80 | 2 | // Timezone stuff |
81 | 3 | // tz in format [+-]HHMM |
82 | 4 | window.checkTimezone = function( tz, msg ) { |
— | — | @@ -214,4 +136,3 @@ |
215 | 137 | } |
216 | 138 | |
217 | 139 | addOnloadHook( timezoneSetup ); |
218 | | -addOnloadHook( tabbedprefs ); |
Index: trunk/phase3/includes/specials/SpecialPreferences.php |
— | — | @@ -51,8 +51,9 @@ |
52 | 52 | $this->showResetForm(); |
53 | 53 | return; |
54 | 54 | } |
55 | | - |
| 55 | + |
56 | 56 | $wgOut->addModules( 'mediawiki.legacy.prefs' ); |
| 57 | + $wgOut->addModuleScripts( 'mediawiki.specials.preferences' ); |
57 | 58 | |
58 | 59 | if ( $wgRequest->getCheck( 'success' ) ) { |
59 | 60 | $wgOut->wrapWikiMsg( |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -304,6 +304,9 @@ |
305 | 305 | 'scripts' => 'resources/mediawiki/mediawiki.js', |
306 | 306 | 'debugScripts' => 'resources/mediawiki/mediawiki.log.js', |
307 | 307 | ) ), |
| 308 | + 'mediawiki.specials.preferences' => new ResourceLoaderFileModule( array( |
| 309 | + 'scripts' => 'resources/mediawiki/mediawiki.specials.preferences.js', |
| 310 | + ) ), |
308 | 311 | |
309 | 312 | /* MediaWiki Legacy */ |
310 | 313 | |
Index: trunk/phase3/resources/mediawiki/mediawiki.specials.preferences.js |
— | — | @@ -0,0 +1,40 @@ |
| 2 | +/* |
| 3 | + * JavaScript for Special:Preferences |
| 4 | + */ |
| 5 | + |
| 6 | +$( '#prefsubmit' ).attr( 'id', 'prefcontrol' ).end() |
| 7 | +$( '#preferences' ) |
| 8 | + .addClass( 'jsprefs' ) |
| 9 | + .before( $( '<ul id="preftoc"></ul>' ) ) |
| 10 | + .find( '> fieldset' ) |
| 11 | + .hide() |
| 12 | + .addClass( 'prefsection' ) |
| 13 | + .find( '> legend' ) |
| 14 | + .addClass( 'mainLegend' ) |
| 15 | + .each( function( i ) { |
| 16 | + $(this).parent().attr( 'id', 'prefsection-' + i ); |
| 17 | + if ( i === 0 ) { |
| 18 | + $(this).parent().show(); |
| 19 | + } |
| 20 | + $( '#preftoc' ).append( |
| 21 | + $( '<li></li>' ) |
| 22 | + .addClass( i === 0 ? 'selected' : null ) |
| 23 | + .append( |
| 24 | + $( '<a></a>') |
| 25 | + .text( $(this).text() ) |
| 26 | + .attr( 'href', '#prefsection-' + i ) |
| 27 | + .mousedown( function( e ) { |
| 28 | + $(this).parent().parent().find( 'li' ).removeClass( 'selected' ); |
| 29 | + $(this).parent().addClass( 'selected' ); |
| 30 | + e.preventDefault(); |
| 31 | + return false; |
| 32 | + } ) |
| 33 | + .click( function( e ) { |
| 34 | + $( '#preferences > fieldset' ).hide(); |
| 35 | + $( '#prefsection-' + i ).show(); |
| 36 | + e.preventDefault(); |
| 37 | + return false; |
| 38 | + } ) |
| 39 | + ) |
| 40 | + ); |
| 41 | + } ); |
Property changes on: trunk/phase3/resources/mediawiki/mediawiki.specials.preferences.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 42 | + native |