MediaWiki:Gadget-AbuseLink.trial.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at MediaWiki:Gadget-AbuseLink.trial. |
- Report page listing warnings and errors.
(function() {
var ab,
$abuseButton,
$file = $('#file'),
$img = $file.find('img').eq(0),
$imgAnnDiv = $img.closest('div');
if (!$imgAnnDiv.length) return;
if ($imgAnnDiv.hasClass('fullImageLink')) {
// Image Annotator not loaded yet; we have to wrap the image into the div
$imgAnnDiv = $imgAnnDiv.find('a').first().wrap('<div>').parent().css('position', 'relative').width($img.width());
}
ab = mw.libs.abuseButton = {
$getUI: function() {
return $('<button style="position:absolute; right:0; bottom:0; margin:0; display:inline-block;" title="Report abuse">').text("report").button({
icons: {
primary: 'ui-icon-flag'
}
}).removeClass('ui-corner-all').addClass('ui-corner-bottom');
},
install: function() {
$imgAnnDiv.css('position', 'relative');
mw.loader.using(['jquery.ui'], function() {
$abuseButton = ab.$getUI().appendTo($imgAnnDiv).click(ab.loadDlg);
$abuseButton.css('bottom', parseFloat($abuseButton.height()) * -1);
setTimeout(function() {
$abuseButton.animate({
bottom: parseFloat($abuseButton.height()) * -1
}, {
duration: 200
});
}, 1000);
});
},
loadDlg: function() {
mw.loader.using(['jquery.ui', 'mediawiki.util'], ab.showDlg);
// Fixing broken Accordion
mw.util.addCSS('.ui-accordion .ui-accordion-header { padding: 5px 5px 5px 30px }' + '.ui-accordion .ui-accordion-header { font-weight: bold; font-size: 150% }');
},
showDlg: function() {
var $dlg = $('<div>').css('position', 'relative').appendTo('body'),
w = Math.min($(window).width() - 10, 1000),
h = Math.min($(window).height() - 10, 900),
$load = $('<div>').text('reporting abuse').appendTo($dlg),
$accordion;
$dlg.dialog({
modal: true,
title: "Report an issue concerning this media file",
height: h,
width: w,
close: function() {
$(this).remove();
}
});
$load.css({
position: 'absolute',
top: '50%',
width: $dlg.width() - 10,
'font-size': '4em',
'font-weight': 'bold',
'text-align': 'center'
}).css('margin-top', - 1 * ($load.height() / 2));
$.get(mw.util.getUrl('Template:ReportAbuse/render') + '?action=render').done(function(r) {
var $r = $(r);
$load.remove();
$r.appendTo($dlg);
$accordion = $r.find('#abuseReportWrap').add($r.filter('#abuseReportWrap')).accordion();
}).fail(function() {
alert("Error while loading content. Please report this issue to the Administrator's noticeboard.");
});
}
}
ab.install();
}());