EIOS/tpl/js/scripts.js

47 lines
1.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$(document).ready(function(){
$(".widget-title").css({"cursor":"pointer"});
//Иконка у плашек ни чего не должна делать
$(".widget-title i.icon-reorder").click(function(){ return false;});
//Сворачивание/Разворачивание плашек
$(".widget-title").click(function(e){
e.preventDefault();
var clas = $(e.target).attr("class");
if(clas=="icon-chevron-down"||clas=="icon-chevron-up"){
}else{
let par = $(this).parent(".widget");
if( $(this).find(".icon-chevron-up").length ){
$(this).find(".icon-chevron-up").addClass("icon-chevron-down").removeClass("icon-chevron-up");
par.find(".widget-body").show();
}else{
$(this).find(".icon-chevron-down").addClass("icon-chevron-up").removeClass("icon-chevron-down");
par.find(".widget-body").hide();
}
}
});
//при прокрутке скрывать правую часть блога!
$(window).scroll(function() {
if ($(window).width() > '766'){
if($(".blog_right").length){
var el = document.querySelector(".blog_right");
var inViewport = elementInViewport(el);
if(inViewport){
$(".blog_left").removeClass("span12").addClass("span8");
$(".blog_right").css({"position":"initial","right":"0"});
}else{
$(".blog_left").removeClass("span8").addClass("span12");
$(".blog_right").css({"position":"absolute","right":"0","top":"0"});
}
}
}
});
function elementInViewport(el){
var bounds = el.getBoundingClientRect();
return (
(bounds.top + bounds.height > 0) && // Елемент ниже верхней границы
(window.innerHeight - bounds.top > 0) && // Выше нижней
(bounds.left + bounds.width > 0) && // Правее левой
(window.innerWidth - bounds.left > 0)// Левее правой
);
}
});