2 * JavaScript for History action
4 jQuery( document
).ready( function ( $ ) {
5 var $lis
= $( '#pagehistory > li' ),
9 * @context {Element} input
10 * @param e {jQuery.Event}
12 function updateDiffRadios() {
13 var diffLi
= false, // the li where the diff radio is checked
14 oldLi
= false; // the li where the oldid radio is checked
21 .removeClass( 'selected' )
24 $inputs
= $li
.find( 'input[type="radio"]' ),
25 $oldidRadio
= $inputs
.filter( '[name="oldid"]' ).eq(0),
26 $diffRadio
= $inputs
.filter( '[name="diff"]' ).eq(0);
28 if ( !$oldidRadio
.length
|| !$diffRadio
.length
) {
32 if ( $oldidRadio
.prop( 'checked' ) ) {
34 $li
.addClass( 'selected' );
35 $oldidRadio
.css( 'visibility', 'visible' );
36 $diffRadio
.css( 'visibility', 'hidden' );
38 } else if ( $diffRadio
.prop( 'checked' ) ) {
40 $li
.addClass( 'selected' );
41 $oldidRadio
.css( 'visibility', 'hidden' );
42 $diffRadio
.css( 'visibility', 'visible' );
44 // This list item has neither checked
46 // We're below the selected radios
47 if ( diffLi
&& oldLi
) {
48 $oldidRadio
.css( 'visibility', 'visible' );
49 $diffRadio
.css( 'visibility', 'hidden' );
51 // We're between the selected radios
52 } else if ( diffLi
) {
53 $diffRadio
.css( 'visibility', 'visible' );
54 $oldidRadio
.css( 'visibility', 'visible' );
56 // We're above the selected radios
58 $diffRadio
.css( 'visibility', 'visible' );
59 $oldidRadio
.css( 'visibility', 'hidden' );
67 $radios
= $( '#pagehistory li input[name="diff"], #pagehistory li input[name="oldid"]' ).click( updateDiffRadios
);