PageSourceSearch

https://www.kreativekiwiembroidery.co.nz/uploads/js/ecommerce/viewProductVariantChangeV3.js?ver=1789602108896

js kreativekiwiembroidery.co.nz collected 2026-09-26 10:36:16 UTC 9,808 bytes, 1 lines download raw bytes

1var lastSelectedOption=!1;function onOptionComboChanged(e){if(console.log("onOptionComboChanged "+e.name+" "+e.nodeName+" "+e.type),lastSelectedOption=e,"INPUT"==e.nodeName&&"radio"==e.type&&($(e).parents("ul").find("li.optionSelected").removeClass("optionSelected"),$(e).parents("li").addClass("optionSelected"),console.log("radio selected")),$(e).closest(".SetProductImage").each(function(){var e=$(this).find("img").attr("src");console.log("onOptionComboChanged.SetProductImage "+e),changeImageSrc($(this).closest(".cmsItem").find(".cmsImage img"),e),changeImageSrc($(this).closest(".productVariantChangeWrapper").find(".zoomedphoto img"),e)}),"BUTTON"==e.nodeName){$(e).parent().find("button.optionSelected").removeClass("optionSelected"),$(e).addClass("optionSelected"),console.log("onOptionComboChanged.optionSelected");var t=jQuery(e).siblings("input[type=hidden]")[0];t.value=encodeDoubleQuote(e.value),e=t}var i=getSelectedVariant(e);i?variantChangeEvent(e,i):$(".cmsCustomProductQuestion").length&&refreshPricingTableCheckVariant(e)}function getSelectedVariant(e){var t=getVariantList(e);if(console.log("getSelectedVariant"),t){console.log("getSelectedVariant has variant list"),updateOptionsAvailabilityAll(e,t);var n=e.form,o=!!n.b_option&&encodeDoubleQuote(n.b_option.value),a=!!n.b_colour&&encodeDoubleQuote(n.b_colour.value),l=!!n.b_size&&encodeDoubleQuote(n.b_size.value);for(i=0;i<t.length;i++)if(!(t[i].style&&t[i].style!=o||t[i].size&&t[i].size!=l||t[i].colour&&t[i].colour!=a))return t[i]}return console.log("getSelectedVariant none found"),!1}function getOptionScope(e){var t=$(e).parents(".productVariantChangeWrapper");return t.length||(t=$(e.form)),t}function getVariantList(e){var t=getOptionScope(e).find(".VariantList");return!!t.length&&JSON.parse(t.text())}function getVariantProductByPID(e,t){for(i=0;i<e.length;i++)if(e[i].pid==t)return e[i];return!1}function onVariantComboChanged(e){variantChangeEvent(e,getVariantProductByPID(getVariantList(e),e.options[e.selectedIndex].value))}function onVariantRadioChanged(e){var t=getVariantList(e);console.log("onVariantRadioChanged"),"INPUT"==e.nodeName&&"radio"==e.type&&($(e).parents("ul").find("li.optionSelected").removeClass("optionSelected"),$(e).parents("li").addClass("optionSelected"),console.log("radio selected")),variantChangeEvent(e,getVariantProductByPID(t,e.value))}function variantChangeEvent(e,t){console.log("variantChangeEvent"),t&&(t.imgsrc&&(console.log("variantChanged has image "+t.imgsrc),setMainProductImage(t.imgsrc)),console.log("variantChangeEvent.object pid ="+t.pid),$(e).find("input.SingleChoicePerCategoryRadioButton").val(t.pid).trigger("change"),refreshPricingTable(e,t.pid))}function setMainProductImage(e){e&&(console.log("setMainProductImage "+e),changeImageSrc($(".zoomedphoto img"),e),$(".zoomedphoto a").attr("href",e),$(".imageAlignmentBlock .cb-slider").length&&$(".imageAlignmentBlock .cb-slider").replaceWith('<div class="zoomedphoto"><a class="colorbox " rel="colorbox" href="'+e+'"><img class=img_product_view border=0 itemprop="image" src="'+e+'"></a></div>'))}function changeImageSrc(e,t){console.log("changeImageSrc "+t),0!=e.length&&t&&(e.removeAttr("src"),e.removeAttr("srcset"),e.attr("src",t))}function hasDifferentPrices(e){var t=0;for(i=0;i<e.length;i++){if(t>0&&t!=e[i].price)return!0;t=e[i].price}return!1}function initVariantLogic(){console.log("variantChangeScripts - initVariantLogic");const e=$("#cmsProductSummary");e.on("click",".RadioSwatch .ColorSwatchIMG",swatchSpanClickProductPage),e.on("click",".cmsOptionSwatches span",function(){swatchSpanClick(this)}),e.on("click",".cmsOptionSwatches img",function(){swatchSpanClick(this)}),e.on("click",".cmsOptionButtonSet button[type=button]",function(){console.log("buttonListeners button.click()"),$(this).parent().find("button.optionSelected").removeClass("optionSelected").removeClass("activeOptionButton"),$(this).addClass("optionSelected"),$(this).parents(".cmsOptionButtonSet").find("input[type=hidden]").val(this.value).change()}),$(".cmsCustomProductQuestion :input[type=file]").length>0&&console.log("variantChangeScripts - initVariantLogic.cmsCustomProductQuestion WARNING: FILE INPUT EXISTS... Refresh pricing disabled... "),$(".cmsCustomProductQuestion").length&&(console.log("variantChangeScripts - initVariantLogic cmsCustomProductQuestion"),e.on("change",".cmsCustomProductQuestion :input:not([type=file])",onChangeCustomProductQuestion),e.on("change",".cmsFormElementQuantity :input[name=b_qty]",function(){refreshPricingTableCheckVariant(this)}),e.on("change","#materialProductID",function(){refreshPricingTableCheckVariant(this),$("#add2cartMaterialProductID").val(this.value)}))}function swatchSpanClick(e){console.log("swatchSpanClick");var t=$(e).attr("variationimagesrc");t&&"null"!=t?$(e).parents(".cmsItem").find(".cmsImage img").attr("src",t):console.log("swatchSpanClick bg"),$(e).parents(".RadioButtonSet").find("input.ColourSwatchInputTarget").val($(e).attr("title"))}function swatchSpanClickProductPage(e){if(console.log("swatchSpanClickProductPage"),jQuery(e.target).not(":input, a").length){var t=jQuery(this).parents(".RadioSwatch").find('input[type="radio"]');t.prop("checked")||(t.prop("checked",!0),onOptionComboChanged(t[0]))}}function encodeDoubleQuote(e){return e?e.replace(/"/g,"&quot;"):e}function anyVariantWithMatchingOption(e,t,n,o,a){if(n=encodeDoubleQuote(n),a=encodeDoubleQuote(a),void 0===e||!e)return!0;for(i=0;i<e.length;i++)if(!e[i].disabled&&!("style"==t&&e[i].style!=n||"size"==t&&e[i].size!=n||"colour"==t&&e[i].colour!=n||"style"==o&&e[i].style!=a||"size"==o&&e[i].size!=a||"colour"==o&&e[i].colour!=a))return!0;return!1}function anyVariantWithOptionValue(e,t,n){for(n=encodeDoubleQuote(n),i=0;i<e.length;i++)if(!e[i].disabled){if("style"==t&&e[i].style==n)return!0;
1if("size"==t&&e[i].size==n)return!0;if("colour"==t&&e[i].colour==n)return!0}return!1}function updateOtherOptionsAvailability(e,t,i,n,o,a){console.log("updateOtherOptionsAvailability "+e+" "+n+" "+t),o.find('select[name="'+n+'"] > option').each(function(){anyVariantWithMatchingOption(a,e,t,i,this.value)?this.disabled=!1:(this.disabled=!0,this.selected=!1)}),o.find(':radio[name="'+n+'"]').each(function(){anyVariantWithMatchingOption(a,e,t,i,this.value)?this.disabled=!1:disableRadio(this)}),o.find("#ButtonSet_"+n+">button").each(function(){anyVariantWithMatchingOption(a,e,t,i,this.value)?this.disabled=!1:(this.disabled=!0,this.classList.remove("optionSelected"))})}function enableAllMyOptions(e,t,i){jQuery('select[name="'+e.name+'"] > option').each(function(){this.disabled=!anyVariantWithOptionValue(i,t,this.value)}),jQuery(':radio[name="'+e.name+'"]').each(function(){this.disabled=!anyVariantWithOptionValue(i,t,this.value)}),jQuery("#ButtonSet_"+e.name+" > button").each(function(){this.disabled=!anyVariantWithOptionValue(i,t,this.value)})}function onChangeCustomProductQuestion(){onChangeFormField(this,event),ele=this,console.log("onChangeCustomProductQuestion."+ele.name+"="+ele.value),console.log("onChangeCustomProductQuestion.classList ="+ele.classList),$(ele).hasClass("val
1idateHasErrors")||refreshPricingTableCheckVariant(ele)}function refreshPricingTableCheckVariant(e){var t=getSelectedVariant(e);t?(console.log("refreshPricingTableCheckVariant - has variant"),refreshPricingTable(e,t.pid)):(console.log("refreshPricingTableCheckVariant - no variant"),refreshPricingTable(e))}window.thumbnailImageClicked=function(e,t){getVariantProductByPID(e);$("select[name=b_colour]").val(t)};var isReloadingPricePleaseWait=!1,nextInputFocusIndex=!1;function refreshPricingTable(e,t){if(!isReloadingPricePleaseWait)if($(e).parents(".productPriceTableDetailedWrapper").length<=0)console.log("ignore selections on multiple lists... ");else{console.log("refreshPricingTable  "+t),nextInputFocusIndex=$(":input").index(e)+1,isReloadingPricePleaseWait=!0;var i="/page/"+page+"/shopping/productview/price-table-ajax.html?notrack=1&getPriceTableOnly=1&"+jQuery(e.form).serialize();i=(i=i.replace("add2cart=","pid=")).replace("add2cartMaterialProductID=","ignoreParam="),t&&(i+="&select_variant_pid="+t),i+=" .productPriceTableDetailed ",console.log("Load URL "+i),jQuery("div.productPriceTableDetailedWrapper").load(i,function(e){console.log("refreshPricingTable completed "),setMainProductImage(jQuery(e).find(".productPriceTableDetailed").attr("data-image")),initForms(),isReloadingPricePleaseWait=!1,nextInputFocusIndex&&$(":input").eq(nextInputFocusIndex).focus()})}}function updateOptionsAvailabilityAll(e,t){"BUTTON"==e.nodeName&&(e=jQuery(e).siblings("input[type=hidden]")[0]);var i=jQuery(e).val();console.log("updateOptionsAvailabilityAll --- "+e.name+"="+e.value),jQuery('div[id="disabledRadio"]').each(function(){jQuery(this).remove()});var n=getOptionScope(e);t&&("b_colour"==e.name&&(enableAllMyOptions(e,"colour",t),updateOtherOptionsAvailability("colour",i,"size","b_size",n,t),updateOtherOptionsAvailability("colour",i,"style","b_option",n,t)),"b_size"==e.name&&(enableAllMyOptions(e,"size",t),updateOtherOptionsAvailability("size",i,"colour","b_colour",n,t),updateOtherOptionsAvailability("size",i,"style","b_option",n,t)),"b_option"==e.name&&(enableAllMyOptions(e,"style",t),updateOtherOptionsAvailability("style",i,"size","b_size",n,t),updateOtherOptionsAvailability("style",i,"colour","b_colour",n,t)))}function disableRadio(e){e.disabled=!0,e.checked=!1;var t=$(e),i=t,n=$('<div id="disabledRadio" />');t.parent().is("label")&&(i=t.parent()),n.css({position:"absolute",top:i.position().top,left:i.position().left,width:i.outerWidth(),height:i.outerHeight(),zIndex:1e4,backgroundColor:"#ffffff",opacity:0}).on("click",function(){alert("This option is not available,Please select from the available options.")}),t.parent().append(n)}$(document).ready(function(){initVariantLogic()});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.