mediawiki.util: Deprecate mw.util.updateTooltipAccessKeys
authorFomafix <fomafix@googlemail.com>
Mon, 1 Sep 2014 05:29:23 +0000 (05:29 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 18 Sep 2014 17:59:18 +0000 (10:59 -0700)
Use $nodes.updateTooltipAccessKeys() instead of
mw.util.updateTooltipAccessKeys( $nodes )

mw.util.updateTooltipAccessKeys() with empty parameter
to update all nodes is only needed in mediawiki.page.ready.js.
Copy that code to mediawiki.page.ready.js.

Adapt wikibits.js

Change-Id: I300a23e614e5f91fe2f536d958e91a47f6203021

resources/Resources.php
resources/src/mediawiki.legacy/wikibits.js
resources/src/mediawiki.page/mediawiki.page.ready.js
resources/src/mediawiki/mediawiki.util.js

index 8e907ee..2f961e6 100644 (file)
@@ -1175,11 +1175,11 @@ return array(
        'mediawiki.page.ready' => array(
                'scripts' => 'resources/src/mediawiki.page/mediawiki.page.ready.js',
                'dependencies' => array(
+                       'jquery.accessKeyLabel',
                        'jquery.checkboxShiftClick',
                        'jquery.makeCollapsible',
                        'jquery.placeholder',
                        'jquery.mw-jump',
-                       'mediawiki.util',
                ),
                'targets' => array( 'desktop', 'mobile' ),
        ),
index 5c6e63b..a403996 100644 (file)
@@ -144,15 +144,18 @@ mw.log.deprecate( win, 'jsMsg', function ( message ) {
 /**
  * Misc. utilities
  *
- * @deprecated since 1.17 Use mediawiki.util instead
+ * @deprecated since 1.17 Use mediawiki.util or jquery.accessKeyLabel instead
  */
 msg = 'Use mediawiki.util instead.';
-mw.log.deprecate( win, 'updateTooltipAccessKeys', mw.util.updateTooltipAccessKeys, msg );
 mw.log.deprecate( win, 'addPortletLink', mw.util.addPortletLink, msg );
 mw.log.deprecate( win, 'appendCSS', mw.util.addCSS, msg );
 msg = 'Use jquery.accessKeyLabel instead.';
 mw.log.deprecate( win, 'tooltipAccessKeyPrefix', 'alt-', msg );
 mw.log.deprecate( win, 'tooltipAccessKeyRegexp', /\[(alt-)?(.)\]$/, msg );
+// mw.util.updateTooltipAccessKeys already generates a deprecation message.
+win.updateTooltipAccessKeys = function () {
+       return mw.util.updateTooltipAccessKeys.apply( null, arguments );
+};
 
 /**
  * Wikipage import methods
index a05a054..246cc81 100644 (file)
@@ -36,6 +36,7 @@
 
        // Things outside the wikipage content
        $( function () {
+               var $nodes;
 
                if ( !supportsPlaceholder ) {
                        // Exclude content to avoid hitting it twice for the (first) wikipage content
                }
 
                // Add accesskey hints to the tooltips
-               mw.util.updateTooltipAccessKeys();
+               if ( document.querySelectorAll ) {
+                       // If we're running on a browser where we can do this efficiently,
+                       // just find all elements that have accesskeys. We can't use jQuery's
+                       // polyfill for the selector since looping over all elements on page
+                       // load might be too slow.
+                       $nodes = $( document.querySelectorAll( '[accesskey]' ) );
+               } else {
+                       // Otherwise go through some elements likely to have accesskeys rather
+                       // than looping over all of them. Unfortunately this will not fully
+                       // work for custom skins with different HTML structures. Input, label
+                       // and button should be rare enough that no optimizations are needed.
+                       $nodes = $( '#column-one a, #mw-head a, #mw-panel a, #p-logo a, input, label, button' );
+               }
+               $nodes.updateTooltipAccessKeys();
 
        } );
 
index 887885e..2662913 100644 (file)
                        return null;
                },
 
-               /**
-                * Add the appropriate prefix to the accesskey shown in the tooltip.
-                *
-                * If the `$nodes` parameter is given, only those nodes are updated;
-                * otherwise, depending on browser support, we update either all elements
-                * with accesskeys on the page or a bunch of elements which are likely to
-                * have them on core skins.
-                *
-                * @param {Array|jQuery} [$nodes] A jQuery object, or array of nodes to update.
-                */
-               updateTooltipAccessKeys: function ( $nodes ) {
-                       if ( !$nodes ) {
-                               if ( document.querySelectorAll ) {
-                                       // If we're running on a browser where we can do this efficiently,
-                                       // just find all elements that have accesskeys. We can't use jQuery's
-                                       // polyfill for the selector since looping over all elements on page
-                                       // load might be too slow.
-                                       $nodes = $( document.querySelectorAll( '[accesskey]' ) );
-                               } else {
-                                       // Otherwise go through some elements likely to have accesskeys rather
-                                       // than looping over all of them. Unfortunately this will not fully
-                                       // work for custom skins with different HTML structures. Input, label
-                                       // and button should be rare enough that no optimizations are needed.
-                                       $nodes = $( '#column-one a, #mw-head a, #mw-panel a, #p-logo a, input, label, button' );
-                               }
-                       } else if ( !( $nodes instanceof $ ) ) {
-                               $nodes = $( $nodes );
-                       }
-
-                       $nodes.updateTooltipAccessKeys();
-               },
-
                /**
                 * The content wrapper of the skin (e.g. `.mw-body`).
                 *
         */
        mw.log.deprecate( util, 'tooltipAccessKeyRegexp', /\[(ctrl-)?(option-)?(alt-)?(shift-)?(esc-)?(.)\]$/, 'Use jquery.accessKeyLabel instead.' );
 
+       /**
+        * Add the appropriate prefix to the accesskey shown in the tooltip.
+        *
+        * If the `$nodes` parameter is given, only those nodes are updated;
+        * otherwise, depending on browser support, we update either all elements
+        * with accesskeys on the page or a bunch of elements which are likely to
+        * have them on core skins.
+        *
+        * @method updateTooltipAccessKeys
+        * @param {Array|jQuery} [$nodes] A jQuery object, or array of nodes to update.
+        * @deprecated since 1.24 Use the module jquery.accessKeyLabel instead.
+        */
+       mw.log.deprecate( util, 'updateTooltipAccessKeys', function ( $nodes ) {
+               if ( !$nodes ) {
+                       if ( document.querySelectorAll ) {
+                               // If we're running on a browser where we can do this efficiently,
+                               // just find all elements that have accesskeys. We can't use jQuery's
+                               // polyfill for the selector since looping over all elements on page
+                               // load might be too slow.
+                               $nodes = $( document.querySelectorAll( '[accesskey]' ) );
+                       } else {
+                               // Otherwise go through some elements likely to have accesskeys rather
+                               // than looping over all of them. Unfortunately this will not fully
+                               // work for custom skins with different HTML structures. Input, label
+                               // and button should be rare enough that no optimizations are needed.
+                               $nodes = $( '#column-one a, #mw-head a, #mw-panel a, #p-logo a, input, label, button' );
+                       }
+               } else if ( !( $nodes instanceof $ ) ) {
+                       $nodes = $( $nodes );
+               }
+
+               $nodes.updateTooltipAccessKeys();
+       }, 'Use jquery.accessKeyLabel instead.' );
+
        /**
         * Add a little box at the top of the screen to inform the user of
         * something, replacing any previous message.