|
@@ -1,6 +1,11 @@
|
|
|
$(document).ready(function(){
|
|
$(document).ready(function(){
|
|
|
|
|
|
|
|
// ******* Navbars & dropdowns *******
|
|
// ******* Navbars & dropdowns *******
|
|
|
|
|
+
|
|
|
|
|
+ // delay in ms before dropdown collapse after the cursor leave
|
|
|
|
|
+ var collapsingDelay = 400;
|
|
|
|
|
+
|
|
|
|
|
+ // hide the dropdown element and its children
|
|
|
var hideDropdownsFor = function(elt, delay=0) {
|
|
var hideDropdownsFor = function(elt, delay=0) {
|
|
|
if (delay === 0) {
|
|
if (delay === 0) {
|
|
|
elt.children('ul.dropdown-menu').removeClass('dropdown-displayed');
|
|
elt.children('ul.dropdown-menu').removeClass('dropdown-displayed');
|
|
@@ -16,6 +21,7 @@ $(document).ready(function(){
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // stop any delayed commands on elt and its children
|
|
|
var stopDelayedHidingFor = function(elt) {
|
|
var stopDelayedHidingFor = function(elt) {
|
|
|
elt.stop(true);
|
|
elt.stop(true);
|
|
|
elt.children('ul.dropdown-menu').stop(true);
|
|
elt.children('ul.dropdown-menu').stop(true);
|
|
@@ -23,19 +29,25 @@ $(document).ready(function(){
|
|
|
|
|
|
|
|
$('.dropdown').on('mouseenter', function(e) {
|
|
$('.dropdown').on('mouseenter', function(e) {
|
|
|
|
|
|
|
|
|
|
+ // stop any delayed hiding on this since the cursor went back on it
|
|
|
stopDelayedHidingFor($(this));
|
|
stopDelayedHidingFor($(this));
|
|
|
|
|
+
|
|
|
|
|
+ // hide every other dropdown in the page
|
|
|
$('.dropdown.dropdown-displayed').not($(this).parents()).each(function() {
|
|
$('.dropdown.dropdown-displayed').not($(this).parents()).each(function() {
|
|
|
hideDropdownsFor($(this));
|
|
hideDropdownsFor($(this));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // display the dropdown
|
|
|
dropdown = $(this).find('ul.dropdown-menu:first');
|
|
dropdown = $(this).find('ul.dropdown-menu:first');
|
|
|
if (dropdown.length !== 0) {
|
|
if (dropdown.length !== 0) {
|
|
|
$(this).addClass('dropdown-displayed');
|
|
$(this).addClass('dropdown-displayed');
|
|
|
dropdown.addClass('dropdown-displayed');
|
|
dropdown.addClass('dropdown-displayed');
|
|
|
dropdown.show();
|
|
dropdown.show();
|
|
|
|
|
|
|
|
|
|
+ // if this is a second level dropdown
|
|
|
if ($(this).parents('.dropdown').length !== 0) {
|
|
if ($(this).parents('.dropdown').length !== 0) {
|
|
|
- // second level dropdown
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // move it on the right or left according to its current position
|
|
|
dropdown.removeClass('dropdown-left').removeClass('dropdown-right');
|
|
dropdown.removeClass('dropdown-left').removeClass('dropdown-right');
|
|
|
if (($(this).offset().left + $(this).width() + dropdown.width()) > $(window).width()) {
|
|
if (($(this).offset().left + $(this).width() + dropdown.width()) > $(window).width()) {
|
|
|
dropdown.addClass('dropdown-left');
|
|
dropdown.addClass('dropdown-left');
|
|
@@ -44,14 +56,16 @@ $(document).ready(function(){
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}).on('mouseleave', function(e) {
|
|
}).on('mouseleave', function(e) {
|
|
|
if ($(this).hasClass('delayed-collapsing')) {
|
|
if ($(this).hasClass('delayed-collapsing')) {
|
|
|
- hideDropdownsFor($(this), 800);
|
|
|
|
|
|
|
+ hideDropdownsFor($(this), collapsingDelay);
|
|
|
} else {
|
|
} else {
|
|
|
hideDropdownsFor($(this));
|
|
hideDropdownsFor($(this));
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// **** Login Pop-Up and Auth
|
|
// **** Login Pop-Up and Auth
|
|
|
$('#login-btn').on('click', function(e) {
|
|
$('#login-btn').on('click', function(e) {
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|