(function(){
var __webpack_exports__={};
window.germanized=window.germanized||{};
(function ($, germanized){
germanized.cart_voucher={
params: {},
vouchers: {},
init: function (){
this.params=wc_gzd_cart_voucher_params;
this.vouchers=wc_gzd_cart_voucher_params.vouchers;
if($('.woocommerce-checkout').length){
this.manipulate_checkout_totals();
}
if($('.woocommerce-cart-form').length){
this.manipulate_cart_totals();
}
$(document.body).on('updated_cart_totals', this.manipulate_cart_totals);
$(document.body).on('updated_checkout', this.manipulate_checkout_totals);
$(document.body).on('applied_coupon', this.refresh_cart_vouchers);
$(document.body).on('removed_coupon', this.refresh_cart_vouchers);
},
refresh_cart_vouchers: function (){
var self=germanized.cart_voucher;
setTimeout(function (){
$.ajax({
type: 'POST',
url: self.params.wc_ajax_url.toString().replace('%%endpoint%%', 'gzd_refresh_cart_vouchers'),
data: {
security: self.params.refresh_cart_vouchers_nonce
},
success: function (data){
self.vouchers=data.vouchers;
self.manipulate_cart_totals();
},
dataType: 'json'
});
}, 75);
},
manipulate_checkout_totals: function (e, ajaxData){
var self=germanized.cart_voucher,
$table=$('.woocommerce-checkout #order_review table');
ajaxData=typeof ajaxData==='undefined' ? {}:ajaxData;
if(ajaxData.hasOwnProperty('fragments')&&ajaxData.fragments.hasOwnProperty('.gzd-vouchers')){
self.vouchers=ajaxData.fragments['.gzd-vouchers'];
}
if(!self.params.display_prices_including_tax){
self.move_vouchers_before_total_checkout();
}
self.manipulate_coupons($table);
},
manipulate_cart_totals: function (){
var $table=$('.cart_totals table'),
$total=$table.find('tr.order-total'),
self=germanized.cart_voucher;
if(!self.params.display_prices_including_tax){
self.move_vouchers_before_total($table, $total);
if($('.woocommerce-checkout').length){
self.move_vouchers_before_total_checkout();
}}
self.manipulate_coupons($table);
},
manipulate_coupons: function ($table){
var self=germanized.cart_voucher;
$.each(self.vouchers, function (voucherId, voucher){
var $coupon=self.get_voucher_coupon(voucher, $table),
$fee=self.get_voucher_fee(voucher, $table);
$coupon.hide();
if($fee.length > 0&&$coupon.length > 0){
var $remove_link=$coupon.find('a.woocommerce-remove-coupon');
if($remove_link.length > 0){
$fee.find('td:last').append(" ");
$fee.find('td:last').append($remove_link);
}}
});
},
move_vouchers_before_total_checkout: function (){
var $table=$('.woocommerce-checkout #order_review table'),
$total=$table.find('tr.order-total'),
self=germanized.cart_voucher;
self.move_vouchers_before_total($table, $total);
},
get_voucher_fee: function (voucher, $table){
var $fee=false;
$table.find('tr.fee').each(function (){
$tr=$(this);
var title=$tr.find('th').text();
var maybeVoucherTitle=title.substr(title.length - voucher.code.length);
if(maybeVoucherTitle===voucher.code){
$fee=$tr;
}});
if(!$fee){
$fee=$table.find('tr.fee th:contains("' + voucher.name + '")').parents('tr');
}
return $fee;
},
get_voucher_coupon: function (voucher, $table){
return $table.find('tr.' + voucher.coupon_class);
},
move_vouchers_before_total: function ($table, $total){
var self=germanized.cart_voucher;
$.each(self.vouchers, function (voucherId, voucher){
var $fee=self.get_voucher_fee(voucher, $table);
if($fee.length > 0){
$fee.insertBefore($total);
}});
}};
$(document).ready(function (){
germanized.cart_voucher.init();
});
})(jQuery, window.germanized);
((window.germanized=window.germanized||{})["static"]=window.germanized["static"]||{})["cart-voucher"]=__webpack_exports__;
})()
;
document.body.classList.contains("woocommerce-cart")||document.body.classList.contains("woocommerce-checkout")||window.innerWidth<768||!document.getElementById("site-header-cart")||window.addEventListener("load",function(){document.querySelector(".site-header-cart").addEventListener("mouseover",function(){var e=window.outerHeight,t=this.querySelector(".widget_shopping_cart_content").getBoundingClientRect().bottom+this.offsetHeight,o=this.querySelector(".cart_list");e<t&&(o.style.maxHeight="15em",o.style.overflowY="auto")})});
document.addEventListener("DOMContentLoaded",function(){if(0!==document.getElementsByClassName("storefront-handheld-footer-bar").length){[].forEach.call(document.querySelectorAll(".storefront-handheld-footer-bar .search > a"),function(t){t.addEventListener("click",function(e){t.parentElement.classList.toggle("active"),e.preventDefault()})});var t=document.getElementsByClassName("storefront-handheld-footer-bar"),n=document.forms,o=function(t){return function(e){t&&-1!==e.target.tabIndex?document.body.classList.add("sf-input-focused"):document.body.classList.remove("sf-input-focused")}};if(t.length&&n.length)for(let e=0;e<n.length;e++)t[0].contains(n[e])||(n[e].addEventListener("focus",o(!0),!0),n[e].addEventListener("blur",o(!1),!0))}});
document.addEventListener("DOMContentLoaded",function(){let i=document.getElementsByClassName("brands_index");if(i.length){let n=document.body.classList.contains("admin-bar")?32:0,t=document.getElementById("brands_a_z").scrollHeight,e=i[0].scrollHeight+40,d=function(){768<window.innerWidth&&i[0].getBoundingClientRect().top<0?i[0].style.paddingTop=Math.min(Math.abs(i[0].getBoundingClientRect().top)+20+n,t-e)+"px":i[0].style.paddingTop=0};d(),window.addEventListener("scroll",function(){d()})}});