Followup to r86047: Fix empty button on pages with only one rev
authorLeo Koppelkamm <diebuche@users.mediawiki.org>
Sat, 16 Apr 2011 08:44:33 +0000 (08:44 +0000)
committerLeo Koppelkamm <diebuche@users.mediawiki.org>
Sat, 16 Apr 2011 08:44:33 +0000 (08:44 +0000)
resources/mediawiki.action/mediawiki.action.history.js

index 616e794..92a780b 100644 (file)
@@ -50,15 +50,25 @@ jQuery( function( $ ) {
        };
        
        var fixCompare = function () {
-               var $histForm = $( '#mw-history-compare' ),
-                       $diffList = $( '#pagehistory' ),
-                       buttonText = $histForm.find( 'input.historysubmit' ).remove().first().val(),
-                       $compareLink = $( '<a></a>', {
+               var $diffList = $( '#pagehistory' ),
+                $histForm = $( '#mw-history-compare' ),
+                $buttons = $histForm.find( 'input.historysubmit' );
+
+               // There's only one rev, nothing to do here
+               if ( !$buttons.length ) {
+                       return false;
+               }
+
+               var buttonText = $buttons.remove().first().val(),
+                 $compareLink = $( '<a></a>', {
                                'class': 'compare-link',
                                'text': buttonText
                        }).button();
-               $histForm.prepend( $compareLink )
-                                                       .append( $compareLink.clone() );
+               $histForm.prepend( $compareLink );
+               if ( $buttons.length == 2 ) {
+                       $histForm.append( $compareLink.clone() );
+               }
+
                function updateCompare() {
                        var $radio = $histForm.find( 'input[type=radio]:checked' );
                        var genLink = mw.config.get( 'wgScript' )