r71993 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71992‎ | r71993 | r71994 >
Date:23:58, 30 August 2010
Author:tparscal
Status:resolved
Tags:
Comment:
Explicity attached global variables and functions to the window object to support files being wrapped in closures by ResourceLoader. Also changed usage of $j to $ and removed an instantiation of mw as a global for future use.
Modified paths:
  • /branches/resourceloader/phase3/skins/common/IEFixes.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/ajax.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/ajaxwatch.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/block.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/changepassword.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/edit.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/enhancedchanges.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/history.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/htmlform.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/metadata.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/mwsuggest.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/password.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/prefs.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/preview.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/protect.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/rightclickedit.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/search.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/upload.js (modified) (history)
  • /branches/resourceloader/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/skins/common/metadata.js
@@ -5,7 +5,7 @@
66 //
77 // attachMetadataToggle('mw_metadata', 'More...', 'Fewer...');
88
9 -function attachMetadataToggle( tableId, showText, hideText ) {
 9+window.attachMetadataToggle = function( tableId, showText, hideText ) {
1010 if ( document.createTextNode ) {
1111 var box = document.getElementById( tableId );
1212 if ( !box ) {
Index: branches/resourceloader/phase3/skins/common/protect.js
@@ -1,5 +1,5 @@
22
3 -var ProtectionForm = {
 3+window.ProtectionForm = {
44 'existingMatch': false,
55
66 /**
Index: branches/resourceloader/phase3/skins/common/rightclickedit.js
@@ -1,4 +1,4 @@
2 -function setupRightClickEdit() {
 2+window.setupRightClickEdit = function() {
33 if (document.getElementsByTagName) {
44 var spans = document.getElementsByTagName('span');
55 for (var i = 0; i < spans.length; i++) {
@@ -10,7 +10,7 @@
1111 }
1212 }
1313
14 -function addRightClickEditHandler(el) {
 14+window.addRightClickEditHandler = function(el) {
1515 for (var i = 0; i < el.childNodes.length; i++) {
1616 var link = el.childNodes[i];
1717 if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') {
Index: branches/resourceloader/phase3/skins/common/block.js
@@ -1,6 +1,4 @@
2 -addOnloadHook( considerChangingExpiryFocus );
3 -
4 -function considerChangingExpiryFocus() {
 2+window.considerChangingExpiryFocus = function() {
53 if ( !document.getElementById ) {
64 return;
75 }
@@ -19,8 +17,7 @@
2018 field.style.display = 'none';
2119 }
2220 }
23 -
24 -function updateBlockOptions() {
 21+window.updateBlockOptions = function() {
2522 if ( !document.getElementById ) {
2623 return;
2724 }
@@ -55,3 +52,5 @@
5653 watchuserRow.style.display = isIpRange && !isEmpty ? 'none' : '';
5754 }
5855 }
 56+
 57+addOnloadHook( considerChangingExpiryFocus );
\ No newline at end of file
Index: branches/resourceloader/phase3/skins/common/IEFixes.js
@@ -1,14 +1,14 @@
22 // IE fixes javascript
33
4 -var isMSIE55 = ( window.showModalDialog && window.clipboardData && window.createPopup );
5 -var doneIETransform;
6 -var doneIEAlphaFix;
 4+window.isMSIE55 = ( window.showModalDialog && window.clipboardData && window.createPopup );
 5+window.doneIETransform;
 6+window.doneIEAlphaFix;
77
88 if ( document.attachEvent ) {
99 document.attachEvent( 'onreadystatechange', hookit );
1010 }
1111
12 -function hookit() {
 12+window.hookit = function() {
1313 if ( !doneIETransform && document.getElementById && document.getElementById( 'bodyContent' ) ) {
1414 doneIETransform = true;
1515 relativeforfloats();
@@ -17,7 +17,7 @@
1818 }
1919
2020 // png alpha transparency fixes
21 -function fixalpha( logoId ) {
 21+window.fixalpha = function( logoId ) {
2222 // bg
2323 if ( isMSIE55 && !doneIEAlphaFix ) {
2424 var plogo = document.getElementById( logoId || 'p-logo' );
@@ -64,7 +64,7 @@
6565 }
6666
6767 // fix ie6 disappering float bug
68 -function relativeforfloats() {
 68+window.relativeforfloats = function() {
6969 var bc = document.getElementById( 'bodyContent' );
7070 if ( bc ) {
7171 var tables = bc.getElementsByTagName( 'table' );
@@ -73,7 +73,7 @@
7474 setrelative( tables );
7575 setrelative( divs );
7676 }
77 -function setrelative( nodes ) {
 77+window.setrelative = function( nodes ) {
7878 var i = 0;
7979 while ( i < nodes.length ) {
8080 if( ( ( nodes[i].style.float && nodes[i].style.float != ( 'none' ) ||
@@ -97,9 +97,9 @@
9898 return false;
9999 }
100100
101 -var expandedURLs;
 101+window.expandedURLs = undefined;
102102
103 -onbeforeprint = function() {
 103+window.onbeforeprint = function() {
104104 expandedURLs = [];
105105
106106 var contentEl = document.getElementById( 'content' );
@@ -119,7 +119,7 @@
120120 }
121121 }
122122
123 -onafterprint = function() {
 123+window.onafterprint = function() {
124124 for ( var i = 0; i < expandedURLs.length; i++ ) {
125125 if ( expandedURLs[i] ) {
126126 expandedURLs[i].removeNode( true );
Index: branches/resourceloader/phase3/skins/common/enhancedchanges.js
@@ -24,7 +24,7 @@
2525 * Switch an RC line between hidden/shown
2626 * @param int idNumber : the id number of the RC group
2727 */
28 -function toggleVisibility(idNumber) {
 28+window.toggleVisibility = function(idNumber) {
2929 var openarrow = document.getElementById("mw-rc-openarrow-"+idNumber);
3030 var closearrow = document.getElementById("mw-rc-closearrow-"+idNumber);
3131 var subentries = document.getElementById("mw-rc-subentries-"+idNumber);
Index: branches/resourceloader/phase3/skins/common/password.js
@@ -5,7 +5,7 @@
66 * @todo Check for popular passwords and keyboard sequences (QWERTY, etc)
77 */
88
9 -function bruteForceComplexity( pwd ) {
 9+window.bruteForceComplexity = function( pwd ) {
1010 var score = 0;
1111
1212 if ( pwd.length < 16 ) {
@@ -42,7 +42,7 @@
4343 return score;
4444 }
4545
46 -function repetitionScore( pwd ) {
 46+window.repetitionScore = function( pwd ) {
4747 var unique = '';
4848 for ( var i=0; i< pwd.length; i++ ) {
4949 if ( unique.indexOf( pwd[i] ) < 0 ) {
@@ -54,7 +54,7 @@
5555 return 100 / ratio;
5656 }
5757
58 -function sequenceScore( pwd ) {
 58+window.sequenceScore = function( pwd ) {
5959 pwd = pwd.concat( '\0' );
6060 var score = 100, sequence = 1;
6161 for ( var i = 1; i < pwd.length; i++ ) {
Index: branches/resourceloader/phase3/skins/common/search.js
@@ -1,7 +1,7 @@
22 // JS specific to Special:Search
33
44 // change the search link to what user entered
5 -function mwSearchHeaderClick( obj ) {
 5+window.mwSearchHeaderClick = function( obj ) {
66 var searchbox = document.getElementById( 'searchText' );
77 if( searchbox === null ) {
88 searchbox = document.getElementById( 'powerSearchText' );
@@ -22,7 +22,7 @@
2323 obj.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart;
2424 }
2525
26 -function mwToggleSearchCheckboxes( btn ) {
 26+window.mwToggleSearchCheckboxes = function( btn ) {
2727 if( !document.getElementById ) {
2828 return;
2929 }
Index: branches/resourceloader/phase3/skins/common/changepassword.js
@@ -1,5 +1,5 @@
22
3 -function onNameChange() {
 3+window.onNameChange = function() {
44 if ( wgUserName != document.getElementById('wpName').value ) {
55 document.getElementById('wpPassword').disabled = true;
66 document.getElementById('wpComment').disabled = false;
@@ -9,7 +9,7 @@
1010 }
1111 }
1212
13 -function onNameChangeHook() {
 13+window.onNameChangeHook = function() {
1414 document.getElementById( 'wpName' ).onblur = onNameChange;
1515 }
1616
Index: branches/resourceloader/phase3/skins/common/ajaxwatch.js
@@ -4,15 +4,8 @@
55 * Uses jsMsg() from wikibits.js.
66 */
77
8 -if( typeof wgAjaxWatch === 'undefined' || !wgAjaxWatch ) {
9 - var wgAjaxWatch = {
10 - watchMsg: 'Watch',
11 - unwatchMsg: 'Unwatch',
12 - watchingMsg: 'Watching...',
13 - unwatchingMsg: 'Unwatching...',
14 - 'tooltip-ca-watchMsg': 'Add this page to your watchlist',
15 - 'tooltip-ca-unwatchMsg': 'Remove this page from your watchlist'
16 - };
 8+if ( typeof wgAjaxWatch === 'undefined' || !wgAjaxWatch ) {
 9+ window.wgAjaxWatch = { };
1710 }
1811
1912 wgAjaxWatch.setLinkText = function( $link, action ) {
@@ -21,23 +14,23 @@
2215 var keyCommand = $link.attr( 'title' ).match( /\[.*?\]$/ )
2316 ? $link.attr( 'title' ).match( /\[.*?\]$/ )[0]
2417 : '';
25 - $link.attr( 'title', wgAjaxWatch['tooltip-ca-' + action + 'Msg'] + ' ' + keyCommand );
 18+ $link.attr( 'title', mediaWiki.msg.get( 'tooltip-ca-' + action + 'Msg') + ' ' + keyCommand );
2619 }
2720 if( $link.data( 'icon' ) ) {
28 - $link.attr( 'alt', wgAjaxWatch[action + 'Msg'] );
 21+ $link.attr( 'alt', mediaWiki.msg.get( action + 'Msg' ) );
2922 if ( action == 'watching' || action == 'unwatching' ) {
3023 $link.addClass( 'loading' );
3124 } else {
3225 $link.removeClass( 'loading' );
3326 }
3427 } else {
35 - $link.html( wgAjaxWatch[action + 'Msg'] );
 28+ $link.html( mediaWiki.msg.get( action + 'Msg' ) );
3629 }
3730 };
3831
3932 wgAjaxWatch.processResult = function( response ) {
4033 response = response.watch;
41 - var $link = $j( this );
 34+ var $link = $( this );
4235 // To ensure we set the same status for all watch links with the
4336 // same target we trigger a custom event on *all* watch links.
4437 if( response.watched !== undefined ) {
@@ -55,23 +48,23 @@
5649 // Bug 12395 - update the watch checkbox on edit pages when the
5750 // page is watched or unwatched via the tab.
5851 if( response.watched !== undefined ) {
59 - $j( '#wpWatchthis' ).attr( 'checked', '1' );
 52+ $( '#wpWatchthis' ).attr( 'checked', '1' );
6053 } else {
61 - $j( '#wpWatchthis' ).removeAttr( 'checked' );
 54+ $( '#wpWatchthis' ).removeAttr( 'checked' );
6255 }
6356 };
6457
65 -$j( document ).ready( function() {
66 - var $links = $j( '.mw-watchlink a, a.mw-watchlink' );
 58+$( document ).ready( function() {
 59+ var $links = $( '.mw-watchlink a, a.mw-watchlink' );
6760 // BC with older skins
6861 $links = $links
69 - .add( $j( '#ca-watch a, #ca-unwatch a, a#mw-unwatch-link1' ) )
70 - .add( $j( 'a#mw-unwatch-link2, a#mw-watch-link2, a#mw-watch-link1' ) );
 62+ .add( $( '#ca-watch a, #ca-unwatch a, a#mw-unwatch-link1' ) )
 63+ .add( $( 'a#mw-unwatch-link2, a#mw-watch-link2, a#mw-watch-link1' ) );
7164 // allowing people to add inline animated links is a little scary
7265 $links = $links.filter( ':not( #bodyContent *, #content * )' );
7366
7467 $links.each( function() {
75 - var $link = $j( this );
 68+ var $link = $( this );
7669 $link
7770 .data( 'icon', $link.parents( 'li' ).hasClass( 'icon' ) )
7871 .data( 'action', $link.attr( 'href' ).match( /[\?\&]action=unwatch/i ) ? 'unwatch' : 'watch' );
@@ -80,7 +73,7 @@
8174 });
8275
8376 $links.click( function( event ) {
84 - var $link = $j( this );
 77+ var $link = $( this );
8578
8679 if( wgAjaxWatch.supported === false || !wgEnableWriteAPI || !wfSupportsAjax() ) {
8780 // Lazy initialization so we don't toss up
@@ -91,7 +84,7 @@
9285 }
9386
9487 wgAjaxWatch.setLinkText( $link, $link.data( 'action' ) + 'ing' );
95 - $j.get( wgScriptPath
 88+ $.get( wgScriptPath
9689 + '/api' + wgScriptExtension + '?action=watch&format=json&title='
9790 + encodeURIComponent( $link.data( 'target' ) )
9891 + ( $link.data( 'action' ) == 'unwatch' ? '&unwatch' : '' ),
@@ -106,7 +99,7 @@
107100 // When a request returns, a custom event 'mw-ajaxwatch' is triggered
108101 // on *all* watch links, so they can be updated if necessary
109102 $links.bind( 'mw-ajaxwatch', function( event, target, action ) {
110 - var $link = $j( this );
 103+ var $link = $( this );
111104 var foo = $link.data( 'target' );
112105 if( $link.data( 'target' ) == target ) {
113106 var otheraction = action == 'watch'
@@ -119,7 +112,7 @@
120113 if( $link.parents( 'li' ).attr( 'id' ) == 'ca-' + action ) {
121114 $link.parents( 'li' ).attr( 'id', 'ca-' + otheraction );
122115 // update the link text with the new message
123 - $link.text( wgAjaxWatch[ otheraction + 'Msg'] );
 116+ $link.text( mediaWiki.msg.get( otheraction + 'Msg' ) );
124117 }
125118 };
126119 return false;
Index: branches/resourceloader/phase3/skins/common/prefs.js
@@ -1,7 +1,7 @@
22 // generate toc from prefs form, fold sections
33 // XXX: needs testing on IE/Mac and safari
44 // more comments to follow
5 -function tabbedprefs() {
 5+window.tabbedprefs = function() {
66 var prefform = document.getElementById( 'preferences' );
77 if ( !prefform || !document.createElement ) {
88 return;
@@ -59,7 +59,7 @@
6060 document.getElementById( 'prefsubmit' ).id = 'prefcontrol';
6161 }
6262
63 -function uncoversection() {
 63+window.uncoversection = function() {
6464 var oldsecid = this.parentNode.parentNode.selectedid;
6565 var newsec = document.getElementById( this.secid );
6666 if ( oldsecid != this.secid ) {
@@ -78,7 +78,7 @@
7979
8080 // Timezone stuff
8181 // tz in format [+-]HHMM
82 -function checkTimezone( tz, msg ) {
 82+window.checkTimezone = function( tz, msg ) {
8383 var localclock = new Date();
8484 // returns negative offset from GMT in minutes
8585 var tzRaw = localclock.getTimezoneOffset();
@@ -91,7 +91,7 @@
9292 }
9393 }
9494
95 -function timezoneSetup() {
 95+window.timezoneSetup = function() {
9696 var tzSelect = document.getElementById( 'mw-input-timecorrection' );
9797 var tzTextbox = document.getElementById( 'mw-input-timecorrection-other' );
9898
@@ -105,7 +105,7 @@
106106
107107 // in [-]HH:MM format...
108108 // won't yet work with non-even tzs
109 -function fetchTimezone() {
 109+window.fetchTimezone = function() {
110110 // FIXME: work around Safari bug
111111 var localclock = new Date();
112112 // returns negative offset from GMT in minutes
@@ -117,7 +117,7 @@
118118 return tzString;
119119 }
120120
121 -function guessTimezone() {
 121+window.guessTimezone = function() {
122122 var textbox = document.getElementById( 'mw-input-timecorrection-other' );
123123 var selector = document.getElementById( 'mw-input-timecorrection' );
124124
@@ -127,7 +127,7 @@
128128 updateTimezoneSelection( true );
129129 }
130130
131 -function updateTimezoneSelection( force_offset ) {
 131+window.updateTimezoneSelection = function( force_offset ) {
132132 var selector = document.getElementById( 'mw-input-timecorrection' );
133133
134134 if ( selector.value == 'guess' ) {
Index: branches/resourceloader/phase3/skins/common/preview.js
@@ -2,12 +2,12 @@
33 * Live preview script for MediaWiki
44 */
55
6 -function doLivePreview( e ) {
 6+window.doLivePreview = function( e ) {
77 e.preventDefault();
88
9 - $j( mw ).trigger( 'LivePreviewPrepare' );
 9+ $( mw ).trigger( 'LivePreviewPrepare' );
1010
11 - var postData = $j('#editform').formToArray();
 11+ var postData = $('#editform').formToArray();
1212 postData.push( { 'name' : 'wpPreview', 'value' : '1' } );
1313
1414 // Hide active diff, used templates, old preview if shown
@@ -15,14 +15,14 @@
1616 '#catlinks'];
1717 var copySelector = copyElements.join(',');
1818
19 - $j.each( copyElements, function(k,v) { $j(v).fadeOut('fast'); } );
 19+ $.each( copyElements, function(k,v) { $(v).fadeOut('fast'); } );
2020
2121 // Display a loading graphic
22 - var loadSpinner = $j('<div class="mw-ajax-loader"/>');
23 - $j('#wikiPreview').before( loadSpinner );
 22+ var loadSpinner = $('<div class="mw-ajax-loader"/>');
 23+ $('#wikiPreview').before( loadSpinner );
2424
25 - var page = $j('<div/>');
26 - var target = $j('#editform').attr('action');
 25+ var page = $('<div/>');
 26+ var target = $('#editform').attr('action');
2727
2828 if ( !target ) {
2929 target = window.location.href;
@@ -36,25 +36,25 @@
3737 // and the real page, empty the element in the real page, and fill it
3838 // with the content of the loaded page
3939 var copyContent = page.find( copyElements[i] ).contents();
40 - $j(copyElements[i]).empty().append( copyContent );
 40+ $(copyElements[i]).empty().append( copyContent );
4141 var newClasses = page.find( copyElements[i] ).attr('class');
42 - $j(copyElements[i]).attr( 'class', newClasses );
 42+ $(copyElements[i]).attr( 'class', newClasses );
4343 }
4444
45 - $j.each( copyElements, function(k,v) {
 45+ $.each( copyElements, function(k,v) {
4646 // Don't belligerently show elements that are supposed to be hidden
47 - $j(v).fadeIn( 'fast', function() { $j(this).css('display', ''); } );
 47+ $(v).fadeIn( 'fast', function() { $(this).css('display', ''); } );
4848 } );
4949
5050 loadSpinner.remove();
5151
52 - $j( mw ).trigger( 'LivePreviewDone', [copyElements] );
 52+ $( mw ).trigger( 'LivePreviewDone', [copyElements] );
5353 } );
5454 }
5555
5656 // Shamelessly stolen from the jQuery form plugin, which is licensed under the GPL.
5757 // http://jquery.malsup.com/form/#download
58 -$j.fn.formToArray = function() {
 58+$.fn.formToArray = function() {
5959 var a = [];
6060 if (this.length == 0) return a;
6161
@@ -66,7 +66,7 @@
6767 var n = el.name;
6868 if (!n) continue;
6969
70 - var v = $j.fieldValue(el, true);
 70+ var v = $.fieldValue(el, true);
7171 if (v && v.constructor == Array) {
7272 for(var j=0, jmax=v.length; j < jmax; j++)
7373 a.push({name: n, value: v[j]});
@@ -89,7 +89,7 @@
9090 /**
9191 * Returns the value of the field element.
9292 */
93 -$j.fieldValue = function(el, successful) {
 93+$.fieldValue = function(el, successful) {
9494 var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
9595 if (typeof successful == 'undefined') successful = true;
9696
@@ -122,6 +122,6 @@
123123 return el.value;
124124 };
125125
126 -$j(document).ready( function() {
127 - $j('#wpPreview').click( doLivePreview );
 126+$(document).ready( function() {
 127+ $('#wpPreview').click( doLivePreview );
128128 } );
Index: branches/resourceloader/phase3/skins/common/ajax.js
@@ -1,14 +1,14 @@
22 // remote scripting library
33 // (c) copyright 2005 modernmethod, inc
4 -var sajax_debug_mode = false;
5 -var sajax_request_type = "GET";
 4+window.sajax_debug_mode = false;
 5+window.sajax_request_type = "GET";
66
77 /**
88 * if sajax_debug_mode is true, this function outputs given the message into
99 * the element with id = sajax_debug; if no such element exists in the document,
1010 * it is injected.
1111 */
12 -function sajax_debug(text) {
 12+window.sajax_debug = function(text) {
1313 if (!sajax_debug_mode) return false;
1414
1515 var e= document.getElementById('sajax_debug');
@@ -35,7 +35,7 @@
3636 /**
3737 * compatibility wrapper for creating a new XMLHttpRequest object.
3838 */
39 -function sajax_init_object() {
 39+window.sajax_init_object = function() {
4040 sajax_debug("sajax_init_object() called..")
4141 var A;
4242 try {
@@ -76,7 +76,7 @@
7777 * (1, 2, 3) as the parameter list, and will show the result in the element
7878 * with id = showFoo
7979 */
80 -function sajax_do_call(func_name, args, target) {
 80+window.sajax_do_call = function(func_name, args, target) {
8181 var i, x, n;
8282 var uri;
8383 var post_data;
@@ -158,7 +158,7 @@
159159 /**
160160 * @return boolean whether the browser supports XMLHttpRequest
161161 */
162 -function wfSupportsAjax() {
 162+window.wfSupportsAjax = function() {
163163 var request = sajax_init_object();
164164 var supportsAjax = request ? true : false;
165165 delete request;
Index: branches/resourceloader/phase3/skins/common/upload.js
@@ -1,4 +1,4 @@
2 -function licenseSelectorCheck() {
 2+window.licenseSelectorCheck = function() {
33 var selector = document.getElementById( "wpLicense" );
44 var selection = selector.options[selector.selectedIndex].value;
55 if( selector.selectedIndex > 0 ) {
@@ -11,7 +11,7 @@
1212 wgUploadLicenseObj.fetchPreview( selection );
1313 }
1414
15 -function wgUploadSetup() {
 15+window.wgUploadSetup = function() {
1616 // Disable URL box if the URL copy upload source type is not selected
1717 var e = document.getElementById( 'wpSourceTypeurl' );
1818 if( e ) {
@@ -92,7 +92,7 @@
9393 * @param enabledId The id of the selected radio button
9494 * @return emptiness
9595 */
96 -function toggleUploadInputs() {
 96+window.toggleUploadInputs = function() {
9797 // Iterate over all rows with UploadSourceField
9898 var rows;
9999 if ( document.getElementsByClassName ) {
@@ -126,7 +126,7 @@
127127 }
128128 }
129129
130 -var wgUploadWarningObj = {
 130+window.wgUploadWarningObj = {
131131 'responseCache' : { '' : '&nbsp;' },
132132 'nameToCheck' : '',
133133 'typing': false,
@@ -212,7 +212,7 @@
213213 }
214214 }
215215
216 -function fillDestFilename(id) {
 216+window.fillDestFilename = function(id) {
217217 if (!wgUploadAutoFill) {
218218 return;
219219 }
@@ -286,7 +286,7 @@
287287 }
288288 }
289289
290 -function toggleFilenameFiller() {
 290+window.toggleFilenameFiller = function() {
291291 if(!document.getElementById) return;
292292 var upfield = document.getElementById('wpUploadFile');
293293 var destName = document.getElementById('wpDestFile').value;
@@ -297,7 +297,7 @@
298298 }
299299 }
300300
301 -var wgUploadLicenseObj = {
 301+window.wgUploadLicenseObj = {
302302
303303 'responseCache' : { '' : '' },
304304
Index: branches/resourceloader/phase3/skins/common/mwsuggest.js
@@ -8,38 +8,38 @@
99 */
1010
1111 // search_box_id -> Results object
12 -var os_map = {};
 12+window.os_map = {};
1313 // cached data, url -> json_text
14 -var os_cache = {};
 14+window.os_cache = {};
1515 // global variables for suggest_keypress
16 -var os_cur_keypressed = 0;
17 -var os_keypressed_count = 0;
 16+window.os_cur_keypressed = 0;
 17+window.os_keypressed_count = 0;
1818 // type: Timer
19 -var os_timer = null;
 19+window.os_timer = null;
2020 // tie mousedown/up events
21 -var os_mouse_pressed = false;
22 -var os_mouse_num = -1;
 21+window.os_mouse_pressed = false;
 22+window.os_mouse_num = -1;
2323 // if true, the last change was made by mouse (and not keyboard)
24 -var os_mouse_moved = false;
 24+window.os_mouse_moved = false;
2525 // delay between keypress and suggestion (in ms)
26 -var os_search_timeout = 250;
 26+window.os_search_timeout = 250;
2727 // these pairs of inputs/forms will be autoloaded at startup
28 -var os_autoload_inputs = new Array('searchInput', 'searchInput2', 'powerSearchText', 'searchText');
29 -var os_autoload_forms = new Array('searchform', 'searchform2', 'powersearch', 'search' );
 28+window.os_autoload_inputs = new Array('searchInput', 'searchInput2', 'powerSearchText', 'searchText');
 29+window.os_autoload_forms = new Array('searchform', 'searchform2', 'powersearch', 'search' );
3030 // if we stopped the service
31 -var os_is_stopped = false;
 31+window.os_is_stopped = false;
3232 // max lines to show in suggest table
33 -var os_max_lines_per_suggest = 7;
 33+window.os_max_lines_per_suggest = 7;
3434 // number of steps to animate expansion/contraction of container width
35 -var os_animation_steps = 6;
 35+window.os_animation_steps = 6;
3636 // num of pixels of smallest step
37 -var os_animation_min_step = 2;
 37+window.os_animation_min_step = 2;
3838 // delay between steps (in ms)
39 -var os_animation_delay = 30;
 39+window.os_animation_delay = 30;
4040 // max width of container in percent of normal size (1 == 100%)
41 -var os_container_max_width = 2;
 41+window.os_container_max_width = 2;
4242 // currently active animation timer
43 -var os_animation_timer = null;
 43+window.os_animation_timer = null;
4444 /**
4545 * <datalist> is a new HTML5 element that allows you to manually supply
4646 * suggestion lists and have them rendered according to the right platform
@@ -50,17 +50,17 @@
5151 * (maybe with a UA check) when some browser has a better implementation.
5252 */
5353 // var os_use_datalist = 'list' in document.createElement( 'input' );
54 -var os_use_datalist = false;
 54+window.os_use_datalist = false;
5555
5656 /** Timeout timer class that will fetch the results */
57 -function os_Timer( id, r, query ) {
 57+window.os_Timer = function( id, r, query ) {
5858 this.id = id;
5959 this.r = r;
6060 this.query = query;
6161 }
6262
6363 /** Property class for single search box */
64 -function os_Results( name, formname ) {
 64+window.os_Results = function( name, formname ) {
6565 this.searchform = formname; // id of the searchform
6666 this.searchbox = name; // id of the searchbox
6767 this.container = name + 'Suggest'; // div that holds results
@@ -80,7 +80,7 @@
8181 }
8282
8383 /** Timer user to animate expansion/contraction of container width */
84 -function os_AnimationTimer( r, target ) {
 84+window.os_AnimationTimer = function( r, target ) {
8585 this.r = r;
8686 var current = document.getElementById(r.container).offsetWidth;
8787 this.inc = Math.round( ( target - current ) / os_animation_steps );
@@ -98,7 +98,7 @@
9999 ******************/
100100
101101 /** Initialization, call upon page onload */
102 -function os_MWSuggestInit() {
 102+window.os_MWSuggestInit = function() {
103103 for( i = 0; i < os_autoload_inputs.length; i++ ) {
104104 var id = os_autoload_inputs[i];
105105 var form = os_autoload_forms[i];
@@ -110,7 +110,7 @@
111111 }
112112
113113 /** Init Result objects and event handlers */
114 -function os_initHandlers( name, formname, element ) {
 114+window.os_initHandlers = function( name, formname, element ) {
115115 var r = new os_Results( name, formname );
116116 var formElement = document.getElementById( formname );
117117 if( !formElement ) {
@@ -159,7 +159,7 @@
160160
161161 }
162162
163 -function os_hookEvent( element, hookName, hookFunct ) {
 163+window.os_hookEvent = function( element, hookName, hookFunct ) {
164164 if ( element.addEventListener ) {
165165 element.addEventListener( hookName, hookFunct, false );
166166 } else if ( window.attachEvent ) {
@@ -172,7 +172,7 @@
173173 ********************/
174174
175175 /** Event handler that will fetch results on keyup */
176 -function os_eventKeyup( e ) {
 176+window.os_eventKeyup = function( e ) {
177177 var targ = os_getTarget( e );
178178 var r = os_map[targ.id];
179179 if( r == null ) {
@@ -188,7 +188,7 @@
189189 }
190190
191191 /** catch arrows up/down and escape to hide the suggestions */
192 -function os_processKey( r, keypressed, targ ) {
 192+window.os_processKey = function( r, keypressed, targ ) {
193193 if ( keypressed == 40 && !r.visible && os_timer == null ) {
194194 // If the user hits the down arrow, fetch results immediately if none
195195 // are already displayed.
@@ -218,7 +218,7 @@
219219 }
220220
221221 /** When keys is held down use a timer to output regular events */
222 -function os_eventKeypress( e ) {
 222+window.os_eventKeypress = function( e ) {
223223 var targ = os_getTarget( e );
224224 var r = os_map[targ.id];
225225 if( r == null ) {
@@ -232,7 +232,7 @@
233233 }
234234
235235 /** Catch the key code (Firefox bug) */
236 -function os_eventKeydown( e ) {
 236+window.os_eventKeydown = function( e ) {
237237 if ( !e ) {
238238 e = window.event;
239239 }
@@ -250,7 +250,7 @@
251251
252252
253253 /** When the form is submitted hide everything, cancel updates... */
254 -function os_eventOnsubmit( e ) {
 254+window.os_eventOnsubmit = function( e ) {
255255 var targ = os_getTarget( e );
256256
257257 os_is_stopped = true;
@@ -278,7 +278,7 @@
279279
280280 /** Hide results from the user, either making the div visibility=hidden or
281281 * detaching the datalist from the input. */
282 -function os_hideResults( r ) {
 282+window.os_hideResults = function( r ) {
283283 if ( os_use_datalist ) {
284284 document.getElementById( r.searchbox ).setAttribute( 'list', '' );
285285 } else {
@@ -291,7 +291,7 @@
292292 r.selected = -1;
293293 }
294294
295 -function os_decodeValue( value ) {
 295+window.os_decodeValue = function( value ) {
296296 if ( decodeURIComponent ) {
297297 return decodeURIComponent( value );
298298 }
@@ -301,7 +301,7 @@
302302 return null;
303303 }
304304
305 -function os_encodeQuery( value ) {
 305+window.os_encodeQuery = function( value ) {
306306 if ( encodeURIComponent ) {
307307 return encodeURIComponent( value );
308308 }
@@ -312,7 +312,7 @@
313313 }
314314
315315 /** Handles data from XMLHttpRequest, and updates the suggest results */
316 -function os_updateResults( r, query, text, cacheKey ) {
 316+window.os_updateResults = function( r, query, text, cacheKey ) {
317317 os_cache[cacheKey] = text;
318318 r.query = query;
319319 r.original = query;
@@ -348,7 +348,7 @@
349349 * @param r os_Result object
350350 * @param results Array of the new results to replace existing ones
351351 */
352 -function os_setupDatalist( r, results ) {
 352+window.os_setupDatalist = function( r, results ) {
353353 var s = document.getElementById( r.searchbox );
354354 var c = document.getElementById( r.container );
355355 if ( c == null ) {
@@ -374,7 +374,7 @@
375375
376376 /** Fetch namespaces from checkboxes or hidden fields in the search form,
377377 if none defined use wgSearchNamespaces global */
378 -function os_getNamespaces( r ) {
 378+window.os_getNamespaces = function( r ) {
379379 var namespaces = '';
380380 var elements = document.forms[r.searchform].elements;
381381 for( i = 0; i < elements.length; i++ ) {
@@ -398,7 +398,7 @@
399399 }
400400
401401 /** Update results if user hasn't already typed something else */
402 -function os_updateIfRelevant( r, query, text, cacheKey ) {
 402+window.os_updateIfRelevant = function( r, query, text, cacheKey ) {
403403 var t = document.getElementById( r.searchbox );
404404 if( t != null && t.value == query ) { // check if response is still relevant
405405 os_updateResults( r, query, text, cacheKey );
@@ -407,7 +407,7 @@
408408 }
409409
410410 /** Fetch results after some timeout */
411 -function os_delayedFetch() {
 411+window.os_delayedFetch = function() {
412412 if( os_timer == null ) {
413413 return;
414414 }
@@ -444,7 +444,7 @@
445445 }
446446
447447 /** Init timed update via os_delayedUpdate() */
448 -function os_fetchResults( r, query, timeout ) {
 448+window.os_fetchResults = function( r, query, timeout ) {
449449 if( query == '' ) {
450450 r.query = '';
451451 os_hideResults( r );
@@ -469,7 +469,7 @@
470470 }
471471
472472 /** Find event target */
473 -function os_getTarget( e ) {
 473+window.os_getTarget = function( e ) {
474474 if ( !e ) {
475475 e = window.event;
476476 }
@@ -483,7 +483,7 @@
484484 }
485485
486486 /** Check if x is a valid integer */
487 -function os_isNumber( x ) {
 487+window.os_isNumber = function( x ) {
488488 if( x == '' || isNaN( x ) ) {
489489 return false;
490490 }
@@ -497,12 +497,12 @@
498498 }
499499
500500 /** Call this to enable suggestions on input (id=inputId), on a form (name=formName) */
501 -function os_enableSuggestionsOn( inputId, formName ) {
 501+window.os_enableSuggestionsOn = function( inputId, formName ) {
502502 os_initHandlers( inputId, formName, document.getElementById( inputId ) );
503503 }
504504
505505 /** Call this to disable suggestios on input box (id=inputId) */
506 -function os_disableSuggestionsOn( inputId ) {
 506+window.os_disableSuggestionsOn = function( inputId ) {
507507 r = os_map[inputId];
508508 if( r != null ) {
509509 // cancel/hide results
@@ -526,7 +526,7 @@
527527 ************************************************/
528528
529529 /** Event: loss of focus of input box */
530 -function os_eventBlur( e ) {
 530+window.os_eventBlur = function( e ) {
531531 var targ = os_getTarget( e );
532532 var r = os_map[targ.id];
533533 if( r == null ) {
@@ -545,7 +545,7 @@
546546 }
547547
548548 /** Event: focus (catch only when stopped) */
549 -function os_eventFocus( e ) {
 549+window.os_eventFocus = function( e ) {
550550 var targ = os_getTarget( e );
551551 var r = os_map[targ.id];
552552 if( r == null ) {
@@ -560,7 +560,7 @@
561561 * @param r os_Result object
562562 * @param results Array of the new results to replace existing ones
563563 */
564 -function os_setupDiv( r, results ) {
 564+window.os_setupDiv = function( r, results ) {
565565 var c = document.getElementById( r.container );
566566 if ( c == null ) {
567567 c = os_createContainer( r );
@@ -576,7 +576,7 @@
577577 }
578578
579579 /** Create the result table to be placed in the container div */
580 -function os_createResultTable( r, results ) {
 580+window.os_createResultTable = function( r, results ) {
581581 var c = document.getElementById( r.container );
582582 var width = c.offsetWidth - os_operaWidthFix( c.offsetWidth );
583583 var html = '<table class="os-suggest-results" id="' + r.resultTable + '" style="width: ' + width + 'px;">';
@@ -592,7 +592,7 @@
593593 }
594594
595595 /** Show results div */
596 -function os_showResults( r ) {
 596+window.os_showResults = function( r ) {
597597 if( os_is_stopped ) {
598598 return;
599599 }
@@ -609,7 +609,7 @@
610610 }
611611 }
612612
613 -function os_operaWidthFix( x ) {
 613+window.os_operaWidthFix = function( x ) {
614614 // For browsers that don't understand overflow-x, estimate scrollbar width
615615 if( typeof document.body.style.overflowX != 'string' ) {
616616 return 30;
@@ -618,7 +618,7 @@
619619 }
620620
621621 /** Brower-dependent functions to find window inner size, and scroll status */
622 -function f_clientWidth() {
 622+window.f_clientWidth = function() {
623623 return f_filterResults(
624624 window.innerWidth ? window.innerWidth : 0,
625625 document.documentElement ? document.documentElement.clientWidth : 0,
@@ -626,7 +626,7 @@
627627 );
628628 }
629629
630 -function f_clientHeight() {
 630+window.f_clientHeight = function() {
631631 return f_filterResults(
632632 window.innerHeight ? window.innerHeight : 0,
633633 document.documentElement ? document.documentElement.clientHeight : 0,
@@ -634,7 +634,7 @@
635635 );
636636 }
637637
638 -function f_scrollLeft() {
 638+window.f_scrollLeft = function() {
639639 return f_filterResults(
640640 window.pageXOffset ? window.pageXOffset : 0,
641641 document.documentElement ? document.documentElement.scrollLeft : 0,
@@ -642,7 +642,7 @@
643643 );
644644 }
645645
646 -function f_scrollTop() {
 646+window.f_scrollTop = function() {
647647 return f_filterResults(
648648 window.pageYOffset ? window.pageYOffset : 0,
649649 document.documentElement ? document.documentElement.scrollTop : 0,
@@ -650,7 +650,7 @@
651651 );
652652 }
653653
654 -function f_filterResults( n_win, n_docel, n_body ) {
 654+window.f_filterResults = function( n_win, n_docel, n_body ) {
655655 var n_result = n_win ? n_win : 0;
656656 if ( n_docel && ( !n_result || ( n_result > n_docel ) ) ) {
657657 n_result = n_docel;
@@ -659,7 +659,7 @@
660660 }
661661
662662 /** Get the height available for the results container */
663 -function os_availableHeight( r ) {
 663+window.os_availableHeight = function( r ) {
664664 var absTop = document.getElementById( r.container ).style.top;
665665 var px = absTop.lastIndexOf( 'px' );
666666 if( px > 0 ) {
@@ -669,7 +669,7 @@
670670 }
671671
672672 /** Get element absolute position {left,top} */
673 -function os_getElementPosition( elemID ) {
 673+window.os_getElementPosition = function( elemID ) {
674674 var offsetTrail = document.getElementById( elemID );
675675 var offsetLeft = 0;
676676 var offsetTop = 0;
@@ -686,7 +686,7 @@
687687 }
688688
689689 /** Create the container div that will hold the suggested titles */
690 -function os_createContainer( r ) {
 690+window.os_createContainer = function( r ) {
691691 var c = document.createElement( 'div' );
692692 var s = document.getElementById( r.searchbox );
693693 var pos = os_getElementPosition( r.searchbox );
@@ -712,7 +712,7 @@
713713 }
714714
715715 /** change container height to fit to screen */
716 -function os_fitContainer( r ) {
 716+window.os_fitContainer = function( r ) {
717717 var c = document.getElementById( r.container );
718718 var h = os_availableHeight( r ) - 20;
719719 var inc = r.containerRow;
@@ -733,7 +733,7 @@
734734 }
735735
736736 /** If some entries are longer than the box, replace text with "..." */
737 -function os_trimResultText( r ) {
 737+window.os_trimResultText = function( r ) {
738738 // find max width, first see if we could expand the container to fit it
739739 var maxW = 0;
740740 for( var i = 0; i < r.resultCount; i++ ) {
@@ -799,7 +799,7 @@
800800 }
801801
802802 /** Invoked on timer to animate change in container width */
803 -function os_animateChangeWidth() {
 803+window.os_animateChangeWidth = function() {
804804 var r = os_animation_timer.r;
805805 var c = document.getElementById( r.container );
806806 var w = c.offsetWidth;
@@ -823,7 +823,7 @@
824824 }
825825
826826 /** Change the highlighted row (i.e. suggestion), from position cur to next */
827 -function os_changeHighlight( r, cur, next, updateSearchBox ) {
 827+window.os_changeHighlight = function( r, cur, next, updateSearchBox ) {
828828 if ( next >= r.resultCount ) {
829829 next = r.resultCount - 1;
830830 }
@@ -870,7 +870,7 @@
871871 }
872872 }
873873
874 -function os_HighlightClass() {
 874+window.os_HighlightClass = function() {
875875 var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
876876 if ( match ) {
877877 var webKitVersion = parseInt( match[1] );
@@ -884,7 +884,7 @@
885885 return 'os-suggest-result-hl';
886886 }
887887
888 -function os_updateSearchQuery( r, newText ) {
 888+window.os_updateSearchQuery = function( r, newText ) {
889889 document.getElementById( r.searchbox ).value = newText;
890890 r.query = newText;
891891 }
@@ -895,7 +895,7 @@
896896 ********************/
897897
898898 /** Mouse over the container */
899 -function os_eventMouseover( srcId, e ) {
 899+window.os_eventMouseover = function( srcId, e ) {
900900 var targ = os_getTarget( e );
901901 var r = os_map[srcId];
902902 if( r == null || !os_mouse_moved ) {
@@ -908,7 +908,7 @@
909909 }
910910
911911 /* Get row where the event occured (from its id) */
912 -function os_getNumberSuffix( id ) {
 912+window.os_getNumberSuffix = function( id ) {
913913 var num = id.substring( id.length - 2 );
914914 if( !( num.charAt( 0 ) >= '0' && num.charAt( 0 ) <= '9' ) ) {
915915 num = num.substring( 1 );
@@ -921,12 +921,12 @@
922922 }
923923
924924 /** Save mouse move as last action */
925 -function os_eventMousemove( srcId, e ) {
 925+window.os_eventMousemove = function( srcId, e ) {
926926 os_mouse_moved = true;
927927 }
928928
929929 /** Mouse button held down, register possible click */
930 -function os_eventMousedown( srcId, e ) {
 930+window.os_eventMousedown = function( srcId, e ) {
931931 var targ = os_getTarget( e );
932932 var r = os_map[srcId];
933933 if( r == null ) {
@@ -946,7 +946,7 @@
947947 }
948948
949949 /** Mouse button released, check for click on some row */
950 -function os_eventMouseup( srcId, e ) {
 950+window.os_eventMouseup = function( srcId, e ) {
951951 var targ = os_getTarget( e );
952952 var r = os_map[srcId];
953953 if( r == null ) {
@@ -967,7 +967,7 @@
968968 /** Toggle stuff seems to be dead code? */
969969
970970 /** Return the span element that contains the toggle link */
971 -function os_createToggle( r, className ) {
 971+window.os_createToggle = function( r, className ) {
972972 var t = document.createElement( 'span' );
973973 t.className = className;
974974 t.setAttribute( 'id', r.toggle );
@@ -981,7 +981,7 @@
982982 }
983983
984984 /** Call when user clicks on some of the toggle links */
985 -function os_toggle( inputId, formName ) {
 985+window.os_toggle = function( inputId, formName ) {
986986 r = os_map[inputId];
987987 var msg = '';
988988 if( r == null ) {
Index: branches/resourceloader/phase3/skins/common/edit.js
@@ -1,7 +1,7 @@
2 -var currentFocused;
 2+window.currentFocused;
33
44 // this function adds a toolbar button to the mwEditButtons list
5 -function addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId ) {
 5+window.addButton = function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId ) {
66 // Don't generate buttons for browsers which don't fully
77 // support it.
88 mwEditButtons.push({
@@ -15,7 +15,7 @@
1616 }
1717
1818 // this function adds one toolbar button from a mwEditButtons/mwCustomEditButtons item
19 -function mwInsertEditButton( parent, item ) {
 19+window.mwInsertEditButton = function( parent, item ) {
2020 var image = document.createElement( 'img' );
2121 image.width = 23;
2222 image.height = 22;
@@ -31,8 +31,8 @@
3232 image.onclick = function() {
3333 insertTags( item.tagOpen, item.tagClose, item.sampleText );
3434 // click tracking
35 - if ( ( typeof $j != 'undefined' ) && ( typeof $j.trackAction != 'undefined' ) ) {
36 - $j.trackAction( 'oldedit.' + item.speedTip.replace(/ /g, "-") );
 35+ if ( ( typeof $ != 'undefined' ) && ( typeof $.trackAction != 'undefined' ) ) {
 36+ $.trackAction( 'oldedit.' + item.speedTip.replace(/ /g, "-") );
3737 }
3838 return false;
3939 };
@@ -43,7 +43,7 @@
4444
4545 // this function generates the actual toolbar buttons with localized text
4646 // we use it to avoid creating the toolbar where javascript is not enabled
47 -function mwSetupToolbar() {
 47+window.mwSetupToolbar = function() {
4848 var toolbar = document.getElementById( 'toolbar' );
4949 if ( !toolbar ) {
5050 return false;
@@ -77,10 +77,10 @@
7878
7979 // apply tagOpen/tagClose to selection in textarea,
8080 // use sampleText instead of selection if there is none
81 -function insertTags( tagOpen, tagClose, sampleText ) {
82 - if ( typeof $j != 'undefined' && typeof $j.fn.textSelection != 'undefined' &&
 81+window.insertTags = function( tagOpen, tagClose, sampleText ) {
 82+ if ( typeof $ != 'undefined' && typeof $.fn.textSelection != 'undefined' &&
8383 ( currentFocused.nodeName.toLowerCase() == 'iframe' || currentFocused.id == 'wpTextbox1' ) ) {
84 - $j( '#wpTextbox1' ).textSelection(
 84+ $( '#wpTextbox1' ).textSelection(
8585 'encapsulateSelection', { 'pre': tagOpen, 'peri': sampleText, 'post': tagClose }
8686 );
8787 return;
@@ -166,7 +166,7 @@
167167 * Restore the edit box scroll state following a preview operation,
168168 * and set up a form submission handler to remember this state
169169 */
170 -function scrollEditBox() {
 170+window.scrollEditBox = function() {
171171 var editBox = document.getElementById( 'wpTextbox1' );
172172 var scrollTop = document.getElementById( 'wpScrolltop' );
173173 var editForm = document.getElementById( 'editform' );
@@ -217,10 +217,10 @@
218218
219219 // HACK: make currentFocused work with the usability iframe
220220 // With proper focus detection support (HTML 5!) this'll be much cleaner
221 - if ( typeof $j != 'undefined' ) {
222 - var iframe = $j( '.wikiEditor-ui-text iframe' );
 221+ if ( typeof $ != 'undefined' ) {
 222+ var iframe = $( '.wikiEditor-ui-text iframe' );
223223 if ( iframe.length > 0 ) {
224 - $j( iframe.get( 0 ).contentWindow.document )
 224+ $( iframe.get( 0 ).contentWindow.document )
225225 .add( iframe.get( 0 ).contentWindow.document.body ) // for IE
226226 .focus( function() { currentFocused = iframe.get( 0 ); } );
227227 }
Index: branches/resourceloader/phase3/skins/common/wikibits.js
@@ -1,39 +1,39 @@
22 // MediaWiki JavaScript support functions
33
4 -var clientPC = navigator.userAgent.toLowerCase(); // Get client info
5 -var is_gecko = /gecko/.test( clientPC ) &&
 4+window.clientPC = navigator.userAgent.toLowerCase(); // Get client info
 5+window.is_gecko = /gecko/.test( clientPC ) &&
66 !/khtml|spoofer|netscape\/7\.0/.test(clientPC);
7 -var webkit_match = clientPC.match(/applewebkit\/(\d+)/);
 7+window.webkit_match = clientPC.match(/applewebkit\/(\d+)/);
88 if (webkit_match) {
9 - var is_safari = clientPC.indexOf('applewebkit') != -1 &&
 9+ window.is_safari = clientPC.indexOf('applewebkit') != -1 &&
1010 clientPC.indexOf('spoofer') == -1;
11 - var is_safari_win = is_safari && clientPC.indexOf('windows') != -1;
12 - var webkit_version = parseInt(webkit_match[1]);
 11+ window.is_safari_win = is_safari && clientPC.indexOf('windows') != -1;
 12+ window.webkit_version = parseInt(webkit_match[1]);
1313 // Tests for chrome here, to avoid breaking old scripts safari left alone
1414 // This is here for accesskeys
15 - var is_chrome = clientPC.indexOf('chrome') !== -1 &&
 15+ window.is_chrome = clientPC.indexOf('chrome') !== -1 &&
1616 clientPC.indexOf('spoofer') === -1;
17 - var is_chrome_mac = is_chrome && clientPC.indexOf('mac') !== -1
 17+ window.is_chrome_mac = is_chrome && clientPC.indexOf('mac') !== -1
1818 }
1919 // For accesskeys; note that FF3+ is included here!
20 -var is_ff2 = /firefox\/[2-9]|minefield\/3/.test( clientPC );
21 -var ff2_bugs = /firefox\/2/.test( clientPC );
 20+window.is_ff2 = /firefox\/[2-9]|minefield\/3/.test( clientPC );
 21+window.ff2_bugs = /firefox\/2/.test( clientPC );
2222 // These aren't used here, but some custom scripts rely on them
23 -var is_ff2_win = is_ff2 && clientPC.indexOf('windows') != -1;
24 -var is_ff2_x11 = is_ff2 && clientPC.indexOf('x11') != -1;
 23+window.is_ff2_win = is_ff2 && clientPC.indexOf('windows') != -1;
 24+window.is_ff2_x11 = is_ff2 && clientPC.indexOf('x11') != -1;
2525 if (clientPC.indexOf('opera') != -1) {
26 - var is_opera = true;
27 - var is_opera_preseven = window.opera && !document.childNodes;
28 - var is_opera_seven = window.opera && document.childNodes;
29 - var is_opera_95 = /opera\/(9\.[5-9]|[1-9][0-9])/.test( clientPC );
30 - var opera6_bugs = is_opera_preseven;
31 - var opera7_bugs = is_opera_seven && !is_opera_95;
32 - var opera95_bugs = /opera\/(9\.5)/.test( clientPC );
 26+ window.is_opera = true;
 27+ window.is_opera_preseven = window.opera && !document.childNodes;
 28+ window.is_opera_seven = window.opera && document.childNodes;
 29+ window.is_opera_95 = /opera\/(9\.[5-9]|[1-9][0-9])/.test( clientPC );
 30+ window.opera6_bugs = is_opera_preseven;
 31+ window.opera7_bugs = is_opera_seven && !is_opera_95;
 32+ window.opera95_bugs = /opera\/(9\.5)/.test( clientPC );
3333 }
3434 // As recommended by <http://msdn.microsoft.com/en-us/library/ms537509.aspx>,
3535 // avoiding false positives from moronic extensions that append to the IE UA
3636 // string (bug 23171)
37 -var ie6_bugs = false;
 37+window.ie6_bugs = false;
3838 if ( /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec( clientPC ) != null
3939 && parseFloat( RegExp.$1 ) <= 6.0 ) {
4040 ie6_bugs = true;
@@ -43,13 +43,13 @@
4444 /*extern ta, stylepath, skin */
4545
4646 // add any onload functions in this hook (please don't hard-code any events in the xhtml source)
47 -var doneOnloadHook;
 47+window.doneOnloadHook;
4848
4949 if (!window.onloadFuncts) {
50 - var onloadFuncts = [];
 50+ window.onloadFuncts = [];
5151 }
5252
53 -function addOnloadHook( hookFunct ) {
 53+window.addOnloadHook = function( hookFunct ) {
5454 // Allows add-on scripts to add onload functions
5555 if( !doneOnloadHook ) {
5656 onloadFuncts[onloadFuncts.length] = hookFunct;
@@ -58,11 +58,11 @@
5959 }
6060 }
6161
62 -function hookEvent( hookName, hookFunct ) {
 62+window.hookEvent = function( hookName, hookFunct ) {
6363 addHandler( window, hookName, hookFunct );
6464 }
6565
66 -function importScript( page ) {
 66+window.importScript = function( page ) {
6767 // TODO: might want to introduce a utility function to match wfUrlencode() in PHP
6868 var uri = wgScript + '?title=' +
6969 encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') +
@@ -70,8 +70,8 @@
7171 return importScriptURI( uri );
7272 }
7373
74 -var loadedScripts = {}; // included-scripts tracker
75 -function importScriptURI( url ) {
 74+window.loadedScripts = {}; // included-scripts tracker
 75+window.importScriptURI = function( url ) {
7676 if ( loadedScripts[url] ) {
7777 return null;
7878 }
@@ -83,11 +83,11 @@
8484 return s;
8585 }
8686
87 -function importStylesheet( page ) {
 87+window.importStylesheet = function( page ) {
8888 return importStylesheetURI( wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent( page.replace(/ /g,'_') ) );
8989 }
9090
91 -function importStylesheetURI( url, media ) {
 91+window.importStylesheetURI = function( url, media ) {
9292 var l = document.createElement( 'link' );
9393 l.type = 'text/css';
9494 l.rel = 'stylesheet';
@@ -99,7 +99,7 @@
100100 return l;
101101 }
102102
103 -function appendCSS( text ) {
 103+window.appendCSS = function( text ) {
104104 var s = document.createElement( 'style' );
105105 s.type = 'text/css';
106106 s.rel = 'stylesheet';
@@ -133,7 +133,7 @@
134134 }
135135 }
136136
137 -function showTocToggle() {
 137+window.showTocToggle = function() {
138138 if ( document.createTextNode ) {
139139 // Uses DOM calls to avoid document.write + XHTML issues
140140
@@ -169,7 +169,7 @@
170170 }
171171 }
172172
173 -function changeText( el, newText ) {
 173+window.changeText = function( el, newText ) {
174174 // Safari work around
175175 if ( el.innerText ) {
176176 el.innerText = newText;
@@ -178,7 +178,7 @@
179179 }
180180 }
181181
182 -function killEvt( evt ) {
 182+window.killEvt = function( evt ) {
183183 evt = evt || window.event || window.Event; // W3C, IE, Netscape
184184 if ( typeof ( evt.preventDefault ) != 'undefined' ) {
185185 evt.preventDefault(); // Don't follow the link
@@ -189,7 +189,7 @@
190190 return false; // Don't follow the link (IE)
191191 }
192192
193 -function toggleToc() {
 193+window.toggleToc = function() {
194194 var tocmain = document.getElementById( 'toc' );
195195 var toc = document.getElementById('toc').getElementsByTagName('ul')[0];
196196 var toggleLink = document.getElementById( 'togglelink' );
@@ -208,10 +208,10 @@
209209 return false;
210210 }
211211
212 -var mwEditButtons = [];
213 -var mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js
 212+window.mwEditButtons = [];
 213+window.mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js
214214
215 -function escapeQuotes( text ) {
 215+window.escapeQuotes = function( text ) {
216216 var re = new RegExp( "'", "g" );
217217 text = text.replace( re, "\\'" );
218218 re = new RegExp( "\\n", "g" );
@@ -219,7 +219,7 @@
220220 return escapeQuotesHTML( text );
221221 }
222222
223 -function escapeQuotesHTML( text ) {
 223+window.escapeQuotesHTML = function( text ) {
224224 var re = new RegExp( '&', "g" );
225225 text = text.replace( re, "&amp;" );
226226 re = new RegExp( '"', "g" );
@@ -234,7 +234,7 @@
235235 /**
236236 * Set the accesskey prefix based on browser detection.
237237 */
238 -var tooltipAccessKeyPrefix = 'alt-';
 238+window.tooltipAccessKeyPrefix = 'alt-';
239239 if ( is_opera ) {
240240 tooltipAccessKeyPrefix = 'shift-esc-';
241241 } else if ( is_chrome ) {
@@ -248,7 +248,7 @@
249249 } else if ( is_ff2 ) {
250250 tooltipAccessKeyPrefix = 'alt-shift-';
251251 }
252 -var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?(.)\]$/;
 252+window.tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?(.)\]$/;
253253
254254 /**
255255 * Add the appropriate prefix to the accesskey shown in the tooltip.
@@ -258,7 +258,7 @@
259259 *
260260 * @param Array nodeList -- list of elements to update
261261 */
262 -function updateTooltipAccessKeys( nodeList ) {
 262+window.updateTooltipAccessKeys = function( nodeList ) {
263263 if ( !nodeList ) {
264264 // Rather than scan all links on the whole page, we can just scan these
265265 // containers which contain the relevant links. This is really just an
@@ -318,7 +318,7 @@
319319 *
320320 * @return Node -- the DOM node of the new item (an LI element) or null
321321 */
322 -function addPortletLink( portlet, href, text, id, tooltip, accesskey, nextnode ) {
 322+window.addPortletLink = function( portlet, href, text, id, tooltip, accesskey, nextnode ) {
323323 var root = document.getElementById( portlet );
324324 if ( !root ) {
325325 return null;
@@ -382,7 +382,7 @@
383383 return item;
384384 }
385385
386 -function getInnerText( el ) {
 386+window.getInnerText = function( el ) {
387387 if ( typeof el == 'string' ) {
388388 return el;
389389 }
@@ -414,20 +414,20 @@
415415
416416 /* Dummy for deprecated function */
417417 window.ta = [];
418 -function akeytt( doId ) {
 418+window.akeytt = function( doId ) {
419419 }
420420
421 -var checkboxes;
422 -var lastCheckbox;
 421+window.checkboxes;
 422+window.lastCheckbox;
423423
424 -function setupCheckboxShiftClick() {
 424+window.setupCheckboxShiftClick = function() {
425425 checkboxes = [];
426426 lastCheckbox = null;
427427 var inputs = document.getElementsByTagName( 'input' );
428428 addCheckboxClickHandlers( inputs );
429429 }
430430
431 -function addCheckboxClickHandlers( inputs, start ) {
 431+window.addCheckboxClickHandlers = function( inputs, start ) {
432432 if ( !start ) {
433433 start = 0;
434434 }
@@ -455,7 +455,7 @@
456456 }
457457 }
458458
459 -function checkboxClickHandler( e ) {
 459+window.checkboxClickHandler = function( e ) {
460460 if ( typeof e == 'undefined' ) {
461461 e = window.event;
462462 }
@@ -489,7 +489,7 @@
490490 Author says "The credit comment is all it takes, no license. Go crazy with it!:-)"
491491 From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
492492 */
493 -function getElementsByClassName( oElm, strTagName, oClassNames ) {
 493+window.getElementsByClassName = function( oElm, strTagName, oClassNames ) {
494494 var arrReturnElements = new Array();
495495 if ( typeof( oElm.getElementsByClassName ) == 'function' ) {
496496 /* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */
@@ -533,7 +533,7 @@
534534 return ( arrReturnElements );
535535 }
536536
537 -function redirectToFragment( fragment ) {
 537+window.redirectToFragment = function( fragment ) {
538538 var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
539539 if ( match ) {
540540 var webKitVersion = parseInt( match[1] );
@@ -573,16 +573,16 @@
574574 * @todo support all accepted date formats (bug 8226)
575575 */
576576
577 -var ts_image_path = stylepath + '/common/images/';
578 -var ts_image_up = 'sort_up.gif';
579 -var ts_image_down = 'sort_down.gif';
580 -var ts_image_none = 'sort_none.gif';
581 -var ts_europeandate = wgContentLanguage != 'en'; // The non-American-inclined can change to "true"
582 -var ts_alternate_row_colors = false;
583 -var ts_number_transform_table = null;
584 -var ts_number_regex = null;
 577+window.ts_image_path = stylepath + '/common/images/';
 578+window.ts_image_up = 'sort_up.gif';
 579+window.ts_image_down = 'sort_down.gif';
 580+window.ts_image_none = 'sort_none.gif';
 581+window.ts_europeandate = wgContentLanguage != 'en'; // The non-American-inclined can change to "true"
 582+window.ts_alternate_row_colors = false;
 583+window.ts_number_transform_table = null;
 584+window.ts_number_regex = null;
585585
586 -function sortables_init() {
 586+window.sortables_init = function() {
587587 var idnum = 0;
588588 // Find all tables with class sortable and make them sortable
589589 var tables = getElementsByClassName( document, 'table', 'sortable' );
@@ -595,7 +595,7 @@
596596 }
597597 }
598598
599 -function ts_makeSortable( table ) {
 599+window.ts_makeSortable = function( table ) {
600600 var firstRow;
601601 if ( table.rows && table.rows.length > 0 ) {
602602 if ( table.tHead && table.tHead.rows.length > 0 ) {
@@ -626,11 +626,11 @@
627627 }
628628 }
629629
630 -function ts_getInnerText( el ) {
 630+window.ts_getInnerText = function( el ) {
631631 return getInnerText( el );
632632 }
633633
634 -function ts_resortTable( lnk ) {
 634+window.ts_resortTable = function( lnk ) {
635635 // get the span
636636 var span = lnk.getElementsByTagName('span')[0];
637637
@@ -757,7 +757,7 @@
758758 }
759759 }
760760
761 -function ts_initTransformTable() {
 761+window.ts_initTransformTable = function() {
762762 if ( typeof wgSeparatorTransformTable == 'undefined'
763763 || ( wgSeparatorTransformTable[0] == '' && wgDigitTransformTable[2] == '' ) )
764764 {
@@ -810,11 +810,11 @@
811811 );
812812 }
813813
814 -function ts_toLowerCase( s ) {
 814+window.ts_toLowerCase = function( s ) {
815815 return s.toLowerCase();
816816 }
817817
818 -function ts_dateToSortKey( date ) {
 818+window.ts_dateToSortKey = function( date ) {
819819 // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
820820 if ( date.length == 11 ) {
821821 switch ( date.substr( 3, 3 ).toLowerCase() ) {
@@ -879,7 +879,7 @@
880880 return '00000000';
881881 }
882882
883 -function ts_parseFloat( s ) {
 883+window.ts_parseFloat = function( s ) {
884884 if ( !s ) {
885885 return 0;
886886 }
@@ -900,15 +900,15 @@
901901 return ( isNaN( num ) ? -Infinity : num );
902902 }
903903
904 -function ts_currencyToSortKey( s ) {
 904+window.ts_currencyToSortKey = function( s ) {
905905 return ts_parseFloat(s.replace(/[^-\u22120-9.,]/g,''));
906906 }
907907
908 -function ts_sort_generic( a, b ) {
 908+window.ts_sort_generic = function( a, b ) {
909909 return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : a[2] - b[2];
910910 }
911911
912 -function ts_alternate( table ) {
 912+window.ts_alternate = function( table ) {
913913 // Take object table and get all it's tbodies.
914914 var tableBodies = table.getElementsByTagName( 'tbody' );
915915 // Loop through these tbodies
@@ -945,7 +945,7 @@
946946 * call to allow CSS/JS to hide different boxes. null = no class used.
947947 * @return Boolean True on success, false on failure
948948 */
949 -function jsMsg( message, className ) {
 949+window.jsMsg = function( message, className ) {
950950 if ( !document.getElementById ) {
951951 return false;
952952 }
@@ -997,7 +997,7 @@
998998 * @param element Element to inject after
999999 * @param id Identifier string (for use with removeSpinner(), below)
10001000 */
1001 -function injectSpinner( element, id ) {
 1001+window.injectSpinner = function( element, id ) {
10021002 var spinner = document.createElement( 'img' );
10031003 spinner.id = 'mw-spinner-' + id;
10041004 spinner.src = stylepath + '/common/images/spinner.gif';
@@ -1014,14 +1014,14 @@
10151015 *
10161016 * @param id Identifier string
10171017 */
1018 -function removeSpinner( id ) {
 1018+window.removeSpinner = function( id ) {
10191019 var spinner = document.getElementById( 'mw-spinner-' + id );
10201020 if( spinner ) {
10211021 spinner.parentNode.removeChild( spinner );
10221022 }
10231023 }
10241024
1025 -function runOnloadHook() {
 1025+window.runOnloadHook = function() {
10261026 // don't run anything below this for non-dom browsers
10271027 if ( doneOnloadHook || !( document.getElementById && document.getElementsByTagName ) ) {
10281028 return;
@@ -1048,7 +1048,7 @@
10491049 * @param String attach Event to attach to
10501050 * @param callable handler Event handler callback
10511051 */
1052 -function addHandler( element, attach, handler ) {
 1052+window.addHandler = function( element, attach, handler ) {
10531053 if( window.addEventListener ) {
10541054 element.addEventListener( attach, handler, false );
10551055 } else if( window.attachEvent ) {
@@ -1062,7 +1062,7 @@
10631063 * @param Element element Element to add handler to
10641064 * @param callable handler Event handler callback
10651065 */
1066 -function addClickHandler( element, handler ) {
 1066+window.addClickHandler = function( element, handler ) {
10671067 addHandler( element, 'click', handler );
10681068 }
10691069
@@ -1073,7 +1073,7 @@
10741074 * @param String remove Event to remove
10751075 * @param callable handler Event handler callback to remove
10761076 */
1077 -function removeHandler( element, remove, handler ) {
 1077+window.removeHandler = function( element, remove, handler ) {
10781078 if( window.removeEventListener ) {
10791079 element.removeEventListener( remove, handler, false );
10801080 } else if( window.detachEvent ) {
@@ -1086,9 +1086,4 @@
10871087
10881088 if ( ie6_bugs ) {
10891089 importScriptURI( stylepath + '/common/IEFixes.js' );
1090 -}
1091 -
1092 -// For future use.
1093 -mw = {};
1094 -
1095 -
 1090+}
\ No newline at end of file
Index: branches/resourceloader/phase3/skins/common/htmlform.js
@@ -12,7 +12,7 @@
1313 }
1414 } );
1515
16 -var htmlforms = {
 16+window.htmlforms = {
1717 'selectOrOtherSelectChanged' : function( e ) {
1818 var select;
1919 if ( !e ) {
Index: branches/resourceloader/phase3/skins/common/history.js
@@ -1,4 +1,4 @@
2 -function historyRadios(parent) {
 2+window.historyRadios = function(parent) {
33 var inputs = parent.getElementsByTagName('input');
44 var radios = [];
55 for (var i = 0; i < inputs.length; i++) {
@@ -10,7 +10,7 @@
1111 }
1212
1313 // check selection and tweak visibility/class onclick
14 -function diffcheck() {
 14+window.diffcheck = function() {
1515 var dli = false; // the li where the diff radio is checked
1616 var oli = false; // the li where the oldid radio is checked
1717 var hf = document.getElementById('pagehistory');
@@ -77,7 +77,7 @@
7878 }
7979
8080 // Attach event handlers to the input elements on history page
81 -function histrowinit() {
 81+window.histrowinit = function() {
8282 var hf = document.getElementById('pagehistory');
8383 if (!hf) return;
8484 var lis = hf.getElementsByTagName('li');

Status & tagging log