Difference between revisions of "MediaWiki:Perseids-toolbar.js"

From EAGLE MediaWiki
Jump to navigation Jump to search
Line 11: Line 11:
 
'href': '#'
 
'href': '#'
 
} )
 
} )
.before( '<span class="toolbar-separator">|</span>' )
+
.before( $('<span class="toolbar-separator">|</span>') )
 
.text( 'edit in Perseids' )
 
.text( 'edit in Perseids' )
 
.click( function ( event ) {
 
.click( function ( event ) {
Line 26: Line 26:
 
'href': '#'
 
'href': '#'
 
} )
 
} )
.before( '<span class="toolbar-separator">|</span>' )
+
.before( $('<span class="toolbar-separator">|</span>') )
 
.text( 'add via Perseids' )
 
.text( 'add via Perseids' )
 
.click( function ( event ) {
 
.click( function ( event ) {
Line 42: Line 42:
 
'href': '#'
 
'href': '#'
 
} )
 
} )
.before( '<span class="toolbar-separator">|</span>' )
+
.before( $('<span class="toolbar-separator">|</span>') )
 
.text( 'save to Perseids' )
 
.text( 'save to Perseids' )
 
.click( function ( event ) {
 
.click( function ( event ) {

Revision as of 11:16, 31 July 2014

function setPerseidsToolbarEdit() {
	
	$('.perseids-toolbar-edit', $(this).parent()).remove(); // Resets all links
	$('.toolbar-separator', $(this).parent()).remove();
	
	$( '.wikibase-toolbareditgroup-innoneditmode .wikibase-toolbar .wikibase-toolbarbutton' )
		.after(
			$( '<a>' )
			.addClass('wikibase-toolbarbutton perseids-toolbar-edit')
			.attr( {
				'href': '#'
			} )
			.before( $('<span class="toolbar-separator">|</span>') )
			.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( $('<span class="toolbar-separator">|</span>') )
		.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( $('<span class="toolbar-separator">|</span>') )
				.text( 'save to Perseids' )
				.click( function ( event ) {
					event.preventDefault();
				} )
			);
	});
	
setPerseidsToolbarEdit();
$( '.wikibase-toolbar' ).click( setPerseidsToolbarEdit );