/**
 * @package KnowledgeHub
 */

jQuery(document).ready(function ($) {
  $("#dashboard-changelog-button").click(function (e) {
    e.stopPropagation();
    $("#knowledgehub-dashboard-offcanvas").addClass("open");
    $(".wrap").addClass("overlay");
  });

  $("#dialog-close").click(function (e) {
    e.stopPropagation();
    $("#knowledgehub-dashboard-offcanvas").removeClass("open");
    $(".wrap").removeClass("overlay");
  });

  $(document).on("click", function (e) {
    if (
      !$("#knowledgehub-dashboard-offcanvas").is(e.target) &&
      $("#knowledgehub-dashboard-offcanvas").has(e.target).length === 0
    ) {
      $("#knowledgehub-dashboard-offcanvas").removeClass("open");
      $(".wrap").removeClass("overlay");
    }
  });
});

jQuery(document).ready(function ($) {
  var knowledgehub_adminUrl = knowledgehubRedirectDemoPage.admin_url;

  var knowledgehub_targetUrl = knowledgehub_adminUrl + "themes.php?page=knowledgehub";

  var knowledgehub_currentPage = window.location.href;

  $(".dashboard-header-nav ul li").each(function () {
    var pageURL = $(this).find("a").attr("href");
    $;
    if (knowledgehub_currentPage === pageURL) {
      $(this).addClass("active");
    }
  });

  if (knowledgehub_currentPage === knowledgehub_targetUrl) {
    $(".dashboard-header-nav ul li:first").addClass("active");
  }
});