MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
m (temp) |
mNo edit summary |
||
Line 542: | Line 542: | ||
$(oldApertureInfobox.init); | $(oldApertureInfobox.init); | ||
// End OldAperture infobox hover code | // End OldAperture infobox hover code | ||
// Fancy diffs | |||
var fancyDiffs = { | |||
toggle: function(element) { | |||
var expanded = element.hasClass('diff-expanded'); | |||
var contents = element.parent().children('.diff-contents'); | |||
if(expanded) { // Just collapse then | |||
element.removeClass('diff-expanded'); | |||
contents.slideUp('fast'); | |||
} else if(element.hasClass('diff-data-loaded')) { // Stuff is already loaded, expand | |||
element.addClass('diff-expanded'); | |||
contents.slideDown('fast'); | |||
} else if(!element.hasClass('diff-data-requested')) { // Stuff is not loaded | |||
element.addClass('diff-data-requested'); | |||
var fileName = element.find('span').text().replace(/^\s+|\s+$/g); | |||
$.get('/w/?title=' + encodeURIComponent(wgPageName) + '/' + encodeURIComponent(fileName) + '&action=raw', function(data) { | |||
contents.html(data); | |||
contents.slideDown('fast'); | |||
element.removeClass('diff-data-requested').addClass('diff-data-loaded').addClass('diff-expanded'); | |||
}); | |||
} | |||
}, | |||
init: function() { | |||
var diffText = $('.diff-name-text'); | |||
if(diffText.length) { | |||
// Preload leetle gif | |||
$('body').append($('<img/>').attr('src', 'http://theportalwiki.com/w/images/4/43/Patch_diff_loading.gif').css('display', 'none')); | |||
diffText.find('span').each(function() { | |||
$(this).text($(this).find('a').text().replace(/^\s+|\s+$/g)); | |||
}); | |||
diffText.click(function() { | |||
fancyDiffs.toggle($(this)); | |||
return false; | |||
}); | |||
} | |||
} | |||
}; | |||
$(fancyDiffs.init); | |||
// Lightbox stuff | // Lightbox stuff |