Difference between revisions of "MediaWiki:Perseids-toolbar.js"
Jump to navigation
Jump to search
(disabilito temporaneamente per test in locale) |
(versione riveduta e corretta) |
||
Line 1: | Line 1: | ||
+ | function generateButton(type) { |
||
+ | var pulsanti = { |
||
+ | 'edit': |
||
+ | $( '<a>' ) |
||
+ | .attr( { |
||
+ | 'class': 'wikibase-toolbarbutton perseids-edit', |
||
+ | 'href': '#' |
||
+ | } ) |
||
+ | .before( '|' ) |
||
+ | .text( 'edit in Perseids' ) |
||
+ | .click( function ( event ) { |
||
+ | event.preventDefault(); |
||
+ | } ), |
||
+ | |||
+ | 'save': |
||
+ | $( '<a>' ) |
||
+ | .attr( { |
||
+ | 'class': 'wikibase-toolbarbutton perseids-save', |
||
+ | 'href': '#' |
||
+ | } ) |
||
+ | .before( '|' ) |
||
+ | .text( 'save to Perseids' ) |
||
+ | .click( function ( event ) { |
||
+ | event.preventDefault(); |
||
+ | } ), |
||
+ | |||
+ | 'add': |
||
+ | $( '<a>' ) |
||
+ | .attr( { |
||
+ | 'class': 'wikibase-toolbarbutton perseids-add', |
||
+ | 'href': '#' |
||
+ | } ) |
||
+ | .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-claim-section .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))' ).append(generateButton('edit')); |
||
+ | }); |
||
+ | }); |
Revision as of 18:11, 14 September 2014
function generateButton(type) { var pulsanti = { 'edit': $( '<a>' ) .attr( { 'class': 'wikibase-toolbarbutton perseids-edit', 'href': '#' } ) .before( '|' ) .text( 'edit in Perseids' ) .click( function ( event ) { event.preventDefault(); } ), 'save': $( '<a>' ) .attr( { 'class': 'wikibase-toolbarbutton perseids-save', 'href': '#' } ) .before( '|' ) .text( 'save to Perseids' ) .click( function ( event ) { event.preventDefault(); } ), 'add': $( '<a>' ) .attr( { 'class': 'wikibase-toolbarbutton perseids-add', 'href': '#' } ) .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-claim-section .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))' ).append(generateButton('edit')); }); });