From: Ed Sanders Date: Tue, 24 Apr 2018 12:40:34 +0000 (+0100) Subject: Remove onhashchange fallback code X-Git-Tag: 1.34.0-rc.0~5626^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=b60f6c61b157a81452b23d9fc746586d7067ca94;p=lhc%2Fweb%2Fwiklou.git Remove onhashchange fallback code We no longer support any browsers that don't have the hashchange event. Change-Id: I5e6bfd1d5c634df21b6b3d06dcf007112cdf15fa --- diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js index a7470da768..1fa00dc162 100644 --- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js +++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js @@ -822,19 +822,7 @@ ApiSandbox.updateUI(); } - // If the hashchange event exists, use it. Otherwise, fake it. - // And, of course, IE has to be dumb. - if ( 'onhashchange' in window && - ( document.documentMode === undefined || document.documentMode >= 8 ) - ) { - $( window ).on( 'hashchange', ApiSandbox.loadFromHash ); - } else { - setInterval( function () { - if ( oldhash !== location.hash ) { - ApiSandbox.loadFromHash(); - } - }, 1000 ); - } + $( window ).on( 'hashchange', ApiSandbox.loadFromHash ); $content .empty() diff --git a/resources/src/mediawiki.special/mediawiki.special.preferences.tabs.js b/resources/src/mediawiki.special/mediawiki.special.preferences.tabs.js index dcfad271d1..0d97d68e84 100644 --- a/resources/src/mediawiki.special/mediawiki.special.preferences.tabs.js +++ b/resources/src/mediawiki.special/mediawiki.special.preferences.tabs.js @@ -115,38 +115,16 @@ } } - // In browsers that support the onhashchange event we will not bind click - // handlers and instead let the browser do the default behavior (clicking the - // will naturally set the hash, handled by onhashchange. - // But other things that change the hash will also be caught (e.g. using - // the Back and Forward browser navigation). - // Note the special check for IE "compatibility" mode. - if ( 'onhashchange' in window && - ( document.documentMode === undefined || document.documentMode >= 8 ) - ) { - $( window ).on( 'hashchange', function () { - var hash = location.hash; - if ( hash.match( /^#mw-[\w-]+/ ) ) { - detectHash(); - } else if ( hash === '' ) { - switchPrefTab( 'personal', 'noHash' ); - } - } ) - // Run the function immediately to select the proper tab on startup. - .trigger( 'hashchange' ); - // In older browsers we'll bind a click handler as fallback. - // We must not have onhashchange *and* the click handlers, otherwise - // the click handler calls switchPrefTab() which sets the hash value, - // which triggers onhashchange and calls switchPrefTab() again. - } else { - $preftoc.on( 'click', 'li a', function ( e ) { - switchPrefTab( $( this ).attr( 'href' ).replace( '#mw-prefsection-', '' ) ); - e.preventDefault(); - } ); - // If we've reloaded the page or followed an open-in-new-window, - // make the selected tab visible. - detectHash(); - } + $( window ).on( 'hashchange', function () { + var hash = location.hash; + if ( hash.match( /^#mw-[\w-]+/ ) ) { + detectHash(); + } else if ( hash === '' ) { + switchPrefTab( 'personal', 'noHash' ); + } + } ) + // Run the function immediately to select the proper tab on startup. + .trigger( 'hashchange' ); // Restore the active tab after saving the preferences previousTab = mw.storage.session.get( 'mwpreferences-prevTab' );