Add more tests for GlobalVarConfig
[lhc/web/wiklou.git] / resources / src / mediawiki.action / mediawiki.action.view.redirectToFragment.js
1 /*!
2 * JavaScript to scroll the page to an id, when a redirect with fragment is viewed.
3 */
4 ( function ( mw, $ ) {
5 var profile = $.client.profile(),
6 fragment = mw.config.get( 'wgRedirectToFragment' );
7
8 if ( fragment === null ) {
9 // nothing to do
10 return;
11 }
12
13 if ( profile.layout === 'webkit' && profile.layoutVersion < 420 ) {
14 // Released Safari w/ WebKit 418.9.1 messes up horribly
15 // Nightlies of 420+ are ok
16 return;
17 }
18 if ( !window.location.hash ) {
19 window.location.hash = fragment;
20
21 // Mozilla needs to wait until after load, otherwise the window doesn't
22 // scroll. See <https://bugzilla.mozilla.org/show_bug.cgi?id=516293>.
23 // There's no obvious way to detect this programmatically, so we use
24 // version-testing. If Firefox fixes the bug, they'll jump twice, but
25 // better twice than not at all, so make the fix hit future versions as
26 // well.
27 if ( profile.layout === 'gecko' ) {
28 $( function () {
29 if ( window.location.hash === fragment ) {
30 window.location.hash = fragment;
31 }
32 } );
33 }
34 }
35 }( mediaWiki, jQuery ) );