* (bug 28945) Keyboard shortcuts on history page no longer work in 1.18
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 14 May 2011 09:27:36 +0000 (09:27 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 14 May 2011 09:27:36 +0000 (09:27 +0000)
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.

resources/mediawiki.action/mediawiki.action.history.js

index 580c570..6674590 100644 (file)
@@ -57,17 +57,21 @@ jQuery( function( $ ) {
                if ( !$buttons.length ) {
                        return false;
                }
-
-               var buttonText = $buttons.remove().first().val(),
-                 $compareLink = $( '<a></a>', {
+               var copyAttrs = ['title', 'accesskey'];
+               $buttons.each(function() {
+                       var $button = $(this),
+                               $compareLink= $( '<a></a>', {
                                'class': 'compare-link',
-                               'text': buttonText
+                               'text': $button.val()
                        }).button();
-               $histForm.prepend( $compareLink );
-               if ( $buttons.length == 2 ) {
-                       $histForm.append( $compareLink.clone() );
-               }
-
+                       $.each(copyAttrs, function(i, name) {
+                               var val = $button.attr(name);
+                               if (val) {
+                                       $compareLink.attr(name, val);
+                               }
+                       });
+                       $button.replaceWith($compareLink);
+               });
                var updateCompare = function() {
                        var $radio = $histForm.find( 'input[type=radio]:checked' );
                        var genLink = mw.config.get( 'wgScript' )