// source --> https://www.christysserenity.com/wp-content/plugins/team-showcase-supreme/assets/js/ajaxdata-pro.js?ver=d8037f7bd41f0513834d639f3d183f44 
window.addEventListener("load", function () {
  jQuery("body").on(
    "click",
    ".wpm-6310-custom-field-mail-link-cls",
    function (event) {
      var customField = jQuery(this).attr("wpm-data-custom-field");
      if (customField != undefined) {
        window.open(customField, "_blank").focus();
        event.preventDefault();

        var closest = jQuery(this).closest(".wpm_main_template");
        if (Number(closest.attr("wpm-6310-google-tag"))) {
          if (!window.dataLayer) {
            window.dataLayer = window.dataLayer || [];
          }
          var text = jQuery(this)
            .closest(".wpm-6310-custom-field-mail-link-cls")
            .attr("wpm-data-custom-field");
          var dataSet = {
            event: "click",
            eventAction: "Click",
            eventUrl: text,
            elementText: text,
            elementLabel: text,
            eventText: text,
            eventLabel: text,
          };
          console.log("dataSet", dataSet);
          window.dataLayer.push(dataSet);
        }
        return false;
      }
    }
  );
  var modalId = "";
  jQuery("body").on(
    "click",
    ".wpm_6310_team_member_info, .wpm_6310_team_member_internal_link",
    function (event) {
      var linkActive = jQuery(this).attr("wpm-6310-link-active");
      var closest = jQuery(this).closest(".wpm_main_template");
      var memberInfo = jQuery(this).closest(".wpm_6310_team_member_info");
      var memberSelector = jQuery(this).closest(
        ".wpm_6310_team_style_" + closest.attr("wpm-6310-carousel-id")
      );
      if (typeof linkActive !== "undefined" && linkActive !== false) {
        return;
      }
      var allModal = jQuery(".wpm_6310_modal");
      allModal.each(function () {
        jQuery(this).remove();
      });

      if (Number(closest.attr("wpm-6310-google-tag"))) {
        if (!window.dataLayer) {
          window.dataLayer = window.dataLayer || [];
        }
        var text =
          memberSelector.find('[class$="_title"]').text() +
          " - " +
          memberSelector.find('[class$="_designation"]').text();

        var dataSet = {
          event: "click",
          eventAction: "Click",
          eventUrl: memberInfo.attr("link-url") || "modal open",
          elementText: text,
          elementLabel: text,
          eventText: text,
          eventLabel: text,
        };
        console.log("dataSet", dataSet);
        window.dataLayer.push(dataSet);
      }

      modalId = parseInt(jQuery(this).attr("team-id"));
      var linkId = parseInt(jQuery(this).attr("link-id"));
      var linkUrl = jQuery(this).attr("data-wpm-link-url");

      if (linkId > 0) {
        event.preventDefault();
        if (jQuery(this).attr("target") == "1") {
          window.open(jQuery(this).attr("link-url"), "_blank").focus();
        } else {
          window.open(jQuery(this).attr("link-url"), "_parent").focus();
        }
        return false;
      } else if (linkUrl) {
        window.location.href = linkUrl;
      } else if (modalId > 0) {
        var mId = Number(closest.attr("wpm-6310-modal-template"));
        var tId = Number(closest.attr("wpm-6310-carousel-id"));

        var modal_02_custom_text = closest
          .find(".wpm-6310-modal-02-custom-text")
          .val();
        var modal_03_custom_text = closest
          .find(".wpm-6310-modal-03-custom-text")
          .val();
        var modal_03_custom_tooltip = closest
          .find(".wpm-6310-modal-03-custom-tooltip")
          .val();
        var modal_05_custom_tooltip = closest
          .find(".wpm-6310-modal-05-custom-tooltip")
          .val();

        if (modal_03_custom_tooltip) {
          modal_03_custom_tooltip =
            '<div class="wpm_6310_modal_preword"> <div class="wpm_6310_modal_pre_title"> ' +
            modal_03_custom_tooltip +
            "</div></div>";
        }

        var html =
          '<div id="mywpm_6310_modal" class="wpm_6310_modal wpm_6310_mmt_' +
          tId +
          '"> <div class="wpm_6310_modal-content"> <span class="wpm-6310-close">&times;</span><div class="wpm_6310_modal_template_before"></div><div class="wpm_6310_modal_template_after"></div>';
        if (mId == 2) {
          html +=
            '<div class="wpm_6310_modal_template wpm_6310_modal_template_2"><div class="wpm_6310_modal_body_picture_content"> <div class="wpm_6310_modal_body_picture"> <img src="" class="wpm_6310_modal_img"/> <img src="" class="wpm_6310_modal_hover_img"/> </div><div class="wpm_6310_modal_social"></div></div><div class="wpm_6310_modal_body_content"> <div class="wpm_6310_modal_title"> ' +
            modal_02_custom_text +
            '<div class="wpm_6310_modal_name"></div></div><div class="wpm_6310_modal_designation"></div><div class="wpm_6310_modal_category"></div><div class="wpm_6310_modal_details"></div><div class="wpm_6310_modal_contact"></div><div class="wpm_6310_member_skills_wrapper"></div></div></div>';
        } else if (mId == 3) {
          html +=
            '<div class="wpm_6310_modal_template wpm_6310_modal_template_3"><div class="wpm_6310_modal_body_picture_content"> <div class="wpm_6310_modal_body_picture"> <img src="" class="wpm_6310_modal_img" alt=""> <img src="" class="wpm_6310_modal_hover_img"/> </div></div><div class="wpm_6310_modal_body_content"> ' +
            modal_03_custom_tooltip +
            '<div class="wpm_6310_modal_title">' +
            modal_03_custom_text +
            '<div class="wpm_6310_modal_name"></div></div><div class="wpm_6310_modal_designation"></div><div class="wpm_6310_modal_category"></div><div class="wpm_6310_modal_hr"> </div><div class="wpm_6310_modal_details"></div><div class="wpm_6310_modal_contact"></div><div class="wpm_6310_member_skills_wrapper"></div><div class="wpm_6310_modal_footer"> <div class="wpm_6310_modal_social"></div></div></div></div>';
        } else if (mId == 4) {
          html +=
            ' <div class="wpm_6310_modal_template wpm_6310_modal_template_4"><div class="wpm_6310_modal_upper"> <div class="wpm_6310_modal_upper_right"> <div class="wpm_6310_modal_upper_right_img"> <img src="" class="wpm_6310_modal_img" alt=""> <img src="" class="wpm_6310_modal_hover_img"/> </div></div><div class="wpm_6310_modal_upper_left"> <div class="wpm_6310_modal_name"></div><div class="wpm_6310_modal_designation"></div><div class="wpm_6310_modal_category"></div><div class="wpm_6310_modal_contact"></div><div class="wpm_6310_modal_social"></div></div></div><div class="wpm_6310_modal_about"> <div class="wpm_6310_modal_details"></div></div><div class="wpm_6310_member_skills_section"> <div class="wpm_6310_member_skills_wrapper"></div></div></div>';
        } else if (mId == 5) {
          html +=
            '<div class="wpm_6310_modal_template wpm_6310_modal_template_5"><div class="wpm_6310_modal_left_col"> <div class="wpm_6310_modal_profile_pic"> <img src="" class="wpm_6310_modal_img" alt=""> <img src="" class="wpm_6310_modal_hover_img"/> </div><div class="wpm_6310_modal_name"></div><div class="wpm_6310_modal_designation"></div><div class="wpm_6310_modal_category"></div><div class="wpm_6310_modal_social"></div></div><div class="wpm_6310_modal_right_col"> <div class="wpm_6310_modal_title">' +
            modal_05_custom_tooltip +
            '</div><div class="wpm_6310_modal_details"></div><div class="wpm_6310_modal_hr"></div><div class="wpm_6310_modal_contact"></div><div class="wpm_6310_member_skills_wrapper"></div></div></div>';
        } else if (mId == 6) {
          html +=
            '<div class="wpm_6310_modal_template wpm_6310_modal_template_6"><div class="wpm_6310_modal_profile_pic"> <img src="" class="wpm_6310_modal_img" alt=""> <img src="" class="wpm_6310_modal_hover_img"/> </div><div class="wpm_6310_modal_top"> <div class="wpm_6310_modal_name"></div><div class="wpm_6310_modal_designation"></div><div class="wpm_6310_modal_category"></div><div class="wpm_6310_modal_social"></div></div><div class="wpm_6310_modal_hr"></div><div class="wpm_6310_modal_details"></div><div class="wpm_6310_modal_hr2"></div><div class="wpm_6310_modal_contact"></div><div class="wpm_6310_member_skills_section"> <div class="wpm_6310_member_skills_wrapper"></div></div></div>';
        } else {
          html +=
            '<div class="wpm_6310_modal_template wpm_6310_modal_template_1"><div class="wpm_6310_modal_body_picture_content"> <div class="wpm_6310_modal_body_picture"> <img src="" class="wpm_6310_modal_img"/> <img src="" class="wpm_6310_modal_hover_img"/> </div></div><div class="wpm_6310_modal_body_content"> <div class="wpm_6310_modal_designation"></div><div class="wpm_6310_modal_name"></div><div class="wpm_6310_modal_category"></div><div class="wpm_6310_modal_details"></div><br><br><div class="wpm_6310_modal_contact"></div><div class="wpm_6310_member_skills_wrapper"></div><div class="wpm_6310_modal_social"></div></div><br class="wpm_6310_clear"/> </div>';
        }

        html +=
          '<br class="wpm_6310_clear"/> </div><br class="wpm_6310_clear"/> </div>';
        jQuery("body").prepend(html);

        jQuery(
          ".wpm_6310_loading_" + closest.attr("wpm-6310-carousel-id")
        ).show();
        jQuery("body").css({
          overflow: "hidden",
        });

        var dataList = {
          action: "wpm_6310_team_member_details",
          ids: modalId,
          styleId: closest.attr("wpm-6310-carousel-id"),
          categoryStatus: closest.attr("wpm-6310-category-active"),
          selectedCategory: closest.attr("wpm-6310-selected-category"),
          clicked: "",
          progress_bar_animation: closest.attr(
            "wpm_6310_progress_bar_animation"
          ),
          progress_bar_border_radius: closest.attr(
            "wpm_6310_progress_bar_border_radius"
          ),
        };
        wpm_6310_load_modal(dataList);
      }
    }
  );

  jQuery("body").on("click", ".wpm_6310_modal_template_before", function () {
    var datas = {
      action: "wpm_6310_team_member_details",
      ids: jQuery(".wpm_6310_modal").attr("wpm-6310-member-id"),
      styleId: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm-6310-carousel-id"),
      categoryStatus: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm-6310-category-active"),
      selectedCategory: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm-6310-selected-category"),
      clicked: "prev",
      progress_bar_animation: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm_6310_progress_bar_animation"),
      progress_bar_border_radius: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm_6310_progress_bar_border_radius"),
    };
    jQuery(
      ".wpm_6310_loading_" +
        jQuery(this).closest(".wpm_6310_modal").attr("wpm-6310-carousel-id")
    ).show();
    jQuery(".wpm_6310_modal").hide();
    wpm_6310_load_modal(datas);
  });

  jQuery("body").on("click", ".wpm_6310_modal_template_after", function () {
    var datas = {
      action: "wpm_6310_team_member_details",
      ids: jQuery(".wpm_6310_modal").attr("wpm-6310-member-id"),
      styleId: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm-6310-carousel-id"),
      categoryStatus: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm-6310-category-active"),
      selectedCategory: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm-6310-selected-category"),
      clicked: "next",
      progress_bar_animation: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm_6310_progress_bar_animation"),
      progress_bar_border_radius: jQuery(this)
        .closest(".wpm_6310_modal")
        .attr("wpm_6310_progress_bar_border_radius"),
    };
    jQuery(
      ".wpm_6310_loading_" +
        jQuery(this).closest(".wpm_6310_modal").attr("wpm-6310-carousel-id")
    ).show();
    jQuery(".wpm_6310_modal").hide();
    wpm_6310_load_modal(datas);
  });
});

