MediaWiki:Perseids-toolbar.js
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 generateButton(type) {
var pulsanti = {
'edit':
$( '<a>' )
.attr( {
'class': 'wikibase-toolbarbutton perseids-edit',
'href': 'javascript:void(0);'
} )
.before( '|' )
.text( 'edit in Perseids' )
.click( function ( event ) {
event.preventDefault();
} ),
'save':
$( '<a>' )
.attr( {
'class': 'wikibase-toolbarbutton perseids-save',
'href': 'javascript:void(0);'
} )
.before( '|' )
.text( 'save to Perseids' )
.click( function ( event ) {
event.preventDefault();
} ),
'add':
$( '<a>' )
.attr( {
'class': 'wikibase-toolbarbutton perseids-add',
'href': 'javascript:void(0);'
} )
.before( '|' )
.text( 'add via Perseids' )
.click( function ( event ) {
event.preventDefault();
} ),
};
return pulsanti[type].clone();
}
$( '.wikibase-toolbareditgroup-innoneditmode .wikibase-toolbar .wikibase-toolbarbutton:first-child' )
.after(generateButton('edit'));
$( '.wb-addtoolbar .wb-editsection a.wikibase-toolbarbutton:first-child')
.after(generateButton('add'));
$( '.wikibase-toolbareditgroup-ineditmode .wikibase-toolbar .wikibase-toolbarbutton:first-child')
.after(generateButton('save'));
/* Quando clicco sul pulsante "edit"... */
$( '.wikibase-toolbareditgroup .wikibase-toolbarbutton:first-child:not(.wikibase-toolbarbutton-disabled)' ).click(function () {
/* Genero il pulsante "save to Perseids" */
$( '.wikibase-toolbareditgroup-ineditmode .wikibase-toolbar:not(:has(.perseids-save)) .wikibase-toolbarbutton:first-child')
.after(generateButton('save'));
/* Click su "annulla": rigenero il pulsante "edit" */
$( '.wikibase-toolbareditgroup-ineditmode .wikibase-toolbar .wikibase-toolbarbutton:last-child').click(function(){
$( '.wikibase-toolbareditgroup-innoneditmode .wikibase-toolbar:not(:has(.perseids-edit)) .wikibase-toolbarbutton:first-child' ).after(generateButton('edit'));
});
});