From: Fomafix Date: Sat, 5 Apr 2014 18:46:53 +0000 (+0000) Subject: mediawiki.util: Init tooltipAccessKeyPrefix immediately instead of on domready X-Git-Tag: 1.31.0-rc.0~16355^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=e5c817f1b735e9a44c280642b823a9226c75c562;p=lhc%2Fweb%2Fwiklou.git mediawiki.util: Init tooltipAccessKeyPrefix immediately instead of on domready Change-Id: I60e30e1d029d29b713b229bf2b0313e92a59f120 --- diff --git a/resources/Resources.php b/resources/Resources.php index 6e0d717f85..72c17f302e 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1088,7 +1088,6 @@ return array( 'mediawiki.page.startup' => array( 'scripts' => 'resources/mediawiki.page/mediawiki.page.startup.js', 'dependencies' => array( - 'jquery.client', 'mediawiki.util', ), 'position' => 'top', diff --git a/resources/mediawiki.page/mediawiki.page.startup.js b/resources/mediawiki.page/mediawiki.page.startup.js index e3541069d4..c75e59fb9c 100644 --- a/resources/mediawiki.page/mediawiki.page.startup.js +++ b/resources/mediawiki.page/mediawiki.page.startup.js @@ -9,8 +9,7 @@ .removeClass( 'client-nojs' ); $( function () { - // Initialize utilities as soon as the document is ready (mw.util.$content, - // messageBoxNew, profile, tooltip access keys, Table of contents toggle, ..). + // Initialize utilities as soon as the document is ready (mw.util.$content). // In the domready here instead of in mediawiki.page.ready to ensure that it gets enqueued // before other modules hook into domready, so that mw.util.$content (defined by // mw.util.init), is defined for them. diff --git a/resources/mediawiki/mediawiki.util.js b/resources/mediawiki/mediawiki.util.js index ffafd33675..22342384fd 100644 --- a/resources/mediawiki/mediawiki.util.js +++ b/resources/mediawiki/mediawiki.util.js @@ -13,52 +13,6 @@ * (don't call before document ready) */ init: function () { - var profile; - - /* Set tooltipAccessKeyPrefix */ - profile = $.client.profile(); - - // Opera on any platform - if ( profile.name === 'opera' ) { - util.tooltipAccessKeyPrefix = 'shift-esc-'; - - // Chrome on any platform - } else if ( profile.name === 'chrome' ) { - - util.tooltipAccessKeyPrefix = ( - profile.platform === 'mac' - // Chrome on Mac - ? 'ctrl-option-' - // Chrome on Windows or Linux - // (both alt- and alt-shift work, but alt with E, D, F etc does not - // work since they are browser shortcuts) - : 'alt-shift-' - ); - - // Non-Windows Safari with webkit_version > 526 - } else if ( profile.platform !== 'win' - && profile.name === 'safari' - && profile.layoutVersion > 526 ) { - util.tooltipAccessKeyPrefix = 'ctrl-alt-'; - // Firefox 14+ on Mac - } else if ( profile.platform === 'mac' - && profile.name === 'firefox' - && profile.versionNumber >= 14 ) { - util.tooltipAccessKeyPrefix = 'ctrl-option-'; - // Safari/Konqueror on any platform, or any browser on Mac - // (but not Safari on Windows) - } else if ( !( profile.platform === 'win' && profile.name === 'safari' ) - && ( profile.name === 'safari' - || profile.platform === 'mac' - || profile.name === 'konqueror' ) ) { - util.tooltipAccessKeyPrefix = 'ctrl-'; - - // Firefox/Iceweasel 2.x and later - } else if ( ( profile.name === 'firefox' || profile.name === 'iceweasel' ) - && profile.versionBase > '1' ) { - util.tooltipAccessKeyPrefix = 'alt-shift-'; - } - /* Fill $content var */ util.$content = ( function () { var i, l, $content, selectors; @@ -242,10 +196,62 @@ /** * @property {string} - * Access key prefix. Will be re-defined based on browser/operating system - * detection in mw.util#init. + * Access key prefix. */ - tooltipAccessKeyPrefix: 'alt-', + tooltipAccessKeyPrefix: ( function () { + var profile = $.client.profile(); + + // Opera on any platform + if ( profile.name === 'opera' ) { + return 'shift-esc-'; + } + + // Chrome on any platform + if ( profile.name === 'chrome' ) { + if ( profile.platform === 'mac' ) { + // Chrome on Mac + return 'ctrl-option-'; + } + // Chrome on Windows or Linux + // (both alt- and alt-shift work, but alt with E, D, F etc does not + // work since they are browser shortcuts) + return 'alt-shift-'; + } + + // Non-Windows Safari with webkit_version > 526 + if ( profile.platform !== 'win' + && profile.name === 'safari' + && profile.layoutVersion > 526 + ) { + return 'ctrl-alt-'; + } + + // Firefox 14+ on Mac + if ( profile.platform === 'mac' + && profile.name === 'firefox' + && profile.versionNumber >= 14 + ) { + return 'ctrl-option-'; + } + + // Safari/Konqueror on any platform, or any browser on Mac + // (but not Safari on Windows) + if ( !( profile.platform === 'win' && profile.name === 'safari' ) + && ( profile.name === 'safari' + || profile.platform === 'mac' + || profile.name === 'konqueror' ) + ) { + return 'ctrl-'; + } + + // Firefox/Iceweasel 2.x and later + if ( ( profile.name === 'firefox' || profile.name === 'iceweasel' ) + && profile.versionBase > '1' ) { + return 'alt-shift-'; + } + + return 'alt-'; + } )(), /** * @property {RegExp}