117.png

Difference between revisions of "MediaWiki:Common.js"

From ITSTEP
Jump to: navigation, search
Line 30: Line 30:
 
m[k].getElementsByTagName("dd")[0].style.display="none";}};
 
m[k].getElementsByTagName("dd")[0].style.display="none";}};
 
  };
 
  };
 +
 +
 +
 +
 +
 +
 +
 +
(function($)
 +
{
 +
$(document).ready(function()
 +
{
 +
$('body').append('<div id="scrll"><div class="go-top help" id="ToTop"><span class="help_i">Вверх</span><span class="icon-arrow-up-2"></span></div><div class="go-content help" id="ToContent"><span class="help_i">К содержимому</span><span class="icon-list-view"></span></div><div class="go-bottom help" id="ToBottom"><span class="help_i">Вниз</span><span class="icon-arrow-down-2"></span></div></div>');
 +
var allhlp = $('span.help_i');
 +
var adh = $('div.help');
 +
$(allhlp).hide();
 +
$(adh).each(function(i) {
 +
$(this).on("hover",function(){
 +
$(allhlp[i]).show(200);
 +
})
 +
$(this).on("mouseleave",function(){
 +
$(allhlp[i]).hide(200).stop(false, true);
 +
})
 +
})
 +
var scrll = $("#scrll");
 +
var t=$("#ToTop");
 +
var b=$("#ToBottom");
 +
var ht=$("html,body");
 +
var content_position = $(window).scrollTop();
 +
if ($(window).scrollTop() >= "250") {
 +
$(t).fadeIn(500);
 +
}
 +
$(window).scroll(function(){
 +
if ($(window).scrollTop() <= "250") {
 +
$(t).fadeOut(500);
 +
} else {
 +
$(t).fadeIn(500);
 +
}
 +
if ($(window).scrollTop()>=$(document).height()-"999") $(b).fadeOut(500)
 +
else $(b).fadeIn(500)
 +
});
 +
$(t).on("click",function(){
 +
content_position = $(window).scrollTop();
 +
$(ht).animate({scrollTop:0},500);
 +
});
 +
$(b).on("click",function(){
 +
content_position = $(window).scrollTop();
 +
$(ht).animate({scrollTop:jQuery(document).height()},500);
 +
});
 +
$("#ToContent").on("click",function(){
 +
$(ht).animate({scrollTop:content_position},500);
 +
});
 +
//OFF ready
 +
})
 +
})(jQuery);

Revision as of 17:01, 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";}};
 };







(function($)
{
$(document).ready(function()
{
$('body').append('<div id="scrll"><div class="go-top help" id="ToTop"><span class="help_i">Вверх</span><span class="icon-arrow-up-2"></span></div><div class="go-content help" id="ToContent"><span class="help_i">К содержимому</span><span class="icon-list-view"></span></div><div class="go-bottom help" id="ToBottom"><span class="help_i">Вниз</span><span class="icon-arrow-down-2"></span></div></div>');
var allhlp = $('span.help_i');
var adh = $('div.help');
$(allhlp).hide();
$(adh).each(function(i) {
$(this).on("hover",function(){
$(allhlp[i]).show(200);
})
$(this).on("mouseleave",function(){
$(allhlp[i]).hide(200).stop(false, true);
})
})
var scrll = $("#scrll");
var t=$("#ToTop");
var b=$("#ToBottom");
var ht=$("html,body");
var content_position = $(window).scrollTop();
if ($(window).scrollTop() >= "250") {
$(t).fadeIn(500);
}
$(window).scroll(function(){
if ($(window).scrollTop() <= "250") {
$(t).fadeOut(500);
} else {
$(t).fadeIn(500);
}
if ($(window).scrollTop()>=$(document).height()-"999") $(b).fadeOut(500)
 else $(b).fadeIn(500)
});
$(t).on("click",function(){
content_position = $(window).scrollTop();
$(ht).animate({scrollTop:0},500);
});
$(b).on("click",function(){
content_position = $(window).scrollTop();
$(ht).animate({scrollTop:jQuery(document).height()},500);
});
$("#ToContent").on("click",function(){
$(ht).animate({scrollTop:content_position},500);
});
//OFF ready
})
})(jQuery);