MediaWiki:Perseids-toolbar.js

From EAGLE MediaWiki
Revision as of 11:09, 31 July 2014 by Pietrodn (talk | contribs)
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
function setPerseidsToolbarEdit() {
	
	$('.perseids-toolbar-edit').remove(); // Resets all links
	
	$( '.wikibase-toolbareditgroup-innoneditmode .wikibase-toolbar .wikibase-toolbarbutton' )
		.after(
			$( '<a>' )
			.addClass('wikibase-toolbarbutton', 'perseids-toolbar-edit')
			.attr( {
				'href': '#'
			} )
			.before( '|' )
			.text( 'edit in Perseids' )
			.click( function ( event ) {
				event.preventDefault();
			} )
		);
}

$( '.wb-claim-section .wb-addtoolbar .wb-editsection a.wikibase-toolbarbutton')
	.after(
		$( '<a>' )
		.addClass('wikibase-toolbarbutton', 'perseids-toolbar-add')
		.attr( {
			'href': '#'
		} )
		.before( '|' )
		.text( 'add via Perseids' )
		.click( function ( event ) {
			event.preventDefault();
		} )
	);
		
$( '.wikibase-toolbareditgroup .wikibase-toolbarbutton:not(.wikibase-toolbarbutton-disabled' ).click(function () {			
		$( '.wikibase-toolbareditgroup-ineditmode .wikibase-toolbar .wikibase-toolbarbutton')
			.slice(-2,-1)
			.after(
				$( '<a>' )
				.addClass('wikibase-toolbarbutton', 'perseids-toolbar-save')
				.attr( {
					'href': '#'
				} )
				.before( '|' )
				.text( 'save to Perseids' )
				.click( function ( event ) {
					event.preventDefault();
				} )
			);
	});
	
setPerseidsToolbarEdit();
$( '.wikibase-toolbar' ).click( setPerseidsToolbarEdit );