MediaWiki:Common.js: различия между версиями
Материал из Anekdot.me
Перейти к навигацииПерейти к поискум (fix) |
м (Пусть будет) |
||
Строка 130: | Строка 130: | ||
/* nologo */ | /* nologo */ | ||
$(function() { if($('#nologo').length) $('#p-logo').hide(); }); | $(function() { if($('#nologo').length) $('#p-logo').hide(); }); | ||
+ | |||
+ | /* | ||
+ | * Scrolling to top -- 23 November 2012 | ||
+ | * Stolen from http://habrahabr.ru/post/146049/ | ||
+ | * Вместе с предшествующими комментариями спёрто из http://ru.wikipedia.org/?oldid=50093825 и слегка изменено | ||
+ | */ | ||
+ | |||
+ | $('body').append("<div class='to-top' title='Наверх'>↑</div>"); // Создаем элемент на странице | ||
+ | |||
+ | $(window).scroll( function() { | ||
+ | if ( $(this).scrollTop() > $(window).height() ) { // Если длина прокрутки страницы больше высоты экрана, то... | ||
+ | $('.to-top').fadeIn(); // Показать кнопку | ||
+ | } else { // Если нет, то... | ||
+ | $('.to-top').fadeOut(); // Скрыть кнопку | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | $('.to-top').on('click', function() { | ||
+ | $('html, body').animate({scrollTop : 0}, 800); // По клику на кнопку прокручиваем страницу вверх | ||
+ | return false; | ||
+ | }); | ||
+ | |||
+ | mw.util.addCSS('.to-top { position: fixed; top: 0; bottom: 0; left: 0; padding:.7em; font:40px PT Sans,Tahoma,Verdana,sans-serif; color:#555; height:100%; -moz-opacity: 0.3; filter: alpha(opacity=30); opacity: 0.3; display:none; } .to-top:hover { -moz-opacity: 0.9; filter: alpha(opacity=90); opacity: 0.9; cursor: pointer; background: #999; font:40px PT Sans,Tahoma,Verdana,sans-serif; color:#ffffff;}'); |
Версия от 22:32, 4 июля 2013
importScript("MediaWiki:Dynavbar.js");
window._gaq = [['_require', 'inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js'], ['_setAccount', 'UA-37560376-6'], ['_trackPageview']];
$.ajax({
url: 'http://google-analytics.com/ga.js',
dataType: 'script',
cache: true
});
$.ajax({ /* http://absurdopedia.net/wiki/MediaWiki:Gadget-friends.js */
url: 'http://absurdopedia.net/w/load.php?debug=false&lang=ru&modules=ext.gadget.friends&skin=monobook',
dataType: 'script',
cache: true
});
/** Morph LM Edition *************************************
*
* Description: слайдер скрытого контента
* Stolen^W Made by: hikki-zadrot, Tachikoma, Anotubus
* Стырено из Лукоморья (http://lurkmore.to/?oldid=1236836)
*/
function createMorphObjects() {
var morphTargets = new Array(), morphLinks = new Array(), currentMorph = new Array();
function morphHandler(cont, num) {
return function() {
currentMorph[cont].curr = num;
var t = morphTargets[cont];
var l = morphLinks[cont];
for(i in t) if(currentMorph[cont].ms != null) t[i].style.display = t[i].className.match(l[num].className.replace(/.*morphlink\s+morph(\S+).*/, '$1'))? "" : "none"; else t[i].style.display = i==num ? "" : "none";
var h = currentMorph[cont].hilight, d = currentMorph[cont].defstyle;
for(i in l) l[i].setAttribute('style', (i!=num)?d:h);
};
};
function morphNext(cont) {
return function() {
var t = currentMorph[cont];
morphHandler(cont, t.curr<(t.max-1)?t.curr+1:0)();
}
}
function morphPrev(cont) {
return function() {
var t = currentMorph[cont];
morphHandler(cont, t.curr>0?t.curr-1:t.max-1)();
}
}
var morphContainers = document.querySelectorAll(".morphcontainer");
for(var i = 0; i<morphContainers.length; i++) {
var this_ = morphContainers[i];
morphTargets[i] = {};
morphLinks[i] = {};
var isHover = this_.className.match(/\bhover\b/);
var isManualsort = this_.className.match(/\bmanualsort\b/);
var morphCs = this_.querySelectorAll(".morphcontent");
var morphLs = this_.querySelectorAll(".morphlink");
var h = this_.querySelector(".morphlink_hilight");
h = h ? h.getAttribute('style') : "color:blue; text-decoration:underline; cursor: pointer;";
var def = this_.querySelector(".morphlink_default");
def = def ? def.getAttribute('style') : "color:blue; cursor: pointer;";
currentMorph[i] = {max: morphLs.length, curr: 0, hilight: h, defstyle: def, ms: isManualsort};
for(var m = 0; m<morphLs.length; m++) {
morphLinks[i][m] = morphLs[m];
addHandler(morphLs[m], isHover?'mouseover':'click', morphHandler(i, m));
morphLs[m].setAttribute('style', m?def:h);
};
for(var m = 0; m<morphCs.length; m++) {
morphTargets[i][m] = morphCs[m];
if (isManualsort != null) morphCs[m].style.display = morphCs[m].className.match(morphLs[0].className.replace(/.*morphlink\s+morph(\S+).*/, '$1'))? "" : "none"; else morphCs[m].style.display = m ? "none" : "";
};
if (this_.querySelector(".morphprev")) addClickHandler(this_.querySelector(".morphprev"), morphPrev(i));
if (this_.querySelector(".morphnext")) addClickHandler(this_.querySelector(".morphnext"), morphNext(i));
}
}
addOnloadHook(createMorphObjects);
/* Счётчик Рамблера */
function ramblerInit()
{
var ramblerCnt = document.createElement('img');
ramblerCnt.src = "http://counter.rambler.ru/top100.scn?2534618" +
"&rn=" + Math.round(Math.random() * 2147483647) +
(document.referrer ? "&rf=" + encodeURIComponent(document.referrer) : "") +
"&pt=" + encodeURIComponent(document.title.split(" — ")[0]) +
"&en=" + (document.characterSet || document.charset || "") +
"&fv=" +
"&ja=" + (navigator.javaEnabled() ? 1 : 0) +
"&cd=" + (screen ? screen.colorDepth + "-bit" : "") +
(screen ? "&sr=" + screen.width + "x" + screen.height : "") +
(navigator && navigator.language ? "&la=" + navigator.language : "") +
"&tz=" + (new Date).getTimezoneOffset();
var ramblerDiv = document.createElement('div');
ramblerDiv.id = "top100Counter";
ramblerDiv.appendChild(ramblerCnt);
var link = document.createElement('a');
link.href = 'http://top100.rambler.ru/';
link.appendChild(ramblerDiv);
document.getElementById('f-copyrightico').appendChild(link);
}
addOnloadHook(ramblerInit);
/* /Счётчик Рамблера */
/* Викификатор */
function addWikifButton() {
var toolbar = document.getElementById('toolbar')
if (!toolbar) return
var i = document.createElement('img')
i.src = 'http://i.anekdot.me/d/d1/Button-wikifikator.png'
i.alt = i.title = 'викификатор'
i.onclick = Wikify
i.style.cursor = 'pointer'
toolbar.insertBefore(i, toolbar.firstChild)
}
if (document.URL.indexOf('action=edit') > 0 || document.URL.indexOf('action=submit') > 0) {
document.write('<script type="text/javascript" src="http://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript"><\/script>')
addOnloadHook(addWikifButton)
}
/* /Викификатор */
/* nologo */
$(function() { if($('#nologo').length) $('#p-logo').hide(); });
/*
* Scrolling to top -- 23 November 2012
* Stolen from http://habrahabr.ru/post/146049/
* Вместе с предшествующими комментариями спёрто из http://ru.wikipedia.org/?oldid=50093825 и слегка изменено
*/
$('body').append("<div class='to-top' title='Наверх'>↑</div>"); // Создаем элемент на странице
$(window).scroll( function() {
if ( $(this).scrollTop() > $(window).height() ) { // Если длина прокрутки страницы больше высоты экрана, то...
$('.to-top').fadeIn(); // Показать кнопку
} else { // Если нет, то...
$('.to-top').fadeOut(); // Скрыть кнопку
}
});
$('.to-top').on('click', function() {
$('html, body').animate({scrollTop : 0}, 800); // По клику на кнопку прокручиваем страницу вверх
return false;
});
mw.util.addCSS('.to-top { position: fixed; top: 0; bottom: 0; left: 0; padding:.7em; font:40px PT Sans,Tahoma,Verdana,sans-serif; color:#555; height:100%; -moz-opacity: 0.3; filter: alpha(opacity=30); opacity: 0.3; display:none; } .to-top:hover { -moz-opacity: 0.9; filter: alpha(opacity=90); opacity: 0.9; cursor: pointer; background: #999; font:40px PT Sans,Tahoma,Verdana,sans-serif; color:#ffffff;}');