MediaWiki:Gadget-CropTool.js

From Wikimedia Commons, the free media repository
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.
// CropTool code begins, see [[Commons:CropTool]] for details
'use strict';
var title = mw.config.get('wgTitle');
if (mw.config.get('wgNamespaceNumber') === 6 &&
	mw.config.get('wgIsArticle') &&
	/(PNG|GIF|JPE?G|DJVU|PDF|TIF?F)$/i.test(title) &&
	document.getElementById('file')) {
	$(function () {
		title = new mw.Uri('https://croptool.toolforge.org/')
			.extend({
				title: title,
				page: new mw.Uri().query.page,
				site: mw.config.get('wgDBname') !== 'commonswiki' ? mw.config.get('wgServer').replace(/^\/\//, '') : undefined
			});
		mw.util.addPortletLink(
			'p-tb',
			title.toString(),
			'⌗ CropTool',
			't-crop',
			'Crop this image');
	});
}