r88035 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88034‎ | r88035 | r88036 >
Date:09:27, 14 May 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
* (bug 28945) Keyboard shortcuts on history page no longer work in 1.18

The link replacements for the button were dropping title & accesskey attributes, losing the shortcut key. Now copying these and replacing the buttons in-place, makes em work.
Modified paths:
  • /trunk/phase3/resources/mediawiki.action/mediawiki.action.history.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.history.js
@@ -57,17 +57,21 @@
5858 if ( !$buttons.length ) {
5959 return false;
6060 }
61 -
62 - var buttonText = $buttons.remove().first().val(),
63 - $compareLink = $( '<a></a>', {
 61+ var copyAttrs = ['title', 'accesskey'];
 62+ $buttons.each(function() {
 63+ var $button = $(this),
 64+ $compareLink= $( '<a></a>', {
6465 'class': 'compare-link',
65 - 'text': buttonText
 66+ 'text': $button.val()
6667 }).button();
67 - $histForm.prepend( $compareLink );
68 - if ( $buttons.length == 2 ) {
69 - $histForm.append( $compareLink.clone() );
70 - }
71 -
 68+ $.each(copyAttrs, function(i, name) {
 69+ var val = $button.attr(name);
 70+ if (val) {
 71+ $compareLink.attr(name, val);
 72+ }
 73+ });
 74+ $button.replaceWith($compareLink);
 75+ });
7276 var updateCompare = function() {
7377 var $radio = $histForm.find( 'input[type=radio]:checked' );
7478 var genLink = mw.config.get( 'wgScript' )

Comments

#Comment by Krinkle (talk | contribs)   09:47, 14 May 2011

It doesn't appear to work on the history page. The js-button created (nor the original input[type=submit]) has a title or accesskey attribute.

#Comment by Brion VIBBER (talk | contribs)   09:48, 14 May 2011

There are two buttons -- the bottom one has the access key + title.

#Comment by Krinkle (talk | contribs)   09:48, 14 May 2011

Hm... There are two input[type=submit] on the page (on top and on the bottom), looks like PHP only outputs title/accesskey on the bottom one. I guess that makes sense since accesskeys need to be unique... Nevermind :) Marking ok, works good for the one that do have title/accesskey.

Status & tagging log