MediaWiki:Gadget-RailModule.js: Różnice pomiędzy wersjami

Z Nonsensopedii, polskiej encyklopedii humoru
(przemeblowańsko, optymalizowańsko, dodawańsko ficzerów)
M
Linia 1: Linia 1:
/**
/**
* Magia dodająca bajery do stopki na skórce Minerva.
* Magia dodająca bajery do stopki w trybie mobilnym.
*
*
* Autorzy: [[User:Ostrzyciel]], [[User:Polskacafe]]
* Autorzy: [[User:Ostrzyciel]], [[User:Polskacafe]]
Linia 6: Linia 6:


jQuery( document ).ready( function () {
jQuery( document ).ready( function () {
var afterContent = $( '#mw-data-after-content' );
if ( mw.config.get( 'skin' ) !== 'minerva' ) return;
var lmBar = $( '.last-modified-bar' );
var catlinks = $( '#catlinks' );
var footerContent = $( '.footer-content' );
const railDiv = '<div class="post-content footer-railmodule-content" style="margin-top: 22px;"><div class="railmodule-container"><div class="ra-railmodule noprint"></div></div></div>';
const railDiv = '<div class="post-content footer-railmodule-content" style="margin-top: 22px;"><div class="railmodule-container"><div class="ra-railmodule noprint"></div></div></div>';

// railmodule -- czywiesze i te sprawy
// nie wszędzie to jest -- patrz strony specjalne etc
var ratingstars = $( '.footer-ratingstars' );
if ( lmBar.length === 1 ) {
if ( !ratingstars.length ) {
// railmodule -- czywiesze i te sprawy
afterContent.prepend( railDiv );
var ratingstars = $( '.footer-ratingstars' );
} else {
if ( !ratingstars.length ) {
lmBar.after( railDiv );
ratingstars.after( railDiv );
}
// przycisk edycji
if ( mw.config.get( 'wgAction' ) === 'view' &&
mw.config.get( 'wgIsProbablyEditable' )
) {
href = 'https://nonsa.pl/wiki/' + mw.Uri.encode( mw.config.get( 'wgPageName' ) ) + '?action=edit';
toInsert = '<a href="' + href + '" id="bottom-edit-button"> \
<div>Edytuj tę stronę</div> \
</a>';
if ( catlinks.length === 1 ) {
catlinks.after( toInsert );
} else {
} else {
ratingstars.after( railDiv );
afterContent.before( toInsert );
}
}

// przycisk edycji
if ( mw.config.get( 'wgIsProbablyEditable' ) ) {
href = 'https://nonsa.pl/wiki/' + mw.Uri.encode( mw.config.get( 'wgPageName' ) ) + '?action=edit';
toInsert = '<a href="' + href + '" style="display: block;background-color: #ffed90;text-align: center;border-bottom: solid 1px #c8ccd1;padding-top: 0.625em;padding-bottom: 0.625em;font-size: 1.1em;font-weight: bold;color: #54595d;"> \
<div style="line-height: 1em;"> \
<span class="mw-ui-icon mw-ui-icon-small mw-ui-icon-minerva-edit-enabled edit-page" style="margin-right: 0.25em;vertical-align: top;"></span>Edytuj tę stronę \
</div> \
</a>';
lmBar.before( toInsert );
}
} else {
footerContent.before( railDiv );
}
}


// wypełnij railmodule
// wypełnij railmodule
footerContent.css( 'margin-top', '0px' );
$.ajax( {
$.ajax( {
url: 'https://nonsa.pl/wiki/MediaWiki:RailModule?action=render',
url: 'https://nonsa.pl/wiki/MediaWiki:RailModule?action=render',

Wersja z 19:43, 20 cze 2020

/**
 * Magia dodająca bajery do stopki w trybie mobilnym.
 *
 * Autorzy: [[User:Ostrzyciel]], [[User:Polskacafe]]
 **/

jQuery( document ).ready( function () {
	var afterContent = $( '#mw-data-after-content' );
	var catlinks = $( '#catlinks' );
	const railDiv = '<div class="post-content footer-railmodule-content" style="margin-top: 22px;"><div class="railmodule-container"><div class="ra-railmodule noprint"></div></div></div>';
	
	// railmodule -- czywiesze i te sprawy
	var ratingstars = $( '.footer-ratingstars' );
	if ( !ratingstars.length ) {
		afterContent.prepend( railDiv );
	} else {
		ratingstars.after( railDiv );
	}
	
	// przycisk edycji
	if ( mw.config.get( 'wgAction' ) === 'view' && 
		mw.config.get( 'wgIsProbablyEditable' ) 
		) {
		href = 'https://nonsa.pl/wiki/' + mw.Uri.encode( mw.config.get( 'wgPageName' ) ) + '?action=edit';
		toInsert = '<a href="' + href + '" id="bottom-edit-button"> \
			<div>Edytuj tę stronę</div> \
		</a>';
		
		if ( catlinks.length === 1 ) {
			catlinks.after( toInsert );
		} else {
			afterContent.before( toInsert );
		}
	}

	// wypełnij railmodule
	$.ajax( {
		url: 'https://nonsa.pl/wiki/MediaWiki:RailModule?action=render',
		type: 'GET',
		success: function ( data ) {
			$( 'div.ra-railmodule' ).prepend( data );
		}
	} );
}() );