Index: trunk/phase3/resources/mediawiki/mediawiki.util.js |
— | — | @@ -1,9 +1,10 @@ |
2 | 2 | /** |
3 | 3 | * Utilities |
4 | 4 | */ |
5 | | -( function( $, mw ) { |
| 5 | +( function( $ ) { |
6 | 6 | |
7 | | - mw.util = { |
| 7 | + // Local cache and alias |
| 8 | + var util = mw.util = { |
8 | 9 | |
9 | 10 | /* Initialisation */ |
10 | 11 | /** |
— | — | @@ -14,8 +15,8 @@ |
15 | 16 | if ( this.initialised === false ) { |
16 | 17 | this.initialised = true; |
17 | 18 | |
18 | | - // Any initialisation after the DOM is ready |
19 | | - $( function() { |
| 19 | + // Folllowing the initialisation after the DOM is ready |
| 20 | + $(document).ready( function() { |
20 | 21 | |
21 | 22 | /* Set up $.messageBox */ |
22 | 23 | $.messageBoxNew( { |
— | — | @@ -30,19 +31,19 @@ |
31 | 32 | |
32 | 33 | // Opera on any platform |
33 | 34 | if ( profile.name == 'opera' ) { |
34 | | - mw.util.tooltipAccessKeyPrefix = 'shift-esc-'; |
| 35 | + util.tooltipAccessKeyPrefix = 'shift-esc-'; |
35 | 36 | |
36 | 37 | // Chrome on any platform |
37 | 38 | } else if ( profile.name == 'chrome' ) { |
38 | 39 | // Chrome on Mac or Chrome on other platform ? |
39 | | - mw.util.tooltipAccessKeyPrefix = ( profile.platform == 'mac' |
| 40 | + util.tooltipAccessKeyPrefix = ( profile.platform == 'mac' |
40 | 41 | ? 'ctrl-option-' : 'alt-' ); |
41 | 42 | |
42 | 43 | // Non-Windows Safari with webkit_version > 526 |
43 | 44 | } else if ( profile.platform !== 'win' |
44 | 45 | && profile.name == 'safari' |
45 | 46 | && profile.layoutVersion > 526 ) { |
46 | | - mw.util.tooltipAccessKeyPrefix = 'ctrl-alt-'; |
| 47 | + util.tooltipAccessKeyPrefix = 'ctrl-alt-'; |
47 | 48 | |
48 | 49 | // Safari/Konqueror on any platform, or any browser on Mac |
49 | 50 | // (but not Safari on Windows) |
— | — | @@ -50,32 +51,32 @@ |
51 | 52 | && ( profile.name == 'safari' |
52 | 53 | || profile.platform == 'mac' |
53 | 54 | || profile.name == 'konqueror' ) ) { |
54 | | - mw.util.tooltipAccessKeyPrefix = 'ctrl-'; |
| 55 | + util.tooltipAccessKeyPrefix = 'ctrl-'; |
55 | 56 | |
56 | 57 | // Firefox 2.x |
57 | 58 | } else if ( profile.name == 'firefox' && profile.versionBase == '2' ) { |
58 | | - mw.util.tooltipAccessKeyPrefix = 'alt-shift-'; |
| 59 | + util.tooltipAccessKeyPrefix = 'alt-shift-'; |
59 | 60 | } |
60 | 61 | |
61 | 62 | /* Fill $content var */ |
62 | 63 | if ( $( '#bodyContent' ).length ) { |
63 | 64 | // Vector, Monobook, Chick etc. |
64 | | - mw.util.$content = $( '#bodyContent' ); |
| 65 | + util.$content = $( '#bodyContent' ); |
65 | 66 | |
66 | 67 | } else if ( $( '#mw_contentholder' ).length ) { |
67 | 68 | // Modern |
68 | | - mw.util.$content = $( '#mw_contentholder' ); |
| 69 | + util.$content = $( '#mw_contentholder' ); |
69 | 70 | |
70 | 71 | } else if ( $( '#article' ).length ) { |
71 | 72 | // Standard, CologneBlue |
72 | | - mw.util.$content = $( '#article' ); |
| 73 | + util.$content = $( '#article' ); |
73 | 74 | |
74 | 75 | } else { |
75 | 76 | // #content is present on almost all if not all skins. Most skins (the above cases) |
76 | 77 | // have #content too, but as an outer wrapper instead of the article text container. |
77 | 78 | // The skins that don't have an outer wrapper do have #content for everything |
78 | 79 | // so it's a good fallback |
79 | | - mw.util.$content = $( '#content' ); |
| 80 | + util.$content = $( '#content' ); |
80 | 81 | } |
81 | 82 | |
82 | 83 | /* Table of Contents toggle */ |
— | — | @@ -89,7 +90,7 @@ |
90 | 91 | .text( mw.msg( 'hidetoc' ) ) |
91 | 92 | .click( function(e){ |
92 | 93 | e.preventDefault(); |
93 | | - mw.util.toggleToc( $(this) ); |
| 94 | + util.toggleToc( $(this) ); |
94 | 95 | } ); |
95 | 96 | $tocTitle.append( $tocToggleLink.wrap( '<span class="toctoggle">' ).parent().prepend( ' [' ).append( '] ' ) ); |
96 | 97 | |
— | — | @@ -271,9 +272,9 @@ |
272 | 273 | |
273 | 274 | $nodes.each( function ( i ) { |
274 | 275 | var tip = $(this).attr( 'title' ); |
275 | | - if ( !!tip && mw.util.tooltipAccessKeyRegexp.exec( tip ) ) { |
276 | | - tip = tip.replace( mw.util.tooltipAccessKeyRegexp, |
277 | | - '[' + mw.util.tooltipAccessKeyPrefix + "$5]" ); |
| 276 | + if ( !!tip && util.tooltipAccessKeyRegexp.exec( tip ) ) { |
| 277 | + tip = tip.replace( util.tooltipAccessKeyRegexp, |
| 278 | + '[' + util.tooltipAccessKeyPrefix + "$5]" ); |
278 | 279 | $(this).attr( 'title', tip ); |
279 | 280 | } |
280 | 281 | } ); |
— | — | @@ -398,7 +399,7 @@ |
399 | 400 | |
400 | 401 | // Where to put our node ? |
401 | 402 | // - nextnode is a DOM element (before MW 1.17, in wikibits.js, this was the only option) |
402 | | - if ( nextnode && nextnode.parentNode == $ul[0] ) { |
| 403 | + if ( nextnode && nextnode.parentNode == $ul[0] ) { |
403 | 404 | $(nextnode).before( $item ); |
404 | 405 | |
405 | 406 | // - nextnode is a CSS selector for jQuery |
— | — | @@ -442,8 +443,8 @@ |
443 | 444 | var $messageDiv = $( '#mw-js-message' ); |
444 | 445 | if ( !$messageDiv.length ) { |
445 | 446 | $messageDiv = $( '<div id="mw-js-message">' ); |
446 | | - if ( mw.util.$content.parent().length ) { |
447 | | - mw.util.$content.parent().prepend( $messageDiv ); |
| 447 | + if ( util.$content.parent().length ) { |
| 448 | + util.$content.parent().prepend( $messageDiv ); |
448 | 449 | } else { |
449 | 450 | return false; |
450 | 451 | } |
— | — | @@ -587,6 +588,6 @@ |
588 | 589 | |
589 | 590 | }; |
590 | 591 | |
591 | | - mw.util.init(); |
| 592 | + util.init(); |
592 | 593 | |
593 | | -} )( jQuery, mediaWiki ); |
\ No newline at end of file |
| 594 | +} )( jQuery ); |