function wpm_6310_load_modal(dataList) {
  jQuery.ajax({
    type: "GET",
    dataType: "json",
    url: my_ajax_object.ajax_url,
    data: dataList,
    success: function (data) {
      jQuery(".wpm_6310_loading").hide();
      jQuery(".wpm_6310_modal-content").css({
        "animation-name": "wpm-animate" + data["styledata"]["effect"],
      });
      jQuery(".wpm_6310_modal").show();
      jQuery(".wpm_6310_modal").attr(
        "wpm-6310-member-id",
        data["styledata"]["id"]
      );
      jQuery(".wpm_6310_modal").attr({
        "wpm-6310-carousel-id": dataList["styleId"],
        "wpm-6310-category-active": dataList["categoryStatus"],
        "wpm-6310-selected-category": dataList["selectedCategory"],
      });
      jQuery(".wpm_6310_modal").attr(
        "wpm_6310_progress_bar_animation",
        dataList["progress_bar_animation"]
      );
      jQuery(".wpm_6310_modal").attr(
        "wpm_6310_progress_bar_border_radius",
        dataList["progress_bar_border_radius"]
      );
      jQuery(".wpm_6310_modal_img").attr(
        "src",
        data["styledata"]["image"]
          ? data["styledata"]["image"]
          : data["styledata"]["hover_image"]
      );
      jQuery(".wpm_6310_modal_hover_img").attr(
        "src",
        data["styledata"]["hover_image"]
          ? data["styledata"]["hover_image"]
          : data["styledata"]["image"]
      );
      jQuery(".wpm_6310_modal_designation").text(
        data["styledata"]["designation"]
      );
      jQuery(".wpm_6310_modal_name").text(data["styledata"]["name"]);
      jQuery(".wpm_6310_modal_category").text(
        data["styledata"]["categoryList"]
      );
      jQuery(".wpm_6310_modal_contact").html("");
      jQuery(".wpm_6310_modal_contact").append(data["contact"]);
      jQuery(".wpm_6310_modal_social").html("");
      jQuery(".wpm_6310_modal_social").append(data["link"]);
      jQuery(".wpm_6310_modal_details").html(
        data["styledata"]["profile_details"]
          .replace(/\n/g, "<br>")
          .replace(/&lt;/g, "<")
          .replace(/&gt;/g, ">")
      );
      jQuery(".wpm_6310_member_skills_wrapper").html("");
      jQuery(".wpm_6310_member_skills_wrapper").append(data["skills"]);
    },
  });
};