MediaWiki:Common.js
Материал из Справочника наблюдателя
Замечание. Возможно, после сохранения вам придётся очистить кэш своего браузера, чтобы увидеть изменения.
- Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить либо нажмите Ctrl-F5 или Ctrl-R (⌘-R на Mac)
- Google Chrome: Нажмите Ctrl-Shift-R (⌘-Shift-R на Mac)
- Internet Explorer: Удерживая Ctrl, нажмите Обновить либо нажмите Ctrl-F5
- Opera: Выберите очистку кэша в меню Инструменты → Настройки
importMW = function ( name ) {
importScript( 'MediaWiki:' + name + '.js' );
};
importMWcss = function ( name ) {
importStylesheet( 'MediaWiki:' + name + '.css' );
};
mw.config.set( 'tableSorterCollation', { 'ё': 'е' } );
//Execution
mw.loader.using(
'mediawiki.util',
function () {
if ( mw.config.get( 'wgCanonicalNamespace' ) == 'Special' ) {
if ( /^(Uplo|Sear|Stat|Spec|Abus|Prefe|Move|Watch|Newp|Log)/i.test( mw.config.get( 'wgCanonicalSpecialPageName' ) ) ) {
importMW( 'Common.js/' + mw.config.get( 'wgCanonicalSpecialPageName' ) );
}
} else {
switch ( mw.config.get( 'wgAction' ) ) {
case 'history':
importMW( 'History' );
break;
case 'delete':
importMW( 'Deletepage' );
break;
case 'edit':
case 'submit':
importMW( 'Common.js/edit' );
//and continue with the default: view, purge
default:
if ( navigator.platform.indexOf( 'Win' ) != -1 ) {
mw.util.addCSS( '.IPA, .Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; }' );
}
}
}
/* Helper script for .hlist class in common.css
* Author: [[:en:User:Edokter]]
*/
if ( $.client.profile().name == 'msie' ) {
/* Add pseudo-selector class to last child list items in IE 8 */
if ( $.client.profile().versionBase == '8' ) {
$( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' )
.addClass( 'hlist-last-child' );
}
/* Generate interpuncts and parens for IE < 8 */
if ( $.client.profile().versionBase < '8' ) {
$( '.hlist' ).find( 'dt + dd, dt + dt' ).prev()
.append( '<b>:</b> ' );
$( '.hlist' ).find( 'dd + dd, dd + dt, li + li' ).prev()
.append( '<b>•</b> ' );
$( '.hlist' ).find( 'dl dl, ol ol, ul ul' )
.prepend( '( ' ).append( ') ' );
}
}
importMW('Wikibugs');
}
);
//extra scripts
var withJS = document.URL.match( /[&?]withjs=((mediawiki:)?([^&#]+))/i );
if ( withJS ) {
importScript( 'MediaWiki:' + withJS[3] );
}
var execJS = document.getElementById( 'executeJS' );
if ( execJS ) {
$.each( execJS.className.split( ' ' ), function ( i, sc ) {
sc = $.trim( sc.replace( /[^\w ]/g, '' ) );
if ( sc ) {
importMW( 'Script/' + sc );
importMWcss( 'Script/' + sc );
}
} );
}
// The function actually applying the offset
function offsetAnchor() {
if (location.hash.length !== 0) {
window.scrollTo(window.scrollX, window.scrollY - 50);
}
}
// This will capture hash changes while on the page
// Let the page finish loading.
$(document).ready(function() {
offsetAnchor();
$(window).on("hashchange", function () {
offsetAnchor();
});
$( '#revision-badge' ).click( function() {
$( '#revision-box' ).collapse( 'toggle' );
} );
$( '#revision-box' ).click( function() {
$( '#revision-box' ).collapse( 'toggle' );
} );
});