r86188 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86187‎ | r86188 | r86189 >
Date:08:44, 16 April 2011
Author:diebuche
Status:ok
Tags:
Comment:
Followup to r86047: Fix empty button on pages with only one rev
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
@@ -50,15 +50,25 @@
5151 };
5252
5353 var fixCompare = function () {
54 - var $histForm = $( '#mw-history-compare' ),
55 - $diffList = $( '#pagehistory' ),
56 - buttonText = $histForm.find( 'input.historysubmit' ).remove().first().val(),
57 - $compareLink = $( '<a></a>', {
 54+ var $diffList = $( '#pagehistory' ),
 55+ $histForm = $( '#mw-history-compare' ),
 56+ $buttons = $histForm.find( 'input.historysubmit' );
 57+
 58+ // There's only one rev, nothing to do here
 59+ if ( !$buttons.length ) {
 60+ return false;
 61+ }
 62+
 63+ var buttonText = $buttons.remove().first().val(),
 64+ $compareLink = $( '<a></a>', {
5865 'class': 'compare-link',
5966 'text': buttonText
6067 }).button();
61 - $histForm.prepend( $compareLink )
62 - .append( $compareLink.clone() );
 68+ $histForm.prepend( $compareLink );
 69+ if ( $buttons.length == 2 ) {
 70+ $histForm.append( $compareLink.clone() );
 71+ }
 72+
6373 function updateCompare() {
6474 var $radio = $histForm.find( 'input[type=radio]:checked' );
6575 var genLink = mw.config.get( 'wgScript' )

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86047History: Adding JS that converts buttons to links for better UX. Patch based...diebuche13:18, 14 April 2011

Status & tagging log