From ddaf0fe2b27c8b7fb044397fe963c5242a701f7c Mon Sep 17 00:00:00 2001 From: Leo Koppelkamm Date: Thu, 14 Apr 2011 13:18:39 +0000 Subject: [PATCH] History: Adding JS that converts buttons to links for better UX. Patch based on one by Matthew Flaschen. Fixes Bug 16165 --- .../mediawiki.action.history.js | 3 + skins/common/history.js | 86 ++++++++++++++++++- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/resources/mediawiki.action/mediawiki.action.history.js b/resources/mediawiki.action/mediawiki.action.history.js index 3f9634776e..fb62d65e49 100644 --- a/resources/mediawiki.action/mediawiki.action.history.js +++ b/resources/mediawiki.action/mediawiki.action.history.js @@ -5,4 +5,7 @@ jQuery( function( $ ) { // Replaces histrowinit $( '#pagehistory li input[name="diff"], #pagehistory li input[name="oldid"]' ).click( diffcheck ); diffcheck(); + mediaWiki.loader.using('jquery.ui.button', function() { + window.fixCompare(); + }); }); \ No newline at end of file diff --git a/skins/common/history.js b/skins/common/history.js index ee14ac97d9..98db46e44c 100644 --- a/skins/common/history.js +++ b/skins/common/history.js @@ -1,6 +1,6 @@ window.historyRadios = function( parent ) { - var inputs = parent.getElementsByTagName( 'input' ); - var radios = [], + var inputs = parent.getElementsByTagName( 'input' ); + var radios = [], i = 0; for ( i = 0; i < inputs.length; i++ ) { if ( inputs[i].name == 'diff' || inputs[i].name == 'oldid' ) { @@ -76,4 +76,84 @@ window.diffcheck = function() { } } return true; -}; \ No newline at end of file +}; + +//update the compare link as you select radio buttons +window.updateCompare = function () { + var hf = compareLink.$form.get(0); + var oldInd = -1; + var i = 0; + while(oldInd == -1 & i" + this.value + "").button(); + compareLink.$form.before($linkTop); + $linkEnd = $linkTop.clone(); + compareLink.$form.append($linkEnd); + + if(this.name == "htmldiff") { + compareLink.htmlTop = $linkTop; + compareLink.htmlEnd = $linkEnd; + } else { + compareLink.wikiTop = $linkTop; + compareLink.wikiEnd = $linkEnd; + } + }); + $buttons.hide(); + + $("#pagehistory").change(function() {window.updateCompare()}); +}; + -- 2.20.1