| @@ -13,17 +13,17 @@ | ||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | 'use strict'; |
| 16 | 16 | |
| 17 | -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(_e) { throw _e; }, 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(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | |
| 18 | -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | |
| 19 | -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | |
| 20 | -function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | |
| 21 | -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
| 22 | -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | |
| 23 | -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | |
| 24 | -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | |
| 25 | -function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | |
| 17 | +function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; } | |
| 18 | +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } | |
| 19 | +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } | |
| 20 | +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | |
| 21 | +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } | |
| 22 | +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } | |
| 23 | +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } | |
| 24 | +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } | |
| 25 | +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } | |
| 26 | 26 | var Siema = /*#__PURE__*/function () { |
| 27 | 27 | /** |
| 28 | 28 | * Create a Siema. |
| 29 | 29 | * @param {Object} options - Optional settings object. |
| @@ -73,9 +73,9 @@ | ||
| 73 | 73 | * Overrides default settings with custom ones. |
| 74 | 74 | * @param {Object} options - Optional settings object. |
| 75 | 75 | * @returns {Object} - Custom Siema settings. |
| 76 | 76 | */ |
| 77 | - _createClass(Siema, [{ | |
| 77 | + return _createClass(Siema, [{ | |
| 78 | 78 | key: "attachEvents", |
| 79 | 79 | value: |
| 80 | 80 | /** |
| 81 | 81 | * Attaches listeners to required events. |
| @@ -202,11 +202,12 @@ | ||
| 202 | 202 | }, { |
| 203 | 203 | key: "buildSliderFrame", |
| 204 | 204 | value: function buildSliderFrame() { |
| 205 | 205 | if (this.innerElements.length <= this.perPage) { |
| 206 | + var _this$parentSelector$, _this$parentSelector$2; | |
| 206 | 207 | this.parentSelector.classList.add('no-nav'); |
| 207 | - this.parentSelector.querySelector('.merchant-carousel-nav-next').remove(); | |
| 208 | - this.parentSelector.querySelector('.merchant-carousel-nav-prev').remove(); | |
| 208 | + (_this$parentSelector$ = this.parentSelector.querySelector('.merchant-carousel-nav-next')) === null || _this$parentSelector$ === void 0 || _this$parentSelector$.remove(); | |
| 209 | + (_this$parentSelector$2 = this.parentSelector.querySelector('.merchant-carousel-nav-prev')) === null || _this$parentSelector$2 === void 0 || _this$parentSelector$2.remove(); | |
| 209 | 210 | return false; |
| 210 | 211 | } |
| 211 | 212 | var widthItem = (this.selectorWidth + this.config.margin) / this.perPage; |
| 212 | 213 | var itemsToBuild = this.config.loop ? this.innerElements.length + 2 * this.perPage : this.innerElements.length; |
| @@ -792,9 +793,8 @@ | ||
| 792 | 793 | } |
| 793 | 794 | return 'WebkitTransform'; |
| 794 | 795 | } |
| 795 | 796 | }]); |
| 796 | - return Siema; | |
| 797 | 797 | }(); |
| 798 | 798 | /** |
| 799 | 799 | * Merchant Carousel |
| 800 | 800 | * |
| @@ -807,9 +807,15 @@ | ||
| 807 | 807 | } |
| 808 | 808 | if (document.readyState === 'interactive' || document.readyState === 'complete') { |
| 809 | 809 | return fn(); |
| 810 | 810 | } |
| 811 | - document.addEventListener('DOMContentLoaded', fn, false); | |
| 811 | + var that = this; | |
| 812 | + document.addEventListener('DOMContentLoaded', function () { | |
| 813 | + that.init(); // Required for some themes | |
| 814 | + }); | |
| 815 | + jQuery(document).on('photoSliderTriggered', function () { | |
| 816 | + that.init(); | |
| 817 | + }); | |
| 812 | 818 | }, |
| 813 | 819 | init: function init() { |
| 814 | 820 | this.build(); |
| 815 | 821 | this.events(); |
| @@ -836,8 +842,9 @@ | ||
| 836 | 842 | perPage = columns; |
| 837 | 843 | } |
| 838 | 844 | }); |
| 839 | 845 | } |
| 846 | + var loop = carouselEl.getAttribute('data-loop') !== '0'; | |
| 840 | 847 | |
| 841 | 848 | // Mount carousel wrapper |
| 842 | 849 | var wrapper = document.createElement('div'), |
| 843 | 850 | stage = carouselEl.querySelector('.merchant-carousel-stage'); |
| @@ -868,14 +875,24 @@ | ||
| 868 | 875 | startIndex: 0, |
| 869 | 876 | draggable: true, |
| 870 | 877 | multipleDrag: false, |
| 871 | 878 | threshold: 20, |
| 872 | - loop: true, | |
| 879 | + loop: loop, | |
| 873 | 880 | rtl: false, |
| 874 | 881 | // autoplay: true, TO DO |
| 875 | 882 | margin: margin, |
| 876 | 883 | onInit: function onInit() { |
| 884 | + var _this$innerElements; | |
| 877 | 885 | window.dispatchEvent(new Event('merchant.carousel.initialized')); |
| 886 | + | |
| 887 | + // Fix for theme that has lazy-load but not working | |
| 888 | + this === null || this === void 0 || (_this$innerElements = this.innerElements) === null || _this$innerElements === void 0 || _this$innerElements.forEach(function (item) { | |
| 889 | + var img = item.querySelector('img'); | |
| 890 | + var src = img === null || img === void 0 ? void 0 : img.getAttribute('src'); | |
| 891 | + if (src !== null && src !== void 0 && src.startsWith('data')) { | |
| 892 | + img.src = img === null || img === void 0 ? void 0 : img.getAttribute('data-src'); | |
| 893 | + } | |
| 894 | + }); | |
| 878 | 895 | } |
| 879 | 896 | }); |
| 880 | 897 | } |
| 881 | 898 | } |
| @@ -891,16 +908,16 @@ | ||
| 891 | 908 | var onpageload = true; |
| 892 | 909 | jQuery(document.body).on('wc_fragment_refresh added_to_cart removed_from_cart', function () { |
| 893 | 910 | setTimeout(function () { |
| 894 | 911 | var mini_cart = document.getElementById('site-header-cart'), |
| 895 | - mini_cart_list = mini_cart.querySelector('.cart_list'); | |
| 912 | + mini_cart_list = mini_cart === null || mini_cart === void 0 ? void 0 : mini_cart.querySelector('.cart_list'); | |
| 896 | 913 | if (mini_cart_list !== null) { |
| 897 | - if (mini_cart_list.children.length > 2) { | |
| 898 | - mini_cart.classList.remove('mini-cart-has-no-scroll'); | |
| 899 | - mini_cart.classList.add('mini-cart-has-scroll'); | |
| 914 | + if ((mini_cart_list === null || mini_cart_list === void 0 ? void 0 : mini_cart_list.children.length) > 2) { | |
| 915 | + mini_cart === null || mini_cart === void 0 || mini_cart.classList.remove('mini-cart-has-no-scroll'); | |
| 916 | + mini_cart === null || mini_cart === void 0 || mini_cart.classList.add('mini-cart-has-scroll'); | |
| 900 | 917 | } else { |
| 901 | - mini_cart.classList.remove('mini-cart-has-scroll'); | |
| 902 | - mini_cart.classList.add('mini-cart-has-no-scroll'); | |
| 918 | + mini_cart === null || mini_cart === void 0 || mini_cart.classList.remove('mini-cart-has-scroll'); | |
| 919 | + mini_cart === null || mini_cart === void 0 || mini_cart.classList.add('mini-cart-has-no-scroll'); | |
| 903 | 920 | } |
| 904 | 921 | } |
| 905 | 922 | _this.build(); |
| 906 | 923 | onpageload = false; |
| @@ -911,6 +928,11 @@ | ||
| 911 | 928 | }; |
| 912 | 929 | |
| 913 | 930 | // Initialize. |
| 914 | 931 | merchant.carousel.domReady(function () { |
| 915 | - merchant.carousel.init(); | |
| 932 | + var _merchant$carousel; | |
| 933 | + merchant === null || merchant === void 0 || (_merchant$carousel = merchant.carousel) === null || _merchant$carousel === void 0 || _merchant$carousel.init(); | |
| 934 | +}); | |
| 935 | +jQuery(document).on('photoSliderTriggered', function () { | |
| 936 | + var _merchant$carousel2; | |
| 937 | + merchant === null || merchant === void 0 || (_merchant$carousel2 = merchant.carousel) === null || _merchant$carousel2 === void 0 || _merchant$carousel2.init(); | |
| 916 | 938 | }); |