Difference between revisions of "MediaWiki:Perseids-toolbar.js"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
− | $( '.wikibase-toolbareditgroup-innoneditmode .wikibase-toolbar .wikibase-toolbarbutton' ) |
||
+ | function setPerseidsToolbar() { |
||
− | .after( |
||
+ | |||
− | $( '<a>' ) |
||
+ | $('.perseids-toolbar').remove(); // Resets all links |
||
− | .attr( { |
||
+ | |||
− | + | $( '.wikibase-toolbareditgroup-innoneditmode .wikibase-toolbar .wikibase-toolbarbutton' ) |
|
− | + | .after( |
|
− | + | $( '<a>' ) |
|
− | . |
+ | .addClass('wikibase-toolbarbutton', 'perseids-toolbar') |
− | . |
+ | .attr( { |
− | + | 'href': '#' |
|
− | + | } ) |
|
− | + | .before( '|' ) |
|
− | + | .text( 'edit in Perseids' ) |
|
− | + | .click( function ( event ) { |
|
− | + | event.preventDefault(); |
|
− | + | } ) |
|
− | + | ); |
|
− | .attr( { |
||
− | 'class': 'wikibase-toolbarbutton', |
||
− | 'href': '#' |
||
− | } ) |
||
− | .before( '|' ) |
||
− | .text( 'add via Perseids' ) |
||
− | .click( function ( event ) { |
||
− | /*event.preventDefault();*/ |
||
− | } ) |
||
− | ); |
||
− | $( '. |
+ | $( '.wb-claim-section .wb-addtoolbar .wb-editsection a.wikibase-toolbarbutton') |
− | $( '.wikibase-toolbareditgroup-ineditmode .wikibase-toolbar .wikibase-toolbarbutton') |
||
− | .slice(-2,-1) |
||
.after( |
.after( |
||
$( '<a>' ) |
$( '<a>' ) |
||
+ | .addClass('wikibase-toolbarbutton', 'perseids-toolbar') |
||
.attr( { |
.attr( { |
||
− | 'class': 'wikibase-toolbarbutton', |
||
'href': '#' |
'href': '#' |
||
} ) |
} ) |
||
.before( '|' ) |
.before( '|' ) |
||
− | .text( ' |
+ | .text( 'add via Perseids' ) |
.click( function ( event ) { |
.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') |
||
+ | .attr( { |
||
+ | 'href': '#' |
||
+ | } ) |
||
+ | .before( '|' ) |
||
+ | .text( 'save to Perseids' ) |
||
+ | .click( function ( event ) { |
||
+ | event.preventDefault(); |
||
+ | } ) |
||
+ | ); |
||
+ | }); |
||
+ | } |
||
+ | |||
+ | $( '.wikibase-toolbar' ).click( setPerseidsToolbar ); |
Revision as of 11:05, 31 July 2014
function setPerseidsToolbar() { $('.perseids-toolbar').remove(); // Resets all links $( '.wikibase-toolbareditgroup-innoneditmode .wikibase-toolbar .wikibase-toolbarbutton' ) .after( $( '<a>' ) .addClass('wikibase-toolbarbutton', 'perseids-toolbar') .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') .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') .attr( { 'href': '#' } ) .before( '|' ) .text( 'save to Perseids' ) .click( function ( event ) { event.preventDefault(); } ) ); }); } $( '.wikibase-toolbar' ).click( setPerseidsToolbar );