mediawiki.util: Init tooltipAccessKeyPrefix immediately instead of on domready
authorFomafix <fomafix@googlemail.com>
Sat, 5 Apr 2014 18:46:53 +0000 (18:46 +0000)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sun, 6 Apr 2014 11:39:03 +0000 (11:39 +0000)
Change-Id: I60e30e1d029d29b713b229bf2b0313e92a59f120

resources/Resources.php
resources/mediawiki.page/mediawiki.page.startup.js
resources/mediawiki/mediawiki.util.js

index 6e0d717..72c17f3 100644 (file)
@@ -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',
index e354106..c75e59f 100644 (file)
@@ -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.
index ffafd33..2234238 100644 (file)
                 * (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;
 
                /**
                 * @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}