site-accueil-insa/assets/scripts/planningScript.js

51 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-03-25 13:22:28 +02:00
var current = null;
var classes = null;
2018-03-25 14:19:53 +02:00
$(document).ready(function () {
/*
* Display clicked event as selected, change info box content and scroll to it
*/
2018-03-25 14:19:53 +02:00
$(".event").click(function () {
2018-03-25 13:22:28 +02:00
/* Reset last selected items */
if (current != null) {
setEventShadow(current, "none");
}
/* Set style for currently selected items */
current = this.className.split(" ")[1];
setEventShadow(current, "0px 0px 10px #000");
/* Load info box text and smoothly scroll to it */
$("#infoBox").load("includes/planning_events/" + current + ".html");
$('html, body').animate({
scrollTop: $("#infoBox").offset().top
}, 300);
});
/*
* Display shadow on hovered events
*/
2018-03-25 14:19:53 +02:00
$(".event").hover(function () {
2018-03-25 13:22:28 +02:00
var element = this.className.split(" ")[1];
if (element != current) {
2018-04-17 09:04:31 +02:00
setEventShadow(element, "0px 0px 5px #aaa");
2018-03-25 13:22:28 +02:00
}
2018-03-25 14:19:53 +02:00
}, function () {
2018-03-25 13:22:28 +02:00
var element = this.className.split(" ")[1];
if (element != current) {
setEventShadow(element, "none");
}
});
/*
* Display shadow under all elements with the save eventName
*/
2018-03-25 14:19:53 +02:00
function setEventShadow(eventName, shadow) {
2018-03-25 13:22:28 +02:00
classes = document.getElementsByClassName(eventName);
for (var i = 0; i < classes.length; i++) {
classes[i].style.boxShadow = shadow;
}
}
});