Version Description
23-06-2022 =
Add: Image type fallback if no attribute image added.
Fix: Archive add to cart issue
Add: Ajax Quick View / Load More support
Download this release
Release Info
Developer | EmranAhmed |
Plugin | WooCommerce Variation Swatches |
Version | 2.0.2 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.0.2
- README.txt +6 -0
- assets/css/admin.css +3 -2
- assets/css/admin.min.css +1 -1
- assets/css/frontend.css +1 -1
- assets/js/admin.js +7 -5
- assets/js/admin.min.js +1 -1
- assets/js/frontend.js +464 -494
- assets/js/frontend.min.js +1 -1
- assets/js/wp-color-picker-alpha.js +1 -1
- includes/class-woo-variation-swatches-product-page.php +23 -5
- woo-variation-swatches.php +2 -2
README.txt
CHANGED
@@ -617,6 +617,12 @@ And your are ready to go.
|
|
617 |
|
618 |
== Changelog ==
|
619 |
|
|
|
|
|
|
|
|
|
|
|
|
|
620 |
= 2.0.1 - 16-06-2022 =
|
621 |
|
622 |
* Add: Hex to RGBA color conversion on migration
|
617 |
|
618 |
== Changelog ==
|
619 |
|
620 |
+
= 2.0.2 - 23-06-2022 =
|
621 |
+
|
622 |
+
* Add: Image type fallback if no attribute image added.
|
623 |
+
* Fix: Archive add to cart issue
|
624 |
+
* Add: Ajax Quick View / Load More support
|
625 |
+
|
626 |
= 2.0.1 - 16-06-2022 =
|
627 |
|
628 |
* Add: Hex to RGBA color conversion on migration
|
assets/css/admin.css
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
-
* Date: 6/
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
.button.button-danger {
|
@@ -53,7 +53,8 @@
|
|
53 |
.wvs-preview {
|
54 |
width: 30px;
|
55 |
height: 30px;
|
56 |
-
border:
|
|
|
57 |
}
|
58 |
|
59 |
.woo-variation-swatches-pro_tab.pro-inactive a {
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 6/23/2022, 8:34:29 PM
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
.button.button-danger {
|
53 |
.wvs-preview {
|
54 |
width: 30px;
|
55 |
height: 30px;
|
56 |
+
border: rgba(0, 0, 0, 0.2) 1px solid;
|
57 |
+
border-radius: 2px;
|
58 |
}
|
59 |
|
60 |
.woo-variation-swatches-pro_tab.pro-inactive a {
|
assets/css/admin.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.button.button-danger{color:#fff;background-color:#af2d2b;border-color:#a62d2b;-webkit-box-shadow:0 1px 0 #a72d2b;box-shadow:0 1px 0 #a72d2b;vertical-align:top}.button.button-danger.active,.button.button-danger:active,.button.button-danger:focus,.button.button-danger:hover{color:#fff;background:#c9302c}[data-dependency]:not(.dependency-show){display:none!important}.meta-image-field-wrapper{display:table}.meta-image-field-wrapper .button{margin:5px 0;display:block}.meta-image-field-wrapper .image-preview{display:table-cell;width:60px;padding-right:10px}.meta-image-field-wrapper .button-wrapper{display:table-cell;vertical-align:top}.wvs-go-pro-action-link>a{font-weight:700;text-transform:capitalize;color:#9c27b0;text-shadow:1px 1px 1px #eee}#wvs-meta-preview{width:30px}.wvs-preview{width:30px;height:30px;border:1px solid
|
1 |
+
.button.button-danger{color:#fff;background-color:#af2d2b;border-color:#a62d2b;-webkit-box-shadow:0 1px 0 #a72d2b;box-shadow:0 1px 0 #a72d2b;vertical-align:top}.button.button-danger.active,.button.button-danger:active,.button.button-danger:focus,.button.button-danger:hover{color:#fff;background:#c9302c}[data-dependency]:not(.dependency-show){display:none!important}.meta-image-field-wrapper{display:table}.meta-image-field-wrapper .button{margin:5px 0;display:block}.meta-image-field-wrapper .image-preview{display:table-cell;width:60px;padding-right:10px}.meta-image-field-wrapper .button-wrapper{display:table-cell;vertical-align:top}.wvs-go-pro-action-link>a{font-weight:700;text-transform:capitalize;color:#9c27b0;text-shadow:1px 1px 1px #eee}#wvs-meta-preview{width:30px}.wvs-preview{width:30px;height:30px;border:1px solid rgba(0,0,0,.2);border-radius:2px}.woo-variation-swatches-pro_tab.pro-inactive a{background-color:var(--wc-primary);color:var(--wc-content-bg)}#woo-variation-swatches-tutorials-wrapper{background:#fff;border-radius:2px;border:1px solid #ddd}#woo-variation-swatches-tutorials-wrapper img{width:100%}#woo-variation-swatches-tutorials-wrapper ul{margin:0}#woo-variation-swatches-tutorials-wrapper li{overflow:hidden;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:50px 30px;margin:0;border-bottom:1px solid #ddd;position:relative}#woo-variation-swatches-tutorials-wrapper li:last-child{border:0}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper,#woo-variation-swatches-tutorials-wrapper .tutorial-image-wrapper{float:left;padding:0 20px;-webkit-box-sizing:border-box;box-sizing:border-box}#woo-variation-swatches-tutorials-wrapper .tutorial-image-wrapper{position:relative;width:60%}#woo-variation-swatches-tutorials-wrapper .tutorial-image-wrapper .ribbon{position:absolute;left:-5px;top:-5px;z-index:1;overflow:hidden;width:75px;height:75px;text-align:right;margin:1px 22px}#woo-variation-swatches-tutorials-wrapper .tutorial-image-wrapper .ribbon span{font-size:10px;font-weight:700;color:#fff;text-transform:uppercase;text-align:center;line-height:20px;-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);width:100px;display:block;background:#bc0808;-webkit-box-shadow:0 3px 10px -5px #000;box-shadow:0 3px 10px -5px #000;position:absolute;top:19px;left:-21px}#woo-variation-swatches-tutorials-wrapper .tutorial-image-wrapper .ribbon span:after{content:"";position:absolute;right:0;top:100%;z-index:-1;border-color:#8f0808 #8f0808 transparent transparent;border-style:solid;border-width:3px}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper{width:40%}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper h3{margin:0 0 20px;font-size:1.5em}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper .tutorial-contents{font-size:15px;line-height:1.5em;margin-bottom:20px}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper .tutorial-buttons .button{border-radius:3px;line-height:1;padding:13px 20px;font-size:13px;height:40px;-webkit-box-shadow:none;box-shadow:none;text-shadow:none}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper .tutorial-buttons .button:active{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper .tutorial-buttons .button.button-live-demo{background-color:#f44336;color:#fff;border:0}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper .tutorial-buttons .button.button-live-demo:hover{background:#c71609}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper .tutorial-buttons .button.button-docs{background-color:#36373a;color:#fff;border:0}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper .tutorial-buttons .button.button-docs:hover{background:#5d5e61;border-color:#5d5e61}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper .tutorial-buttons .button.button-pro{background-color:#39b54a;color:#fff;border:1px solid #39b54a}#woo-variation-swatches-tutorials-wrapper .tutorial-description-wrapper .tutorial-buttons .button.button-pro:hover{background:#3fc851;border-color:#3fc851}.woo-variation-swatches-group-table-list tbody>:nth-child(odd){background-color:#f6f7f7}.woo-variation-swatches-group-section-wrapper .woocommerce-BlankState-message:before{font-family:Dashicons;content:"\F307"}.woo-variation-swatches-variation-product-options-wrapper .woocommerce-message{margin:10px}.woo-variation-swatches-variation-product-options-wrapper #saved-message{display:none}.woo-variation-swatches-variation-product-options-wrapper h4{margin:0!important;padding:10px 18px;font-size:1em!important;overflow:hidden;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.woo-variation-swatches-variation-product-options-wrapper .woocommerce-help-tip{margin:0 5px!important}.woo-variation-swatches-variation-product-options-wrapper [data-gwpdepends].has-dependent-data.show{display:-webkit-box;display:-ms-flexbox;display:flex}.woo-variation-swatches-variation-product-options-wrapper .product-label-settings{background-color:#fff}.woo-variation-swatches-variation-product-options-wrapper .form-settings-group{padding:5px;border-bottom:1px solid #eee;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.woo-variation-swatches-variation-product-options-wrapper .form-settings-group .form-label{vertical-align:middle;line-height:2;width:280px;margin:5px 10px;font-weight:700}.woo-variation-swatches-variation-product-options-wrapper .form-settings-group .form-field{vertical-align:middle;line-height:2;margin:5px 10px}.woo-variation-swatches-variation-product-options-wrapper .form-settings-group .form-field .description{display:inline-block;vertical-align:middle;padding:0 10px}.woo-variation-swatches-variation-product-options-wrapper .form-settings-group-inline{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.woo-variation-swatches-variation-product-options-wrapper .wc-metabox{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;border-bottom:none!important;border-radius:0!important}.woo-variation-swatches-variation-product-options-wrapper .wc-metabox>h4{cursor:pointer;background-color:#fafafa;display:-webkit-box;display:-ms-flexbox;display:flex;border-bottom:1px solid #eee}.woo-variation-swatches-variation-product-options-wrapper .wc-metabox>h4 .attribute-label{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}.woo-variation-swatches-variation-product-options-wrapper .wc-metabox.open>h4{background-color:#eee}.woo-variation-swatches-variation-product-options-wrapper .wc-metabox .wc-metabox{border:1px solid #eee}.woo-variation-swatches-variation-product-options-wrapper .woo-variation-swatches-attribute-data{background-color:#fff}.woo-variation-swatches-variation-product-options-wrapper .woo-variation-swatches-attribute-data-inner{margin:5px 0;padding:0 5px}.woo-variation-swatches-variation-product-options-wrapper .product-term-label-settings{margin:15px}.woo-variation-swatches-variation-product-options-wrapper .product-term-label-settings-pagination{margin:10px 0}.woo-variation-swatches-variation-product-options-wrapper .product-term-label-settings-pagination .tablenav-pages{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;line-height:2;vertical-align:center}.woo-variation-swatches-variation-product-options-wrapper .product-term-label-settings-pagination .tablenav-pages .displaying-num{padding:0 2px}
|
assets/css/frontend.css
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
-
* Date: 6/
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
:root {
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 6/23/2022, 8:34:29 PM
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
:root {
|
assets/js/admin.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
-
* Date: 6/
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
/******/ (function(modules) { // webpackBootstrap
|
@@ -531,12 +531,16 @@ var PluginHelper = function ($) {
|
|
531 |
}, {
|
532 |
key: "ResetAfterTermCreate",
|
533 |
value: function ResetAfterTermCreate() {
|
|
|
|
|
534 |
$(document).ajaxComplete(function (event, request, settings) {
|
535 |
try {
|
536 |
var data = Object.fromEntries(new URLSearchParams(settings.data));
|
537 |
|
538 |
if ('add-tag' === data.action && '' === $('#tag-name').val()) {
|
539 |
-
|
|
|
|
|
540 |
}
|
541 |
} catch (err) {}
|
542 |
});
|
@@ -546,9 +550,7 @@ var PluginHelper = function ($) {
|
|
546 |
value: function ImageUploader() {
|
547 |
$(document.body).off('click', 'button.wvs_upload_image_button');
|
548 |
$(document.body).on('click', 'button.wvs_upload_image_button', this.AddImage);
|
549 |
-
$(document.body).on('click', 'button.wvs_remove_image_button', this.RemoveImage);
|
550 |
-
$(document.body).on('woo_variation_swatches_admin_term_meta_added', this.ClearImagePicker);
|
551 |
-
$(document.body).on('woo_variation_swatches_admin_term_meta_added', this.ClearColorPicker); // $(document.body).on('woo_variation_swatches_admin_term_meta_added', this.ResetTagForm);
|
552 |
}
|
553 |
}, {
|
554 |
key: "AddImage",
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 6/23/2022, 8:34:29 PM
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
/******/ (function(modules) { // webpackBootstrap
|
531 |
}, {
|
532 |
key: "ResetAfterTermCreate",
|
533 |
value: function ResetAfterTermCreate() {
|
534 |
+
$(document.body).on('woo_variation_swatches_admin_term_meta_added', this.ClearImagePicker);
|
535 |
+
$(document.body).on('woo_variation_swatches_admin_term_meta_added', this.ClearColorPicker);
|
536 |
$(document).ajaxComplete(function (event, request, settings) {
|
537 |
try {
|
538 |
var data = Object.fromEntries(new URLSearchParams(settings.data));
|
539 |
|
540 |
if ('add-tag' === data.action && '' === $('#tag-name').val()) {
|
541 |
+
_.delay(function () {
|
542 |
+
$(document.body).trigger('woo_variation_swatches_admin_term_meta_added', data);
|
543 |
+
}, 300);
|
544 |
}
|
545 |
} catch (err) {}
|
546 |
});
|
550 |
value: function ImageUploader() {
|
551 |
$(document.body).off('click', 'button.wvs_upload_image_button');
|
552 |
$(document.body).on('click', 'button.wvs_upload_image_button', this.AddImage);
|
553 |
+
$(document.body).on('click', 'button.wvs_remove_image_button', this.RemoveImage); // $(document.body).on('woo_variation_swatches_admin_term_meta_added', this.ResetTagForm);
|
|
|
|
|
554 |
}
|
555 |
}, {
|
556 |
key: "AddImage",
|
assets/js/admin.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){var e={};function o(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.m=t,o.c=e,o.d=function(t,e,a){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(o.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(a,n,function(e){return t[e]}.bind(null,n));return a},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="/",o(o.s=0)}([function(t,e,o){o(1),o(8),t.exports=o(13)},function(t,e,o){function a(t){return(a="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)}function n(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,o=new WeakMap;return(n=function(t){return t?o:e})(t)}jQuery((function(t){Promise.resolve().then((function(){return function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==a(t)&&"function"!=typeof t)return{default:t};var o=n(e);if(o&&o.has(t))return o.get(t);var i={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var c in t)if("default"!==c&&Object.prototype.hasOwnProperty.call(t,c)){var s=r?Object.getOwnPropertyDescriptor(t,c):null;s&&(s.get||s.set)?Object.defineProperty(i,c,s):i[c]=t[c]}return i.default=t,o&&o.set(t,i),i}(o(2))})).then((function(e){var o=e.PluginHelper;o.ResetAfterTermCreate(),o.ColorPicker(),o.ImageUploader(),o.FieldDependency(),o.Pagination(),o.MetaboxToggle(),o.AttributeTypeSwitch(),o.SaveProductAttributes(),t(document.body).on("woo_variation_swatches_variation_product_options_reset woo_variation_swatches_product_term_paging_done",(function(t,e){o.InitTooltip(),o.SelectWoo(),o.ColorPicker(),o.FieldDependency(),o.SetAttributeTypePaging(e)}))}))}))},function(t,e,o){"use strict";function a(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,a)}return o}function n(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function i(t,e){for(var o=0;o<e.length;o++){var a=e[o];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}o.r(e),o.d(e,"PluginHelper",(function(){return c}));var r,c=(r=jQuery,function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,o,c;return e=t,c=[{key:"GWPAdmin",value:function(){r().gwp_live_feed&&r().gwp_live_feed(),r().gwp_deactivate_popup&&r().gwp_deactivate_popup("woo-variation-swatches")}},{key:"GalleryNotification",value:function(){r(".woocommerce_variation").each((function(){var t=r(this).find(".options:first");r(this).find(".woo-variation-gallery-message").insertBefore(t)})),r("input.upload_image_id").on("change",(function(t){r.trim(r(this).val())?r(this).closest(".data").find(".woo-variation-gallery-message").addClass("enable"):r(this).closest(".data").find(".woo-variation-gallery-message").removeClass("enable")})),r("a.install-woo-variation-gallery-action").on("click",(function(t){t.preventDefault();var e=r(this).parent(),o=e.data("installing"),a=e.data("activated"),n=e.data("nonce");e.text(o),wp.ajax.send("install_woo_variation_gallery",{data:{nonce:n},success:function(t){e.text(a),_.delay((function(){r(".woocommerce_variable_attributes .woo-variation-gallery-message").remove()}),5e3)},error:function(t){e.text(a),_.delay((function(){r(".woocommerce_variable_attributes .woo-variation-gallery-message").remove()}),5e3)}})}))}},{key:"PaginationAjax",value:function(t,e,o,a,n){r.ajax({global:!1,url:woo_variation_swatches_admin.wc_ajax_url.toString().replace("%%endpoint%%","woo_variation_swatches_load_product_terms"),method:"POST",data:{offset:a,product_id:t,attribute_id:e,attribute_name:o,nonce:woo_variation_swatches_admin.nonce},beforeSend:function(t,e){n.block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}})}}).fail((function(e,o){console.error("not available on: ".concat(t," ").concat($attribute_key,"."),o)})).always((function(){n.unblock()})).done((function(t){t&&(n.html(t),r(document.body).trigger("woo_variation_swatches_product_term_paging_done",n))}))}},{key:"MetaboxToggle",value:function(){r("#woo_variation_swatches_variation_product_options").on("click",".wc-metabox > h4",(function(t){var e=r(this).parent(".wc-metabox"),o=r(this).next(".wc-metabox-content");if(r(t.target).filter(":input, option, .sort, select, label, .select2-selection__rendered").length)return!1;e.hasClass("closed")?(e.removeClass("closed open").addClass("open"),o.slideDown()):(e.removeClass("closed open").addClass("closed"),o.slideUp())}))}},{key:"AttributeTypeSwitch",value:function(){r("#woo_variation_swatches_variation_product_options").on("change","select.woo_variation_swatches_attribute_type_switch",(function(t){var e=r(this).val();["select"].includes(e),["image","color","button"].includes(e)&&r(this).closest(".wc-metabox").find(".wc-metabox-content select.woo_variation_swatches_attribute_term_type_switch").val(e).trigger("change")})).on("change","select.woo_variation_swatches_attribute_term_type_switch",(function(t){var e=r(this).closest(".woo-variation-swatches-attribute-options-wrapper").find("select.woo_variation_swatches_attribute_type_switch").val();r(this).val()!==e&&r(this).closest(".woo-variation-swatches-attribute-options-wrapper").find("select.woo_variation_swatches_attribute_type_switch").val("mixed").trigger("change")}))}},{key:"SetAttributeTypePaging",value:function(t){var e=r(t).closest(".woo-variation-swatches-attribute-options-wrapper").find("select.woo_variation_swatches_attribute_type_switch").val();r(t).find("select.woo_variation_swatches_attribute_term_type_switch").hasClass("new-mode"),["image","color","button"].includes(e)&&r(t).find("select.woo_variation_swatches_attribute_term_type_switch.new-mode").val(e).trigger("change"),r(t).find("select.woo_variation_swatches_attribute_term_type_switch.new-mode").each((function(){r(this).val()}))}},{key:"LoadProductAttributes",value:function(){r("#woocommerce-product-data").on("woocommerce_variations_loaded",(function(t){var e=r("#woo_variation_swatches_variation_product_options").data("product_id");r.ajax({global:!1,url:woo_variation_swatches_admin.wc_ajax_url.toString().replace("%%endpoint%%","woo_variation_swatches_load_product_options"),method:"POST",data:{product_id:e,nonce:woo_variation_swatches_admin.nonce},beforeSend:function(t,e){r("#woo_variation_swatches_variation_product_options_inner").block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}})}}).fail((function(t,o){console.error("not load option: ".concat(e,"."),o)})).always((function(){r("#woo_variation_swatches_variation_product_options_inner").unblock()})).done((function(t){r(document.body).trigger("woo_variation_swatches_variation_product_options_loaded",e)}))}))}},{key:"SaveProductAttributes",value:function(){var t=!1,e=r("#woo_variation_swatches_variation_product_options");e.on("change input color-changed",":input:not(.wvs-skip-field)",(function(){t||(window.onbeforeunload=function(){return woo_variation_swatches_admin.nav_warning},t=!0)})).on("click",".woo_variation_swatches_save_product_attributes, .woo_variation_swatches_reset_product_attributes",(function(){window.onbeforeunload=""})).on("click",".woo_variation_swatches_save_product_attributes",(function(t){t.preventDefault();var o,a=e.find(":input:not(.wvs-skip-field)").serializeJSON({disableColonTypes:!0}),n=Object.keys(a)?Object.keys(a).shift():"woo_variation_swatches_product_options",i=e.data("product_id");r.ajax({global:!1,url:woo_variation_swatches_admin.wc_ajax_url.toString().replace("%%endpoint%%","woo_variation_swatches_save_product_options"),method:"POST",data:{data:a[n],product_id:i,nonce:woo_variation_swatches_admin.nonce},beforeSend:function(t,e){clearTimeout(o),r("#woo_variation_swatches_variation_product_options_inner").block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}})}}).fail((function(t,e){console.error("not saved on: ".concat(i,"."),e)})).always((function(){r("#woo_variation_swatches_variation_product_options_inner").unblock()})).done((function(t){r("#saved-message").show(),o=setTimeout((function(){r("#saved-message").hide(600)}),5e3),r(document.body).trigger("woo_variation_swatches_variation_product_options_saved",i)}))})).on("click",".woo_variation_swatches_reset_product_attributes",(function(t){if(t.preventDefault(),confirm(woo_variation_swatches_admin.reset_notice)){var e=r(this).data("product_id");r.ajax({global:!1,url:woo_variation_swatches_admin.wc_ajax_url.toString().replace("%%endpoint%%","woo_variation_swatches_reset_product_options"),method:"POST",data:{product_id:e,nonce:woo_variation_swatches_admin.nonce},beforeSend:function(t,e){r("#woo_variation_swatches_variation_product_options_inner").block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}})}}).fail((function(t,o){console.error("not reset on: ".concat(e,"."),o)})).always((function(){r("#woo_variation_swatches_variation_product_options_inner").unblock()})).done((function(t){var o=r(t).find("#woo_variation_swatches_variation_product_options_inner").html();r("#woo_variation_swatches_variation_product_options_inner").html(o),r(document.body).trigger("woo_variation_swatches_variation_product_options_reset",e)}))}}))}},{key:"ResetProductAttributes",value:function(){r("#woo_variation_swatches_variation_product_options")}},{key:"Pagination",value:function(){var t=this,e=!1;r("#woo_variation_swatches_variation_product_options").on("change input color-changed",":input:not(.wvs-skip-field)",(function(t){e||(e=!0)})).on("click",".woo_variation_swatches_reset_product_attributes",(function(t){t.preventDefault(),e=!1})).on("click",".woo_variation_swatches_save_product_attributes",(function(t){t.preventDefault(),e=!1})).on("click",".first-page:not(.disabled), .prev-page:not(.disabled), .last-page:not(.disabled), .next-page:not(.disabled)",(function(t){e&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),alert(woo_variation_swatches_admin.nav_warning))})).on("click",".first-page.disabled, .prev-page.disabled, .last-page.disabled, .next-page.disabled",(function(t){t.preventDefault()})).on("click",".first-page:not(.disabled)",(function(e){e.preventDefault();var o=r(e.currentTarget).closest(".product-term-label-settings").find(".product-term-label-settings-contents"),a=r(e.currentTarget).closest(".product-term-label-settings-pagination"),n=o.data("product_id"),i=o.data("attribute_id"),c=o.data("attribute_name");t.PaginationAjax(n,i,c,0,o),a.find(".next-page, .last-page").removeClass("disabled"),a.find(".current-page").text(1),o.data("current",1),a.find(".first-page, .prev-page").addClass("disabled")})).on("click",".prev-page:not(.disabled)",(function(e){e.preventDefault();var o=r(e.currentTarget).closest(".product-term-label-settings").find(".product-term-label-settings-contents"),a=r(e.currentTarget).closest(".product-term-label-settings-pagination");o.block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}});var n=o.data("product_id"),i=(o.data("pages"),o.data("attribute_id")),c=o.data("attribute_name"),s=o.data("current"),l=o.data("limit"),d=(o.data("total"),(s-1)*l-l),u=s-1;t.PaginationAjax(n,i,c,d,o),a.find(".next-page, .last-page").removeClass("disabled"),a.find(".current-page").text(u),o.data("current",u),0===d&&a.find(".first-page, .prev-page").addClass("disabled")})).on("click",".next-page:not(.disabled)",(function(e){e.preventDefault();var o=r(e.currentTarget).closest(".product-term-label-settings").find(".product-term-label-settings-contents"),a=r(e.currentTarget).closest(".product-term-label-settings-pagination");o.block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}});var n=o.data("product_id"),i=o.data("pages"),c=o.data("attribute_id"),s=o.data("attribute_name"),l=o.data("current"),d=o.data("limit"),u=(o.data("total"),l*d),_=l+1;t.PaginationAjax(n,c,s,u,o),a.find(".first-page, .prev-page").removeClass("disabled"),a.find(".current-page").text(_),o.data("current",_),i===_&&a.find(".next-page, .last-page").addClass("disabled")})).on("click",".last-page:not(.disabled)",(function(e){e.preventDefault();var o=r(e.currentTarget).closest(".product-term-label-settings").find(".product-term-label-settings-contents"),a=r(e.currentTarget).closest(".product-term-label-settings-pagination");o.block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}});var n=o.data("product_id"),i=o.data("pages"),c=o.data("attribute_id"),s=o.data("attribute_name"),l=(o.data("current"),o.data("limit")),d=i*l-l;t.PaginationAjax(n,c,s,d,o),a.find(".first-page, .prev-page").removeClass("disabled"),a.find(".current-page").text(i),o.data("current",i),a.find(".next-page, .last-page").addClass("disabled")}))}},{key:"ResetAfterTermCreate",value:function(){r(document).ajaxComplete((function(t,e,o){try{var a=Object.fromEntries(new URLSearchParams(o.data));"add-tag"===a.action&&""===r("#tag-name").val()&&r(document.body).trigger("woo_variation_swatches_admin_term_meta_added",a)}catch(t){}}))}},{key:"ImageUploader",value:function(){r(document.body).off("click","button.wvs_upload_image_button"),r(document.body).on("click","button.wvs_upload_image_button",this.AddImage),r(document.body).on("click","button.wvs_remove_image_button",this.RemoveImage),r(document.body).on("woo_variation_swatches_admin_term_meta_added",this.ClearImagePicker),r(document.body).on("woo_variation_swatches_admin_term_meta_added",this.ClearColorPicker)}},{key:"AddImage",value:function(t){var e,o=this;if(t.preventDefault(),t.stopPropagation(),"undefined"!=typeof wp&&wp.media&&wp.media.editor){if(e)return void e.open();(e=wp.media.frames.select_image=wp.media({title:woo_variation_swatches_admin.media_title,button:{text:woo_variation_swatches_admin.button_title},multiple:!1})).on("select",(function(){var t=e.state().get("selection").first().toJSON();if(""!==r.trim(t.id)){var a=void 0===t.sizes.thumbnail?t.sizes.full.url:t.sizes.thumbnail.url;r(o).prev().val(t.id),r(o).closest(".meta-image-field-wrapper").find("img").attr("src",a),r(o).next().show()}})),e.on("open",(function(){var t=e.state().get("selection"),a=r(o).prev().val(),n=wp.media.attachment(a);n.fetch(),t.add(n?[n]:[])})),e.open()}}},{key:"RemoveImage",value:function(t){t.preventDefault(),t.stopPropagation();var e=r(this).closest(".meta-image-field-wrapper").find("img").data("placeholder");return r(this).closest(".meta-image-field-wrapper").find("img").attr("src",e),r(this).prev().prev().val(""),r(this).hide(),!1}},{key:"ClearImagePicker",value:function(){r("#addtag").find(".wvs_remove_image_button").trigger("click")}},{key:"__SelectWoo",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"select.wvs-select-woo";try{r(document.body).on("woo_variation_swatches_select_woo_init",(function(e){r(t).selectWoo({allowClear:!0})})).trigger("woo_variation_swatches_select_woo_init")}catch(t){window.console.log(t)}}},{key:"InitTooltip",value:function(){r(document.body).trigger("init_tooltips")}},{key:"SelectWoo",value:function(){try{r(document.body).trigger("wc-enhanced-select-init")}catch(t){window.console.log(t)}}},{key:"ColorPicker",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"input.wvs-color-picker";try{r(document.body).on("woo_variation_swatches_color_picker_init",(function(e){r(t).wpColorPicker({change:function(e,o){r(t).trigger("color-changed")},clear:function(){r(t).trigger("color-changed")}})})).trigger("woo_variation_swatches_color_picker_init")}catch(t){window.console.log(t)}}},{key:"ClearColorPicker",value:function(){r("#addtag").find(".wp-picker-clear").trigger("click")}},{key:"FieldDependency",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-dependency]";try{r(document.body).on("init_form_field_dependency",(function(){r(t).GWPFormFieldDependency()})).trigger("init_form_field_dependency")}catch(t){window.console.log(t)}}},{key:"savingDialog",value:function(t,e,o){var i={},c="";if(e.find("input, select").each((function(){var t=r(this).attr("name"),e=r(this).val();t&&("tag_name"===t?c=e:i[t]=e,r(this).val(""))})),c){r(".product_attributes").block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}});var s=function(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?a(Object(o),!0).forEach((function(e){n(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):a(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({action:"woocommerce_add_new_attribute",taxonomy:o,term:c,security:woocommerce_admin_meta_boxes.add_attribute_nonce},i);r.post(woocommerce_admin_meta_boxes.ajax_url,s,(function(e){e.error?window.alert(e.error):e.slug&&(t.find("select.attribute_values").append('<option value="'+e.term_id+'" selected="selected">'+e.name+"</option>"),t.find("select.attribute_values").change()),r(".product_attributes").unblock()}))}else r(".product_attributes").unblock()}},{key:"AttributeDialog",value:function(){var t=this;r(".product_attributes").on("click","button.wvs_add_new_attribute",(function(e){e.preventDefault();var o=r(this).closest(".woocommerce_attribute"),a=o.data("taxonomy"),n=r(this).data("dialog_title");r(".wvs-attribute-dialog-for-"+a).dialog({title:"",dialogClass:"wp-dialog wvs-attribute-dialog",classes:{"ui-dialog":"wp-dialog wvs-attribute-dialog"},autoOpen:!1,draggable:!0,width:"auto",modal:!0,resizable:!1,closeOnEscape:!0,position:{my:"center",at:"center",of:window},open:function(){r(".ui-widget-overlay").bind("click",(function(){r("#attribute-dialog").dialog("close")}))},create:function(){}}).dialog("option","title",n).dialog("option","buttons",[{text:woo_variation_swatches_admin.dialog_save,click:function(){t.savingDialog(o,r(this),a),r(this).dialog("close").dialog("destroy")}},{text:woo_variation_swatches_admin.dialog_cancel,click:function(){r(this).dialog("close").dialog("destroy")}}]).dialog("open")}))}}],(o=null)&&i(e.prototype,o),c&&i(e,c),t}())},,,,,,function(t,e){},,,,,function(t,e){}]);
|
1 |
+
!function(t){var e={};function o(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.m=t,o.c=e,o.d=function(t,e,a){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(o.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(a,n,function(e){return t[e]}.bind(null,n));return a},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="/",o(o.s=0)}([function(t,e,o){o(1),o(8),t.exports=o(13)},function(t,e,o){function a(t){return(a="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)}function n(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,o=new WeakMap;return(n=function(t){return t?o:e})(t)}jQuery((function(t){Promise.resolve().then((function(){return function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==a(t)&&"function"!=typeof t)return{default:t};var o=n(e);if(o&&o.has(t))return o.get(t);var i={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var c in t)if("default"!==c&&Object.prototype.hasOwnProperty.call(t,c)){var s=r?Object.getOwnPropertyDescriptor(t,c):null;s&&(s.get||s.set)?Object.defineProperty(i,c,s):i[c]=t[c]}return i.default=t,o&&o.set(t,i),i}(o(2))})).then((function(e){var o=e.PluginHelper;o.ResetAfterTermCreate(),o.ColorPicker(),o.ImageUploader(),o.FieldDependency(),o.Pagination(),o.MetaboxToggle(),o.AttributeTypeSwitch(),o.SaveProductAttributes(),t(document.body).on("woo_variation_swatches_variation_product_options_reset woo_variation_swatches_product_term_paging_done",(function(t,e){o.InitTooltip(),o.SelectWoo(),o.ColorPicker(),o.FieldDependency(),o.SetAttributeTypePaging(e)}))}))}))},function(t,e,o){"use strict";function a(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,a)}return o}function n(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function i(t,e){for(var o=0;o<e.length;o++){var a=e[o];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}o.r(e),o.d(e,"PluginHelper",(function(){return c}));var r,c=(r=jQuery,function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,o,c;return e=t,c=[{key:"GWPAdmin",value:function(){r().gwp_live_feed&&r().gwp_live_feed(),r().gwp_deactivate_popup&&r().gwp_deactivate_popup("woo-variation-swatches")}},{key:"GalleryNotification",value:function(){r(".woocommerce_variation").each((function(){var t=r(this).find(".options:first");r(this).find(".woo-variation-gallery-message").insertBefore(t)})),r("input.upload_image_id").on("change",(function(t){r.trim(r(this).val())?r(this).closest(".data").find(".woo-variation-gallery-message").addClass("enable"):r(this).closest(".data").find(".woo-variation-gallery-message").removeClass("enable")})),r("a.install-woo-variation-gallery-action").on("click",(function(t){t.preventDefault();var e=r(this).parent(),o=e.data("installing"),a=e.data("activated"),n=e.data("nonce");e.text(o),wp.ajax.send("install_woo_variation_gallery",{data:{nonce:n},success:function(t){e.text(a),_.delay((function(){r(".woocommerce_variable_attributes .woo-variation-gallery-message").remove()}),5e3)},error:function(t){e.text(a),_.delay((function(){r(".woocommerce_variable_attributes .woo-variation-gallery-message").remove()}),5e3)}})}))}},{key:"PaginationAjax",value:function(t,e,o,a,n){r.ajax({global:!1,url:woo_variation_swatches_admin.wc_ajax_url.toString().replace("%%endpoint%%","woo_variation_swatches_load_product_terms"),method:"POST",data:{offset:a,product_id:t,attribute_id:e,attribute_name:o,nonce:woo_variation_swatches_admin.nonce},beforeSend:function(t,e){n.block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}})}}).fail((function(e,o){console.error("not available on: ".concat(t," ").concat($attribute_key,"."),o)})).always((function(){n.unblock()})).done((function(t){t&&(n.html(t),r(document.body).trigger("woo_variation_swatches_product_term_paging_done",n))}))}},{key:"MetaboxToggle",value:function(){r("#woo_variation_swatches_variation_product_options").on("click",".wc-metabox > h4",(function(t){var e=r(this).parent(".wc-metabox"),o=r(this).next(".wc-metabox-content");if(r(t.target).filter(":input, option, .sort, select, label, .select2-selection__rendered").length)return!1;e.hasClass("closed")?(e.removeClass("closed open").addClass("open"),o.slideDown()):(e.removeClass("closed open").addClass("closed"),o.slideUp())}))}},{key:"AttributeTypeSwitch",value:function(){r("#woo_variation_swatches_variation_product_options").on("change","select.woo_variation_swatches_attribute_type_switch",(function(t){var e=r(this).val();["select"].includes(e),["image","color","button"].includes(e)&&r(this).closest(".wc-metabox").find(".wc-metabox-content select.woo_variation_swatches_attribute_term_type_switch").val(e).trigger("change")})).on("change","select.woo_variation_swatches_attribute_term_type_switch",(function(t){var e=r(this).closest(".woo-variation-swatches-attribute-options-wrapper").find("select.woo_variation_swatches_attribute_type_switch").val();r(this).val()!==e&&r(this).closest(".woo-variation-swatches-attribute-options-wrapper").find("select.woo_variation_swatches_attribute_type_switch").val("mixed").trigger("change")}))}},{key:"SetAttributeTypePaging",value:function(t){var e=r(t).closest(".woo-variation-swatches-attribute-options-wrapper").find("select.woo_variation_swatches_attribute_type_switch").val();r(t).find("select.woo_variation_swatches_attribute_term_type_switch").hasClass("new-mode"),["image","color","button"].includes(e)&&r(t).find("select.woo_variation_swatches_attribute_term_type_switch.new-mode").val(e).trigger("change"),r(t).find("select.woo_variation_swatches_attribute_term_type_switch.new-mode").each((function(){r(this).val()}))}},{key:"LoadProductAttributes",value:function(){r("#woocommerce-product-data").on("woocommerce_variations_loaded",(function(t){var e=r("#woo_variation_swatches_variation_product_options").data("product_id");r.ajax({global:!1,url:woo_variation_swatches_admin.wc_ajax_url.toString().replace("%%endpoint%%","woo_variation_swatches_load_product_options"),method:"POST",data:{product_id:e,nonce:woo_variation_swatches_admin.nonce},beforeSend:function(t,e){r("#woo_variation_swatches_variation_product_options_inner").block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}})}}).fail((function(t,o){console.error("not load option: ".concat(e,"."),o)})).always((function(){r("#woo_variation_swatches_variation_product_options_inner").unblock()})).done((function(t){r(document.body).trigger("woo_variation_swatches_variation_product_options_loaded",e)}))}))}},{key:"SaveProductAttributes",value:function(){var t=!1,e=r("#woo_variation_swatches_variation_product_options");e.on("change input color-changed",":input:not(.wvs-skip-field)",(function(){t||(window.onbeforeunload=function(){return woo_variation_swatches_admin.nav_warning},t=!0)})).on("click",".woo_variation_swatches_save_product_attributes, .woo_variation_swatches_reset_product_attributes",(function(){window.onbeforeunload=""})).on("click",".woo_variation_swatches_save_product_attributes",(function(t){t.preventDefault();var o,a=e.find(":input:not(.wvs-skip-field)").serializeJSON({disableColonTypes:!0}),n=Object.keys(a)?Object.keys(a).shift():"woo_variation_swatches_product_options",i=e.data("product_id");r.ajax({global:!1,url:woo_variation_swatches_admin.wc_ajax_url.toString().replace("%%endpoint%%","woo_variation_swatches_save_product_options"),method:"POST",data:{data:a[n],product_id:i,nonce:woo_variation_swatches_admin.nonce},beforeSend:function(t,e){clearTimeout(o),r("#woo_variation_swatches_variation_product_options_inner").block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}})}}).fail((function(t,e){console.error("not saved on: ".concat(i,"."),e)})).always((function(){r("#woo_variation_swatches_variation_product_options_inner").unblock()})).done((function(t){r("#saved-message").show(),o=setTimeout((function(){r("#saved-message").hide(600)}),5e3),r(document.body).trigger("woo_variation_swatches_variation_product_options_saved",i)}))})).on("click",".woo_variation_swatches_reset_product_attributes",(function(t){if(t.preventDefault(),confirm(woo_variation_swatches_admin.reset_notice)){var e=r(this).data("product_id");r.ajax({global:!1,url:woo_variation_swatches_admin.wc_ajax_url.toString().replace("%%endpoint%%","woo_variation_swatches_reset_product_options"),method:"POST",data:{product_id:e,nonce:woo_variation_swatches_admin.nonce},beforeSend:function(t,e){r("#woo_variation_swatches_variation_product_options_inner").block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}})}}).fail((function(t,o){console.error("not reset on: ".concat(e,"."),o)})).always((function(){r("#woo_variation_swatches_variation_product_options_inner").unblock()})).done((function(t){var o=r(t).find("#woo_variation_swatches_variation_product_options_inner").html();r("#woo_variation_swatches_variation_product_options_inner").html(o),r(document.body).trigger("woo_variation_swatches_variation_product_options_reset",e)}))}}))}},{key:"ResetProductAttributes",value:function(){r("#woo_variation_swatches_variation_product_options")}},{key:"Pagination",value:function(){var t=this,e=!1;r("#woo_variation_swatches_variation_product_options").on("change input color-changed",":input:not(.wvs-skip-field)",(function(t){e||(e=!0)})).on("click",".woo_variation_swatches_reset_product_attributes",(function(t){t.preventDefault(),e=!1})).on("click",".woo_variation_swatches_save_product_attributes",(function(t){t.preventDefault(),e=!1})).on("click",".first-page:not(.disabled), .prev-page:not(.disabled), .last-page:not(.disabled), .next-page:not(.disabled)",(function(t){e&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),alert(woo_variation_swatches_admin.nav_warning))})).on("click",".first-page.disabled, .prev-page.disabled, .last-page.disabled, .next-page.disabled",(function(t){t.preventDefault()})).on("click",".first-page:not(.disabled)",(function(e){e.preventDefault();var o=r(e.currentTarget).closest(".product-term-label-settings").find(".product-term-label-settings-contents"),a=r(e.currentTarget).closest(".product-term-label-settings-pagination"),n=o.data("product_id"),i=o.data("attribute_id"),c=o.data("attribute_name");t.PaginationAjax(n,i,c,0,o),a.find(".next-page, .last-page").removeClass("disabled"),a.find(".current-page").text(1),o.data("current",1),a.find(".first-page, .prev-page").addClass("disabled")})).on("click",".prev-page:not(.disabled)",(function(e){e.preventDefault();var o=r(e.currentTarget).closest(".product-term-label-settings").find(".product-term-label-settings-contents"),a=r(e.currentTarget).closest(".product-term-label-settings-pagination");o.block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}});var n=o.data("product_id"),i=(o.data("pages"),o.data("attribute_id")),c=o.data("attribute_name"),s=o.data("current"),l=o.data("limit"),d=(o.data("total"),(s-1)*l-l),u=s-1;t.PaginationAjax(n,i,c,d,o),a.find(".next-page, .last-page").removeClass("disabled"),a.find(".current-page").text(u),o.data("current",u),0===d&&a.find(".first-page, .prev-page").addClass("disabled")})).on("click",".next-page:not(.disabled)",(function(e){e.preventDefault();var o=r(e.currentTarget).closest(".product-term-label-settings").find(".product-term-label-settings-contents"),a=r(e.currentTarget).closest(".product-term-label-settings-pagination");o.block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}});var n=o.data("product_id"),i=o.data("pages"),c=o.data("attribute_id"),s=o.data("attribute_name"),l=o.data("current"),d=o.data("limit"),u=(o.data("total"),l*d),_=l+1;t.PaginationAjax(n,c,s,u,o),a.find(".first-page, .prev-page").removeClass("disabled"),a.find(".current-page").text(_),o.data("current",_),i===_&&a.find(".next-page, .last-page").addClass("disabled")})).on("click",".last-page:not(.disabled)",(function(e){e.preventDefault();var o=r(e.currentTarget).closest(".product-term-label-settings").find(".product-term-label-settings-contents"),a=r(e.currentTarget).closest(".product-term-label-settings-pagination");o.block({message:null,overlayCSS:{background:"#DDDDDD",opacity:.6}});var n=o.data("product_id"),i=o.data("pages"),c=o.data("attribute_id"),s=o.data("attribute_name"),l=(o.data("current"),o.data("limit")),d=i*l-l;t.PaginationAjax(n,c,s,d,o),a.find(".first-page, .prev-page").removeClass("disabled"),a.find(".current-page").text(i),o.data("current",i),a.find(".next-page, .last-page").addClass("disabled")}))}},{key:"ResetAfterTermCreate",value:function(){r(document.body).on("woo_variation_swatches_admin_term_meta_added",this.ClearImagePicker),r(document.body).on("woo_variation_swatches_admin_term_meta_added",this.ClearColorPicker),r(document).ajaxComplete((function(t,e,o){try{var a=Object.fromEntries(new URLSearchParams(o.data));"add-tag"===a.action&&""===r("#tag-name").val()&&_.delay((function(){r(document.body).trigger("woo_variation_swatches_admin_term_meta_added",a)}),300)}catch(t){}}))}},{key:"ImageUploader",value:function(){r(document.body).off("click","button.wvs_upload_image_button"),r(document.body).on("click","button.wvs_upload_image_button",this.AddImage),r(document.body).on("click","button.wvs_remove_image_button",this.RemoveImage)}},{key:"AddImage",value:function(t){var e,o=this;if(t.preventDefault(),t.stopPropagation(),"undefined"!=typeof wp&&wp.media&&wp.media.editor){if(e)return void e.open();(e=wp.media.frames.select_image=wp.media({title:woo_variation_swatches_admin.media_title,button:{text:woo_variation_swatches_admin.button_title},multiple:!1})).on("select",(function(){var t=e.state().get("selection").first().toJSON();if(""!==r.trim(t.id)){var a=void 0===t.sizes.thumbnail?t.sizes.full.url:t.sizes.thumbnail.url;r(o).prev().val(t.id),r(o).closest(".meta-image-field-wrapper").find("img").attr("src",a),r(o).next().show()}})),e.on("open",(function(){var t=e.state().get("selection"),a=r(o).prev().val(),n=wp.media.attachment(a);n.fetch(),t.add(n?[n]:[])})),e.open()}}},{key:"RemoveImage",value:function(t){t.preventDefault(),t.stopPropagation();var e=r(this).closest(".meta-image-field-wrapper").find("img").data("placeholder");return r(this).closest(".meta-image-field-wrapper").find("img").attr("src",e),r(this).prev().prev().val(""),r(this).hide(),!1}},{key:"ClearImagePicker",value:function(){r("#addtag").find(".wvs_remove_image_button").trigger("click")}},{key:"__SelectWoo",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"select.wvs-select-woo";try{r(document.body).on("woo_variation_swatches_select_woo_init",(function(e){r(t).selectWoo({allowClear:!0})})).trigger("woo_variation_swatches_select_woo_init")}catch(t){window.console.log(t)}}},{key:"InitTooltip",value:function(){r(document.body).trigger("init_tooltips")}},{key:"SelectWoo",value:function(){try{r(document.body).trigger("wc-enhanced-select-init")}catch(t){window.console.log(t)}}},{key:"ColorPicker",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"input.wvs-color-picker";try{r(document.body).on("woo_variation_swatches_color_picker_init",(function(e){r(t).wpColorPicker({change:function(e,o){r(t).trigger("color-changed")},clear:function(){r(t).trigger("color-changed")}})})).trigger("woo_variation_swatches_color_picker_init")}catch(t){window.console.log(t)}}},{key:"ClearColorPicker",value:function(){r("#addtag").find(".wp-picker-clear").trigger("click")}},{key:"FieldDependency",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-dependency]";try{r(document.body).on("init_form_field_dependency",(function(){r(t).GWPFormFieldDependency()})).trigger("init_form_field_dependency")}catch(t){window.console.log(t)}}},{key:"savingDialog",value:function(t,e,o){var i={},c="";if(e.find("input, select").each((function(){var t=r(this).attr("name"),e=r(this).val();t&&("tag_name"===t?c=e:i[t]=e,r(this).val(""))})),c){r(".product_attributes").block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}});var s=function(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?a(Object(o),!0).forEach((function(e){n(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):a(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({action:"woocommerce_add_new_attribute",taxonomy:o,term:c,security:woocommerce_admin_meta_boxes.add_attribute_nonce},i);r.post(woocommerce_admin_meta_boxes.ajax_url,s,(function(e){e.error?window.alert(e.error):e.slug&&(t.find("select.attribute_values").append('<option value="'+e.term_id+'" selected="selected">'+e.name+"</option>"),t.find("select.attribute_values").change()),r(".product_attributes").unblock()}))}else r(".product_attributes").unblock()}},{key:"AttributeDialog",value:function(){var t=this;r(".product_attributes").on("click","button.wvs_add_new_attribute",(function(e){e.preventDefault();var o=r(this).closest(".woocommerce_attribute"),a=o.data("taxonomy"),n=r(this).data("dialog_title");r(".wvs-attribute-dialog-for-"+a).dialog({title:"",dialogClass:"wp-dialog wvs-attribute-dialog",classes:{"ui-dialog":"wp-dialog wvs-attribute-dialog"},autoOpen:!1,draggable:!0,width:"auto",modal:!0,resizable:!1,closeOnEscape:!0,position:{my:"center",at:"center",of:window},open:function(){r(".ui-widget-overlay").bind("click",(function(){r("#attribute-dialog").dialog("close")}))},create:function(){}}).dialog("option","title",n).dialog("option","buttons",[{text:woo_variation_swatches_admin.dialog_save,click:function(){t.savingDialog(o,r(this),a),r(this).dialog("close").dialog("destroy")}},{text:woo_variation_swatches_admin.dialog_cancel,click:function(){r(this).dialog("close").dialog("destroy")}}]).dialog("open")}))}}],(o=null)&&i(e.prototype,o),c&&i(e,c),t}())},,,,,,function(t,e){},,,,,function(t,e){}]);
|
assets/js/frontend.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
-
* Date: 6/
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
/******/ (function(modules) { // webpackBootstrap
|
@@ -94,11 +94,9 @@
|
|
94 |
/******/ ({
|
95 |
|
96 |
/***/ "./src/js/WooVariationSwatches.js":
|
97 |
-
/***/ (function(module,
|
98 |
|
99 |
-
"
|
100 |
-
__webpack_require__.r(__webpack_exports__);
|
101 |
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
102 |
|
103 |
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
104 |
|
@@ -120,165 +118,148 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
120 |
|
121 |
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
122 |
|
|
|
|
|
123 |
// ================================================================
|
124 |
// WooCommerce Variation Swatches
|
125 |
|
126 |
/*global _, wc_add_to_cart_variation_params, woo_variation_swatches_options */
|
127 |
// ================================================================
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
var
|
132 |
-
function
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
value: function isAjaxVariation() {
|
155 |
-
//this.product_variations = this.$element.data('product_variations') || []
|
156 |
-
return this.is_ajax_variation; // = this.product_variations.length < 1
|
157 |
}
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
});
|
177 |
}
|
178 |
-
}
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
var out_of_stocks = []; // All Options
|
204 |
-
|
205 |
-
options.each(function () {
|
206 |
-
if ($(this).val() !== '') {
|
207 |
-
selects.push($(this).val());
|
208 |
-
selected = current.length === 0 ? eq.val() : current.val();
|
209 |
-
}
|
210 |
-
}); // Disabled
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
222 |
});
|
|
|
|
|
|
|
|
|
|
|
223 |
|
224 |
-
|
|
|
|
|
|
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
value: function setupItem(element, selected, in_stocks, out_of_stocks, $selected_variation_item) {
|
232 |
-
var _this3 = this;
|
233 |
-
|
234 |
-
// Mark Selected
|
235 |
-
$(element).find('li.variable-item').each(function (index, el) {
|
236 |
-
var attribute_value = $(el).attr('data-value');
|
237 |
-
var attribute_title = $(el).attr('data-title'); // Resetting LI
|
238 |
-
|
239 |
-
$(el).removeClass('selected disabled no-stock').addClass('disabled');
|
240 |
-
$(el).attr('aria-checked', 'false');
|
241 |
-
$(el).attr('tabindex', '-1');
|
242 |
-
$(el).attr('data-wvstooltip-out-of-stock', '');
|
243 |
-
$(el).find('input.variable-item-radio-input:radio').prop('disabled', true).prop('checked', false); // To Prevent blink
|
244 |
-
|
245 |
-
if (selected.length < 1 && woo_variation_swatches_options.show_variation_label) {
|
246 |
-
$selected_variation_item.text('');
|
247 |
-
} // Ajax variation
|
248 |
-
|
249 |
-
|
250 |
-
if (_this3.isAjaxVariation()) {
|
251 |
-
$(el).find('input.variable-item-radio-input:radio').prop('disabled', false);
|
252 |
-
$(el).removeClass('selected disabled no-stock'); // Selected
|
253 |
-
|
254 |
-
if (attribute_value === selected) {
|
255 |
-
$(el).addClass('selected');
|
256 |
-
$(el).attr('aria-checked', 'true');
|
257 |
-
$(el).attr('tabindex', '0');
|
258 |
-
$(el).find('input.variable-item-radio-input:radio').prop('disabled', false).prop('checked', true);
|
259 |
-
|
260 |
-
if (woo_variation_swatches_options.show_variation_label) {
|
261 |
-
$selected_variation_item.text("".concat(woo_variation_swatches_options.variation_label_separator, " ").concat(attribute_title));
|
262 |
-
}
|
263 |
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
if (_.includes(in_stocks, attribute_value)) {
|
273 |
-
$(el).removeClass('selected disabled');
|
274 |
-
$(el).removeAttr('aria-hidden');
|
275 |
-
$(el).attr('tabindex', '0');
|
276 |
-
$(el).find('input.variable-item-radio-input:radio').prop('disabled', false); // Selected
|
277 |
|
278 |
if (attribute_value === selected) {
|
279 |
$(el).addClass('selected');
|
280 |
$(el).attr('aria-checked', 'true');
|
281 |
-
$(el).
|
|
|
282 |
|
283 |
if (woo_variation_swatches_options.show_variation_label) {
|
284 |
$selected_variation_item.text("".concat(woo_variation_swatches_options.variation_label_separator, " ").concat(attribute_title));
|
@@ -286,422 +267,411 @@ var WooVariationSwatches = function ($) {
|
|
286 |
|
287 |
$(el).trigger('wvs-item-updated', [selected, attribute_value]);
|
288 |
}
|
289 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
295 |
}
|
296 |
-
}
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
event.stopPropagation();
|
325 |
-
var value = $(this).val();
|
326 |
-
select.val('').trigger('change');
|
327 |
-
select.trigger('click'); //select.trigger('focusin')
|
328 |
-
|
329 |
-
if (woo_variation_swatches_options.is_mobile) {// select.trigger('touchstart')
|
330 |
-
} // $(this).trigger('focus') // Mobile tooltip
|
331 |
-
|
332 |
-
|
333 |
-
$(this).trigger('wvs-unselected-item', [value, select, self.$element]); // Custom Event for li
|
334 |
-
}); // RADIO
|
335 |
-
// On Click trigger change event on Radio button
|
336 |
-
|
337 |
-
$(element).on('click.wvs', 'input.variable-item-radio-input:radio', function (event) {
|
338 |
-
event.stopPropagation();
|
339 |
-
$(this).trigger('change.wvs', {
|
340 |
-
radioChange: true
|
341 |
-
});
|
342 |
-
});
|
343 |
-
$(element).on('change.wvs', 'input.variable-item-radio-input:radio', function (event, params) {
|
344 |
-
event.preventDefault();
|
345 |
-
event.stopPropagation();
|
346 |
-
|
347 |
-
if (params && params.radioChange) {
|
348 |
var value = $(this).val();
|
349 |
-
|
350 |
-
|
351 |
-
if (is_selected) {
|
352 |
-
select.val('').trigger('change');
|
353 |
-
$(this).parent('li.radio-variable-item').trigger('wvs-unselected-item', [value, select, self.$element]); // Custom Event for li
|
354 |
-
} else {
|
355 |
-
select.val(value).trigger('change');
|
356 |
-
$(this).parent('li.radio-variable-item').trigger('wvs-selected-item', [value, select, self.$element]); // Custom Event for li
|
357 |
-
}
|
358 |
-
|
359 |
select.trigger('click'); //select.trigger('focusin')
|
360 |
|
361 |
-
if (woo_variation_swatches_options.is_mobile) {//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
}
|
363 |
-
}
|
364 |
-
}
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
select.trigger('click'); // select.trigger('focusin')
|
372 |
|
373 |
-
|
374 |
-
|
375 |
|
376 |
|
377 |
-
|
378 |
-
|
379 |
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
|
387 |
-
|
388 |
-
|
389 |
|
390 |
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
|
396 |
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
|
|
402 |
});
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
}
|
409 |
-
}
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
}
|
421 |
-
}
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
var _this5 = this;
|
426 |
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
|
432 |
-
|
433 |
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
|
442 |
-
|
443 |
-
|
444 |
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
|
449 |
-
|
450 |
-
|
451 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
}
|
|
|
|
|
|
|
453 |
});
|
454 |
-
|
455 |
-
|
456 |
-
|
|
|
|
|
|
|
457 |
}
|
458 |
-
}
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
477 |
}
|
478 |
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
'mayChosenCount': chosen + 1,
|
486 |
-
'data': data
|
487 |
-
};
|
488 |
-
}
|
489 |
-
}, {
|
490 |
-
key: "findStockVariations",
|
491 |
-
value: function findStockVariations(allVariations, selectedAttributes) {
|
492 |
-
var found = [];
|
493 |
|
494 |
-
|
495 |
-
|
496 |
-
attribute_name = _Object$entries$_i[0],
|
497 |
-
attribute_value = _Object$entries$_i[1];
|
498 |
|
499 |
-
|
500 |
-
|
|
|
|
|
501 |
|
502 |
-
|
503 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
504 |
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
|
509 |
-
|
|
|
|
|
510 |
|
511 |
-
|
|
|
|
|
|
|
512 |
|
513 |
-
|
514 |
-
|
515 |
-
var data = {};
|
516 |
-
data['attribute_name'] = attribute_name;
|
517 |
-
data['attribute_value'] = value;
|
518 |
-
data['variation'] = variation;
|
519 |
-
found.push(data);
|
520 |
-
}
|
521 |
-
}
|
522 |
-
} catch (err) {
|
523 |
-
_iterator.e(err);
|
524 |
-
} finally {
|
525 |
-
_iterator.f();
|
526 |
-
}
|
527 |
-
}
|
528 |
}
|
529 |
|
530 |
-
return
|
531 |
-
|
532 |
-
}, {
|
533 |
-
key: "findMatchingVariations",
|
534 |
-
value: function findMatchingVariations(variations, attributes) {
|
535 |
-
var matching = [];
|
536 |
|
537 |
-
|
538 |
-
var variation = variations[i];
|
539 |
|
540 |
-
if (
|
541 |
-
|
|
|
542 |
}
|
543 |
-
}
|
544 |
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
var val1 = variation_attributes[attr_name];
|
555 |
-
var val2 = attributes[attr_name];
|
556 |
-
|
557 |
-
if (val1 !== undefined && val2 !== undefined && val1.length !== 0 && val2.length !== 0 && val1 !== val2) {
|
558 |
-
match = false;
|
559 |
}
|
560 |
}
|
561 |
-
}
|
562 |
|
563 |
-
|
564 |
-
}
|
565 |
-
}], [{
|
566 |
-
key: "_jQueryInterface",
|
567 |
-
value: function _jQueryInterface(config) {
|
568 |
-
return this.each(function () {
|
569 |
-
new WooVariationSwatches(this, config);
|
570 |
});
|
571 |
-
}
|
572 |
-
}]);
|
573 |
|
574 |
-
return WooVariationSwatches;
|
575 |
-
}();
|
576 |
-
/**
|
577 |
-
* ------------------------------------------------------------------------
|
578 |
-
* jQuery
|
579 |
-
* ------------------------------------------------------------------------
|
580 |
-
*/
|
581 |
|
|
|
582 |
|
583 |
-
|
584 |
-
|
585 |
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
};
|
590 |
|
591 |
-
|
592 |
-
}
|
593 |
|
594 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
|
596 |
/***/ }),
|
597 |
|
598 |
/***/ "./src/js/frontend.js":
|
599 |
-
/***/ (function(module, exports
|
600 |
|
601 |
-
|
|
|
|
|
|
|
602 |
|
603 |
-
|
604 |
|
605 |
-
|
|
|
|
|
|
|
|
|
|
|
606 |
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
})
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
$(document).on('wc_variation_form.wvs', '.woo_variation_swatches_variations_form:not(.wvs-loaded)', function (event) {
|
617 |
-
$(this).WooVariationSwatches();
|
618 |
-
}); // Yith Composite Product
|
619 |
-
|
620 |
-
$(document).on('wc_variation_form.wvs', '.ywcp_inner_selected_container:not(.wvs-loaded)', function (event) {
|
621 |
-
$(this).WooVariationSwatches();
|
622 |
-
}); // Try to cover all ajax data complete
|
623 |
-
|
624 |
-
$(document).ajaxComplete(function (event, request, settings) {
|
625 |
-
_.delay(function () {
|
626 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {// $(this).wc_variation_form()
|
627 |
-
});
|
628 |
-
}, 100);
|
629 |
-
}); // Support for Jetpack's Infinite Scroll,
|
630 |
-
|
631 |
-
$(document.body).on('post-load.wvs', function () {
|
632 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {
|
633 |
-
$(this).wc_variation_form();
|
634 |
-
});
|
635 |
-
}); // Composite product load
|
636 |
-
// JS API: https://docs.woocommerce.com/document/composite-products/composite-products-js-api-reference/
|
637 |
-
|
638 |
-
$(document.body).on('wc-composite-initializing', '.composite_data', function (event, composite) {
|
639 |
-
composite.actions.add_action('component_options_state_changed', function (self) {
|
640 |
-
$(self.$component_content).find('.variations_form').removeClass('wvs-loaded wvs-pro-loaded');
|
641 |
-
});
|
642 |
-
/* composite.actions.add_action('active_scenarios_updated', (self) => {
|
643 |
-
console.log('active_scenarios_updated')
|
644 |
-
$(self.$component_content).find('.variations_form').removeClass('wvs-loaded wvs-pro-loaded')
|
645 |
-
})*/
|
646 |
-
}); // Support for Yith Infinite Scroll
|
647 |
-
|
648 |
-
$(document).on('yith_infs_added_elem.wvs', function () {
|
649 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {
|
650 |
-
$(this).wc_variation_form();
|
651 |
-
});
|
652 |
-
}); // Support for Yith Ajax Filter
|
653 |
-
|
654 |
-
$(document).on('yith-wcan-ajax-filtered.wvs', function () {
|
655 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {
|
656 |
-
$(this).wc_variation_form();
|
657 |
-
});
|
658 |
-
}); // Support for Woodmart theme
|
659 |
-
|
660 |
-
$(document).on('wood-images-loaded.wvs', function () {
|
661 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {
|
662 |
-
$(this).wc_variation_form();
|
663 |
-
});
|
664 |
-
}); // Support for berocket ajax filters
|
665 |
-
|
666 |
-
$(document).on('berocket_ajax_products_loaded.wvs berocket_ajax_products_infinite_loaded.wvs', function () {
|
667 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {
|
668 |
-
$(this).wc_variation_form();
|
669 |
-
});
|
670 |
-
}); // Flatsome Infinite Scroll Support
|
671 |
-
|
672 |
-
$('.shop-container .products, .infinite-scroll-wrap').on('append.infiniteScroll', function (event, response, path) {
|
673 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {
|
674 |
-
$(this).wc_variation_form();
|
675 |
-
});
|
676 |
-
}); // FacetWP Load More
|
677 |
-
|
678 |
-
$(document).on('facetwp-loaded.wvs', function () {
|
679 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {
|
680 |
-
$(this).wc_variation_form();
|
681 |
-
});
|
682 |
-
}); // Savoy Load More
|
683 |
-
|
684 |
-
$(document).on('nm_infload_after.wvs nm_ajax_shop_update_content.wvs', function () {
|
685 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {
|
686 |
-
$(this).wc_variation_form();
|
687 |
-
});
|
688 |
-
}); // WooCommerce Filter Nav
|
689 |
-
|
690 |
-
$('body').on('aln_reloaded.wvs', function () {
|
691 |
-
_.delay(function () {
|
692 |
-
$('.variations_form:not(.wvs-loaded)').each(function () {
|
693 |
-
$(this).wc_variation_form();
|
694 |
-
});
|
695 |
-
}, 100);
|
696 |
});
|
|
|
|
|
|
|
|
|
697 |
});
|
698 |
-
});
|
699 |
|
700 |
/***/ }),
|
701 |
|
702 |
/***/ 1:
|
703 |
/***/ (function(module, exports, __webpack_require__) {
|
704 |
|
|
|
705 |
module.exports = __webpack_require__("./src/js/frontend.js");
|
706 |
|
707 |
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 6/23/2022, 8:34:29 PM
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
/******/ (function(modules) { // webpackBootstrap
|
94 |
/******/ ({
|
95 |
|
96 |
/***/ "./src/js/WooVariationSwatches.js":
|
97 |
+
/***/ (function(module, exports) {
|
98 |
|
99 |
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
|
100 |
|
101 |
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
102 |
|
118 |
|
119 |
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
120 |
|
121 |
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
122 |
+
|
123 |
// ================================================================
|
124 |
// WooCommerce Variation Swatches
|
125 |
|
126 |
/*global _, wc_add_to_cart_variation_params, woo_variation_swatches_options */
|
127 |
// ================================================================
|
128 |
+
(function (window) {
|
129 |
+
'use strict';
|
130 |
+
|
131 |
+
var Plugin = function ($) {
|
132 |
+
return /*#__PURE__*/function () {
|
133 |
+
function _class2(element, options) {
|
134 |
+
_classCallCheck(this, _class2);
|
135 |
+
|
136 |
+
_defineProperty(this, "defaults", {});
|
137 |
+
|
138 |
+
// Assign
|
139 |
+
this._element = element;
|
140 |
+
this.$element = $(element);
|
141 |
+
this._config = $.extend(true, {}, this.defaults, options);
|
142 |
+
this.product_variations = this.$element.data('product_variations') || [];
|
143 |
+
this.is_ajax_variation = this.product_variations.length < 1;
|
144 |
+
this.product_id = this.$element.data('product_id');
|
145 |
+
this.reset_variations = this.$element.find('.reset_variations');
|
146 |
+
this.attributeFields = this.$element.find('.variations select');
|
147 |
+
this.selected_item_template = "<span class=\"woo-selected-variation-item-name\" data-default=\"\"></span>";
|
148 |
+
this.$element.addClass('wvs-loaded'); // Call
|
149 |
+
|
150 |
+
this.init();
|
151 |
+
this.update(); // Trigger
|
152 |
+
|
153 |
+
$(document).trigger('woo_variation_swatches_loaded', this);
|
|
|
|
|
|
|
154 |
}
|
155 |
+
|
156 |
+
_createClass(_class2, [{
|
157 |
+
key: "isAjaxVariation",
|
158 |
+
value: function isAjaxVariation() {
|
159 |
+
//this.product_variations = this.$element.data('product_variations') || []
|
160 |
+
return this.is_ajax_variation; // = this.product_variations.length < 1
|
161 |
+
}
|
162 |
+
}, {
|
163 |
+
key: "init",
|
164 |
+
value: function init() {
|
165 |
+
this.prepareLabel();
|
166 |
+
this.prepareItems();
|
167 |
+
this.setupItems();
|
168 |
+
this.setupEvents();
|
169 |
+
this.setUpStockInfo();
|
170 |
+
}
|
171 |
+
}, {
|
172 |
+
key: "prepareLabel",
|
173 |
+
value: function prepareLabel() {
|
174 |
+
var _this = this;
|
175 |
+
|
176 |
+
// Append Selected Item Template
|
177 |
+
if (woo_variation_swatches_options.show_variation_label) {
|
178 |
+
this.$element.find('.variations .label').each(function (index, el) {
|
179 |
+
$(el).append(_this.selected_item_template);
|
180 |
+
});
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}, {
|
184 |
+
key: "prepareItems",
|
185 |
+
value: function prepareItems() {
|
186 |
+
this.$element.find('ul.variable-items-wrapper').each(function (i, el) {
|
187 |
+
$(el).parent().addClass('woo-variation-items-wrapper');
|
188 |
});
|
189 |
}
|
190 |
+
}, {
|
191 |
+
key: "setupItems",
|
192 |
+
value: function setupItems() {
|
193 |
+
var _this2 = this;
|
194 |
+
|
195 |
+
var self = this;
|
196 |
+
this.$element.find('ul.variable-items-wrapper').each(function (i, element) {
|
197 |
+
var selected = '';
|
198 |
+
var $selected_variation_item = $(element).parent().prev().find('.woo-selected-variation-item-name');
|
199 |
+
var select = $(element).parent().find('select.woo-variation-raw-select');
|
200 |
+
var options = select.find('option');
|
201 |
+
var disabled = select.find('option:disabled');
|
202 |
+
var out_of_stock = select.find('option.enabled.out-of-stock');
|
203 |
+
var current = select.find('option:selected');
|
204 |
+
var eq = select.find('option').eq(1);
|
205 |
+
var selects = [];
|
206 |
+
var disabled_selects = [];
|
207 |
+
var out_of_stocks = []; // All Options
|
208 |
+
|
209 |
+
options.each(function () {
|
210 |
+
if ($(this).val() !== '') {
|
211 |
+
selects.push($(this).val());
|
212 |
+
selected = current.length === 0 ? eq.val() : current.val();
|
213 |
+
}
|
214 |
+
}); // Disabled
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
|
216 |
+
disabled.each(function () {
|
217 |
+
if ($(this).val() !== '') {
|
218 |
+
disabled_selects.push($(this).val());
|
219 |
+
}
|
220 |
+
}); // Out Of Stocks
|
221 |
|
222 |
+
out_of_stock.each(function () {
|
223 |
+
if ($(this).val() !== '') {
|
224 |
+
out_of_stocks.push($(this).val());
|
225 |
+
}
|
226 |
+
});
|
227 |
+
|
228 |
+
var in_stocks = _.difference(selects, disabled_selects);
|
229 |
+
|
230 |
+
_this2.setupItem(element, selected, in_stocks, out_of_stocks, $selected_variation_item);
|
231 |
});
|
232 |
+
}
|
233 |
+
}, {
|
234 |
+
key: "setupItem",
|
235 |
+
value: function setupItem(element, selected, in_stocks, out_of_stocks, $selected_variation_item) {
|
236 |
+
var _this3 = this;
|
237 |
|
238 |
+
// Mark Selected
|
239 |
+
$(element).find('li.variable-item').each(function (index, el) {
|
240 |
+
var attribute_value = $(el).attr('data-value');
|
241 |
+
var attribute_title = $(el).attr('data-title'); // Resetting LI
|
242 |
|
243 |
+
$(el).removeClass('selected disabled no-stock').addClass('disabled');
|
244 |
+
$(el).attr('aria-checked', 'false');
|
245 |
+
$(el).attr('tabindex', '-1');
|
246 |
+
$(el).attr('data-wvstooltip-out-of-stock', '');
|
247 |
+
$(el).find('input.variable-item-radio-input:radio').prop('disabled', true).prop('checked', false); // To Prevent blink
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
|
249 |
+
if (selected.length < 1 && woo_variation_swatches_options.show_variation_label) {
|
250 |
+
$selected_variation_item.text('');
|
251 |
+
} // Ajax variation
|
252 |
+
|
253 |
+
|
254 |
+
if (_this3.isAjaxVariation()) {
|
255 |
+
$(el).find('input.variable-item-radio-input:radio').prop('disabled', false);
|
256 |
+
$(el).removeClass('selected disabled no-stock'); // Selected
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
if (attribute_value === selected) {
|
259 |
$(el).addClass('selected');
|
260 |
$(el).attr('aria-checked', 'true');
|
261 |
+
$(el).attr('tabindex', '0');
|
262 |
+
$(el).find('input.variable-item-radio-input:radio').prop('disabled', false).prop('checked', true);
|
263 |
|
264 |
if (woo_variation_swatches_options.show_variation_label) {
|
265 |
$selected_variation_item.text("".concat(woo_variation_swatches_options.variation_label_separator, " ").concat(attribute_title));
|
267 |
|
268 |
$(el).trigger('wvs-item-updated', [selected, attribute_value]);
|
269 |
}
|
270 |
+
} else {
|
271 |
+
// Default Selected
|
272 |
+
// We can't use es6 includes for IE11
|
273 |
+
// in_stocks.includes(attribute_value)
|
274 |
+
// _.contains(in_stocks, attribute_value)
|
275 |
+
// _.includes(in_stocks, attribute_value)
|
276 |
+
if (_.includes(in_stocks, attribute_value)) {
|
277 |
+
$(el).removeClass('selected disabled');
|
278 |
+
$(el).removeAttr('aria-hidden');
|
279 |
+
$(el).attr('tabindex', '0');
|
280 |
+
$(el).find('input.variable-item-radio-input:radio').prop('disabled', false); // Selected
|
281 |
+
|
282 |
+
if (attribute_value === selected) {
|
283 |
+
$(el).addClass('selected');
|
284 |
+
$(el).attr('aria-checked', 'true');
|
285 |
+
$(el).find('input.variable-item-radio-input:radio').prop('checked', true);
|
286 |
+
|
287 |
+
if (woo_variation_swatches_options.show_variation_label) {
|
288 |
+
$selected_variation_item.text("".concat(woo_variation_swatches_options.variation_label_separator, " ").concat(attribute_title));
|
289 |
+
}
|
290 |
+
|
291 |
+
$(el).trigger('wvs-item-updated', [selected, attribute_value]);
|
292 |
+
}
|
293 |
+
} // Out of Stock
|
294 |
|
295 |
|
296 |
+
if (_.includes(out_of_stocks, attribute_value) && woo_variation_swatches_options.clickable_out_of_stock) {
|
297 |
+
$(el).removeClass('disabled').addClass('no-stock');
|
298 |
+
$(el).attr('data-wvstooltip-out-of-stock', woo_variation_swatches_options.out_of_stock_tooltip_text);
|
299 |
+
}
|
300 |
}
|
301 |
+
});
|
302 |
+
}
|
303 |
+
}, {
|
304 |
+
key: "setupEvents",
|
305 |
+
value: function setupEvents() {
|
306 |
+
var self = this;
|
307 |
+
this.$element.find('ul.variable-items-wrapper').each(function (i, element) {
|
308 |
+
var select = $(element).parent().find('select.woo-variation-raw-select'); // Trigger Select event based on list
|
309 |
+
|
310 |
+
if (woo_variation_swatches_options.clear_on_reselect) {
|
311 |
+
// Non Selected Item Should Select
|
312 |
+
$(element).on('click.wvs', 'li.variable-item:not(.selected):not(.radio-variable-item)', function (event) {
|
313 |
+
event.preventDefault();
|
314 |
+
event.stopPropagation();
|
315 |
+
var value = $(this).data('value');
|
316 |
+
select.val(value).trigger('change');
|
317 |
+
select.trigger('click'); // select.trigger('focusin')
|
318 |
+
|
319 |
+
if (woo_variation_swatches_options.is_mobile) {// select.trigger('touchstart')
|
320 |
+
} // $(this).trigger('focus') // Mobile tooltip
|
321 |
+
|
322 |
+
|
323 |
+
$(this).trigger('wvs-selected-item', [value, select, self.$element]); // Custom Event for li
|
324 |
+
}); // Selected Item Should un Select
|
325 |
+
|
326 |
+
$(element).on('click.wvs', 'li.variable-item.selected:not(.radio-variable-item)', function (event) {
|
327 |
+
event.preventDefault();
|
328 |
+
event.stopPropagation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
var value = $(this).val();
|
330 |
+
select.val('').trigger('change');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
select.trigger('click'); //select.trigger('focusin')
|
332 |
|
333 |
+
if (woo_variation_swatches_options.is_mobile) {// select.trigger('touchstart')
|
334 |
+
} // $(this).trigger('focus') // Mobile tooltip
|
335 |
+
|
336 |
+
|
337 |
+
$(this).trigger('wvs-unselected-item', [value, select, self.$element]); // Custom Event for li
|
338 |
+
}); // RADIO
|
339 |
+
// On Click trigger change event on Radio button
|
340 |
+
|
341 |
+
$(element).on('click.wvs', 'input.variable-item-radio-input:radio', function (event) {
|
342 |
+
event.stopPropagation();
|
343 |
+
$(this).trigger('change.wvs', {
|
344 |
+
radioChange: true
|
345 |
+
});
|
346 |
+
});
|
347 |
+
$(element).on('change.wvs', 'input.variable-item-radio-input:radio', function (event, params) {
|
348 |
+
event.preventDefault();
|
349 |
+
event.stopPropagation();
|
350 |
+
|
351 |
+
if (params && params.radioChange) {
|
352 |
+
var value = $(this).val();
|
353 |
+
var is_selected = $(this).parent('li.radio-variable-item').hasClass('selected');
|
354 |
+
|
355 |
+
if (is_selected) {
|
356 |
+
select.val('').trigger('change');
|
357 |
+
$(this).parent('li.radio-variable-item').trigger('wvs-unselected-item', [value, select, self.$element]); // Custom Event for li
|
358 |
+
} else {
|
359 |
+
select.val(value).trigger('change');
|
360 |
+
$(this).parent('li.radio-variable-item').trigger('wvs-selected-item', [value, select, self.$element]); // Custom Event for li
|
361 |
+
}
|
362 |
+
|
363 |
+
select.trigger('click'); //select.trigger('focusin')
|
364 |
+
|
365 |
+
if (woo_variation_swatches_options.is_mobile) {// select.trigger('touchstart')
|
366 |
+
}
|
367 |
}
|
368 |
+
});
|
369 |
+
} else {
|
370 |
+
$(element).on('click.wvs', 'li.variable-item:not(.radio-variable-item)', function (event) {
|
371 |
+
event.preventDefault();
|
372 |
+
event.stopPropagation();
|
373 |
+
var value = $(this).data('value');
|
374 |
+
select.val(value).trigger('change');
|
375 |
+
select.trigger('click'); // select.trigger('focusin')
|
|
|
376 |
|
377 |
+
if (woo_variation_swatches_options.is_mobile) {// select.trigger('touchstart')
|
378 |
+
} // $(this).trigger('focus') // Mobile tooltip
|
379 |
|
380 |
|
381 |
+
$(this).trigger('wvs-selected-item', [value, select, self._element]); // Custom Event for li
|
382 |
+
}); // Radio
|
383 |
|
384 |
+
$(element).on('change.wvs', 'input.variable-item-radio-input:radio', function (event) {
|
385 |
+
event.preventDefault();
|
386 |
+
event.stopPropagation();
|
387 |
+
var value = $(this).val();
|
388 |
+
select.val(value).trigger('change');
|
389 |
+
select.trigger('click'); // select.trigger('focusin')
|
390 |
|
391 |
+
if (woo_variation_swatches_options.is_mobile) {// select.trigger('touchstart')
|
392 |
+
} // Radio
|
393 |
|
394 |
|
395 |
+
$(this).parent('li.radio-variable-item').removeClass('selected disabled no-stock').addClass('selected');
|
396 |
+
$(this).parent('li.radio-variable-item').trigger('wvs-selected-item', [value, select, self.$element]); // Custom Event for li
|
397 |
+
});
|
398 |
+
} // Keyboard Access
|
399 |
|
400 |
|
401 |
+
$(element).on('keydown.wvs', 'li.variable-item:not(.disabled)', function (event) {
|
402 |
+
if (event.keyCode && 32 === event.keyCode || event.key && ' ' === event.key || event.keyCode && 13 === event.keyCode || event.key && 'enter' === event.key.toLowerCase()) {
|
403 |
+
event.preventDefault();
|
404 |
+
$(this).trigger('click');
|
405 |
+
}
|
406 |
+
});
|
407 |
});
|
408 |
+
this.$element.on('click.wvs', '.woo-variation-swatches-variable-item-more', function (event) {
|
409 |
+
event.preventDefault();
|
410 |
+
$(this).parent().removeClass('enabled-display-limit-mode enabled-catalog-display-limit-mode');
|
411 |
+
$(this).remove();
|
412 |
+
});
|
413 |
+
}
|
414 |
+
}, {
|
415 |
+
key: "update",
|
416 |
+
value: function update() {
|
417 |
+
var _this4 = this;
|
418 |
+
|
419 |
+
// this.$element.off('woocommerce_variation_has_changed.wvs')
|
420 |
+
this.$element.on('woocommerce_variation_has_changed.wvs', function (event) {
|
421 |
+
// Don't use any propagation. It will disable composite product functionality
|
422 |
+
// event.stopPropagation();
|
423 |
+
_this4.setupItems();
|
424 |
+
});
|
425 |
+
}
|
426 |
+
}, {
|
427 |
+
key: "setUpStockInfo",
|
428 |
+
value: function setUpStockInfo() {
|
429 |
+
var _this5 = this;
|
|
|
430 |
|
431 |
+
if (woo_variation_swatches_options.show_variation_stock) {
|
432 |
+
var max_stock_label = parseInt(woo_variation_swatches_options.stock_label_threshold, 10);
|
433 |
+
this.$element.on('wvs-selected-item.wc-variation-form', function () {
|
434 |
+
var attributes = _this5.getChosenAttributes();
|
435 |
|
436 |
+
var variations = _this5.findStockVariations(_this5.product_variations, attributes);
|
437 |
|
438 |
+
if (attributes.count > 1 && attributes.count === attributes.chosenCount) {
|
439 |
+
_this5.resetStockInfo();
|
440 |
+
}
|
441 |
|
442 |
+
if (attributes.count > 1 && attributes.count === attributes.mayChosenCount) {
|
443 |
+
variations.forEach(function (data) {
|
444 |
+
var stockInfoSelector = "[data-attribute_name=\"".concat(data.attribute_name, "\"] > [data-value=\"").concat(data.attribute_value, "\"]");
|
445 |
|
446 |
+
if (data.variation.is_in_stock && data.variation.max_qty && data.variation.variation_stock_left && data.variation.max_qty <= max_stock_label) {
|
447 |
+
_this5.$element.find("".concat(stockInfoSelector, " .wvs-stock-left-info")).attr('data-wvs-stock-info', data.variation.variation_stock_left);
|
448 |
|
449 |
+
_this5.$element.find(stockInfoSelector).addClass('wvs-show-stock-left-info');
|
450 |
+
} else {
|
451 |
+
_this5.$element.find(stockInfoSelector).removeClass('wvs-show-stock-left-info');
|
452 |
|
453 |
+
_this5.$element.find("".concat(stockInfoSelector, " .wvs-stock-left-info")).attr('data-wvs-stock-info', '');
|
454 |
+
}
|
455 |
+
});
|
456 |
+
}
|
457 |
+
});
|
458 |
+
this.$element.on('hide_variation.wc-variation-form', function () {
|
459 |
+
_this5.resetStockInfo();
|
460 |
+
});
|
461 |
+
}
|
462 |
+
}
|
463 |
+
}, {
|
464 |
+
key: "resetStockInfo",
|
465 |
+
value: function resetStockInfo() {
|
466 |
+
this.$element.find('.variable-item').removeClass('wvs-show-stock-left-info');
|
467 |
+
this.$element.find('.wvs-stock-left-info').attr('data-wvs-stock-info', '');
|
468 |
+
}
|
469 |
+
}, {
|
470 |
+
key: "getChosenAttributes",
|
471 |
+
value: function getChosenAttributes() {
|
472 |
+
var data = {};
|
473 |
+
var count = 0;
|
474 |
+
var chosen = 0;
|
475 |
+
this.attributeFields.each(function () {
|
476 |
+
var attribute_name = $(this).data('attribute_name') || $(this).attr('name');
|
477 |
+
var value = $(this).val() || '';
|
478 |
+
|
479 |
+
if (value.length > 0) {
|
480 |
+
chosen++;
|
481 |
}
|
482 |
+
|
483 |
+
count++;
|
484 |
+
data[attribute_name] = value;
|
485 |
});
|
486 |
+
return {
|
487 |
+
'count': count,
|
488 |
+
'chosenCount': chosen,
|
489 |
+
'mayChosenCount': chosen + 1,
|
490 |
+
'data': data
|
491 |
+
};
|
492 |
}
|
493 |
+
}, {
|
494 |
+
key: "findStockVariations",
|
495 |
+
value: function findStockVariations(allVariations, selectedAttributes) {
|
496 |
+
var found = [];
|
497 |
+
|
498 |
+
for (var _i = 0, _Object$entries = Object.entries(selectedAttributes.data); _i < _Object$entries.length; _i++) {
|
499 |
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
500 |
+
attribute_name = _Object$entries$_i[0],
|
501 |
+
attribute_value = _Object$entries$_i[1];
|
502 |
+
|
503 |
+
if (attribute_value.length === 0) {
|
504 |
+
var values = this.$element.find("ul[data-attribute_name='".concat(attribute_name, "']")).data('attribute_values') || [];
|
505 |
+
|
506 |
+
var _iterator = _createForOfIteratorHelper(values),
|
507 |
+
_step;
|
508 |
+
|
509 |
+
try {
|
510 |
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
511 |
+
var value = _step.value;
|
512 |
+
|
513 |
+
var compare = _.extend(selectedAttributes.data, _defineProperty({}, attribute_name, value));
|
514 |
+
|
515 |
+
var matched_variation = this.findMatchingVariations(allVariations, compare);
|
516 |
+
|
517 |
+
if (matched_variation.length > 0) {
|
518 |
+
var variation = matched_variation.shift();
|
519 |
+
var data = {};
|
520 |
+
data['attribute_name'] = attribute_name;
|
521 |
+
data['attribute_value'] = value;
|
522 |
+
data['variation'] = variation;
|
523 |
+
found.push(data);
|
524 |
+
}
|
525 |
+
}
|
526 |
+
} catch (err) {
|
527 |
+
_iterator.e(err);
|
528 |
+
} finally {
|
529 |
+
_iterator.f();
|
530 |
+
}
|
531 |
+
}
|
532 |
}
|
533 |
|
534 |
+
return found;
|
535 |
+
}
|
536 |
+
}, {
|
537 |
+
key: "findMatchingVariations",
|
538 |
+
value: function findMatchingVariations(variations, attributes) {
|
539 |
+
var matching = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
540 |
|
541 |
+
for (var i = 0; i < variations.length; i++) {
|
542 |
+
var variation = variations[i];
|
|
|
|
|
543 |
|
544 |
+
if (this.isMatch(variation.attributes, attributes)) {
|
545 |
+
matching.push(variation);
|
546 |
+
}
|
547 |
+
}
|
548 |
|
549 |
+
return matching;
|
550 |
+
}
|
551 |
+
}, {
|
552 |
+
key: "isMatch",
|
553 |
+
value: function isMatch(variation_attributes, attributes) {
|
554 |
+
var match = true;
|
555 |
+
|
556 |
+
for (var attr_name in variation_attributes) {
|
557 |
+
if (variation_attributes.hasOwnProperty(attr_name)) {
|
558 |
+
var val1 = variation_attributes[attr_name];
|
559 |
+
var val2 = attributes[attr_name];
|
560 |
+
|
561 |
+
if (val1 !== undefined && val2 !== undefined && val1.length !== 0 && val2.length !== 0 && val1 !== val2) {
|
562 |
+
match = false;
|
563 |
+
}
|
564 |
+
}
|
565 |
+
}
|
566 |
|
567 |
+
return match;
|
568 |
+
}
|
569 |
+
}]);
|
570 |
|
571 |
+
return _class2;
|
572 |
+
}();
|
573 |
+
}(jQuery);
|
574 |
|
575 |
+
var jQueryPlugin = function ($) {
|
576 |
+
return function (PluginName, ClassName) {
|
577 |
+
$.fn[PluginName] = function (options) {
|
578 |
+
var _this6 = this;
|
579 |
|
580 |
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
581 |
+
args[_key - 1] = arguments[_key];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
582 |
}
|
583 |
|
584 |
+
return this.each(function (index, element) {
|
585 |
+
var $element = $(element); // let $element = $(this)
|
|
|
|
|
|
|
|
|
586 |
|
587 |
+
var data = $element.data(PluginName);
|
|
|
588 |
|
589 |
+
if (!data) {
|
590 |
+
data = new ClassName($element, $.extend({}, options));
|
591 |
+
$element.data(PluginName, data);
|
592 |
}
|
|
|
593 |
|
594 |
+
if (typeof options === 'string') {
|
595 |
+
if (_typeof(data[options]) === 'object') {
|
596 |
+
return data[options];
|
597 |
+
}
|
598 |
+
|
599 |
+
if (typeof data[options] === 'function') {
|
600 |
+
var _data;
|
601 |
+
|
602 |
+
return (_data = data)[options].apply(_data, args);
|
|
|
|
|
|
|
|
|
|
|
603 |
}
|
604 |
}
|
|
|
605 |
|
606 |
+
return _this6;
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
});
|
608 |
+
}; // Constructor
|
|
|
609 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
610 |
|
611 |
+
$.fn[PluginName].Constructor = ClassName; // Short hand
|
612 |
|
613 |
+
$[PluginName] = function (options) {
|
614 |
+
var _$;
|
615 |
|
616 |
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
617 |
+
args[_key2 - 1] = arguments[_key2];
|
618 |
+
}
|
|
|
619 |
|
620 |
+
return (_$ = $({}))[PluginName].apply(_$, [options].concat(args));
|
621 |
+
}; // No Conflict
|
622 |
|
623 |
+
|
624 |
+
$.fn[PluginName].noConflict = function () {
|
625 |
+
return $.fn[PluginName];
|
626 |
+
};
|
627 |
+
};
|
628 |
+
}(jQuery);
|
629 |
+
|
630 |
+
jQueryPlugin('WooVariationSwatches', Plugin);
|
631 |
+
})(window);
|
632 |
|
633 |
/***/ }),
|
634 |
|
635 |
/***/ "./src/js/frontend.js":
|
636 |
+
/***/ (function(module, exports) {
|
637 |
|
638 |
+
jQuery(function ($) {
|
639 |
+
try {
|
640 |
+
$(document.body).on('woo_variation_swatches_init', function () {
|
641 |
+
$('.variations_form:not(.wvs-loaded)').WooVariationSwatches(); // Any custom product with .woo_variation_swatches_variations_form class to support
|
642 |
|
643 |
+
$('.woo_variation_swatches_variations_form:not(.wvs-loaded)').WooVariationSwatches(); // Yith Composite Product
|
644 |
|
645 |
+
$('.ywcp_inner_selected_container:not(.wvs-loaded)').WooVariationSwatches();
|
646 |
+
}).trigger('woo_variation_swatches_init');
|
647 |
+
} catch (err) {
|
648 |
+
// If failed (conflict?) log the error but don't stop other scripts breaking.
|
649 |
+
window.console.log('Variation Swatches:', err);
|
650 |
+
} // Init WooVariationSwatches after wc_variation_form script loaded.
|
651 |
|
652 |
+
|
653 |
+
$(document.body).on('wc_variation_form.wvs', function (event) {
|
654 |
+
$(document.body).trigger('woo_variation_swatches_init');
|
655 |
+
}); // Composite Product Load
|
656 |
+
// JS API: https://docs.woocommerce.com/document/composite-products/composite-products-js-api-reference/
|
657 |
+
|
658 |
+
$(document.body).on('wc-composite-initializing', '.composite_data', function (event, composite) {
|
659 |
+
composite.actions.add_action('component_options_state_changed', function (self) {
|
660 |
+
$(self.$component_content).find('.variations_form').removeClass('wvs-loaded wvs-pro-loaded');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
661 |
});
|
662 |
+
/* composite.actions.add_action('active_scenarios_updated', (self) => {
|
663 |
+
console.log('active_scenarios_updated')
|
664 |
+
$(self.$component_content).find('.variations_form').removeClass('wvs-loaded wvs-pro-loaded')
|
665 |
+
})*/
|
666 |
});
|
667 |
+
});
|
668 |
|
669 |
/***/ }),
|
670 |
|
671 |
/***/ 1:
|
672 |
/***/ (function(module, exports, __webpack_require__) {
|
673 |
|
674 |
+
__webpack_require__("./src/js/WooVariationSwatches.js");
|
675 |
module.exports = __webpack_require__("./src/js/frontend.js");
|
676 |
|
677 |
|
assets/js/frontend.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){var e={};function n(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(i,a,function(e){return t[e]}.bind(null,a));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=3)}([,,,function(t,e,n){t.exports=n(4)},function(t,e,n){function i(t){return(i="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)}function a(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(a=function(t){return t?n:e})(t)}jQuery((function(t){Promise.resolve().then((function(){return function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==i(t)&&"function"!=typeof t)return{default:t};var n=a(e);if(n&&n.has(t))return n.get(t);var o={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var c=r?Object.getOwnPropertyDescriptor(t,s):null;c&&(c.get||c.set)?Object.defineProperty(o,s,c):o[s]=t[s]}return o.default=t,n&&n.set(t,o),o}(n(5))})).then((function(){t(document).on("wc_variation_form.wvs",".variations_form:not(.wvs-loaded)",(function(e){t(this).WooVariationSwatches()})),t(document).on("wc_variation_form.wvs",".woo_variation_swatches_variations_form:not(.wvs-loaded)",(function(e){t(this).WooVariationSwatches()})),t(document).on("wc_variation_form.wvs",".ywcp_inner_selected_container:not(.wvs-loaded)",(function(e){t(this).WooVariationSwatches()})),t(document).ajaxComplete((function(e,n,i){_.delay((function(){t(".variations_form:not(.wvs-loaded)").each((function(){}))}),100)})),t(document.body).on("post-load.wvs",(function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))})),t(document.body).on("wc-composite-initializing",".composite_data",(function(e,n){n.actions.add_action("component_options_state_changed",(function(e){t(e.$component_content).find(".variations_form").removeClass("wvs-loaded wvs-pro-loaded")}))})),t(document).on("yith_infs_added_elem.wvs",(function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))})),t(document).on("yith-wcan-ajax-filtered.wvs",(function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))})),t(document).on("wood-images-loaded.wvs",(function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))})),t(document).on("berocket_ajax_products_loaded.wvs berocket_ajax_products_infinite_loaded.wvs",(function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))})),t(".shop-container .products, .infinite-scroll-wrap").on("append.infiniteScroll",(function(e,n,i){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))})),t(document).on("facetwp-loaded.wvs",(function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))})),t(document).on("nm_infload_after.wvs nm_ajax_shop_update_content.wvs",(function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))})),t("body").on("aln_reloaded.wvs",(function(){_.delay((function(){t(".variations_form:not(.wvs-loaded)").each((function(){t(this).wc_variation_form()}))}),100)}))}))}))},function(t,e,n){"use strict";function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=r(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){c=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(c)throw o}}}}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var i,a,o=[],r=!0,s=!1;try{for(n=n.call(t);!(r=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);r=!0);}catch(t){s=!0,a=t}finally{try{r||null==n.return||n.return()}finally{if(s)throw a}}return o}(t,e)||r(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){if(t){if("string"==typeof t)return s(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function c(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}n.r(e);var l=function(t){var e={},n=function(){function n(i,a){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),this._element=i,this.$element=t(i),this._config=t.extend({},e,a),this.product_variations=this.$element.data("product_variations")||[],this.is_ajax_variation=this.product_variations.length<1,this.product_id=this.$element.data("product_id"),this.reset_variations=this.$element.find(".reset_variations"),this.attributeFields=this.$element.find(".variations select"),this.selected_item_template='<span class="woo-selected-variation-item-name" data-default=""></span>',this.$element.addClass("wvs-loaded"),this.init(),this.update()}var r,s,l;return r=n,l=[{key:"_jQueryInterface",value:function(t){return this.each((function(){new n(this,t)}))}}],(s=[{key:"isAjaxVariation",value:function(){return this.is_ajax_variation}},{key:"init",value:function(){this.prepareLabel(),this.prepareItems(),this.setupItems(),this.setupEvents(),this.setUpStockInfo()}},{key:"prepareLabel",value:function(){var e=this;woo_variation_swatches_options.show_variation_label&&this.$element.find(".variations .label").each((function(n,i){t(i).append(e.selected_item_template)}))}},{key:"prepareItems",value:function(){this.$element.find("ul.variable-items-wrapper").each((function(e,n){t(n).parent().addClass("woo-variation-items-wrapper")}))}},{key:"setupItems",value:function(){var e=this;this.$element.find("ul.variable-items-wrapper").each((function(n,i){var a="",o=t(i).parent().prev().find(".woo-selected-variation-item-name"),r=t(i).parent().find("select.woo-variation-raw-select"),s=r.find("option"),c=r.find("option:disabled"),l=r.find("option.enabled.out-of-stock"),u=r.find("option:selected"),d=r.find("option").eq(1),f=[],v=[],h=[];s.each((function(){""!==t(this).val()&&(f.push(t(this).val()),a=0===u.length?d.val():u.val())})),c.each((function(){""!==t(this).val()&&v.push(t(this).val())})),l.each((function(){""!==t(this).val()&&h.push(t(this).val())}));var p=_.difference(f,v);e.setupItem(i,a,p,h,o)}))}},{key:"setupItem",value:function(e,n,i,a,o){var r=this;t(e).find("li.variable-item").each((function(e,s){var c=t(s).attr("data-value"),l=t(s).attr("data-title");t(s).removeClass("selected disabled no-stock").addClass("disabled"),t(s).attr("aria-checked","false"),t(s).attr("tabindex","-1"),t(s).attr("data-wvstooltip-out-of-stock",""),t(s).find("input.variable-item-radio-input:radio").prop("disabled",!0).prop("checked",!1),n.length<1&&woo_variation_swatches_options.show_variation_label&&o.text(""),r.isAjaxVariation()?(t(s).find("input.variable-item-radio-input:radio").prop("disabled",!1),t(s).removeClass("selected disabled no-stock"),c===n&&(t(s).addClass("selected"),t(s).attr("aria-checked","true"),t(s).attr("tabindex","0"),t(s).find("input.variable-item-radio-input:radio").prop("disabled",!1).prop("checked",!0),woo_variation_swatches_options.show_variation_label&&o.text("".concat(woo_variation_swatches_options.variation_label_separator," ").concat(l)),t(s).trigger("wvs-item-updated",[n,c]))):(_.includes(i,c)&&(t(s).removeClass("selected disabled"),t(s).removeAttr("aria-hidden"),t(s).attr("tabindex","0"),t(s).find("input.variable-item-radio-input:radio").prop("disabled",!1),c===n&&(t(s).addClass("selected"),t(s).attr("aria-checked","true"),t(s).find("input.variable-item-radio-input:radio").prop("checked",!0),woo_variation_swatches_options.show_variation_label&&o.text("".concat(woo_variation_swatches_options.variation_label_separator," ").concat(l)),t(s).trigger("wvs-item-updated",[n,c]))),_.includes(a,c)&&woo_variation_swatches_options.clickable_out_of_stock&&(t(s).removeClass("disabled").addClass("no-stock"),t(s).attr("data-wvstooltip-out-of-stock",woo_variation_swatches_options.out_of_stock_tooltip_text)))}))}},{key:"setupEvents",value:function(){var e=this;this.$element.find("ul.variable-items-wrapper").each((function(n,i){var a=t(i).parent().find("select.woo-variation-raw-select");woo_variation_swatches_options.clear_on_reselect?(t(i).on("click.wvs","li.variable-item:not(.selected):not(.radio-variable-item)",(function(n){n.preventDefault(),n.stopPropagation();var i=t(this).data("value");a.val(i).trigger("change"),a.trigger("click"),woo_variation_swatches_options.is_mobile,t(this).trigger("wvs-selected-item",[i,a,e.$element])})),t(i).on("click.wvs","li.variable-item.selected:not(.radio-variable-item)",(function(n){n.preventDefault(),n.stopPropagation();var i=t(this).val();a.val("").trigger("change"),a.trigger("click"),woo_variation_swatches_options.is_mobile,t(this).trigger("wvs-unselected-item",[i,a,e.$element])})),t(i).on("click.wvs","input.variable-item-radio-input:radio",(function(e){e.stopPropagation(),t(this).trigger("change.wvs",{radioChange:!0})})),t(i).on("change.wvs","input.variable-item-radio-input:radio",(function(n,i){if(n.preventDefault(),n.stopPropagation(),i&&i.radioChange){var o=t(this).val();t(this).parent("li.radio-variable-item").hasClass("selected")?(a.val("").trigger("change"),t(this).parent("li.radio-variable-item").trigger("wvs-unselected-item",[o,a,e.$element])):(a.val(o).trigger("change"),t(this).parent("li.radio-variable-item").trigger("wvs-selected-item",[o,a,e.$element])),a.trigger("click"),woo_variation_swatches_options.is_mobile}}))):(t(i).on("click.wvs","li.variable-item:not(.radio-variable-item)",(function(n){n.preventDefault(),n.stopPropagation();var i=t(this).data("value");a.val(i).trigger("change"),a.trigger("click"),woo_variation_swatches_options.is_mobile,t(this).trigger("wvs-selected-item",[i,a,e._element])})),t(i).on("change.wvs","input.variable-item-radio-input:radio",(function(n){n.preventDefault(),n.stopPropagation();var i=t(this).val();a.val(i).trigger("change"),a.trigger("click"),woo_variation_swatches_options.is_mobile,t(this).parent("li.radio-variable-item").removeClass("selected disabled no-stock").addClass("selected"),t(this).parent("li.radio-variable-item").trigger("wvs-selected-item",[i,a,e.$element])}))),t(i).on("keydown.wvs","li.variable-item:not(.disabled)",(function(e){(e.keyCode&&32===e.keyCode||e.key&&" "===e.key||e.keyCode&&13===e.keyCode||e.key&&"enter"===e.key.toLowerCase())&&(e.preventDefault(),t(this).trigger("click"))}))})),this.$element.on("click.wvs",".woo-variation-swatches-variable-item-more",(function(e){e.preventDefault(),t(this).parent().removeClass("enabled-display-limit-mode enabled-catalog-display-limit-mode"),t(this).remove()}))}},{key:"update",value:function(){var t=this;this.$element.on("woocommerce_variation_has_changed.wvs",(function(e){t.setupItems()}))}},{key:"setUpStockInfo",value:function(){var t=this;if(woo_variation_swatches_options.show_variation_stock){var e=parseInt(woo_variation_swatches_options.stock_label_threshold,10);this.$element.on("wvs-selected-item.wc-variation-form",(function(){var n=t.getChosenAttributes(),i=t.findStockVariations(t.product_variations,n);n.count>1&&n.count===n.chosenCount&&t.resetStockInfo(),n.count>1&&n.count===n.mayChosenCount&&i.forEach((function(n){var i='[data-attribute_name="'.concat(n.attribute_name,'"] > [data-value="').concat(n.attribute_value,'"]');n.variation.is_in_stock&&n.variation.max_qty&&n.variation.variation_stock_left&&n.variation.max_qty<=e?(t.$element.find("".concat(i," .wvs-stock-left-info")).attr("data-wvs-stock-info",n.variation.variation_stock_left),t.$element.find(i).addClass("wvs-show-stock-left-info")):(t.$element.find(i).removeClass("wvs-show-stock-left-info"),t.$element.find("".concat(i," .wvs-stock-left-info")).attr("data-wvs-stock-info",""))}))})),this.$element.on("hide_variation.wc-variation-form",(function(){t.resetStockInfo()}))}}},{key:"resetStockInfo",value:function(){this.$element.find(".variable-item").removeClass("wvs-show-stock-left-info"),this.$element.find(".wvs-stock-left-info").attr("data-wvs-stock-info","")}},{key:"getChosenAttributes",value:function(){var e={},n=0,i=0;return this.attributeFields.each((function(){var a=t(this).data("attribute_name")||t(this).attr("name"),o=t(this).val()||"";o.length>0&&i++,n++,e[a]=o})),{count:n,chosenCount:i,mayChosenCount:i+1,data:e}}},{key:"findStockVariations",value:function(t,e){for(var n=[],r=0,s=Object.entries(e.data);r<s.length;r++){var c=o(s[r],2),l=c[0];if(0===c[1].length){var u,d=a(this.$element.find("ul[data-attribute_name='".concat(l,"']")).data("attribute_values")||[]);try{for(d.s();!(u=d.n()).done;){var f=u.value,v=_.extend(e.data,i({},l,f)),h=this.findMatchingVariations(t,v);if(h.length>0){var p=h.shift(),m={};m.attribute_name=l,m.attribute_value=f,m.variation=p,n.push(m)}}}catch(t){d.e(t)}finally{d.f()}}}return n}},{key:"findMatchingVariations",value:function(t,e){for(var n=[],i=0;i<t.length;i++){var a=t[i];this.isMatch(a.attributes,e)&&n.push(a)}return n}},{key:"isMatch",value:function(t,e){var n=!0;for(var i in t)if(t.hasOwnProperty(i)){var a=t[i],o=e[i];void 0!==a&&void 0!==o&&0!==a.length&&0!==o.length&&a!==o&&(n=!1)}return n}}])&&c(r.prototype,s),l&&c(r,l),n}();return t.fn.WooVariationSwatches=n._jQueryInterface,t.fn.WooVariationSwatches.Constructor=n,t.fn.WooVariationSwatches.noConflict=function(){return t.fn.WooVariationSwatches=t.fn.WooVariationSwatches,n._jQueryInterface},n}(jQuery);e.default=l}]);
|
1 |
+
!function(t){var e={};function i(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=e,i.d=function(t,e,a){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(i.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(a,n,function(e){return t[e]}.bind(null,n));return a},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/",i(i.s=3)}([,,,function(t,e,i){i(4),t.exports=i(5)},function(t,e){function i(t){return(i="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)}function a(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=o(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var a=0,n=function(){};return{s:n,n:function(){return a>=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,s=!0,l=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return s=t.done,t},e:function(t){l=!0,r=t},f:function(){try{s||null==i.return||i.return()}finally{if(l)throw r}}}}function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==i)return;var a,n,o=[],r=!0,s=!1;try{for(i=i.call(t);!(r=(a=i.next()).done)&&(o.push(a.value),!e||o.length!==e);r=!0);}catch(t){s=!0,n=t}finally{try{r||null==i.return||i.return()}finally{if(s)throw n}}return o}(t,e)||o(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){if(t){if("string"==typeof t)return r(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=new Array(e);i<e;i++)a[i]=t[i];return a}function s(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function l(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}!function(t){"use strict";var e,o=(e=jQuery,function(){function t(i,a){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),l(this,"defaults",{}),this._element=i,this.$element=e(i),this._config=e.extend(!0,{},this.defaults,a),this.product_variations=this.$element.data("product_variations")||[],this.is_ajax_variation=this.product_variations.length<1,this.product_id=this.$element.data("product_id"),this.reset_variations=this.$element.find(".reset_variations"),this.attributeFields=this.$element.find(".variations select"),this.selected_item_template='<span class="woo-selected-variation-item-name" data-default=""></span>',this.$element.addClass("wvs-loaded"),this.init(),this.update(),e(document).trigger("woo_variation_swatches_loaded",this)}var i,o,r;return i=t,(o=[{key:"isAjaxVariation",value:function(){return this.is_ajax_variation}},{key:"init",value:function(){this.prepareLabel(),this.prepareItems(),this.setupItems(),this.setupEvents(),this.setUpStockInfo()}},{key:"prepareLabel",value:function(){var t=this;woo_variation_swatches_options.show_variation_label&&this.$element.find(".variations .label").each((function(i,a){e(a).append(t.selected_item_template)}))}},{key:"prepareItems",value:function(){this.$element.find("ul.variable-items-wrapper").each((function(t,i){e(i).parent().addClass("woo-variation-items-wrapper")}))}},{key:"setupItems",value:function(){var t=this;this.$element.find("ul.variable-items-wrapper").each((function(i,a){var n="",o=e(a).parent().prev().find(".woo-selected-variation-item-name"),r=e(a).parent().find("select.woo-variation-raw-select"),s=r.find("option"),l=r.find("option:disabled"),c=r.find("option.enabled.out-of-stock"),u=r.find("option:selected"),d=r.find("option").eq(1),v=[],f=[],h=[];s.each((function(){""!==e(this).val()&&(v.push(e(this).val()),n=0===u.length?d.val():u.val())})),l.each((function(){""!==e(this).val()&&f.push(e(this).val())})),c.each((function(){""!==e(this).val()&&h.push(e(this).val())}));var p=_.difference(v,f);t.setupItem(a,n,p,h,o)}))}},{key:"setupItem",value:function(t,i,a,n,o){var r=this;e(t).find("li.variable-item").each((function(t,s){var l=e(s).attr("data-value"),c=e(s).attr("data-title");e(s).removeClass("selected disabled no-stock").addClass("disabled"),e(s).attr("aria-checked","false"),e(s).attr("tabindex","-1"),e(s).attr("data-wvstooltip-out-of-stock",""),e(s).find("input.variable-item-radio-input:radio").prop("disabled",!0).prop("checked",!1),i.length<1&&woo_variation_swatches_options.show_variation_label&&o.text(""),r.isAjaxVariation()?(e(s).find("input.variable-item-radio-input:radio").prop("disabled",!1),e(s).removeClass("selected disabled no-stock"),l===i&&(e(s).addClass("selected"),e(s).attr("aria-checked","true"),e(s).attr("tabindex","0"),e(s).find("input.variable-item-radio-input:radio").prop("disabled",!1).prop("checked",!0),woo_variation_swatches_options.show_variation_label&&o.text("".concat(woo_variation_swatches_options.variation_label_separator," ").concat(c)),e(s).trigger("wvs-item-updated",[i,l]))):(_.includes(a,l)&&(e(s).removeClass("selected disabled"),e(s).removeAttr("aria-hidden"),e(s).attr("tabindex","0"),e(s).find("input.variable-item-radio-input:radio").prop("disabled",!1),l===i&&(e(s).addClass("selected"),e(s).attr("aria-checked","true"),e(s).find("input.variable-item-radio-input:radio").prop("checked",!0),woo_variation_swatches_options.show_variation_label&&o.text("".concat(woo_variation_swatches_options.variation_label_separator," ").concat(c)),e(s).trigger("wvs-item-updated",[i,l]))),_.includes(n,l)&&woo_variation_swatches_options.clickable_out_of_stock&&(e(s).removeClass("disabled").addClass("no-stock"),e(s).attr("data-wvstooltip-out-of-stock",woo_variation_swatches_options.out_of_stock_tooltip_text)))}))}},{key:"setupEvents",value:function(){var t=this;this.$element.find("ul.variable-items-wrapper").each((function(i,a){var n=e(a).parent().find("select.woo-variation-raw-select");woo_variation_swatches_options.clear_on_reselect?(e(a).on("click.wvs","li.variable-item:not(.selected):not(.radio-variable-item)",(function(i){i.preventDefault(),i.stopPropagation();var a=e(this).data("value");n.val(a).trigger("change"),n.trigger("click"),woo_variation_swatches_options.is_mobile,e(this).trigger("wvs-selected-item",[a,n,t.$element])})),e(a).on("click.wvs","li.variable-item.selected:not(.radio-variable-item)",(function(i){i.preventDefault(),i.stopPropagation();var a=e(this).val();n.val("").trigger("change"),n.trigger("click"),woo_variation_swatches_options.is_mobile,e(this).trigger("wvs-unselected-item",[a,n,t.$element])})),e(a).on("click.wvs","input.variable-item-radio-input:radio",(function(t){t.stopPropagation(),e(this).trigger("change.wvs",{radioChange:!0})})),e(a).on("change.wvs","input.variable-item-radio-input:radio",(function(i,a){if(i.preventDefault(),i.stopPropagation(),a&&a.radioChange){var o=e(this).val();e(this).parent("li.radio-variable-item").hasClass("selected")?(n.val("").trigger("change"),e(this).parent("li.radio-variable-item").trigger("wvs-unselected-item",[o,n,t.$element])):(n.val(o).trigger("change"),e(this).parent("li.radio-variable-item").trigger("wvs-selected-item",[o,n,t.$element])),n.trigger("click"),woo_variation_swatches_options.is_mobile}}))):(e(a).on("click.wvs","li.variable-item:not(.radio-variable-item)",(function(i){i.preventDefault(),i.stopPropagation();var a=e(this).data("value");n.val(a).trigger("change"),n.trigger("click"),woo_variation_swatches_options.is_mobile,e(this).trigger("wvs-selected-item",[a,n,t._element])})),e(a).on("change.wvs","input.variable-item-radio-input:radio",(function(i){i.preventDefault(),i.stopPropagation();var a=e(this).val();n.val(a).trigger("change"),n.trigger("click"),woo_variation_swatches_options.is_mobile,e(this).parent("li.radio-variable-item").removeClass("selected disabled no-stock").addClass("selected"),e(this).parent("li.radio-variable-item").trigger("wvs-selected-item",[a,n,t.$element])}))),e(a).on("keydown.wvs","li.variable-item:not(.disabled)",(function(t){(t.keyCode&&32===t.keyCode||t.key&&" "===t.key||t.keyCode&&13===t.keyCode||t.key&&"enter"===t.key.toLowerCase())&&(t.preventDefault(),e(this).trigger("click"))}))})),this.$element.on("click.wvs",".woo-variation-swatches-variable-item-more",(function(t){t.preventDefault(),e(this).parent().removeClass("enabled-display-limit-mode enabled-catalog-display-limit-mode"),e(this).remove()}))}},{key:"update",value:function(){var t=this;this.$element.on("woocommerce_variation_has_changed.wvs",(function(e){t.setupItems()}))}},{key:"setUpStockInfo",value:function(){var t=this;if(woo_variation_swatches_options.show_variation_stock){var e=parseInt(woo_variation_swatches_options.stock_label_threshold,10);this.$element.on("wvs-selected-item.wc-variation-form",(function(){var i=t.getChosenAttributes(),a=t.findStockVariations(t.product_variations,i);i.count>1&&i.count===i.chosenCount&&t.resetStockInfo(),i.count>1&&i.count===i.mayChosenCount&&a.forEach((function(i){var a='[data-attribute_name="'.concat(i.attribute_name,'"] > [data-value="').concat(i.attribute_value,'"]');i.variation.is_in_stock&&i.variation.max_qty&&i.variation.variation_stock_left&&i.variation.max_qty<=e?(t.$element.find("".concat(a," .wvs-stock-left-info")).attr("data-wvs-stock-info",i.variation.variation_stock_left),t.$element.find(a).addClass("wvs-show-stock-left-info")):(t.$element.find(a).removeClass("wvs-show-stock-left-info"),t.$element.find("".concat(a," .wvs-stock-left-info")).attr("data-wvs-stock-info",""))}))})),this.$element.on("hide_variation.wc-variation-form",(function(){t.resetStockInfo()}))}}},{key:"resetStockInfo",value:function(){this.$element.find(".variable-item").removeClass("wvs-show-stock-left-info"),this.$element.find(".wvs-stock-left-info").attr("data-wvs-stock-info","")}},{key:"getChosenAttributes",value:function(){var t={},i=0,a=0;return this.attributeFields.each((function(){var n=e(this).data("attribute_name")||e(this).attr("name"),o=e(this).val()||"";o.length>0&&a++,i++,t[n]=o})),{count:i,chosenCount:a,mayChosenCount:a+1,data:t}}},{key:"findStockVariations",value:function(t,e){for(var i=[],o=0,r=Object.entries(e.data);o<r.length;o++){var s=n(r[o],2),c=s[0];if(0===s[1].length){var u,d=a(this.$element.find("ul[data-attribute_name='".concat(c,"']")).data("attribute_values")||[]);try{for(d.s();!(u=d.n()).done;){var v=u.value,f=_.extend(e.data,l({},c,v)),h=this.findMatchingVariations(t,f);if(h.length>0){var p=h.shift(),m={};m.attribute_name=c,m.attribute_value=v,m.variation=p,i.push(m)}}}catch(t){d.e(t)}finally{d.f()}}}return i}},{key:"findMatchingVariations",value:function(t,e){for(var i=[],a=0;a<t.length;a++){var n=t[a];this.isMatch(n.attributes,e)&&i.push(n)}return i}},{key:"isMatch",value:function(t,e){var i=!0;for(var a in t)if(t.hasOwnProperty(a)){var n=t[a],o=e[a];void 0!==n&&void 0!==o&&0!==n.length&&0!==o.length&&n!==o&&(i=!1)}return i}}])&&s(i.prototype,o),r&&s(i,r),t}());(function(t){return function(e,a){t.fn[e]=function(n){for(var o=this,r=arguments.length,s=new Array(r>1?r-1:0),l=1;l<r;l++)s[l-1]=arguments[l];return this.each((function(r,l){var c=t(l),u=c.data(e);if(u||(u=new a(c,t.extend({},n)),c.data(e,u)),"string"==typeof n){if("object"===i(u[n]))return u[n];var d;if("function"==typeof u[n])return(d=u)[n].apply(d,s)}return o}))},t.fn[e].Constructor=a,t[e]=function(i){for(var a,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return(a=t({}))[e].apply(a,[i].concat(o))},t.fn[e].noConflict=function(){return t.fn[e]}}})(jQuery)("WooVariationSwatches",o)}(window)},function(t,e){jQuery((function(t){try{t(document.body).on("woo_variation_swatches_init",(function(){t(".variations_form:not(.wvs-loaded)").WooVariationSwatches(),t(".woo_variation_swatches_variations_form:not(.wvs-loaded)").WooVariationSwatches(),t(".ywcp_inner_selected_container:not(.wvs-loaded)").WooVariationSwatches()})).trigger("woo_variation_swatches_init")}catch(t){window.console.log("Variation Swatches:",t)}t(document.body).on("wc_variation_form.wvs",(function(e){t(document.body).trigger("woo_variation_swatches_init")})),t(document.body).on("wc-composite-initializing",".composite_data",(function(e,i){i.actions.add_action("component_options_state_changed",(function(e){t(e.$component_content).find(".variations_form").removeClass("wvs-loaded wvs-pro-loaded")}))}))}))}]);
|
assets/js/wp-color-picker-alpha.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
-
* Date: 6/
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
/******/ (function(modules) { // webpackBootstrap
|
2 |
* Variation Swatches for WooCommerce
|
3 |
*
|
4 |
* Author: Emran Ahmed ( emran.bd.08@gmail.com )
|
5 |
+
* Date: 6/23/2022, 8:34:29 PM
|
6 |
* Released under the GPLv3 license.
|
7 |
*/
|
8 |
/******/ (function(modules) { // webpackBootstrap
|
includes/class-woo-variation-swatches-product-page.php
CHANGED
@@ -203,6 +203,10 @@
|
|
203 |
'is_mobile' => wp_is_mobile(),
|
204 |
'show_variation_stock' => woo_variation_swatches()->is_pro() && wc_string_to_bool( woo_variation_swatches()->get_option( 'show_variation_stock_info', 'no' ) ),
|
205 |
'stock_label_threshold' => absint( woo_variation_swatches()->get_option( 'stock_label_display_threshold', '5' ) ),
|
|
|
|
|
|
|
|
|
206 |
) );
|
207 |
}
|
208 |
|
@@ -414,6 +418,19 @@
|
|
414 |
return $assigned;
|
415 |
}
|
416 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
public function color_attribute( $data, $attribute_type, $variation_data = array() ) {
|
418 |
// Color
|
419 |
if ( 'color' === $attribute_type ) {
|
@@ -431,16 +448,12 @@
|
|
431 |
|
432 |
if ( 'image' === $attribute_type ) {
|
433 |
|
434 |
-
$term = $data[ 'item' ];
|
435 |
$option_name = $data[ 'option_name' ];
|
436 |
|
437 |
// Global
|
438 |
-
$
|
439 |
-
$image_size = apply_filters( 'woo_variation_swatches_global_product_attribute_image_size', sanitize_text_field( woo_variation_swatches()->get_option( 'attribute_image_size', 'variation_swatches_image_size' ) ), $data );
|
440 |
-
$image = wp_get_attachment_image_src( $attachment_id, $image_size );
|
441 |
|
442 |
return sprintf( '<img class="variable-item-image" aria-hidden="true" alt="%s" src="%s" width="%d" height="%d" />', esc_attr( $option_name ), esc_url( $image[ 0 ] ), esc_attr( $image[ 1 ] ), esc_attr( $image[ 2 ] ) );
|
443 |
-
|
444 |
}
|
445 |
}
|
446 |
|
@@ -708,6 +721,11 @@
|
|
708 |
|
709 |
foreach ( $swatches_data as $data ) {
|
710 |
|
|
|
|
|
|
|
|
|
|
|
711 |
$item .= $this->item_start( $data, $attribute_type );
|
712 |
|
713 |
$item .= $this->color_attribute( $data, $attribute_type );
|
203 |
'is_mobile' => wp_is_mobile(),
|
204 |
'show_variation_stock' => woo_variation_swatches()->is_pro() && wc_string_to_bool( woo_variation_swatches()->get_option( 'show_variation_stock_info', 'no' ) ),
|
205 |
'stock_label_threshold' => absint( woo_variation_swatches()->get_option( 'stock_label_display_threshold', '5' ) ),
|
206 |
+
'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add', 'no' ),
|
207 |
+
'enable_ajax_add_to_cart' => get_option( 'woocommerce_enable_ajax_add_to_cart', 'yes' ),
|
208 |
+
'cart_url' => apply_filters( 'woocommerce_add_to_cart_redirect', wc_get_cart_url(), null ),
|
209 |
+
'is_cart' => is_cart(),
|
210 |
) );
|
211 |
}
|
212 |
|
418 |
return $assigned;
|
419 |
}
|
420 |
|
421 |
+
public function get_image_attribute( $data, $attribute_type, $variation_data = array() ) {
|
422 |
+
if ( 'image' === $attribute_type ) {
|
423 |
+
|
424 |
+
$term = $data[ 'item' ];
|
425 |
+
|
426 |
+
// Global
|
427 |
+
$attachment_id = apply_filters( 'woo_variation_swatches_global_product_attribute_image_id', absint( woo_variation_swatches()->get_frontend()->get_product_attribute_image( $term, $data ) ), $data );
|
428 |
+
$image_size = apply_filters( 'woo_variation_swatches_global_product_attribute_image_size', sanitize_text_field( woo_variation_swatches()->get_option( 'attribute_image_size', 'variation_swatches_image_size' ) ), $data );
|
429 |
+
|
430 |
+
return wp_get_attachment_image_src( $attachment_id, $image_size );
|
431 |
+
}
|
432 |
+
}
|
433 |
+
|
434 |
public function color_attribute( $data, $attribute_type, $variation_data = array() ) {
|
435 |
// Color
|
436 |
if ( 'color' === $attribute_type ) {
|
448 |
|
449 |
if ( 'image' === $attribute_type ) {
|
450 |
|
|
|
451 |
$option_name = $data[ 'option_name' ];
|
452 |
|
453 |
// Global
|
454 |
+
$image = $this->get_image_attribute( $data, $attribute_type, $variation_data );
|
|
|
|
|
455 |
|
456 |
return sprintf( '<img class="variable-item-image" aria-hidden="true" alt="%s" src="%s" width="%d" height="%d" />', esc_attr( $option_name ), esc_url( $image[ 0 ] ), esc_attr( $image[ 1 ] ), esc_attr( $image[ 2 ] ) );
|
|
|
457 |
}
|
458 |
}
|
459 |
|
721 |
|
722 |
foreach ( $swatches_data as $data ) {
|
723 |
|
724 |
+
// If attribute have no image we should convert attribute type image to attribute type button
|
725 |
+
if ( 'image' === $attribute_type && ! is_array( $this->get_image_attribute( $data, $attribute_type ) ) ) {
|
726 |
+
$attribute_type = 'button';
|
727 |
+
}
|
728 |
+
|
729 |
$item .= $this->item_start( $data, $attribute_type );
|
730 |
|
731 |
$item .= $this->color_attribute( $data, $attribute_type );
|
woo-variation-swatches.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin URI: https://wordpress.org/plugins/woo-variation-swatches/
|
5 |
* Description: Beautiful colors, images and buttons variation swatches for woocommerce product attributes. Requires WooCommerce 5.6+
|
6 |
* Author: Emran Ahmed
|
7 |
-
* Version: 2.0.
|
8 |
* Domain Path: /languages
|
9 |
* Requires PHP: 7.0
|
10 |
* Requires at least: 5.6
|
@@ -20,7 +20,7 @@
|
|
20 |
|
21 |
|
22 |
if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION' ) ) {
|
23 |
-
define( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION', '2.0.
|
24 |
}
|
25 |
|
26 |
if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_FILE' ) ) {
|
4 |
* Plugin URI: https://wordpress.org/plugins/woo-variation-swatches/
|
5 |
* Description: Beautiful colors, images and buttons variation swatches for woocommerce product attributes. Requires WooCommerce 5.6+
|
6 |
* Author: Emran Ahmed
|
7 |
+
* Version: 2.0.2
|
8 |
* Domain Path: /languages
|
9 |
* Requires PHP: 7.0
|
10 |
* Requires at least: 5.6
|
20 |
|
21 |
|
22 |
if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION' ) ) {
|
23 |
+
define( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION', '2.0.2' );
|
24 |
}
|
25 |
|
26 |
if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_FILE' ) ) {
|