blob: a584ff307c4b9de09006a372825152af83efc9b3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*!
* JavaScript for History action
*/
$( () => {
'use strict';
const $pagehistory = $( '#pagehistory' );
const $lis = $pagehistory.find( '.mw-contributions-list > li' );
/**
* @ignore
* @this Element input
* @param {jQuery.Event} e
* @return {boolean} False to cancel the default event
*/
function updateDiffRadios() {
let nextState = 'before';
$lis.each( function () {
const $li = $( this );
const $inputs = $li.find( 'input[type="radio"]' );
const $oldidRadio = $inputs.filter( '[name="oldid"]' ).eq( 0 );
const $diffRadio = $inputs.filter( '[name="diff"]' ).eq( 0 );
$li.removeClass( 'selected between before after' );
if ( !$oldidRadio.length || !$diffRadio.length ) {
return true;
}
if ( $oldidRadio.prop( 'checked' ) ) {
$li.addClass( 'selected after' );
nextState = 'after';
// Disable the hidden radio because it can still be selected with
// arrow keys on Firefox
$diffRadio.prop( 'disabled', true );
} else if ( $diffRadio.prop( 'checked' ) ) {
// The following classes are used here:
// * before
// * after
$li.addClass( 'selected ' + nextState );
nextState = 'between';
// Disable the hidden radio because it can still be selected with
// arrow keys on Firefox
$oldidRadio.prop( 'disabled', true );
} else {
// This list item has neither checked
// apply the appropriate class following the previous item.
// The following classes are used here:
// * before
// * after
$li.addClass( nextState );
// Disable or re-enable for Firefox, provided the revision is accessible
if ( $li.find( 'a.mw-changeslist-date' ).length ) {
$oldidRadio.prop( 'disabled', nextState === 'before' );
$diffRadio.prop( 'disabled', nextState === 'after' );
}
}
} );
return true;
}
$pagehistory.on( 'change', 'input[name="diff"], input[name="oldid"]', updateDiffRadios );
// Set initial state
updateDiffRadios();
} );
|