/* SCRIPTS */

(function($) {
	"use strict";
	// Add active state to sidbar nav links
	var path = window.location.href; // because the 'href' property of the DOM element is the absolute path
		$("#layoutSidenav_nav .sb-sidenav a.nav-link").each(function() {
			if (this.href === path) {
				$(this).addClass("active");
			}
		});

	// Toggle the side navigation
	$("#sidebarToggle").on("click", function(e) {
		e.preventDefault();
		$("body").toggleClass("sb-sidenav-toggled");
	});
})(jQuery);

$(function(){
	$(".sb-sidenav-menu > .nav > .nav-link").each(function(){
		if ($(this).attr("href") == window.location.pathname) {
			$(this).addClass("selected");
		}
	});
});


$(function(){
	$("#btn-search").click(function(){
		if ($("#navbar-search").hasClass("slidedown")) {
			$("#navbar-search").removeClass("slidedown");
			$(this).find("i").addClass("fadeout");
			$(this).find("i").removeClass("fadein");
		}
		else{
			$("#navbar-search").addClass("slidedown");
			$("#search-navbar").focus();
			$(this).find("i").addClass("fadein");
			$(this).find("i").removeClass("fadeout");
		}
	});
});

$(function(){
	$("#btn-action-filter-sidebar").click(function(){
		$("#filter-sidebar").toggleClass("active");

		if ($("#filter-sidebar").hasClass("active")) {
			document.documentElement.style.overflow = "hidden";
			document.body.scroll = "no";
		}
		else{
			document.documentElement.style.overflow = "auto";
			document.body.scroll = "yes";
		}
	});
});
