Advertisement
Looz_Dreemur

Untitled

Apr 16th, 2020
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function () {
  2.     // load the component using async ajax call
  3.     $("header").load("components/header.html");
  4.  
  5.     // when all ajax call had been completed
  6.     $(document).ajaxStop(function () {
  7.         $("#profileIco").on("click", function () {
  8.             $(".drop-down-container").css(
  9.                 "display",
  10.                 $(".drop-down-container").css("display") == "block"
  11.                     ? "none"
  12.                     : "block"
  13.             );
  14.         });
  15.  
  16.         // I will set the margin too on load
  17.         $(".drop-down-container").css(
  18.             "right",
  19.             `${Math.round(
  20.                 window.innerWidth * 0.1 +
  21.                     (window.innerWidth * 0.8 * 0.25 - 48) / 2
  22.             )}px`
  23.         );
  24.         $(window).on("resize", function () {
  25.             $(".drop-down-container").css(
  26.                 "right",
  27.                 `${Math.round(
  28.                     window.innerWidth * 0.1 +
  29.                         (window.innerWidth * 0.8 * 0.25 - 48) / 2
  30.                 )}px`
  31.             );
  32.         });
  33.  
  34.         // Hope this doesnt override on click in popupHandler
  35.         $("#openLoginBox").on("click", function () {
  36.             $(".drop-down-container").css("display", "none");
  37.         });
  38.  
  39.         $("#openSignupBtn").on("click", function () {
  40.             $(".drop-down-container").css("display", "none");
  41.         });
  42.  
  43.         // If Login was done before hand
  44.         if (sessionStorage.getItem("login") == "true") {
  45.             let disabled = $(".drop-disabled");
  46.             let enabled = $(".drop-enabled");
  47.             enabled.css("display", "none");
  48.             disabled.addClass("drop-enabled").removeClass("drop-disabled");
  49.             $("#logOutBtn").css("display", "block");
  50.             $("#logOutBtn").on("click", function () {
  51.                 alert("You are being logged out.");
  52.                 sessionStorage.setItem("login", false);
  53.                 window.location.href = window.location.href.substring(
  54.                     0,
  55.                     window.location.href.indexOf("?")
  56.                 );
  57.             });
  58.             $("#myProfileBtn").on("click", function () {
  59.                 window.location.href = "memberaccount.html";
  60.             });
  61.             $("#trackOrderBtn").on("click", function () {
  62.                 window.location.href = "track_order.html";
  63.             });
  64.             $("#mycartBtn").on("click", function () {
  65.                 window.location.href = "shoppingCart.html";
  66.             });
  67.         }
  68.     });
  69. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement