Difference between revisions of "MediaWiki:Common.js"
| Line 47: | Line 47: | ||
| − | + | $(function(){$.fn.scrollToTop=function(){$(this).hide().removeAttr("href");if($(window).scrollTop()>="300"){$(this).fadeIn("slow")}var scrollDiv=$(this);$(window).scroll(function(){if($(window).scrollTop()<="350"){$(scrollDiv).fadeOut("slow")}else{$(scrollDiv).fadeIn("slow")}}); | |
| − | + | $(this).click(function(){$("html, body").animate({scrollTop:0},"slow")})}}); | |
| − | + | $(function() { $("#go_up").scrollToTop(); }); | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | }; | ||
Revision as of 09:18, 4 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();
})
})
$(function(){$.fn.scrollToTop=function(){$(this).hide().removeAttr("href");if($(window).scrollTop()>="300"){$(this).fadeIn("slow")}var scrollDiv=$(this);$(window).scroll(function(){if($(window).scrollTop()<="350"){$(scrollDiv).fadeOut("slow")}else{$(scrollDiv).fadeIn("slow")}});
$(this).click(function(){$("html, body").animate({scrollTop:0},"slow")})}});
$(function() { $("#go_up").scrollToTop(); });