summaryrefslogtreecommitdiff
path: root/resources/mediawiki.action/mediawiki.action.history.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/mediawiki.action/mediawiki.action.history.js')
-rw-r--r--resources/mediawiki.action/mediawiki.action.history.js52
1 files changed, 49 insertions, 3 deletions
diff --git a/resources/mediawiki.action/mediawiki.action.history.js b/resources/mediawiki.action/mediawiki.action.history.js
index 66f90b07..1b5b3a00 100644
--- a/resources/mediawiki.action/mediawiki.action.history.js
+++ b/resources/mediawiki.action/mediawiki.action.history.js
@@ -1,7 +1,53 @@
/*
* JavaScript for History action
*/
+jQuery( function( $ ) {
+ var $lis = $( 'ul#pagehistory li' );
+ var updateDiffRadios = function() {
+ var diffLi = false, // the li where the diff radio is checked
+ oldLi = false; // the li where the oldid radio is checked
-// Replaces histrowinit
-$( '#pagehistory li input[name=diff], #pagehistory li input[name=oldid]' ).click( diffcheck );
-diffcheck(); \ No newline at end of file
+ if ( !$lis.length ) {
+ return true;
+ }
+ $lis.removeClass( 'selected' );
+ $lis.each( function() {
+ var $this = $(this);
+ var $inputs = $this.find( 'input[type="radio"]' );
+ if ( $inputs.length !== 2 ) {
+ return true;
+ }
+
+ // this row has a checked radio button
+ if ( $inputs.get(0).checked ) {
+ oldLi = true;
+ $this.addClass( 'selected' );
+ $inputs.eq(0).css( 'visibility', 'visible' );
+ $inputs.eq(1).css( 'visibility', 'hidden' );
+ } else if ( $inputs.get(1).checked ) {
+ diffLi = true;
+ $this.addClass( 'selected' );
+ $inputs.eq(0).css( 'visibility', 'hidden' );
+ $inputs.eq(1).css( 'visibility', 'visible' );
+ } else {
+ // no radio is checked in this row
+ if ( diffLi && oldLi ) {
+ // We're below the selected radios
+ $inputs.eq(0).css( 'visibility', 'visible' );
+ $inputs.eq(1).css( 'visibility', 'hidden' );
+ } else if ( diffLi ) {
+ // We're between the selected radios
+ $inputs.css( 'visibility', 'visible' );
+ } else {
+ // We're above the selected radios
+ $inputs.eq(1).css( 'visibility', 'visible' );
+ $inputs.eq(0).css( 'visibility', 'hidden' );
+ }
+ }
+ });
+ return true;
+ };
+
+ $( '#pagehistory li input[name="diff"], #pagehistory li input[name="oldid"]' ).click( updateDiffRadios );
+ updateDiffRadios();
+}); \ No newline at end of file