From: Brion Vibber Date: Wed, 18 Jul 2007 22:13:35 +0000 (+0000) Subject: Fix several JS problems with MSIE/Mac: X-Git-Tag: 1.31.0-rc.0~52019 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=19ea5ee7f4c1d2f4b5e05ca665ac81429df182b1;p=lhc%2Fweb%2Fwiklou.git Fix several JS problems with MSIE/Mac: * Use of Array.push() broke things, as it's not missing. Work around with a[a.length] = foo -- shift-checkbox selection and sortable table setup were causing JS errors on every page view * Use of 'if (x in arr)' breaks *parsing* in MSIE/Mac. :P Work around work 'for (y in arr) if (x == y)' -- broke upload.js, so the license selector hackaround didn't get run * Upload AJAX calls weren't checking for client compatibility before doing things -- littered spinners on the page --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ab934fef58..df05c5005f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -313,6 +313,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 8054) Return search page for empty search requests with ugly URLs * (bug 10572) Force refresh after clearing visitation timestamps on watchlist * (bug 10631) Warn when illegal characters are removed from filename at upload +* Fix several JavaScript bugs under MSIE 5/Macintosh == API changes since 1.10 == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index a80ab6da3d..bf087db0d7 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1201,7 +1201,7 @@ $wgCacheEpoch = '20030516000000'; * to ensure that client-side caches don't keep obsolete copies of global * styles. */ -$wgStyleVersion = '87'; +$wgStyleVersion = '88'; # Server-side caching: diff --git a/skins/common/upload.js b/skins/common/upload.js index 6477e12849..7cbfc9aae7 100644 --- a/skins/common/upload.js +++ b/skins/common/upload.js @@ -8,9 +8,7 @@ function licenseSelectorCheck() { } } // We might show a preview - if( wgAjaxLicensePreview ) { - wgUploadLicenseObj.fetchPreview( selection ); - } + wgUploadLicenseObj.fetchPreview( selection ); } function licenseSelectorFixup() { @@ -36,6 +34,8 @@ var wgUploadWarningObj = { 'timeoutID': false, 'keypress': function () { + if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return; + // Find file to upload var destFile = document.getElementById('wpDestFile'); var warningElt = document.getElementById( 'wpDestFile-warning' ); @@ -48,15 +48,18 @@ var wgUploadWarningObj = { window.clearTimeout( this.timeoutID ); } // Check response cache - if ( this.nameToCheck in this.responseCache ) { - this.setWarning(this.responseCache[this.nameToCheck]); - return; + for (cached in this.responseCache) { + if (this.nameToCheck == cached) { + this.setWarning(this.responseCache[this.nameToCheck]); + return; + } } this.timeoutID = window.setTimeout( 'wgUploadWarningObj.timeout()', this.delay ); }, 'checkNow': function (fname) { + if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return; if ( this.timeoutID ) { window.clearTimeout( this.timeoutID ); } @@ -65,6 +68,7 @@ var wgUploadWarningObj = { }, 'timeout' : function() { + if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return; injectSpinner( document.getElementById( 'wpDestFile' ), 'destcheck' ); // Get variables into local scope so that they will be preserved for the @@ -131,9 +135,7 @@ function fillDestFilename(id) { var destFile = document.getElementById('wpDestFile'); if (destFile) { destFile.value = fname; - if ( wgAjaxUploadDestCheck ) { - wgUploadWarningObj.checkNow(fname) ; - } + wgUploadWarningObj.checkNow(fname) ; } } @@ -142,18 +144,19 @@ var wgUploadLicenseObj = { 'responseCache' : { '' : '' }, 'fetchPreview': function( license ) { - if( license == "" ) { - this.showPreview( "" ); - } else if( license in this.responseCache ) { - this.showPreview( this.responseCache[license] ); - } else { - injectSpinner( document.getElementById( 'wpLicense' ), 'license' ); - sajax_do_call( 'UploadForm::ajaxGetLicensePreview', [license], - function( result ) { - wgUploadLicenseObj.processResult( result, license ); - } - ); + if( !wgAjaxLicensePreview || !sajax_init_object() ) return; + for (cached in this.responseCache) { + if (cached == license) { + this.showPreview( this.responseCache[license] ); + return; + } } + injectSpinner( document.getElementById( 'wpLicense' ), 'license' ); + sajax_do_call( 'UploadForm::ajaxGetLicensePreview', [license], + function( result ) { + wgUploadLicenseObj.processResult( result, license ); + } + ); }, 'processResult' : function( result, license ) { diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 484ef01f86..becd5111f0 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -725,7 +725,9 @@ function addCheckboxClickHandlers(inputs, start) { var cb = inputs[i]; if ( !cb.type || cb.type.toLowerCase() != 'checkbox' ) continue; - cb.index = checkboxes.push(cb) - 1; + var end = checkboxes.length; + checkboxes[end] = cb; + cb.index = end; cb.onmouseup = checkboxMouseupHandler; } @@ -890,11 +892,13 @@ function getElementsByClassName(oElm, strTagName, oClassNames){ var arrRegExpClassNames = new Array(); if(typeof oClassNames == "object"){ for(var i=0; i