Skip to content

Instantly share code, notes, and snippets.

@Longkt
Created January 20, 2020 15:15
Show Gist options
  • Save Longkt/9052c50366841995f0e315f7dc81d4f8 to your computer and use it in GitHub Desktop.
Save Longkt/9052c50366841995f0e315f7dc81d4f8 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function(t){function e(){t(document.body).trigger("wc_toggle_done")}t.blockUI&&(t.blockUI.defaults.overlayCSS.backgroundColor="#FFF",t.blockUI.defaults.overlayCSS.opacity=.7),jQuery(document).on("selective-refresh-content-rendered",function(e,a){"Customify_Builder_Item_WC_Cart__render"!==a&&"customify_customize_render_header"!==a||t(document.body).trigger("wc_fragment_refresh")}),t(document.body).on("added_to_cart",function(e,a,c){t(".item--wc_cart").addClass("cart-active")}),Customify_JS.wc_open_cart&&t(document.body).trigger("added_to_cart"),t(document.body).on("wc_cart_button_updated",function(e,a){var c=a.parent();a.hasClass("single_add_to_cart_button")||t(".added_to_cart",c).addClass("button");var n=t(".add_to_cart_button",c).data("icon-pos")||"before",o=t(".add_to_cart_button",c).data("cart-icon")||"",i="",r="";o&&(r='<i class="'+o+'"></i>'),i="after"===n?r?wc_add_to_cart_params.i18n_view_cart+" "+r:wc_add_to_cart_params.i18n_view_cart:r?r+" "+wc_add_to_cart_params.i18n_view_cart:wc_add_to_cart_params.i18n_view_cart,t(".added_to_cart.wc-forward",c).html(i)}),t(document.body).on("hover",".item--wc_cart",function(){t(this).removeClass("cart-active")}),t(document.body).on("click",".wc-view-switcher .wc-view-mod",function(e){e.preventDefault();var a=t(this).data("mod")||"grid";t(".wc-view-switcher .wc-view-mod").removeClass("active"),t(this).addClass("active"),t(".woocommerce-listing, .products").removeClass("wc-grid-view wc-list-view"),t(".woocommerce-listing, .products").addClass("wc-"+a+"-view"),function(t,e,a){var c=new Date;c.setTime(c.getTime()+24*a*60*60*1e3);var n="expires="+c.toUTCString();document.cookie=t+"="+e+";"+n+";path=/"}("customify_wc_pl_view_mod",a,360)}),t.fn._wc_plus_minus=function(){return this.each(function(){var e=t(this);if(!(e.data("qty-added")||!1)){e.data("qty-added",1),e.wrap('<span class="input-qty-pm"></span>');var a=e.parent();e.attr("type","text"),a.append('<button type="button" class="input-pm-act input-pm-plus">+</button>'),a.prepend('<button type="button" class="input-pm-act input-pm-minus">-</button>'),t(".input-pm-plus",a).click(function(t){t.preventDefault();var a=parseInt(e.val());isNaN(a)?e.val(0):e.val(a+1),e.trigger("change")}),t(".input-pm-minus",a).click(function(t){t.preventDefault();var a=parseInt(e.val());!isNaN(a)&&a>0?e.val(a-1):e.val(0),e.trigger("change")})}}),this};var a=t(".wc-tabs-toggle");t(".tab-section",a).not(":eq(0)").removeClass("active").find(".tab-section-content").slideUp(e),a.on("click",".tab-section-heading",function(c){c.preventDefault();var n=t(this).closest(".tab-section");n.hasClass("active")?t(".tab-section",a).removeClass("active").find(".tab-section-content").slideUp(e):(t(".tab-section",a).removeClass("active").find(".tab-section-content").slideUp(e),n.toggleClass("active").find(".tab-section-content").slideDown(e))})});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment