MojePrvniPodnikaniMain / js / popup.js
popup.js
Raw
/**
 * @file popup.js
 * @brief Script serving for manipulating the popup.
 *
 * This script has function for showing/hiding popup.
 * Allows to dynamicaly set up border and button of popup according to specific section of the page.
 *
 */

function showPopup(color, interest, number) {
  const popupOverlay = document.getElementById("popupOverlay");
  const popupContent = document.getElementById("popup-content");
  const interestInput = document.getElementById("interest");
  const buttonSubmit = document.getElementById("submitBtn");
  const backLink = document.getElementById("backlink");
  popupOverlay.style.display = "flex";
  backLink.value = number;
  popupContent.style.border = `4px solid ${color}`;
  interestInput.value = interest;
  buttonSubmit.style.backgroundColor = color; // Set button color based on interest
}

function hidePopup() {
  const popupOverlay = document.getElementById("popupOverlay");
  const popupContent = document.getElementById("popup-content");
  const interestInput = document.getElementById("interest");
  popupOverlay.style.display = "none";
  popupContent.style.borderColor = "#000"; // Reset to default border color
  interestInput.value = ""; // Clear hidden input
}