MediaWiki:Common.js — различия между версиями
Designer (обсуждение | вклад) |
Designer (обсуждение | вклад) |
||
| Строка 43: | Строка 43: | ||
$("#block").css("max-height",xx); | $("#block").css("max-height",xx); | ||
| − | + | ||
| − | + | if (z - $(window).scrollTop() < 0) { | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
$("#aside1").offset({top:$(window).scrollTop()}); | $("#aside1").offset({top:$(window).scrollTop()}); | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| + | |||
| + | } | ||
} | } | ||
})() | })() | ||
Версия 07:16, 5 октября 2016
$(function() {
var xx = document.body.offsetHeight -($("#aside1").offset().top+65);
xx = xx + 'px';
$("#block").css("max-height",xx);
});
$("#but1").click(function (event) {
if ($("#win1").is(':visible')) {
$("#win1").hide('slow');
} else {
$("#win1").show('slow');
if ($("#win2").is(':visible')) {
$("#win2").hide('slow');
}
}
});
$("#but2").click(function (event) {
if ($("#win2").is(':visible')) {
$("#win2").hide('slow');
} else {
$("#win2").show('slow');
if ($("#win1").is(':visible')) {
$("#win1").hide('slow');
}
}
});
var z = $("#aside1").offset().top;
(function(){ // анонимная функция (function(){ })(), чтобы переменные "a" и "b" не стали глобальными
var a = document.querySelector('#aside1'), b = null; // селектор блока, который нужно закрепить
window.addEventListener('scroll', Ascroll, false);
document.body.addEventListener('scroll', Ascroll, false); // если у html и body высота равна 100%
function Ascroll() {
$("#aside1").offset({top:z});
var xx0 = z - $(window).scrollTop();
if (xx0 < 0) { xx0 = 0;}
var xx = document.body.offsetHeight -(65+xx0);
xx = xx + 'px';
$("#block").css("max-height",xx);
if (z - $(window).scrollTop() < 0) {
$("#aside1").offset({top:$(window).scrollTop()});
}
}
})()