Difference between revisions of "MediaWiki:Perseids-toolbar.js"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
− | function |
+ | function setPerseidsToolbarEdit() { |
− | $('.perseids-toolbar').remove(); // Resets all links |
+ | $('.perseids-toolbar-edit').remove(); // Resets all links |
$( '.wikibase-toolbareditgroup-innoneditmode .wikibase-toolbar .wikibase-toolbarbutton' ) |
$( '.wikibase-toolbareditgroup-innoneditmode .wikibase-toolbar .wikibase-toolbarbutton' ) |
||
.after( |
.after( |
||
$( '<a>' ) |
$( '<a>' ) |
||
− | .addClass('wikibase-toolbarbutton', 'perseids-toolbar') |
+ | .addClass('wikibase-toolbarbutton', 'perseids-toolbar-edit') |
.attr( { |
.attr( { |
||
'href': '#' |
'href': '#' |
||
Line 16: | Line 16: | ||
} ) |
} ) |
||
); |
); |
||
+ | } |
||
− | + | $( '.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') |
$( '.wikibase-toolbareditgroup-ineditmode .wikibase-toolbar .wikibase-toolbarbutton') |
||
.slice(-2,-1) |
.slice(-2,-1) |
||
.after( |
.after( |
||
$( '<a>' ) |
$( '<a>' ) |
||
− | .addClass('wikibase-toolbarbutton', 'perseids-toolbar') |
+ | .addClass('wikibase-toolbarbutton', 'perseids-toolbar-save') |
.attr( { |
.attr( { |
||
'href': '#' |
'href': '#' |
||
Line 47: | Line 48: | ||
); |
); |
||
}); |
}); |
||
− | } |
||
+ | |||
− | |||
+ | setPerseidsToolbarEdit(); |
||
− | $( '.wikibase-toolbar' ).click( |
+ | $( '.wikibase-toolbar' ).click( setPerseidsToolbarEdit ); |
Revision as of 11:09, 31 July 2014
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 );