Difference between revisions of "MediaWiki:Perseids-toolbar.js"
Jump to navigation
Jump to search
(using javascript:void(0); instead of # for href) |
|||
Line 5: | Line 5: | ||
.attr( { |
.attr( { |
||
'class': 'wikibase-toolbarbutton perseids-edit', |
'class': 'wikibase-toolbarbutton perseids-edit', |
||
− | 'href': ' |
+ | 'href': 'javascript:void(0);' |
} ) |
} ) |
||
.before( '|' ) |
.before( '|' ) |
||
Line 17: | Line 17: | ||
.attr( { |
.attr( { |
||
'class': 'wikibase-toolbarbutton perseids-save', |
'class': 'wikibase-toolbarbutton perseids-save', |
||
− | 'href': ' |
+ | 'href': 'javascript:void(0);' |
} ) |
} ) |
||
.before( '|' ) |
.before( '|' ) |
||
Line 29: | Line 29: | ||
.attr( { |
.attr( { |
||
'class': 'wikibase-toolbarbutton perseids-add', |
'class': 'wikibase-toolbarbutton perseids-add', |
||
− | 'href': ' |
+ | 'href': 'javascript:void(0);' |
} ) |
} ) |
||
.before( '|' ) |
.before( '|' ) |
Revision as of 19:12, 14 September 2014
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')); }); });