MediaWiki:Gadget-translation-editor-launcher.js
Uwaga: aby zobaczyć zmiany po opublikowaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.
- Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5, lub Ctrl+R (⌘-R na komputerze Mac)
- Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
- Internet Explorer / Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5
- Opera: Naciśnij klawisze Ctrl+F5.
var POST_EDIT_STORAGE_KEY = 'ext.gadget.translation-editor.post-edit';
mw.hook( 'wikipage.content' ).add( function ( $content ) {
var $transl, $defs, $defn, $button;
if (
mw.config.get( 'wgRevisionId' ) !== mw.config.get( 'wgCurRevisionId' ) ||
mw.config.get( 'wgDiffNewId' ) !== null ||
mw.config.get( 'wgDiffOldId' ) !== null
) {
return;
}
if ( mw.storage.get( POST_EDIT_STORAGE_KEY ) === mw.config.get( 'wgArticleId' ).toString() ) {
mw.loader.using( [ 'mediawiki.action.view.postEdit' ] ).done( function () {
mw.hook( 'postEdit' ).fire();
mw.storage.remove( POST_EDIT_STORAGE_KEY );
} );
}
$transl = $content.find( 'dt.lang-pl.fldt-tlumaczenia' ).first();
$defs = $content.find( 'dd.lang-pl.fldt-znaczenia' ).not( ':empty' ).has( '.term-num' );
$defn = $defs.find( '.term-num:first' );
if ( !$transl.length || !$defs.length || $defn.length !== $defs.length ) {
return;
}
$button = $( '<small>' ).text( '(edytuj)' ).attr( {
id: 'transl-addbutton',
accesskey: '+'
} ).css( {
cursor: 'pointer',
fontWeight: 'normal',
margin: '0 10px'
} ).appendTo( $transl );
$button.one( 'click', function () {
var module = 'ext.gadget.translation-editor',
$spinner = $.createSpinner( {
size: 'large',
type: 'block'
} ).appendTo( $transl );
mw.loader.using( module ).done( function ( require ) {
require( module ).init( $transl, $defn, $button ).always( function () {
$spinner.remove();
} );
} );
} );
$transl.closest( 'dl' ).removeClass( 'empty-dl' );
} );