Gerrit Patch Uploader has uploaded a new change for review.
https://gerrit.wikimedia.org/r/148264
Change subject: mediawiki.util: Deprecate mw.util.updateTooltipAccessKeys
......................................................................
mediawiki.util: Deprecate mw.util.updateTooltipAccessKeys
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.
Duplicate the code to mediawiki.util.js and wikibits.js
to prevent deprecate message on loading.
Change-Id: I300a23e614e5f91fe2f536d958e91a47f6203021
---
M resources/src/mediawiki.page/mediawiki.page.ready.js
M resources/src/mediawiki/mediawiki.util.js
M skins/common/wikibits.js
3 files changed, 69 insertions(+), 34 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/64/148264/1
diff --git a/resources/src/mediawiki.page/mediawiki.page.ready.js
b/resources/src/mediawiki.page/mediawiki.page.ready.js
index a05a054..246cc81 100644
--- a/resources/src/mediawiki.page/mediawiki.page.ready.js
+++ b/resources/src/mediawiki.page/mediawiki.page.ready.js
@@ -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
@@ -43,7 +44,20 @@
}
// 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();
} );
diff --git a/resources/src/mediawiki/mediawiki.util.js
b/resources/src/mediawiki/mediawiki.util.js
index 887885e..233dd97 100644
--- a/resources/src/mediawiki/mediawiki.util.js
+++ b/resources/src/mediawiki/mediawiki.util.js
@@ -170,38 +170,6 @@
},
/**
- * 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`).
*
* Populated on document ready by #init. To use this property,
@@ -504,6 +472,39 @@
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.
+ *
+ * @param {Array|jQuery} [$nodes] A jQuery object, or array of nodes to
update.
+ * @deprecated since 1.25 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.
* Calling with no arguments, with an empty string or null will hide
the message
diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js
index b6689f9..fa3efe5 100644
--- a/skins/common/wikibits.js
+++ b/skins/common/wikibits.js
@@ -148,12 +148,32 @@
* @deprecated since 1.17 Use mediawiki.util 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.log.deprecate( win, '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();
+}, msg );
/**
* Wikipage import methods
--
To view, visit https://gerrit.wikimedia.org/r/148264
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I300a23e614e5f91fe2f536d958e91a47f6203021
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits