From 13b4ba23ba62cf7db45eadf03f3ebb62e6974f4b Mon Sep 17 00:00:00 2001 From: Leo Koppelkamm Date: Sat, 16 Apr 2011 08:44:33 +0000 Subject: [PATCH] Followup to r86047: Fix empty button on pages with only one rev --- .../mediawiki.action.history.js | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/resources/mediawiki.action/mediawiki.action.history.js b/resources/mediawiki.action/mediawiki.action.history.js index 616e7947f9..92a780bb72 100644 --- a/resources/mediawiki.action/mediawiki.action.history.js +++ b/resources/mediawiki.action/mediawiki.action.history.js @@ -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 = $( '', { + 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 = $( '', { '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' ) -- 2.20.1