Difference between revisions of "MediaWiki:Common.js"
| Line 43: | Line 43: | ||
}) | }) | ||
}) | }) | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | window.onload = function() { // после загрузки страницы | ||
| + | |||
| + | var scrollUp = document.getElementById('scrollup'); // найти элемент | ||
| + | |||
| + | scrollUp.onmouseover = function() { // добавить прозрачность | ||
| + | scrollUp.style.opacity=0.3; | ||
| + | scrollUp.style.filter = 'alpha(opacity=30)'; | ||
| + | }; | ||
| + | |||
| + | scrollUp.onmouseout = function() { //убрать прозрачность | ||
| + | scrollUp.style.opacity = 0.5; | ||
| + | scrollUp.style.filter = 'alpha(opacity=50)'; | ||
| + | }; | ||
| + | |||
| + | scrollUp.onclick = function() { //обработка клика | ||
| + | window.scrollTo(0,0); | ||
| + | }; | ||
| + | |||
| + | // show button | ||
| + | |||
| + | window.onscroll = function () { // при скролле показывать и прятать блок | ||
| + | if ( window.pageYOffset > 0 ) { | ||
| + | scrollUp.style.display = 'block'; | ||
| + | } else { | ||
| + | scrollUp.style.display = 'none'; | ||
| + | } | ||
| + | }; | ||
| + | }; | ||
Revision as of 22:15, 1 April 2017
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */
document.onclick=function(ev){
var obj=ev?ev.target:event.srcElement;
while(obj.parentNode){
if(obj.className=="spoiler"){break;}
else{obj=obj.parentNode;}};
if(obj.className=="spoiler"){
clickSpoiler(obj);
return false;};
closet();
};
function clickSpoiler(el){
var s=el.getElementsByTagName("dd")[0].style.display;
closet();
if(s=="none"||s==""){
el.getElementsByTagName("dd")[0].style.display="block";};
};
function closet(){
var m, k;
m=document.getElementsByTagName("dl");
k=m.length;
while(k--){
if(m[k].className=="spoiler"){
m[k].getElementsByTagName("dd")[0].style.display="none";}};
};
jQuery(document).ready(function(){
jQuery('.spoiler-head').click(function(){
$(this).parents('.spoiler-wrap').toggleClass("active").find('.spoiler-body').slideToggle();
})
})
window.onload = function() { // после загрузки страницы
var scrollUp = document.getElementById('scrollup'); // найти элемент
scrollUp.onmouseover = function() { // добавить прозрачность
scrollUp.style.opacity=0.3;
scrollUp.style.filter = 'alpha(opacity=30)';
};
scrollUp.onmouseout = function() { //убрать прозрачность
scrollUp.style.opacity = 0.5;
scrollUp.style.filter = 'alpha(opacity=50)';
};
scrollUp.onclick = function() { //обработка клика
window.scrollTo(0,0);
};
// show button
window.onscroll = function () { // при скролле показывать и прятать блок
if ( window.pageYOffset > 0 ) {
scrollUp.style.display = 'block';
} else {
scrollUp.style.display = 'none';
}
};
};