var VPC_CONFIG=(function ($, vpc_config){
'use strict';
var canvases=window.__canvases={};
var canvasViews=window._canvasViews=[];
window.is_init=false;
window.initialise_merge_canvas=function (){
if(typeof vpc!='undefined'){
var _width=vpc.images_sizes.width;
var _height=vpc.images_sizes.height;
if(vpc.views){
var all_canvases="";
var activeViews=JSON.parse(active_views);
if(typeof (activeViews)!=='undefined'){
$.each(activeViews, function (key, view){
all_canvases +='<canvas id="merged_imgs_' + key + '" class="ViewsCanvas" style="" width="' + _width + '" height="' + _height + '" data-view-key="' + key + '"></canvas>';
});
$('#vpc_preview_wrapper').html(all_canvases);
}}else{
$('#vpc_preview_wrapper').html('<canvas id="merged_imgs" style="" class="ViewsCanvas" width="' + _width + '" height="' + _height + '"></canvas>');
}
$('canvas.ViewsCanvas').each(function (){
var fabricCanvasObj=window._canvas=new fabric.Canvas(this, {enableRetinaScaling: false});
fabricCanvasObj.setDimensions({
width: _width,
height: _height,
}, {backstoreOnly: true});
if(typeof $(this).data('view-key')!=='undefined'&&$(this).data('view-key')!==''){
canvasViews[$(this).data('view-key')]=fabricCanvasObj;
}else{
canvasViews.push(fabricCanvasObj);
}
fabricCanvasObj.renderAll();
});
}}
$(document).ready(function (){
var load_page=setInterval(function (){
if(!is_init){
clearInterval(load_page);
initialise_merge_canvas();
vpc_onload_content();
is_init=true;
}}, 200);
$(window).bind('orientationchange', function (event){
setTimeout(function (){
var canvas_data=get_canvas_data(canvases);
for (const [key, value] of Object.entries(canvases)){
$('#wrapper_' + key).remove();
for (const [data_key, data_value] of Object.entries(canvas_data[key])){
for (const[_dt_key, _dt_value] of Object.entries(data_value)){
window._all_texts[data_key][_dt_key]=_dt_value;
}}
}
canvases=window.__canvases={};
canvasViews=window._canvasViews=[];
initialise_merge_canvas();
vpc_onload_content();
}, 400);
});
window.vpc_onload_content=function (){
if(typeof vpc!="undefined"&&vpc!=null){
var build_preview_canvas_process=wp.hooks.applyFilters('vpc.build_preview_canvas_process', true);
if(build_preview_canvas_process){
if(typeof (active_views)!=='undefined'){
var activeViews=JSON.parse(active_views);
}
var multi_views=false;
if(typeof (vpc.config)!=='undefined'){
$.each(vpc.config, function (config_key, config_value){
if(config_key==='multi-views'&&config_value==='Yes'){
multi_views=true;
}});
}
var z_index=1;
if(typeof (vpc.config)!=='undefined'&&typeof (vpc.config.components)!=='undefined'){
$.each(vpc.config.components, function (key, component){
if(typeof (component)!=='undefined'){
$.each(component, function (ind, val){
if(ind==='c_index'){
if(val!==''&&val >=z_index){
z_index=val;
}}
});
}});
}
var all_canvases_id={};
if($('[id^="userfile_upload_form"]').length > 0||$('[id$="-field"]').length > 0){
if($('[id^="userfile_upload_form"]').length > 0){
$('[id^="userfile_upload_form"]').each(function (){
if(multi_views){
var key=$(this).data('key');
if(typeof key!=='undefined'){
all_canvases_id[key]=$(this).data('canvas-id');
}}else{
all_canvases_id[0]=$(this).data('canvas-id');
}});
}
if($('[id$="-field"]').length > 0){
$('[id$="-field"]').each(function (){
if(multi_views){
var key=$(this).data('key');
if(typeof key!=='undefined'){
all_canvases_id[key]=$(this).data('canvas-id');
}}else{
all_canvases_id[0]=$(this).data('canvas-id');
}});
}}else{
if(multi_views){
$.each(activeViews, function (key, view){
all_canvases_id[key]='text_and_upload_panel_' + key;
});
}else{
all_canvases_id[0]='text_and_upload_panel';
}}
vpc_set_text_and_upload_canvases(multi_views, z_index, all_canvases_id);
}else{
wp.hooks.doAction('vpc.build_preview_canvas_process');
}}
}
$('#vpc-container').append('<div id="vpc_preview_wrapper" class="" style="position: absolute;"></div>');
function init_onload(){
initialise_merge_canvas();
var intvl=setInterval(vpc_loading_check, 200);
function vpc_loading_check(){
if(($(".vpc-options input:checked").length||$(".vpc-options select option:selected").length)
&& ($("#vpc-preview img").length||$(".vpc-preview img").length)){
clearInterval(intvl);
$('#vpc-preview img, .vpc-preview img').oImageLoad(function (){
var time=0;
var interval=setInterval(function (){
time=time + .5;
if(($(".vpc-selected-icon img").length&&$(".vpc-selected-icon img").attr('src').length!==0)||time==3){
clearInterval(interval);
$("#vpc-loader-container").addClass("fadeOut");
}}, 500);
});
}
if(!$(".vpc-options input:checked").length&&!$(".vpc-options select option:selected").length){
clearInterval(intvl);
$("#vpc-loader-container").addClass("fadeOut");
}
if(($(".vpc-options input:checked").length||$(".vpc-options select option:selected").length)
&& (!$("#vpc-preview img").length&&!$(".vpc-preview img").length)){
clearInterval(intvl);
$("#vpc-loader-container").addClass("fadeOut");
}}
}
setTimeout(function (){
init_onload();
}, 100);
var new_variation_attributes="";
if(typeof vpc!='undefined'){
accounting.settings={
currency: {
symbol: vpc.currency,
format: vpc.price_format,
decimal: vpc.decimal_separator,
thousand: vpc.thousand_separator,
precision: vpc.decimals
},
number: {
precision: vpc.decimals,
thousand: vpc.thousand_separator,
decimal: vpc.decimal_separator
}}
$.each(vpc.body_classes, function (key, value){
$("body").addClass(value);
});
}
if(typeof wc_cart_fragments_params!='undefined'){
var $fragment_refresh={
url: wc_cart_fragments_params.wc_ajax_url.toString().replace('%%endpoint%%', 'get_refreshed_fragments'),
type: 'POST',
success: function (data){
if(data&&data.fragments){
$.each(data.fragments, function (key, value){
$(key).replaceWith(value);
});
$(document.body).trigger('wc_fragments_refreshed');
}}
};}
function vpc_set_text_and_upload_canvases(multi_views, z_index, all_canvases_id){
if(multi_views){
if(typeof (active_views)!=='undefined'){
var activeViews=JSON.parse(active_views);
}
if(typeof (activeViews)!=='undefined'){
$.each(activeViews, function (key, view){
var canvas_id=all_canvases_id[key];
if(typeof canvas_id!=='undefined'){
var view_preview=setInterval(function (){
if($('#preview_' + view).not(".bx-clone").find('#vpc-preview' + key + ' img').length!==0&&$('#wrapper_' + canvas_id).length===0){
clearInterval(view_preview);
var this_preview=$('#preview_' + view).not(".bx-clone").find('#vpc-preview' + key + ' img');
var image_load=setInterval(function (){
var image=new Image();
image.onload=function (){
var global_width=this_preview[0].clientWidth;
var global_height=this_preview[0].clientHeight;
if($('[id^="userfile_upload_form"]').length > 0||$('[id$="-field"]').length > 0){
$('#preview_' + view).not(".bx-clone").prepend('<div id="wrapper_' + canvas_id + '" class="" style="z-index:' + z_index + ';"><canvas id="' + canvas_id + '" width="' + global_width + '" height="' + global_height + '"></canvas></div>');
}else{
$('#preview_' + view).not(".bx-clone").prepend('<div id="wrapper_' + canvas_id + '" class="" style="z-index:' + z_index + ';display:none;"><canvas id="' + canvas_id + '" width="' + global_width + '" height="' + global_height + '"></canvas></div>');
}
canvases[canvas_id]=new fabric.Canvas(canvas_id, {enableRetinaScaling: false});
var natural_width=$('#preview_' + view).not(".bx-clone").find('#vpc-preview' + key + ' img')[0].naturalWidth;
var natural_height=$('#preview_' + view).not(".bx-clone").find('#vpc-preview' + key + ' img')[0].naturalHeight;
canvases[canvas_id].setDimensions({
width: natural_width,
height: natural_height,
}, {backstoreOnly: true});
canvases[canvas_id]=wp.hooks.applyFilters('vpc.after_creating_canvas', canvases[canvas_id], canvas_id, multi_views, z_index, key, view);
clearInterval(image_load);
}
image.onerror=function (){
console.error("Cannot load image");
}
image.src=$('#preview_' + view).not(".bx-clone").find('#vpc-preview' + key + ' img').attr('src')
},100);
}});
}});
}}else{
var canvas_id=all_canvases_id[0];
var vpc_preview=setInterval(function (){
if($('#vpc-preview img').length!==0&&$('#wrapper_' + canvas_id).length===0){
clearInterval(vpc_preview);
if($('.vpc-global-preview').length===0){
$('#vpc-preview').before('<div class="vpc-global-preview"></div>');
$('.vpc-global-preview').html($('#vpc-preview'));
}
var global_width=$("#vpc-preview img")[0].clientWidth;
var global_height=$("#vpc-preview img")[0].clientHeight;
var set_dimension=setInterval(function (){
global_width=$("#vpc-preview img")[0].clientWidth;
global_height=$("#vpc-preview img")[0].clientHeight;
if(global_width!=0){
clearInterval(set_dimension);
if($('[id^="userfile_upload_form"]').length > 0||$('[id$="-field"]').length > 0){
$('.vpc-global-preview').prepend('<div id="wrapper_' + canvas_id + '" class="" style="z-index:' + z_index + ';"><canvas id="' + canvas_id + '" width="' + global_width + '" height="' + global_height + '"></canvas></div>');
}else{
$('.vpc-global-preview').prepend('<div id="wrapper_' + canvas_id + '" class="" style="z-index:' + z_index + ';display:none;"><canvas id="' + canvas_id + '" width="' + global_width + '" height="' + global_height + '"></canvas></div>');
}
canvases[canvas_id]=new fabric.Canvas(canvas_id, {enableRetinaScaling: false});
var natural_width=$('#vpc-preview img')[0].naturalWidth;
var natural_height=$('#vpc-preview img')[0].naturalHeight;
canvases[canvas_id].setDimensions({
width: natural_width,
height: natural_height,
}, {backstoreOnly: true});
canvases[canvas_id]=wp.hooks.applyFilters('vpc.after_creating_canvas', canvases[canvas_id], canvas_id, multi_views, z_index, '', '');
}}, 200);
}});
}}
window.vpc_oriontip=function (){
$("[data-oriontip]").oriontip();
}
window.vpc_build_preview=function (){
if(typeof vpc=='undefined'||(!$("#vpc-add-to-cart").length))
return;
if($("#vpc-add-to-cart").data("price")){
if(vpc.decimal_separator==',')
var total_price=parseFloat($("#vpc-add-to-cart").data("price").toString().replace(',', '.'));
else
var total_price=parseFloat($("#vpc-add-to-cart").data("price"));
}
var form_data=$('form.formbuilt').serializeJSON();
var form_price=get_form_total('#vpc-container form.formbuilt', form_data);
var total_option_price=0;
var configurator_array=[];
if(!total_price)
total_price=0;
wp.hooks.doAction('vpc.before_preview_builder', selected_items_selector, total_price);
var selected_items_selector=wp.hooks.applyFilters('vpc.items_selected', vpc.vpc_selected_items_selector);
var default_preview_builder_process=wp.hooks.applyFilters('vpc.default_preview_builder_process', true);
if(default_preview_builder_process){
$("#vpc-preview").html("");
var i=0;
$(selected_items_selector).each(function (){
var component_id=$(this).attr('data-component-id');
var src=$(this).data("img");
if($(this).data("img-alt")!=""&&$(this).data("img-alt")!='undefined'){
var alt=$(this).data("img-alt");
}else{
var alt=$(this).val() + " image";
}
var option_price=$(this).attr("data-price");
if(option_price)
total_option_price +=parseFloat(option_price);
if(src){
$("#vpc-preview").append("<img src='" + src + "' alt='" + alt + "' style='z-index:" + $(this).data("index") + "' data-component-id='" + component_id + "'>");
configurator_array.push(src);
}});
total_price +=total_option_price;
total_price +=form_price;
total_price=wp.hooks.applyFilters('vpc.total_price', total_price);
var vpc_qty=$('#vpc-qty').val();
total_price *=vpc_qty;
$("#vpc-price").html(accounting.formatMoney(total_price));
wp.hooks.doAction('vpc.after_preview_builder', selected_items_selector, total_price);
} else
wp.hooks.doAction('vpc.default_preview_builder_process', selected_items_selector);
}
window.vpc_apply_rules=function (selector){
if(typeof vpc=='undefined')
return;
if(typeof selector=="undefined")
selector=vpc.vpc_selected_items_selector;
var check_selections=false;
$(selector).each(function (i, e){
var item_id=$(this).attr("id");
var rules_triggered_by_item=vpc.wvpc_conditional_rules[item_id];
if(typeof rules_triggered_by_item=='undefined')
return true;
$.each(rules_triggered_by_item, function (index, groups_arr){
$.each(groups_arr, function (group_index, rules_groups){
var group_verified=true;
$.each(rules_groups.rules, function (rule_index, rule){
if(typeof rules_groups.conditions_relationship=="undefined")
rules_groups.conditions_relationship="and";
var is_selected=$(".vpc-options input[data-oid='" + rule.option + "']").is(':checked');
if(!is_selected)
is_selected=$(".vpc-options input[data-oid='" + rule.option + "']").is(':checked');
if($("option#" + rule.option).length){
is_selected=$("option#" + rule.option).is(':selected');
}
is_selected=wp.hooks.applyFilters('vpc.is_option_selected', is_selected, rule.option);
if(rules_groups.conditions_relationship=="or"&&((rule.trigger=="on_selection"&&is_selected)||(rule.trigger=="on_deselection"&&!is_selected))){
group_verified=true;
return false;
}
else if(rules_groups.conditions_relationship=="or"){
group_verified=false;
}else if(rules_groups.conditions_relationship=="and"&&((rule.trigger=="on_selection"&&!is_selected)||(rule.trigger=="on_deselection"&&is_selected))){
group_verified=false;
return false;
}});
if(group_verified){
if(rules_groups.result.action=="hide"){
check_selections=true;
hide_options_or_component(rules_groups);
}else if(rules_groups.result.action=="show"){
check_selections=true;
show_options_or_component(rules_groups);
}else if(rules_groups.result.action=="select"){
check_selections=true;
select_options_or_component(rules_groups);
}}else if(rules_groups.apply_reverse=="on"){
if(rules_groups.result.action=="hide"){
check_selections=true;
show_options_or_component(rules_groups);
}else if(rules_groups.result.action=="show"){
check_selections=true;
hide_options_or_component(rules_groups);
}else if(rules_groups.result.action=="select"){
check_selections=true;
unselect_options_or_component(rules_groups);
}}
});
});
});
if(check_selections)
vpc_build_preview();
}
window.vpc_load_options=function (){
if(typeof vpc!=='undefined'){
setTimeout(function (){
$(vpc.reverse_triggers).each(function (i, e){
vpc_apply_rules("#" + e);
});
$(vpc.vpc_selected_items_selector).each(function (){
$(this).trigger('change');
});
}, 2000);
}}
$(document).on('click', '#vpc-qty-container .plus, #vpc-qty-container .minus', function (){
var $qty=$("#vpc-qty");
var currentVal=parseFloat($qty.val());
var max=parseFloat($qty.attr('max'));
var min=parseFloat($qty.attr('min'));
var step=$qty.attr('step');
if(!currentVal||currentVal===''||currentVal==='NaN')
currentVal=0;
if(max===''||max==='NaN')
max='';
if(min===''||min==='NaN')
min=0;
if(step==='any'||step===''||step===undefined||parseFloat(step)==='NaN')
step=1;
if($(this).is('.plus')){
if(max&&(max==currentVal||currentVal > max)){
$qty.val(max).trigger('change');
}else{
$qty.val(currentVal + parseFloat(step)).trigger('change');
}}else{
if(min&&(min==currentVal||currentVal < min)){
$qty.val(min).trigger('change');
}else if(currentVal > 0){
$qty.val(currentVal - parseFloat(step)).trigger('change');
}}
});
$(document).on('change', '#vpc-qty', function (){
window.vpc_build_preview();
});
window.after_add_to_cart_ajax_result=function (data){
$("#debug").html(data);
$.ajax($fragment_refresh);
switch (vpc.action_after_add_to_cart){
case 'refresh':
setTimeout(function (){
window.location.reload(true);
}, 50);
break;
case 'redirect':
window.location.href=vpc.cart_url;
break;
case 'redirect_to_product_page':
window.location.href=vpc.current_product_page;
break;
default:
break;
}
$('#vpc-add-to-cart').removeClass('disabledClick');
$('#vpc-add-to-cart').addClass('add-to-cart-button-text-color');
wp.hooks.doAction('vpc.after_add_to_cart', data);
}
$(document).on('click', '#vpc-add-to-cart', function (){
var form_data={};
var div=get_vpc_div_capture();
var product_id=$(this).data("pid");
var alt_products=[];
$('#vpc-container input:checked,#vpc-container option:selected').each(function (i){
if($(this).data("product")){
if($.inArray($(this).data("product"), alt_products)===-1){
alt_products.push($(this).data("product"));
}}
});
alt_products=wp.hooks.applyFilters('vpc.filter_alt_products', alt_products);
var quantity=$("#vpc-qty").val();
var recap=$('#vpc-container').find(':input').serializeJSON();
recap=wp.hooks.applyFilters('vpc.filter_recap', recap);
if(recap.id_ofb)
delete recap.id_ofb;
var custom_vars={};
if(typeof vpc.query_vars["edit"]!=='undefined')
custom_vars["item_key"]=vpc.query_vars["edit"];
custom_vars=wp.hooks.applyFilters('vpc.custom_vars', custom_vars);
if(vpc.isOfb===true){
var form_is_valid=$('form.formbuilt').validationEngine('validate', {showArrow: false});
if(form_is_valid){
form_data=$('form.formbuilt').serializeJSON();
var process=wp.hooks.applyFilters('vpc.proceed_default_add_to_cart', true);
}} else
var process=wp.hooks.applyFilters('vpc.proceed_default_add_to_cart', true);
if(process){
$('#vpc-add-to-cart').removeClass('add-to-cart-button-text-color');
$('#vpc-add-to-cart').addClass('disabledClick');
if(vpc.views){
var multiview=true;
var imgs=get_finish_image_by_view(vpc.vpc_selected_items_selector);
}else{
var multiview=false;
var imgs=get_finish_image(vpc.vpc_selected_items_selector);
}
merge_all_images_of_preview(imgs).then(function (status){
if(status==='completed'){
setTimeout(function (){
var canvas_data={};
if(typeof window.__canvases!=='undefined'&&window.__canvases.length!==0){
add_custom_texts_and_uploads_datas_on_canvas();
var canvases=window.__canvases;
canvas_data=get_canvas_data(canvases);
recap['canvas_data']=JSON.stringify(canvas_data);
}
custom_vars['preview_imgs_merged']=JSON.stringify(generate_canvas_images());
var data_object={
action: "add_vpc_configuration_to_cart",
product_id: product_id,
alt_products: alt_products,
quantity: quantity,
multiview: multiview,
imgs_by_views: imgs,
recap: JSON.stringify(recap),
custom_vars: custom_vars,
form_data: form_data
};
$.ajax({
type: 'POST',
url: ajax_object.ajax_url,
data: data_object,
success: function (data){
nb_images=0;
after_add_to_cart_ajax_result(data);
}});
}, 200 * nb_images);
}});
} else
wp.hooks.doAction('vpc.proceed_default_add_to_cart', custom_vars);
});
window.get_canvas_data=function (canvases){
var continue_process=wp.hooks.applyFilters('vpc.get_canvas_data_process', true);
if(continue_process){
var canvas_data={};
$.each(canvases, function (key, val){
canvas_data[key]={};
var my_objects=val.toJSON(['id', 'name', 'sanitized_name', 'color_name']).objects;
val.getObjects().map(function (data, index){
canvas_data[key][data.id]=my_objects[index];
if(typeof data.type!=='undefined'&&(data.type==='group'||data.type==='textbox'||data.type==='text')){
canvas_data[key][data.id]['text_component_id']=vpc.text_component_data[data.sanitized_name + '-field'];
var text="";
if(data.type==="text"||data.type==='textbox'){
text=canvas_data[key][data.id]['text'];
}else if(data.type==="group"){
text=canvas_data[key][data.id]['objects'][1]['text'];
}
if(typeof text!=='undefined'&&text!==''&&text.split('\n').length > 1){
var text_value='';
$.each(text.split('\n'), function (ind, value){
if(ind===0){
text_value +=value;
}else{
text_value +='|||' + value;
}});
if(data.type==="text"||data.type==='textbox'){
canvas_data[key][data.id]['text']=text_value;
}else if(data.type==="group"){
canvas_data[key][data.id]['objects'][1]['text']=text_value;
}}
if(typeof text!=='undefined'&&text!==''&&text.split('\"').length > 1){
var text_value='';
$.each(text.split('\"'), function (ind, value){
if(ind===0){
text_value +=value;
}else{
text_value +='@' + value;
}});
if(data.type==="text"||data.type==='textbox'){
canvas_data[key][data.id]['text']=text_value;
}else if(data.type==="group"){
canvas_data[key][data.id]['objects'][1]['text']=text_value;
}}
}else if(typeof data.type!=='undefined'&&data.type==='image'){
canvas_data[key][data.id]['upload_component_id']=vpc.upload_component_data[data.sanitized_name + '-field'];
}});
});
canvas_data=wp.hooks.applyFilters('vpc.get_canvas_data', canvas_data, canvases);
return canvas_data;
}else{
wp.hooks.doAction('vpc.get_canvas_data_process', canvases);
}}
window.get_finish_image_by_view=function (items){
var decoded_active_views=JSON.parse(active_views);
var imgs_by_view=[];
var i=0;
$.each(decoded_active_views, function (index, value){
var items_view_selected=[];
var id="#vpc-preview" + i;
$(items).each(function (){
var ind;
if($(this).attr("data-index"))
ind=$(this).attr("data-index");
else
ind=1;
if(typeof $(this).attr("data-" + value)!=='undefined'){
if(typeof (items_view_selected[ind])!=='undefined'){
var arr=items_view_selected[ind];
arr.push($(this).attr("data-" + value));
items_view_selected[ind]=arr;
}else{
var new_arr=[];
new_arr.push($(this).attr("data-" + value));
items_view_selected[ind]=new_arr;
}}
});
var items_view=[index, items_view_selected];
imgs_by_view.push(items_view);
i++;
});
return imgs_by_view;
}
window.get_finish_image=function (items){
var items_selected_imgs=[];
$(items).each(function (index){
var ind;
if($(this).attr("data-index"))
ind=$(this).attr("data-index");
else
ind=1;
if(typeof $(this).attr("data-img")!=='undefined'){
if(typeof (items_selected_imgs[ind])!=='undefined'){
var arr=items_selected_imgs[ind];
arr.push($(this).attr("data-img"));
items_selected_imgs[ind]=arr;
}else{
var new_arr=[];
new_arr.push($(this).attr("data-img"));
items_selected_imgs[ind]=new_arr;
}}
});
return items_selected_imgs;
}
function vpc_add_product_attributes_to_btn(){
var attributes={};
var options=$("select[name^='attribute_']");
var product_id=$("[name='variation_id']").val();
var new_options={};
$.each(options, function (){
var option_name=$(this).attr("name");
new_options[option_name]=$(this).find("option:selected").val();
});
attributes[product_id]=new_options;
return attributes;
}
$(".single_variation_wrap").on("show_variation", function (event, variation){
var variation_id=$("input[name='variation_id']").val();
if(variation_id){
new_variation_attributes=vpc_add_product_attributes_to_btn();
$("select[name^='attribute_']").on('change', function (){
new_variation_attributes=vpc_add_product_attributes_to_btn();
});
$(".vpc-configure-button").hide();
$(".vpc-configure-button[data-id='" + variation_id + "']").show();
}});
function get_vpc_div_capture(){
var div;
if(vpc.views){
var target=$(".vpc-preview:not(.bx-clone)");
target.each(function (){
var target_id=$(this).attr('id');
div=$("#" + target_id + ":not(.bx-clone)")[0];
return false;
});
}else{
if($(".vpc-global-preview").length > 0)
div=$(".vpc-global-preview")[0];
else
div=$("#vpc-preview")[0];
}
return div;
}
function hide_options_or_component(rules_groups){
if(rules_groups.result.scope=="component"&&($("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").not("[style*='display: none;']").length)){
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").hide();
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find('input:checked').removeAttr('checked').trigger('change');
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find('input:checked').prop('checked',false).trigger('change');
}else if(rules_groups.result.scope=="option"&&$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").not("[style*='display: none;']").length){
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").hide();
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "'] input:checked").removeAttr('checked').trigger('change');
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "'] input:checked").prop('checked',false).trigger('change');
if(!$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").parents(".vpc-options").find(".vpc-single-option-wrap").not("[style*='display: none;']").find("input:checked").length&&vpc.select_first_elt=="Yes")
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").parents(".vpc-options").find(".vpc-single-option-wrap").not("[style*='display: none;']").find("input").first().prop("checked", true).trigger("change");
}else if(rules_groups.result.scope=="groups"&&$(".vpc-options div.vpc-group div.vpc-group-name").not("[style*='display: none;']").length){
$.each($(".vpc-options div.vpc-group div.vpc-group-name"), function (){
if($(this).html()==rules_groups.result.apply_on)
$(this).parent().hide();
});
}else if(rules_groups.result.scope=="group_per_component"){
var split_apply_value=rules_groups.result.apply_on.split('>');
var component=split_apply_value[0];
var group=split_apply_value[1];
$.each($('#' + component + ' .vpc-options .vpc-group .vpc-group-name'), function (){
if($(this).html()==group&&$(this).not("[style*='display: none;']").length){
$(this).parent().hide();
if($(this).parent().find("input:checked").length)
$(this).parent().find("input").removeAttr('checked').trigger('change');
else if($(this).parent().find("select option:selected").length)
$(this).parent().find("select option:selected").prop("selected", false);
$(this).parents('.vpc-component').find('.vpc-selected').html("");
}});
}
if(rules_groups.result.scope=="option"&&$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").not(":disabled").length){
$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").prop('disabled', true).trigger('change');
var next_val=$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").siblings("option").not(":disabled").first().val();
if($(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").siblings("option").not(":disabled").length){
$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").siblings("option").not(":disabled").each(function (){
if($(this).is(':selected')){
next_val=$(this).val();
}})
}
$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").parent("select").val(next_val).trigger("change");
}else if(rules_groups.result.scope=="component"&&($("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find("select").length)){
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find(".vpc-options select > option:selected").prop('selected', false);
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find("select").prop('disabled', true);
}
wp.hooks.doAction('vpc.hide_options_or_component', rules_groups);
}
function show_options_or_component(rules_groups){
if(rules_groups.result.scope=="component"&&$("#vpc-container div.vpc-component[data-component_id='" + rules_groups.result.apply_on + "'][style*='display: none;']").length){
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").show();
if($("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find('.vpc-options select').length){
if($("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find(".vpc-options select > option[selected]").length){
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find(".vpc-options select > option[selected]").prop("selected", true).trigger("change");
}else if((!$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").parents(".vpc-options").find("select").not("[style*='display: none;']").find("option:selected").length)&&vpc.select_first_elt=="Yes"){
var first=$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find(".vpc-options select > option").first();
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find(".vpc-options select").select(first);
}}else{
if($("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find(".vpc-options input[data-default]").length){
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find(".vpc-options input[data-default]").prop("checked", true).trigger("change");
}else if((!$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").parents(".vpc-options").find(".vpc-single-option-wrap").not("[style*='display: none;']").find("input:checked").length)&&vpc.select_first_elt=="Yes"){
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find(".vpc-options input").first().click();
}}
}else if(rules_groups.result.scope=="option"&&$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "'][style*='display: none;']").length){
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").show();
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").parents(".vpc-options").find('input:checked').removeAttr('checked').trigger('change');
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").find('input').prop("checked", true).trigger("change");
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").find('input').click();
}else if(rules_groups.result.scope=="groups"&&$(".vpc-options div.vpc-group[style*='display: none;']").length){
$.each($(".vpc-options div.vpc-group div.vpc-group-name"), function (){
if($(this).html()==rules_groups.result.apply_on){
$(this).parent().show();
$(this).parents(".vpc-options").find("input").first().click();
}});
}else if(rules_groups.result.scope=="group_per_component"){
var split_apply_value=rules_groups.result.apply_on.split('>');
var component=split_apply_value[0];
var group=split_apply_value[1];
$.each($('#' + component + ' .vpc-options .vpc-group .vpc-group-name'), function (){
if($(this).html()==group){
$(this).parent().show();
if(!$(this).parents(".vpc-options").find("input:checked").length&&vpc.select_first_elt=="Yes"){
$(this).parent().find("input").first().click()
}else if(!$(this).parents(".vpc-options").find("input:checked").length&&vpc.select_first_elt=="No"){
$(this).parent().find("input[data-default=1]").click()
}
if($(this).parent().find("select option:eq(1)").length){
}}
});
}
if(rules_groups.result.scope=="option"&&$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']:disabled").length){
$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").prop('disabled', false);
}else if(rules_groups.result.scope=="component"&&($("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find("select").length)){
$("#vpc-container div.vpc-component[data-component_id=" + rules_groups.result.apply_on + "]").find("select").prop('disabled', false);
}
wp.hooks.doAction('vpc.show_options_or_component', rules_groups);
}
function select_options_or_component(rules_groups){
if(rules_groups.result.scope=="option"&&$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").length){
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").show();
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']>input").prop('checked', true).trigger('change');
}else if(rules_groups.result.scope=="option"&&$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").length){
$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").show();
$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").prop('selected', true);
var option_value=$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").val();
$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").parents('.vpc-component').find('.vpc-component-header .txt').html(option_value);
}
wp.hooks.doAction('vpc.select_options_or_component', rules_groups);
}
function unselect_options_or_component(rules_groups){
if(rules_groups.result.scope=="option"&&$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']").not("[style*='display: none;']").length){
$(".vpc-options div[data-oid='" + rules_groups.result.apply_on + "']>input").prop('checked', false).trigger('change');
}else if(rules_groups.result.scope=="option"&&$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").not("[style*='display: none;']").length){
$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").prop('selected', false);
var option_value='none';
if($(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").parents('select').find('option:selected').val().length){
option_value=$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").parents('select').find('option:selected').val();
}
$(".vpc-options option[data-oid='" + rules_groups.result.apply_on + "']").parents('.vpc-component').find('.vpc-component-header .txt').html(option_value);
}
wp.hooks.doAction('vpc.hide_options_or_component', rules_groups);
}
if($("#vpc-ajax-container").length){
$.post(ajax_object.ajax_url,
{
action: "get_vpc_editor",
vpc: vpc,
},
function (data){
vpc_load_options();
removeEmptyImage();
wp.hooks.doAction('vpc.ajax_loading_complete');
/* $("#vpc-ajax-container").append(data);
setTimeout(function(){
vpc_ds_load_tooltips();
$('#vpc-ajax-loader-container').hide();
},2000);*/
$("#vpc-ajax-container").append(data).promise().done(function (){
vpc_oriontip();
$('#vpc-ajax-loader-container').hide();
});
});
}
$(document).on("click", ".cart .vpc-configure-button", function (e){
e.preventDefault();
var product_id=$(this).attr('data-id');
var qty=$(this).parent().find("input[name='quantity']").val();
if(!qty)
qty=1;
var process=wp.hooks.applyFilters('vpc.proceed_default_build_your_own', true);
if(process){
$.post(ajax_object.ajax_url,
{
action: "get_vpc_product_qty",
prod_id: product_id,
qty: qty,
new_variation_attributes: new_variation_attributes
},
function (data){
window.location=data;
});
}else{
wp.hooks.doAction('vpc.proceed_default_build_your_own', product_id, qty);
}});
var global_previously_selected="";
$(document).on("change", ".vpc-options select", function (e){
vpc_build_preview();
vpc_apply_rules();
var img=$(this).find("option:selected").data('img');
var val=$(this).val();
var id=$(this).attr("id");
$(this).parents('.vpc-component').find('.vpc-selected-icon img').attr('src', img);
$(this).parents('.vpc-component').find('.vpc-selected').html(val);
if(global_previously_selected&&id!=global_previously_selected){
vpc_apply_rules("#" + global_previously_selected);
}}).on('click', ".vpc-options select", function (e){
global_previously_selected=$(this).find("option:selected").attr('id');
});
$(document).on("change", ".vpc-options select>option", function (e){
$(this).parent().trigger("change");
});
$(document).on("change", ".vpc-options input", function (e){
$('.vpc-component-header > span.vpc-selected-icon img[src=""]').hide();
$('.vpc-component-header > span.vpc-selected-icon img:not([src=""])').show();
});
$(document).on("change", 'form.formbuilt input', function (e){
window.vpc_build_preview();
});
$(document).on("change", 'form.formbuilt textarea', function (e){
window.vpc_build_preview();
});
$(document).on("change", 'form.formbuilt select', function (e){
window.vpc_build_preview();
});
window.get_form_total=function (form_id, fields){
var total_price=0;
$(form_id).find('[name]').each(function (index, value){
var that=$(this),
name=that.attr('name'),
type=that.prop('type');
if(type=='select-one'){
$(that).find('[value]').each(function (index, value){
var option=$(this);
var price=option.attr('data-price');
var value=option.attr('value');
for (var i in fields){
if(name==i&&value==fields[i]){
if(undefined!==price&&''!==price){
total_price +=parseFloat(price);
}}
}});
}else if(type=='radio'){
var price=that.attr('data-price');
for (var i in fields){
if(name==i){
if(typeof (fields[i])=='object'){
var options=fields[i];
for (var j in options){
if(value.value==options[j]){
if(undefined!==price&&''!==price){
total_price +=parseFloat(price);
}}
}}else{
if(value.value==fields[i]){
if(undefined!==price&&''!==price){
total_price +=parseFloat(price);
}}
}}
}}else if(type=='checkbox'){
var price=that.attr('data-price');
for (var i in fields){
if(name==i + '[]'){
if(typeof (fields[i])=='object'){
var options=fields[i];
for (var j in options){
if(value.value==options[j]){
if(undefined!==price&&''!==price){
total_price +=parseFloat(price);
}}
}}else{
if(value.value==fields[i]){
if(undefined!==price&&''!==price){
total_price +=parseFloat(price);
}}
}}else{
if(value.value==fields[i]){
if(undefined!==price&&''!==price){
total_price +=parseFloat(price);
}}
}}
}else if(type=='file'){
var price=that.attr('data-price');
var file=that.prop('files');
var files=get_files_in_ofb();
if(file[0]){
for (var i in files){
if(name==i){
if(undefined!==price&&''!==price){
total_price +=parseFloat(price);
}}
}}
}else{
var price=that.attr('data-price');
var value=that.val();
if(value.length > 0){
for (var i in fields){
if(name==i){
if(undefined!==price&&''!==price){
total_price +=parseFloat(price);
}}
}}
}});
return total_price;
}
window.get_files_in_ofb=function (){
var files=[];
$('form.formbuilt').find('[name]').each(function (index, value){
var that=$(this),
name=that.attr('name'),
value=that.val(),
type=that.prop('type');
if(type=='file'){
if(value!=null)
files[name]=value;
}});
return files;
}
removeEmptyImage();
function removeEmptyImage(){
$('.vpc-selected-icon').each(function (index, value){
if(typeof $(this).find('img').attr('src')!="undefined"&&$(this).find('img').attr('src').length==0){
$(this).find('img').hide();
}});
}
$(document).on("click", ".reset_variations", function (e){
$('.variations_button .vpc-configure-button.button').hide();
});
window.nb_images=0;
window.add_image_on_canvas=function (images, canvas){
return new Promise(function (resolve, reject){
var a;
wp.hooks.doAction('vpc.BeforeAddedImageOnCanvas', images, canvas);
for (var i=0; i < images.length; i++){
if($.isArray(images[i])){
for (var j=0; j < images[i].length; j++){
if($.isArray(images[i][j])){
nb_images +=images[i][j].length;
for (var k=0; k < images[i][j].length; k++){
fabric.Image.fromURL(images[i][j][k], function (myImg){
myImg.set({
originX: "center",
originY: "center"
});
canvas.add(myImg);
canvas.centerObject(myImg);
});
}}else{
if(typeof images[i][j]!=='undefined'){
nb_images=images[i].length;
fabric.Image.fromURL(images[i][j], function (myImg){
myImg.set({
originX: "center",
originY: "center"
});
canvas.add(myImg);
canvas.centerObject(myImg);
});
}}
}}
canvas.renderAll();
a=i;
}
if(a===(images.length - 1)){
wp.hooks.doAction('vpc.AfterAddedImageOnCanvas', images, canvas);
resolve('completed');
}});
}
window.merge_all_images_of_preview=function (imgs){
if(typeof vpc!='undefined'){
if(vpc.views){
return new Promise(function (resolve, reject){
$.each(imgs, function (ind, data){
if(typeof canvasViews[data[0]]!=='undefined'&&canvasViews[data[0]]!==''){
add_image_on_canvas(data[1], canvasViews[data[0]]).then(function (result){
if(result==='completed'&&ind===(imgs.length - 1)){
resolve(result);
}});
}});
});
}else{
return new Promise(function (resolve, reject){
add_image_on_canvas(imgs, canvasViews[0]).then(function (result){
if(result==='completed'){
resolve(result);
}});
});
}}
}
window.add_custom_texts_and_uploads_datas_on_canvas=function (){
var canvases=window.__canvases;
$.each(canvases, function (index, canvas){
var new_index=index.replace('text_and_upload_panel_', '');
if(new_index==='text_and_upload_panel'){
new_index=0;
}
if(typeof canvasViews[new_index]!=='undefined'){
canvas.getObjects().map(function (data, key){
canvasViews[new_index].add(data);
});
canvasViews[new_index].renderAll();
}});
}
window.removeAllObject=function (canvas){
var o=canvas.getObjects();
o.forEach(function (object, key){
if(object.get('type')=='image')
canvas.remove(object);
});
}
window.generate_canvas_images=function (){
var preview_imgs_merged={};
$.each(canvasViews, function (index, canvas){
if(typeof canvas!=='undefined'&&canvas!==''){
preview_imgs_merged[index]=canvas.toDataURL({
format: 'png',
quality: 1.0,
}).replace('data:image/png;base64,', '');
removeAllObject(canvas)
}});
return preview_imgs_merged;
}
window.order_canvas_objects_by_index=function (canvas){
new Promise(function (resolve, reject){
window.canvas_objects_per_index={};
if(canvas){
if(canvas.getActiveObject()){
canvas.discardActiveObject();
}
window.m=0;
var canvas_objects=canvas._objects;
$.each(canvas_objects, function (ind, val){
if(typeof val.z_index!=='undefined'){
if(typeof window.canvas_objects_per_index[val.z_index]=='undefined'||window.canvas_objects_per_index[val.z_index]==null){
window.canvas_objects_per_index[val.z_index]={}}
if(typeof window.canvas_objects_per_index[val.z_index]!=='undefined'||window.canvas_objects_per_index[val.z_index]!==null){
var size_value=Object.keys(window.canvas_objects_per_index[val.z_index]).length;
window.canvas_objects_per_index[val.z_index][size_value]=val;
}
window.m++;
}else{
window.m++;
}
if(window.m===canvas_objects.length){
resolve('completed');
}});
}else{
resolve('completed');
}}).then(function (result){
if(result==='completed'){
new Promise(function (resolve, reject){
window.reordered_objects=[];
window.size_1=Object.keys(window.canvas_objects_per_index).length;
if(window.size_1 > 0){
window.x=0;
$.each(window.canvas_objects_per_index, function (index, objects){
window.size_2=Object.keys(objects).length;
if(window.size_2 > 0){
window.u=0;
$.each(objects, function (obj_id, obj){
window.reordered_objects.push(obj);
window.u++;
if(window.u===window.size_2){
window.x++;
if(window.x===window.size_1){
resolve('completed_2');
}}
});
}else{
window.x++;
if(window.x===window.size_1){
resolve('completed_2');
}}
});
}else{
resolve('completed_1');
}}).then(function (result_2){
if(result_2==='completed_2'){
canvas._objects=window.reordered_objects;
canvas.renderAll();
}});
}});
}});
return vpc_config;
}(jQuery, VPC_CONFIG));
!function(){"use strict";function e(e){e.fn._fadeIn=e.fn.fadeIn;var t=e.noop||function(){},o=/MSIE/.test(navigator.userAgent),n=/MSIE 6.0/.test(navigator.userAgent)&&!/MSIE 8.0/.test(navigator.userAgent),i=(document.documentMode,"function"==typeof document.createElement("div").style.setExpression&&document.createElement("div").style.setExpression);e.blockUI=function(e){d(window,e)},e.unblockUI=function(e){a(window,e)},e.growlUI=function(t,o,n,i){var s=e('<div class="growlUI"></div>');t&&s.append("<h1>"+t+"</h1>"),o&&s.append("<h2>"+o+"</h2>"),n===undefined&&(n=3e3);var l=function(t){t=t||{},e.blockUI({message:s,fadeIn:"undefined"!=typeof t.fadeIn?t.fadeIn:700,fadeOut:"undefined"!=typeof t.fadeOut?t.fadeOut:1e3,timeout:"undefined"!=typeof t.timeout?t.timeout:n,centerY:!1,showOverlay:!1,onUnblock:i,css:e.blockUI.defaults.growlCSS})};l();s.css("opacity");s.on("mouseover",function(){l({fadeIn:0,timeout:3e4});var t=e(".blockMsg");t.stop(),t.fadeTo(300,1)}).on("mouseout",function(){e(".blockMsg").fadeOut(1e3)})},e.fn.block=function(t){if(this[0]===window)return e.blockUI(t),this;var o=e.extend({},e.blockUI.defaults,t||{});return this.each(function(){var t=e(this);o.ignoreIfBlocked&&t.data("blockUI.isBlocked")||t.unblock({fadeOut:0})}),this.each(function(){"static"==e.css(this,"position")&&(this.style.position="relative",e(this).data("blockUI.static",!0)),this.style.zoom=1,d(this,t)})},e.fn.unblock=function(t){return this[0]===window?(e.unblockUI(t),this):this.each(function(){a(this,t)})},e.blockUI.version=2.7,e.blockUI.defaults={message:"<h1>Please wait...</h1>",title:null,draggable:!0,theme:!1,css:{padding:0,margin:0,width:"30%",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"3px solid #aaa",backgroundColor:"#fff",cursor:"wait"},themedCSS:{width:"30%",top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:.6,cursor:"wait"},cursorReset:"default",growlCSS:{width:"350px",top:"10px",left:"",right:"10px",border:"none",padding:"5px",opacity:.6,cursor:"default",color:"#fff",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px","border-radius":"10px"},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",forceIframe:!1,baseZ:1e3,centerX:!0,centerY:!0,allowBodyStretch:!0,bindEvents:!0,constrainTabKey:!0,fadeIn:200,fadeOut:400,timeout:0,showOverlay:!0,focusInput:!0,focusableElements:":input:enabled:visible",onBlock:null,onUnblock:null,onOverlayClick:null,quirksmodeOffsetHack:4,blockMsgClass:"blockMsg",ignoreIfBlocked:!1};var s=null,l=[];function d(d,c){var u,b,h=d==window,k=c&&c.message!==undefined?c.message:undefined;if(!(c=e.extend({},e.blockUI.defaults,c||{})).ignoreIfBlocked||!e(d).data("blockUI.isBlocked")){if(c.overlayCSS=e.extend({},e.blockUI.defaults.overlayCSS,c.overlayCSS||{}),u=e.extend({},e.blockUI.defaults.css,c.css||{}),c.onOverlayClick&&(c.overlayCSS.cursor="pointer"),b=e.extend({},e.blockUI.defaults.themedCSS,c.themedCSS||{}),k=k===undefined?c.message:k,h&&s&&a(window,{fadeOut:0}),k&&"string"!=typeof k&&(k.parentNode||k.jquery)){var y=k.jquery?k[0]:k,m={};e(d).data("blockUI.history",m),m.el=y,m.parent=y.parentNode,m.display=y.style.display,m.position=y.style.position,m.parent&&m.parent.removeChild(y)}e(d).data("blockUI.onUnblock",c.onUnblock);var g,v,I,w,U=c.baseZ;g=o||c.forceIframe?e('<iframe class="blockUI" style="z-index:'+U+++';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+c.iframeSrc+'"></iframe>'):e('<div class="blockUI" style="display:none"></div>'),v=c.theme?e('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+U+++';display:none"></div>'):e('<div class="blockUI blockOverlay" style="z-index:'+U+++';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>'),c.theme&&h?(w='<div class="blockUI '+c.blockMsgClass+' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(U+10)+';display:none;position:fixed">',c.title&&(w+='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(c.title||"&nbsp;")+"</div>"),w+='<div class="ui-widget-content ui-dialog-content"></div>',w+="</div>"):c.theme?(w='<div class="blockUI '+c.blockMsgClass+' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(U+10)+';display:none;position:absolute">',c.title&&(w+='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(c.title||"&nbsp;")+"</div>"),w+='<div class="ui-widget-content ui-dialog-content"></div>',w+="</div>"):w=h?'<div class="blockUI '+c.blockMsgClass+' blockPage" style="z-index:'+(U+10)+';display:none;position:fixed"></div>':'<div class="blockUI '+c.blockMsgClass+' blockElement" style="z-index:'+(U+10)+';display:none;position:absolute"></div>',I=e(w),k&&(c.theme?(I.css(b),I.addClass("ui-widget-content")):I.css(u)),c.theme||v.css(c.overlayCSS),v.css("position",h?"fixed":"absolute"),(o||c.forceIframe)&&g.css("opacity",0);var x=[g,v,I],C=e(h?"body":d);e.each(x,function(){this.appendTo(C)}),c.theme&&c.draggable&&e.fn.draggable&&I.draggable({handle:".ui-dialog-titlebar",cancel:"li"});var S=i&&(!e.support.boxModel||e("object,embed",h?null:d).length>0);if(n||S){if(h&&c.allowBodyStretch&&e.support.boxModel&&e("html,body").css("height","100%"),(n||!e.support.boxModel)&&!h)var E=p(d,"borderTopWidth"),O=p(d,"borderLeftWidth"),T=E?"(0 - "+E+")":0,M=O?"(0 - "+O+")":0;e.each(x,function(e,t){var o=t[0].style;if(o.position="absolute",e<2)h?o.setExpression("height","Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:"+c.quirksmodeOffsetHack+') + "px"'):o.setExpression("height",'this.parentNode.offsetHeight + "px"'),h?o.setExpression("width",'jQuery.support.boxModel&&document.documentElement.clientWidth||document.body.clientWidth + "px"'):o.setExpression("width",'this.parentNode.offsetWidth + "px"'),M&&o.setExpression("left",M),T&&o.setExpression("top",T);else if(c.centerY)h&&o.setExpression("top",'(document.documentElement.clientHeight||document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah=document.documentElement.scrollTop ? document.documentElement.scrollTop:document.body.scrollTop) + "px"'),o.marginTop=0;else if(!c.centerY&&h){var n="((document.documentElement.scrollTop ? document.documentElement.scrollTop:document.body.scrollTop) + "+(c.css&&c.css.top?parseInt(c.css.top,10):0)+') + "px"';o.setExpression("top",n)}})}if(k&&(c.theme?I.find(".ui-widget-content").append(k):I.append(k),(k.jquery||k.nodeType)&&e(k).show()),(o||c.forceIframe)&&c.showOverlay&&g.show(),c.fadeIn){var B=c.onBlock?c.onBlock:t,j=c.showOverlay&&!k?B:t,H=k?B:t;c.showOverlay&&v._fadeIn(c.fadeIn,j),k&&I._fadeIn(c.fadeIn,H)}else c.showOverlay&&v.show(),k&&I.show(),c.onBlock&&c.onBlock.bind(I)();if(r(1,d,c),h?(s=I[0],l=e(c.focusableElements,s),c.focusInput&&setTimeout(f,20)):function(e,t,o){var n=e.parentNode,i=e.style,s=(n.offsetWidth-e.offsetWidth)/2-p(n,"borderLeftWidth"),l=(n.offsetHeight-e.offsetHeight)/2-p(n,"borderTopWidth");t&&(i.left=s>0?s+"px":"0");o&&(i.top=l>0?l+"px":"0")}(I[0],c.centerX,c.centerY),c.timeout){var z=setTimeout(function(){h?e.unblockUI(c):e(d).unblock(c)},c.timeout);e(d).data("blockUI.timeout",z)}}}function a(t,o){var n,i,d=t==window,a=e(t),u=a.data("blockUI.history"),f=a.data("blockUI.timeout");f&&(clearTimeout(f),a.removeData("blockUI.timeout")),o=e.extend({},e.blockUI.defaults,o||{}),r(0,t,o),null===o.onUnblock&&(o.onUnblock=a.data("blockUI.onUnblock"),a.removeData("blockUI.onUnblock")),i=d?e(document.body).children().filter(".blockUI").add("body > .blockUI"):a.find(">.blockUI"),o.cursorReset&&(i.length>1&&(i[1].style.cursor=o.cursorReset),i.length>2&&(i[2].style.cursor=o.cursorReset)),d&&(s=l=null),o.fadeOut?(n=i.length,i.stop().fadeOut(o.fadeOut,function(){0==--n&&c(i,u,o,t)})):c(i,u,o,t)}function c(t,o,n,i){var s=e(i);if(!s.data("blockUI.isBlocked")){t.each(function(e,t){this.parentNode&&this.parentNode.removeChild(this)}),o&&o.el&&(o.el.style.display=o.display,o.el.style.position=o.position,o.el.style.cursor="default",o.parent&&o.parent.appendChild(o.el),s.removeData("blockUI.history")),s.data("blockUI.static")&&s.css("position","static"),"function"==typeof n.onUnblock&&n.onUnblock(i,n);var l=e(document.body),d=l.width(),a=l[0].style.width;l.width(d-1).width(d),l[0].style.width=a}}function r(t,o,n){var i=o==window,l=e(o);if((t||(!i||s)&&(i||l.data("blockUI.isBlocked")))&&(l.data("blockUI.isBlocked",t),i&&n.bindEvents&&(!t||n.showOverlay))){var d="mousedown mouseup keydown keypress keyup touchstart touchend touchmove";t?e(document).on(d,n,u):e(document).off(d,u)}}function u(t){if("keydown"===t.type&&t.keyCode&&9==t.keyCode&&s&&t.data.constrainTabKey){var o=l,n=!t.shiftKey&&t.target===o[o.length-1],i=t.shiftKey&&t.target===o[0];if(n||i)return setTimeout(function(){f(i)},10),!1}var d=t.data,a=e(t.target);return a.hasClass("blockOverlay")&&d.onOverlayClick&&d.onOverlayClick(t),a.parents("div."+d.blockMsgClass).length>0||0===a.parents().children().filter("div.blockUI").length}function f(e){if(l){var t=l[!0===e?l.length-1:0];t&&t.trigger("focus")}}function p(t,o){return parseInt(e.css(t,o),10)||0}}"function"==typeof define&&define.amd&&define.amd.jQuery?define(["jquery"],e):e(jQuery)}();
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}return function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(f){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})});
function on_keydown_remove_from_cart(e){" "===e.key&&(e.preventDefault(),e.currentTarget.click())}function focus_populate_live_region(){var e=["woocommerce-message","woocommerce-error","wc-block-components-notice-banner"].map(function(e){return"."+e+'[role="alert"]'}).join(", "),o=document.querySelectorAll(e);if(0!==o.length){var t=o[0];t.setAttribute("tabindex","-1");var n=setTimeout(function(){t.focus(),clearTimeout(n)},500)}}function refresh_sorted_by_live_region(){var e=document.querySelector(".woocommerce-result-count"),o=document.querySelector('[data-wp-interactive="woocommerce/product-filters"]');if(e&&window.location.search&&!o){var t=e.innerHTML;e.setAttribute("role","alert"),e.setAttribute("aria-hidden","true");var n=setTimeout(function(){e.setAttribute("aria-hidden","false"),e.innerHTML="",e.innerHTML=t,clearTimeout(n)},2e3)}}function on_document_ready(){focus_populate_live_region(),refresh_sorted_by_live_region()}jQuery(function(e){e(".woocommerce-ordering").on("change","select.orderby",function(){e(this).closest("form").trigger("submit")}),e("input.qty:not(.product-quantity input.qty)").each(function(){var o=parseFloat(e(this).attr("min"));o>=0&&parseFloat(e(this).val())<o&&e(this).val(o)});var o="store_notice"+(e(".woocommerce-store-notice").data("noticeId")||"");if("hidden"===Cookies.get(o))e(".woocommerce-store-notice").hide();else{function t(o){["Enter"," "].includes(o.key)&&(o.preventDefault(),e(".woocommerce-store-notice__dismiss-link").click())}e(".woocommerce-store-notice").show(),e(".woocommerce-store-notice__dismiss-link").on("click",function n(r){Cookies.set(o,"hidden",{path:"/"}),e(".woocommerce-store-notice").hide(),r.preventDefault(),e(".woocommerce-store-notice__dismiss-link").off("click",n).off("keydown",t)}).on("keydown",t)}e(".woocommerce-input-wrapper span.description").length&&e(document.body).on("click",function(){e(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),e(".woocommerce-input-wrapper").on("click",function(e){e.stopPropagation()}),e(".woocommerce-input-wrapper :input").on("keydown",function(o){var t=e(this).parent().find("span.description");if(27===o.which&&t.length&&t.is(":visible"))return t.prop("aria-hidden",!0).slideUp(250),o.preventDefault(),!1}).on("click focus",function(){var o=e(this).parent(),t=o.find("span.description");o.addClass("currentTarget"),e(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),t.length&&t.is(":hidden")&&t.prop("aria-hidden",!1).slideDown(250),o.removeClass("currentTarget")}),e.scroll_to_notices=function(o){o.length&&e("html, body").animate({scrollTop:o.offset().top-100},1e3)},e('.woocommerce form .woocommerce-Input[type="password"]').wrap('<span class="password-input"></span>'),e(".woocommerce form input").filter(":password").parent("span").addClass("password-input"),e(".password-input").each(function(){const o=e(this).find("input").attr("id");e(this).append('<button type="button" class="show-password-input" aria-label="'+woocommerce_params.i18n_password_show+'" aria-describedBy="'+o+'"></button>')}),e(".show-password-input").on("click",function(o){o.preventDefault(),e(this).hasClass("display-password")?(e(this).removeClass("display-password"),e(this).attr("aria-label",woocommerce_params.i18n_password_show)):(e(this).addClass("display-password"),e(this).attr("aria-label",woocommerce_params.i18n_password_hide)),e(this).hasClass("display-password")?e(this).siblings(['input[type="password"]']).prop("type","text"):e(this).siblings('input[type="text"]').prop("type","password"),e(this).siblings("input").focus()}),e("a.coming-soon-footer-banner-dismiss").on("click",function(o){var t=e(o.target);e.ajax({type:"post",url:t.data("rest-url"),data:{woocommerce_meta:{coming_soon_banner_dismissed:"yes"}},beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",t.data("rest-nonce"))},complete:function(){e("#coming-soon-footer-banner").hide()}})}),"undefined"==typeof wc_add_to_cart_params&&e(document.body).on("keydown",".remove_from_cart_button",on_keydown_remove_from_cart),e(document.body).on("item_removed_from_classic_cart updated_wc_div",focus_populate_live_region)}),document.addEventListener("DOMContentLoaded",on_document_ready);
(function($){
'use strict';
$(document).ready(function (){
$('body').on('adding_to_cart', function(event, $button){
if($button&&$button.hasClass('vc_gitem-link') ){
$button
.addClass('vc-gitem-add-to-cart-loading-btn')
.parents('.vc_grid-item-mini')
.addClass('vc-woocommerce-add-to-cart-loading')
.append($('<div class="vc_wc-load-add-to-loader-wrapper"><div class="vc_wc-load-add-to-loader"></div></div>') );
}}).on('added_to_cart', function(event, fragments, cart_hash, $button){
if('undefined'===typeof($button) ){
$button=$('.vc-gitem-add-to-cart-loading-btn');
}
if($button&&$button.hasClass('vc_gitem-link') ){
$button
.removeClass('vc-gitem-add-to-cart-loading-btn')
.parents('.vc_grid-item-mini')
.removeClass('vc-woocommerce-add-to-cart-loading')
.find('.vc_wc-load-add-to-loader-wrapper').remove();
}});
});
})(window.jQuery);