MediaWiki:QuickDiff/code.js

// ', {     id: 'quickdiff-modal', width: $(window).width - 100 });

$('#quickdiff').parent // add 'WikiaArticle' class to use wiki's own styling in Oasis .addClass('WikiaArticle') .css({       // scroll within the modal dialog rather than the page        "min-height": "150px",        "max-height": "calc(100vh - 175px)",        "overflow-y": "auto",        // Monobook font styling (default is x-small)        "font-size": "13px",        "line-height": "21px",        // fix styling oddities from 'WikiaArticle' class for admin users        "border": "0",        "box-shadow": "none",        "padding": "0"      });

// Monobook modal dialogs end up halfway down the screen for some reason… if (mw.config.get('skin') === 'monobook') { var modalTop = parseInt($('#quickdiff-modal').css('top'), 10); // …so adjust by half the display height + 90px for a top border modalTop = modalTop - $(window).height / 2 + 90; $('#quickdiff-modal').css('top', modalTop); } }

function showDiff(url) { if (!$('#quickdiff-modal').length) { loadModal; }   $('#quickdiff').text(msg.loading);

// append current hostname to relative URLs if (url.indexOf('http') !== 0) { url = mw.config.get('wgServer') + url; }

$.ajax({     type: "GET",      url: url,      success: function (content) {        content = $(content).find('table.diff').html;        mw.loader.using(['mediawiki.action.history.diff'], function  { $('#quickdiff').html(content); $('#quickdiff-modal > h1').text(msg.title + $('#mw-diff-ntitle1 > strong > a').attr('title')); });     },      error: function (data) {        $('#quickdiff').html(msg.error + ' ' + data.status + ' - ' + data.statusText + ' ');      }    }); }

$('body').on('click', 'a', function (event) {   if ($(this).attr('href').indexOf('diff=')  !== -1) {      event.preventDefault;      showDiff($(this).attr('href'));    }  }); }(jQuery, mediaWiki));

//