/**
 * This file adds some LIVE to the Theme Customizer live preview. To leverage
 * this, set your custom settings to 'postMessage' and then add your handling
 * here. Your javascript should grab settings from customizer controls, and
 * then make any necessary changes to the page using jQuery. https://codex.wordpress.org/Theme_Customization_API
 */

(function ($) {
  // HEADER | All- Search Bar
  wp.customize("header_all_color", function (value) {
    value.bind(function (newval) {
      $(".all-bg").css("header_all_color", newval);
    });
  });

  // HEADER | Cart BG
  wp.customize("header_cart_color", function (value) {
    value.bind(function (newval) {
      $(".cart-bg").css("header_cart_color", newval);
    });
  });
  // HEADER | Cart Number BG
  wp.customize("header_cartNum_color", function (value) {
    value.bind(function (newval) {
      $(".cartNum-bg").css("header_cartNum_color", newval);
    });
  });
  // PRIMARY BUTTONS
  wp.customize("button_primary_color_link", function (value) {
    value.bind(function (newval) {
      $(".button-primary-button").css("button_primary_color_link", newval);
    });
  });
  wp.customize("button_primary_color_hover", function (value) {
    value.bind(function (newval) {
      $(".button-primary-button:hover").css(
        "button_primary_color_hover",
        newval
      );
    });
  });
  wp.customize("button_primary_text_link", function (value) {
    value.bind(function (newval) {
      $("a.button-primary-button").css("button_primary_text_link", newval);
    });
  });
  wp.customize("button_primary_text_hover", function (value) {
    value.bind(function (newval) {
      $("a.button-primary-button:hover").css(
        "button_primary_text_hover",
        newval
      );
    });
  });
  wp.customize("button_primary_color_stroke", function (value) {
    value.bind(function (newval) {
      $(".button-primary-button").css("button_primary_color_stroke", newval);
    });
  });
  wp.customize("button_primary_drop_control", function (value) {
    value.bind(function (newval) {
      $(".button-primary-button").css("button_primary_drop_control", newval);
    });
  });
  // SECONDARY BUTTONS
  wp.customize("button_secondary_color_link", function (value) {
    value.bind(function (newval) {
      $(".button-secondary-button").css("button_secondary_color_link", newval);
    });
  });
  wp.customize("button_secondary_color_hover", function (value) {
    value.bind(function (newval) {
      $(".button-secondary-button:hover").css(
        "button_secondary_color_hover",
        newval
      );
    });
  });
  wp.customize("button_secondary_text_link", function (value) {
    value.bind(function (newval) {
      $("a.button-secondary-button").css("button_secondary_text_link", newval);
    });
  });
  wp.customize("button_secondary_text_hover", function (value) {
    value.bind(function (newval) {
      $("a.button-secondary-button:hover").css(
        "button_secondary_text_hover",
        newval
      );
    });
  });
  wp.customize("button_secondary_color_stroke", function (value) {
    value.bind(function (newval) {
      $(".button-secondary-button").css(
        "button_secondary_color_stroke",
        newval
      );
    });
  });
  wp.customize("button_secondary_drop_control", function (value) {
    value.bind(function (newval) {
      $(".button-primary-button").css("button_secondary_drop_control", newval);
    });
  });
  // ADD TO CART BUTTONS
  wp.customize("button_addToCart_color_link", function (value) {
    value.bind(function (newval) {
      $(".button-addToCart-button").css("button_addToCart_color_link", newval);
    });
  });
  wp.customize("button_addToCart_color_hover", function (value) {
    value.bind(function (newval) {
      $(".button-addToCart-button:hover").css(
        "button_addToCart_color_hover",
        newval
      );
    });
  });
  wp.customize("button_addToCart_text_link", function (value) {
    value.bind(function (newval) {
      $("a.button-addToCart-button").css("button_addToCart_text_link", newval);
    });
  });
  wp.customize("button_addToCart_text_hover", function (value) {
    value.bind(function (newval) {
      $("a.button-addToCart-button:hover").css(
        "button_addToCart_text_hover",
        newval
      );
    });
  });
  wp.customize("button_addToCart_color_stroke", function (value) {
    value.bind(function (newval) {
      $(".button-addToCart-button").css(
        "button_addToCart_color_stroke",
        newval
      );
    });
  });
  wp.customize("button_addToCart_color_hover", function (value) {
    value.bind(function (newval) {
      $(".button-addToCart-button").css(
        "button_addToCart_color_hover",
        newval
      );
    });
  });
  wp.customize("button_addToCart_drop_control", function (value) {
    value.bind(function (newval) {
      $(".button-primary-button").css("button_addToCart_drop_control", newval);
    });
  });

  // FOOTER
  wp.customize("social_color_link", function (value) {
    value.bind(function (newval) {
      $("footer .social-links li a span:first-child:before").css(
        "social_color_link",
        newval
      );
    });
  });
  wp.customize("social_color_hover", function (value) {
    value.bind(function (newval) {
      $("footer .social-links li a:hover span:first-child:before").css(
        "social_color_hover",
        newval
      );
    });
  });
  wp.customize("footer_text_link", function (value) {
    value.bind(function (newval) {
      $("a.footer-text").css("footer_text_link", newval);
    });
  });
  wp.customize("footer_text_hover", function (value) {
    value.bind(function (newval) {
      $("a.footer-text:hover").css("footer_text_hover", newval);
    });
  });
  wp.customize("footer_background_color", function (value) {
    value.bind(function (newval) {
      $(".footer-text").css("footer_background_color", newval);
    });
  });

  // CHECKOUT BANNER
  wp.customize("checkout_banner_color", function (value) {
    value.bind(function (newval) {
      $(".checkout-banner").css("checkout_banner_color", newval);
    });
  });
})(jQuery);
