MediaWiki:Gadget-bottone-case.js
Aspetto
Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5.
function capitalize(testo) {
testo=testo.split(" ");
for (var i=0; i<testo.length; i+=1) {
testo[i]=testo[i].substring(0,1).toLocaleUpperCase()+testo[i].substring(1).toLocaleLowerCase();
}
return testo.join(" ");
}
function changeCase(testo) {
if (testo==testo.toLocaleUpperCase())
testo=testo.toLocaleLowerCase();
else
testo=testo.toLocaleUpperCase();
return testo;
}
function capit() {var t=sel(); t[1][1]=capitalize(t[1][1]); scriviSel(t[1]);}
function up_low() {var t=sel(); t[1][1]=changeCase(t[1][1]); scriviSel(t[1]);}
/* test capit() */
if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' ) {$( function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {'section': {
label: 'Lettera iniziale in maiuscolo',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Button_capitalize.svg/23px-Button_capitalize.svg.png',
action: {type: 'callback',
execute: function(context){capit();} }
}}});});}
/* test up_low() */
if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' ) {$( function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {'section': {
label: 'Inverti maiuscolo/minuscolo',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Button_Up_Low_toggle.svg/23px-Button_Up_Low_toggle.svg.png',
action: {type: 'callback',
execute: function(context){up_low();} }
}}});});}