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

51 lines
1.5 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];
2018-05-20 23:35:17 +02:00
setEventShadow(current, "0px 0px 10px #ee293d");
2018-03-25 13:22:28 +02:00
/* Load info box text and smoothly scroll to it */
$("#infoBox").load("includes/planning_events/" + current + ".html");
$('html, body').animate({
2018-06-05 20:03:33 +02:00
scrollTop: $("#info-box-top").offset().top
2018-03-25 13:22:28 +02:00
}, 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-05-20 23:35:17 +02:00
setEventShadow(element, "0px 0px 10px #1a5dad");
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;
2018-05-20 23:35:17 +02:00
classes[i].style.textShadow = shadow;
2018-03-25 13:22:28 +02:00
}
}
});