MediaWiki:Gadget-tradLink.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Fix |
m fix |
||
| (10 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 20:
}
mw.util.addCSS(
'.tradlinks-buttons { width: 100%; text-align: center; margin-top: 10px }' '.tradlinks-error { color: red; font-size: 120%; font-weight: bold; text-align:center }'
function OptDialog( config ) {
OptDialog.parent.call( this, config );
Riga 32 ⟶ 35:
var self = this;
OptDialog.parent.prototype.initialize.call( this );
this.errorContainer = new OO.ui.LabelWidget( {▼
label: ''▼
} );▼
this.addError = function ( error ) {▼
new OO.ui.HtmlSnippet( '<span class="tradlinks-error">' + error + '</span>' )
);
};▼
this.clearError = function () {
self.errorContainer.setLabel( '' );
};
this.fields = [];
var lingue = getLingue();
Riga 40 ⟶ 56:
maxLength: 3
} );
input.on( 'change', self.clearError );
var field = new OO.ui.FieldLayout(
input,
Riga 67 ⟶ 84:
classes: [ 'tradlinks-buttons' ]
} );
▲ this.errorContainer = new OO.ui.LabelWidget( {
▲ label: ''
▲ } );
▲ this.addError = function ( error ) {
▲ this.errorContainer.setLabel( error );
▲ };
this.panelLayout = new OO.ui.PanelLayout( { padded: true, expanded: false } );
Riga 162 ⟶ 172:
function tradLink( cod ) {
var lingue = getLingue();
▲ }
new mw.ForeignApi( '//' + lingue[cod] + '.wikipedia.org/w/api.php' ).get( {
Riga 190 ⟶ 195:
var trad = data.query.pages[ key ].langlinks[ 0 ][ "*" ];
$( '#wpTextbox1' ).textSelection( 'encapsulateSelection', {
pre: trad + "
} );
document.getElementById( 'wpTextbox1' ).selectionStart = selStart + trad.length + 1;
document.getElementById( 'wpTextbox1' ).selectionEnd = selEnd + trad.length +
return;
}
Riga 209 ⟶ 213:
}
$( function () {
if ( event.altKey && !event.shiftKey && !event.ctrlKey && !event.metaKey ) {
if ( event.which === 48 ) {
event.preventDefault();
mw.loader.using( [ 'oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.widgets' ] )
.done( showDialog )
.fail( function() { console.error( 'Errore configurazione tradLink' ); } );
} else if ( event.which >= 49 && event.which < 57 ) {
event.preventDefault();
tradLink( event.which - 49 );
}
}
} );
} );
}( mediaWiki, jQuery ) );
| |||