PageSourceSearch

https://shophoatuoihaiphong.com/vendor/core/plugins/ecommerce/js/change-products-swatches.js

js shophoatuoihaiphong.com collected 2026-09-28 12:46:55 UTC 6,037 bytes, 1 lines download raw bytes

1(()=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function a(t,e,a){return(e=i(e))in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function i(e){var a=function(e,a){if("object"!==t(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,a||"default");if("object"!==t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===a?String:Number)(e)}(e,"string");return"symbol"===t(a)?a:String(a)}var n=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),a(this,"callAjax",(function(t,e,a){var i={attributes:t,_:+new Date},n=(e.attr("id"),e.closest(".product-wrap-options"));this.xhr=$.ajax({url:e.data("target"),type:"GET",data:i,beforeSend:function(){window.onBeforeChangeSwatches&&"function"==typeof window.onBeforeChangeSwatches&&window.onBeforeChangeSwatches(t,e),n.find(".list-content-loading").show()},success:function(t){if(t){if(n.find(".product-price span:first-child").text(t.data.display_sale_price),1==t.data.in_flashsale){n.find(".product-price span.old-price").text(t.data.display_price).show(),n.find(".product-price span.label-sale").text(t.data.sale_percentage).show(),n.find(".product-price span:first-child").text(t.data.display_flashsale_price);var e=n.find(".flash-sale-badge");if(e.length)t.data.flashsale_title&&e.find("h4").html("<i>"+t.data.flashsale_title+"</i>"),e.show();else if(t.data.flashsale_title){var a='<div class="flash-sale-badge mb-1 d-flex align-items-center"><img style="max-width: 100px" src="'+window.location.origin+'/storage/image-removebg-preview-12.png" /><h4 class="text-danger"><i>'+t.data.flashsale_title+"</i></h4></div>";n.find(".product-price-cover").prepend(a)}}else t.data.sale_price>0?(n.find(".product-price span.old-price").text(t.data.display_price).show(),n.find(".product-price span.label-sale").text(t.data.sale_percentage).show(),n.find(".product-price span:first-child").text(t.data.display_sale_price),n.find(".flash-sale-badge").hide()):(n.find(".product-price span.old-price").text(t.data.display_price).hide(),n.find(".product-price span.label-sale").text(t.data.sale_percentage).hide(),n.find(".product-price span:first-child").text(t.data.display_price),n.find(".flash-sale-badge").hide());t.data.image_with_sizes.pthum&&(n.find(".default-img").attr("src",t.data.image_with_sizes.pthum[0]),n.find(".hover-img").attr("src",t.data.image_with_sizes.pthum[1]))}},complete:function(t){window.onChangeSwatchesComplete&&"function"==typeof window.onChangeSwatchesComplete&&window.onChangeSwatchesComplete(t,e),n.find(".list-content-loading").hide()},error:function(t){window.onChangeSwatchesError&&"function"==typeof window.onChangeSwatchesError&&window.onChangeSwatchesError(t,e)}})})),a(this,"updateSelectingAttributes",(function(t,e){$.each(t,(function(t,a){var i=e.find('.attribute-swatches-wrapper[data-slug="'+t+'"]');if(i.length)if("dropdown"===i.data("type")){var n=i.find('select option[data-slug="'+a+'"]').val();i.find("select").val(n)}else i.find("input:checked").prop("checked",!1),i.find("input[data-slug="+a+"]").prop("checked",!0)}))})),a(this,"parseParamsSearch",(function(t){for(var e,a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=t||window.location.search.substring(1),n=/([^&=]+)=?([^&]*)/g,r=/\+/g,o=function(t){return decodeURIComponent(t.replace(r," "))},s={};e=n.exec(i);){var c=o(e[1]),d=o(e[2]);"[]"===c.substring(c.length-2)?(a&&(c=c.substring(0,c.length-2)),(s[c]||(s[c]=[])).push(d)):s[c]=d}return s})),this.xhr=null,this.handleEvents()}var i,n,r;return i=t,(n=[{key:"handleEvents",value:function(){var t=this,e=$("body");e.on("click",".product-attributes .visual-swatch label, .product-attributes .text-swatch label",(function(t){t.preventDefault();
1var e=$(t.currentTarget),a=e.find("input[type=radio]");if(a.is(":checked"))return!1;a.closest(".attribute-swatch").find(".product-filter-item").prop("checked",!1),a.prop("checked",!0),e.closest(".visual-swatch").find("input[type=radio]:checked").length<1&&a.prop("checked",!0),a.trigger("change")})),e.off("change",".product-attributes input, .product-attributes select").on("change",".product-attributes input, .product-attributes select",(function(e){var a=$(e.currentTarget).closest(".product-attributes");t.getProductVariation(a)})),$(".product-attribute-swatches").length&&window.addEventListener("popstate",(function(e){var a;if(null!==(a=e.state)&&void 0!==a&&a.product_attributes_id){var i=$("#"+e.state.product_attributes_id);window.onChangeSwatchesSuccess&&"function"==typeof window.onChangeSwatchesSuccess&&window.onChangeSwatchesSuccess(e.state.data,i),e.state.slugAttributes&&t.updateSelectingAttributes(e.state.slugAttributes,i)}else $(".product-attribute-swatches").each((function(e,a){var i=t.parseParamsSearch(),n=[],r={},o=$(a);i&&Object.keys(i).length&&$.each(i,(function(t,e){var a,i=o.find('.attribute-swatches-wrapper[data-slug="'+t+'"]');i.length&&(a="dropdown"===i.data("type")?i.find('option[data-slug="'+e+'"]').val():i.find('input[data-slug="'+e+'"]').val())&&(n.push(a),r[t]=a)})),t.callAjax(n,o,r,!1)}))}),!1)}},{key:"getProductVariation",value:function(t){var e=this,a=[],i={};e.xhr&&(e.xhr.abort(),e.xhr=null),t.find(".attribute-swatches-wrapper").each((function(t,e){var n,r=$(e),o=((n="dropdown"===r.data("type")?r.find("select option:selected"):r.find("input[type=radio]:checked")).data("slug"),n.val());if(o){var s=r.find(".attribute-swatch").data("slug");i.setSlug=s,a.push(o)}})),e.callAjax(a,t,i)}}])&&e(i.prototype,n),r&&e(i,r),Object.defineProperty(i,"prototype",{writable:!1}),t}();$((function(){new n}))})();

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.