231. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2023-03-13 03:01:06 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

231.1 Files compared

#LocationFileLast Modified
1Porto v4.0.4/Porto Theme/app/design/frontend/Smartwave/porto/Mageplaza_LayeredNavigation/web/js/viewlayer.js2022-05-11 03:02:23 +0000
2Porto v4.0.5/Porto Theme/app/design/frontend/Smartwave/porto/Mageplaza_LayeredNavigation/web/js/viewlayer.js2023-03-07 10:58:50 +0000

231.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged20982
Changed828
Inserted841
Removed33

231.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

231.4 Active regular expressions

No regular expressions were active.

231.5 Comparison detail

1 /** 1 /**
2  * Mageplaza 2  * Mageplaza
3  * 3  *
4  * NOTICE OF LICENSE 4  * NOTICE OF LICENSE
5  * 5  *
6  * This source file is subject to the Mageplaza.com license sliderConfig is 6  * This source file is subject to the Mageplaza.com license sliderConfig is
7  * available through the world-wide-web at this URL: 7  * available through the world-wide-web at this URL:
8  * https://www.mageplaza.com/LICENSE.txt 8  * https://www.mageplaza.com/LICENSE.txt
9  * 9  *
10  * DISCLAIMER 10  * DISCLAIMER
11  * 11  *
12  * Do not edit or add to this file if you wish to upgrade this extension to newer 12  * Do not edit or add to this file if you wish to upgrade this extension to newer
13  * version in the future. 13  * version in the future.
14  * 14  *
15  * @category    Mageplaza 15  * @category    Mageplaza
16  * @package     Mageplaza_LayeredNavigation 16  * @package     Mageplaza_LayeredNavigation
17  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/) 17  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
18  * @license     https://www.mageplaza.com/LICENSE.txt 18  * @license     https://www.mageplaza.com/LICENSE.txt
19  */ 19  */
20  20 
21 define([ 21 define([
22     'jquery', 22     'jquery',
23     'Mageplaza_AjaxLayer/js/action/submit-filter', 23     'Mageplaza_AjaxLayer/js/action/submit-filter',
24     'Magento_Catalog/js/price-utils', 24     'Magento_Catalog/js/price-utils',
25     'accordion', 25     'accordion',
26     'productListToolbarForm', 26     'productListToolbarForm',
27     'jquery/jquery-ui' 27     'jquery/jquery-ui'
28 ], function ($, submitFilterAction, ultil) { 28 ], function ($, submitFilterAction, ultil) {
29     "use strict"; 29     "use strict";
30     var next_page = ""; 30     var next_page = "";
31     var loading = false; 31     var loading = false;
32     var infinite_loaded_count = 0; 32     var infinite_loaded_count = 0;
33     var active = false; 33     var active = false;
34  34 
35     $.widget('mageplaza.layer', $.mage.accordion, { 35     $.widget('mageplaza.layer', $.mage.accordion, {
36         options: { 36         options: {
37             openedState: 'active', 37             openedState: 'active',
38             collapsible: true, 38             collapsible: true,
39             multipleCollapsible: true, 39             multipleCollapsible: true,
40             animate: 200, 40             animate: 200,
41             productsListSelector: '#layer-product-list', 41             productsListSelector: '#layer-product-list',
42             mobileShopbyElement: '#layered-filter-block .filter-title [data-role=title]', 42             mobileShopbyElement: '#layered-filter-block .filter-title [data-role=title]',
43             collapsibleElement: '[data-role=ln_collapsible]', 43             collapsibleElement: '[data-role=ln_collapsible]',
44             header: '[data-role=ln_title]', 44             header: '[data-role=ln_title]',
45             content: '[data-role=ln_content]', 45             content: '[data-role=ln_content]',
46             isCustomerLoggedIn: false, 46             isCustomerLoggedIn: false,
47             isAjax: true, 47             isAjax: true,
48             params: [], 48             params: [],
49             active: [], 49             active: [],
50             checkboxEl: 'input[type=checkbox]
',
 50             checkboxEl: 'input[type=checkbox], input[type=radio]',
51             sliderElementPrefix: '#ln_slider_', 51             sliderElementPrefix: '#ln_slider_',
52             sliderTextElementPrefix: '#ln_slider_text_' 52             sliderTextElementPrefix: '#ln_slider_text_'
53         }, 53         },
54  54 
55         inFinite: function() { 55         inFinite: function() {
56             var self = this; 56             var self = this;
57             next_page = ""; 57             next_page = "";
58             if($(self.options.productsListSelector +' .infinite-loader').length > 0){ 58             if($(self.options.productsListSelector +' .infinite-loader').length > 0){
59                 active = true; 59                 active = true;
60             } 60             }
61             $(".pages-items li > a.next").each(function(){ 61             $(".pages-items li > a.next").each(function(){
62                 next_page = $(this).attr("href"); 62                 next_page = $(this).attr("href");
63             }); 63             });
64             if(!next_page){ 64             if(!next_page){
65                 $('.infinite-loader').hide(); 65                 $('.infinite-loader').hide();
66             } 66             }
    67             $(window).scroll(function(){
    68                 if(!loading && next_page && active && $(".infinite-loader").hasClass('scrolling') && $(window).scrollTop() >= $(".infinite-loader").offset().top-$(window).height()+100){
    69                     loading = true;
    70                     $(".pages-items li > a.next").each(function(){
    71                         next_page = $(this).attr("href");
    72                     });
    73                     self.ajaxInfinite(next_page);
    74                 }
    75             });
67             $(".infinite-loader .btn-load-more").click(function(){ 76             $(".infinite-loader .btn-load-more").click(function(){
68                 if(!loading && next_page){ 77                 if(!loading && next_page){
69                     loading = true; 78                     loading = true;
70                     self.ajaxInfinite(next_page); 79                     self.ajaxInfinite(next_page);
71                 } 80                 }
72             }); 81             });
73         }, 82         },
74  83 
75         ajaxInfinite: function (submitUrl) { 84         ajaxInfinite: function (submitUrl) {
76             var self = this; 85             var self = this;
77             infinite_loaded_count++; 86             infinite_loaded_count++;
78             $('.infinite-loader .btn-load-more').hide(); 87             $('.infinite-loader .btn-load-more').hide();
79             $('.infinite-loader .loading').hide(); 88             $('.infinite-loader .loading').hide();
80             $.ajax({ 89             $.ajax({
81                 url: submitUrl, 90                 url: submitUrl,
82                 type: 'get', 91                 type: 'get',
83                 beforeSend: function () { 92                 beforeSend: function () {
84                     $('.infinite-loader .btn-load-more').hide(); 93                     $('.infinite-loader .btn-load-more').hide();
85                     $('.infinite-loader .loading').show(); 94                     $('.infinite-loader .loading').show();
86                 }, 95                 },
87                 success: function (res) { 96                 success: function (res) {
88                     loading = false; 97                     loading = false;
89                     var $products = $(res.products); 98                     var $products = $(res.products);
90                     if (res.backUrl) { 99                     if (res.backUrl) {
91                         window.location = res.backUrl; 100                         window.location = res.backUrl;
92                         return; 101                         return;
93                     } 102                     }
94                     if($products){ 103                     if($products){
95                         $products.each(function(i,el){ 104                         $products.each(function(i,el){
96                             if($(el).hasClass('products-grid')){ 105                             if($(el).hasClass('products-grid')){
97                                 var items_grid = $(this).find('.product-items .item'); 106                                 var items_grid = $(this).find('.product-items .item');
98                                 $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_grid); 107                                 $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_grid);
99                                 $(self.options.productsListSelector).trigger('contentUpdated'); 108                                 $(self.options.productsListSelector).trigger('contentUpdated');
100                             } 109                             }
101                             if($(el).hasClass('products-list')){ 110                             if($(el).hasClass('products-list')){
102                                 var items_list = $(this).find('.product-items .item'); 111                                 var items_list = $(this).find('.product-items .item');
103                                 $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_list); 112                                 $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_list);
104                                 $(self.options.productsListSelector).trigger('contentUpdated'); 113                                 $(self.options.productsListSelector).trigger('contentUpdated');
105                             } 114                             }
106                             if($(el).hasClass('toolbar-products')){ 115                             if($(el).hasClass('toolbar-products')){
107                                 if($(this).find('.pages a.next').length > 0){ 116                                 if($(this).find('.pages a.next').length > 0){
108                                     $(self.options.productsListSelector + ' .pages a.next').attr('href', $(this).find('.pages a.next').attr('href')); 117                                     $(self.options.productsListSelector + ' .pages a.next').attr('href', $(this).find('.pages a.next').attr('href'));
109                                 }else{ 118                                 }else{
110                                     $(self.options.productsListSelector + ' .pages a.next').remove(); 119                                     $(self.options.productsListSelector + ' .pages a.next').remove();
111                                 } 120                                 }
112                             } 121                             }
113                         }); 122                         });
114                         if($("form[data-role=tocart-form]").length > 0 && !redirect_cart) { 123                         if($("form[data-role=tocart-form]").length > 0 && !redirect_cart) {
115                             $("form[data-role=tocart-form]").catalogAddToCart(); 124                             $("form[data-role=tocart-form]").catalogAddToCart();
116                         } 125                         }
117                         $('.main .products.grid .product-items li.product-item:nth-child(2n)').addClass('nth-child-2n'); 126                         $('.main .products.grid .product-items li.product-item:nth-child(2n)').addClass('nth-child-2n');
118                         $('.main .products.grid .product-items li.product-item:nth-child(2n+1)').addClass('nth-child-2np1'); 127                         $('.main .products.grid .product-items li.product-item:nth-child(2n+1)').addClass('nth-child-2np1');
119                         $('.main .products.grid .product-items li.product-item:nth-child(3n)').addClass('nth-child-3n'); 128                         $('.main .products.grid .product-items li.product-item:nth-child(3n)').addClass('nth-child-3n');
120                         $('.main .products.grid .product-items li.product-item:nth-child(3n+1)').addClass('nth-child-3np1'); 129                         $('.main .products.grid .product-items li.product-item:nth-child(3n+1)').addClass('nth-child-3np1');
121                         $('.main .products.grid .product-items li.product-item:nth-child(4n)').addClass('nth-child-4n'); 130                         $('.main .products.grid .product-items li.product-item:nth-child(4n)').addClass('nth-child-4n');
122                         $('.main .products.grid .product-items li.product-item:nth-child(4n+1)').addClass('nth-child-4np1'); 131                         $('.main .products.grid .product-items li.product-item:nth-child(4n+1)').addClass('nth-child-4np1');
123                         $('.main .products.grid .product-items li.product-item:nth-child(5n)').addClass('nth-child-5n'); 132                         $('.main .products.grid .product-items li.product-item:nth-child(5n)').addClass('nth-child-5n');
124                         $('.main .products.grid .product-items li.product-item:nth-child(5n+1)').addClass('nth-child-5np1'); 133                         $('.main .products.grid .product-items li.product-item:nth-child(5n+1)').addClass('nth-child-5np1');
125                         $('.main .products.grid .product-items li.product-item:nth-child(6n)').addClass('nth-child-6n'); 134                         $('.main .products.grid .product-items li.product-item:nth-child(6n)').addClass('nth-child-6n');
126                         $('.main .products.grid .product-items li.product-item:nth-child(6n+1)').addClass('nth-child-6np1'); 135                         $('.main .products.grid .product-items li.product-item:nth-child(6n+1)').addClass('nth-child-6np1');
127                         $('.main .products.grid .product-items li.product-item:nth-child(7n)').addClass('nth-child-7n'); 136                         $('.main .products.grid .product-items li.product-item:nth-child(7n)').addClass('nth-child-7n');
128                         $('.main .products.grid .product-items li.product-item:nth-child(7n+1)').addClass('nth-child-7np1'); 137                         $('.main .products.grid .product-items li.product-item:nth-child(7n+1)').addClass('nth-child-7np1');
129                         $('.main .products.grid .product-items li.product-item:nth-child(8n)').addClass('nth-child-8n'); 138                         $('.main .products.grid .product-items li.product-item:nth-child(8n)').addClass('nth-child-8n');
130                         $('.main .products.grid .product-items li.product-item:nth-child(8n+1)').addClass('nth-child-8np1'); 139                         $('.main .products.grid .product-items li.product-item:nth-child(8n+1)').addClass('nth-child-8np1');
131                         var hist = submitUrl; 140                         var hist = submitUrl;
132                         if(submitUrl.indexOf("p=") > -1){ 141                         if(submitUrl.indexOf("p=") > -1){
133                             var len = submitUrl.length-submitUrl.indexOf("p="); 142                             var len = submitUrl.length-submitUrl.indexOf("p=");
134                             var str_temp = submitUrl.substr(submitUrl.indexOf("p="),len); 143                             var str_temp = submitUrl.substr(submitUrl.indexOf("p="),len);
135                             var page_param = ""; 144                             var page_param = "";
136                             if(str_temp.indexOf("&") == -1){ 145                             if(str_temp.indexOf("&") == -1){
137                                 page_param = str_temp; 146                                 page_param = str_temp;
138                             } else { 147                             } else {
139                                 page_param = str_temp.substr(0,str_temp.indexOf("&")); 148                                 page_param = str_temp.substr(0,str_temp.indexOf("&"));
140                             } 149                             }
141                             hist = submitUrl.replace(page_param, ""); 150                             hist = submitUrl.replace(page_param, "");
142                         } 151                         }
143                         if (typeof window.history.pushState === 'function') { 152                         if (typeof window.history.pushState === 'function') {
144                             window.history.pushState({url: hist}, '', hist); 153                             window.history.pushState({url: hist}, '', hist);
145                         } 154                         }
146                         if(typeof enable_quickview != 'undefined' && enable_quickview == true) { 155                         if(typeof enable_quickview != 'undefined' && enable_quickview == true) {
147                             requirejs(['jquery', 'weltpixel_quickview' ], 156                             requirejs(['jquery', 'weltpixel_quickview' ],
148                                 function($, quickview) { 157                                 function($, quickview) {
149                                     $('.weltpixel-quickview').off('click').on('click', function() { 158                                     $('.weltpixel-quickview').off('click').on('click', function() {
150                                         var prodUrl = $(this).attr('data-quickview-url'); 159                                         var prodUrl = $(this).attr('data-quickview-url');
151                                         if (prodUrl.length) { 160                                         if (prodUrl.length) {
152                                             quickview.displayContent(prodUrl); 161                                             quickview.displayContent(prodUrl);
153                                         } 162                                         }
154                                     }); 163                                     });
155                                 }); 164                                 });
156                         } 165                         }
157                         $(".products-grid .weltpixel-quickview").each(function(){ 166                         $(".products-grid .weltpixel-quickview").each(function(){
158                             $(this).appendTo($(this).parent().parent().children(".product-item-photo")); 167                             $(this).appendTo($(this).parent().parent().children(".product-item-photo"));
159                         }); 168                         });
160                         $("#layer-product-list img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"}); 169                         $("#layer-product-list img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"});
161                         if ($('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) { 170                         if ($('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) {
162                             $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('initialized.owl.carousel', function() { 171                             $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('initialized.owl.carousel', function() {
163                                 $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear'); 172                                 $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear');
164                             }); 173                             });
165                             $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() { 174                             $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() {
166                                 $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear'); 175                                 $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear');
167                             }); 176                             });
168                         } 177                         }
169                         self.initWishlistCompare(); 178                         self.initWishlistCompare();
170                         next_page = ""; 179                         next_page = "";
171                         $(".pages-items li > a.next").each(function(){ 180                         $(".pages-items li > a.next").each(function(){
172                             next_page = $(this).attr("href"); 181                             next_page = $(this).attr("href");
173                         }); 182                         });
174                         $('.infinite-loader .loading').hide(); 183                         $('.infinite-loader .loading').hide();
175                         if(next_page){ 184                         if(next_page){
176                             $('.infinite-loader .btn-load-more').show(); 185                             $('.infinite-loader .btn-load-more').show();
177                             $(".infinite-loader .btn-load-more").unbind("click").click(function(){ 186                             $(".infinite-loader .btn-load-more").unbind("click").click(function(){
178                                 if(!loading && next_page){ 187                                 if(!loading && next_page){
179                                     loading = true; 188                                     loading = true;
180                                     self.ajaxInfinite(next_page); 189                                     self.ajaxInfinite(next_page);
181                                 } 190                                 }
182                             }); 191                             });
183                         } 192                         }
184                     } 193                     }
185  194 
186                 }, 195                 },
187                 error: function () { 196                 error: function () {
188                     window.location.reload(); 197                     window.location.reload();
189                 } 198                 }
190             }); 199             });
191         }, 200         },
192  201 
193         _create: function () { 202         _create: function () {
194             this.initActiveItems(); 203             this.initActiveItems();
195  204 
196             this._super(); 205             this._super();
197  206 
198             this.initProductListUrl(); 207             this.initProductListUrl();
199             this.initObserve(); 208             this.initObserve();
200             this.initSlider(); 209             this.initSlider();
201             this.initWishlistCompare(); 210             this.initWishlistCompare();
202             this.selectedAttr(); 211             this.selectedAttr();
    212             this.renderCategoryTree();
203         }, 213         },
204  214 
205         initActiveItems: function () { 215         initActiveItems: function () {
206             var layerActives = this.options.active, 216             var layerActives = this.options.active,
207                 actives = []; 217                 actives = [];
    218             if ($(".page-layout-1column").length){
    219                 this.options.multipleCollapsible = false;
    220             }
208  221 
209             if (typeof window.layerActiveTabs !== 'undefined') { 222             if (typeof window.layerActiveTabs !== 'undefined') {
210                 layerActives = window.layerActiveTabs; 223                 layerActives = window.layerActiveTabs;
211             } 224             }
212             if (layerActives.length) { 225             if (layerActives.length) {
213                 this.element.find('.filter-options-item').each(function (index) { 226                 this.element.find('.filter-options-item').each(function (index) {
214                     if (~$.inArray($(this).attr('attribute'), layerActives)) { 227                     if (~$.inArray($(this).attr('attribute'), layerActives)) {
215                         actives.push(index); 228                         actives.push(index);
216                     } 229                     }
217                 }); 230                 });
218             } 231             }
219  232 
220             this.options.active = actives; 233             this.options.active = actives;
221  234 
222             return this; 235             return this;
223         }, 236         },
224  237 
225         initProductListUrl: function () { 238         initProductListUrl: function () {
226             var isProcessToolbar = false, 239             var isProcessToolbar = false,
227                 isAjax = this.options.isAjax; 240                 isAjax = this.options.isAjax;
228             $.mage.productListToolbarForm.prototype.changeUrl = function (paramName, paramValue, defaultValue) { 241             $.mage.productListToolbarForm.prototype.changeUrl = function (paramName, paramValue, defaultValue) {
229                 if (isProcessToolbar) { 242                 if (isProcessToolbar) {
230                     return; 243                     return;
231                 } 244                 }
232                 if (isAjax) { 245                 if (isAjax) {
233                     isProcessToolbar = true; 246                     isProcessToolbar = true;
234                 } 247                 }
235  248 
236                 var urlPaths = this.options.url.split('?'), 249                 var urlPaths = this.options.url.split('?'),
237                     baseUrl = urlPaths[0], 250                     baseUrl = urlPaths[0],
238                     urlParams = urlPaths[1] ? urlPaths[1].split('&') : [], 251                     urlParams = urlPaths[1] ? urlPaths[1].split('&') : [],
239                     paramData = {}, 252                     paramData = {},
240                     parameters; 253                     parameters;
241                 for (var i = 0; i < urlParams.length; i++) { 254                 for (var i = 0; i < urlParams.length; i++) {
242                     parameters = urlParams[i].split('='); 255                     parameters = urlParams[i].split('=');
243                     paramData[parameters[0]] = parameters[1] !== undefined 256                     paramData[parameters[0]] = parameters[1] !== undefined
244                         ? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20')) 257                         ? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20'))
245                         : ''; 258                         : '';
246                 } 259                 }
247                 paramData[paramName] = paramValue; 260                 paramData[paramName] = paramValue;
248                 if (paramValue === defaultValue) { 261                 if (paramValue === defaultValue) {
249                     delete paramData[paramName]; 262                     delete paramData[paramName];
250                 } 263                 }
251                 paramData = $.param(paramData); 264                 paramData = $.param(paramData);
252                 if (isAjax) { 265                 if (isAjax) {
253                     submitFilterAction(baseUrl + (paramData.length ? '?' + paramData : '')); 266                     submitFilterAction(baseUrl + (paramData.length ? '?' + paramData : ''));
254                 } else location.href = baseUrl + (paramData.length ? '?' + paramData : ''); 267                 } else location.href = baseUrl + (paramData.length ? '?' + paramData : '');
255             } 268             }
256         }, 269         },
257  270 
258         initObserve: function () { 271         initObserve: function () {
259             var self = this; 272             var self = this;
260             var isAjax = this.options.isAjax; 273             var isAjax = this.options.isAjax;
261             infinite_loaded_count = 0;    
262  274 
263             // fix browser back, forward button 275             // fix browser back, forward button
264             if (typeof window.history.replaceState === "function") { 276             if (typeof window.history.replaceState === "function") {
265                 window.history.replaceState({url: document.URL}, document.title); 277                 window.history.replaceState({url: document.URL}, document.title);
266  278 
267                 setTimeout(function () { 279                 setTimeout(function () {
268                     window.onpopstate = function (e) { 280                     window.onpopstate = function (e) {
269                         if (e.state) { 281                         if (e.state) {
270                             submitFilterAction(e.state.url, 1); 282                             submitFilterAction(e.state.url, 1);
271                         } 283                         }
272                     }; 284                     };
273                 }, 0) 285                 }, 0)
274             } 286             }
275  287 
276             var pageElements = $('#layer-product-list').find('.pages a'); 288             var pageElements = $('#layer-product-list').find('.pages a');
277             pageElements.each(function () { 289             pageElements.each(function () {
278                 var el = $(this), 290                 var el = $(this),
279                     link = self.checkUrl(el.prop('href')); 291                     link = self.checkUrl(el.prop('href'));
280                 if (!link) { 292                 if (!link) {
281                     return; 293                     return;
282                 } 294                 }
283  295 
284                 el.bind('click', function (e) { 296                 el.bind('click', function (e) {
285                     e.stopPropagation(); 297                     e.stopPropagation();
286                     e.preventDefault(); 298                     e.preventDefault();
287                     if (isAjax) { 299                     if (isAjax) {
288                         submitFilterAction(link); 300                         submitFilterAction(link);
289                     } 301                     else location.href = link;
290                     
else location.href = link;
    
291                 }) 302                 })
292             }); 303             });
293  304 
294             var currentElements = this.element.find('.filter-current a, .filter-actions a'); 305             var currentElements = this.element.find('.filter-current a, .filter-actions a');
295             currentElements.each(function (index) { 306             currentElements.each(function (index) {
296                 var el = $(this), 307                 var el = $(this),
297                     link = self.checkUrl(el.prop('href')); 308                     link = self.checkUrl(el.prop('href'));
298                 if (!link) { 309                 if (!link) {
299                     return; 310                     return;
300                 } 311                 }
301  312 
302                 el.bind('click', function (e) { 313                 el.bind('click', function (e) {
303                     e.stopPropagation(); 314                     e.stopPropagation();
304                     e.preventDefault(); 315                     e.preventDefault();
305                     if (isAjax) { 316                     if (isAjax) {
306                         submitFilterAction(link); 317                         submitFilterAction(link);
    318                     } else {
    319                         location.href = link;
307                     } 320                     }
308                     else location.href = link;    
309                 }); 321                 });
310             }); 322             });
311  323 
312             var optionElements = this.element.find('.filter-options a'); 324             var optionElements = this.element.find('.filter-options a');
313             optionElements.each(function (index) { 325             optionElements.each(function (index) {
314                 var el = $(this), 326                 var el = $(this),
315                     link = self.checkUrl(el.prop('href')); 327                     link = self.checkUrl(el.prop('href'));
316                 if (!link) { 328                 if (!link) {
317                     return; 329                     return;
318                 } 330                 }
319  331 
320                 el.bind('click', function (e) { 332                 el.bind('click', function (e) {
321                     if (el.hasClass('swatch-option-link-layered')) { 333                     if (el.hasClass('swatch-option-link-layered')) {
322                         self.selectSwatchOption(el); 334                         self.selectSwatchOption(el);
323                     } else { 335                     } else {
324                         var checkboxEl = el.siblings(self.options.checkboxEl); 336                         var checkboxEl = el.siblings(self.options.checkboxEl);
325                         checkboxEl.prop('checked', !checkboxEl.prop('checked')); 337                         checkboxEl.prop('checked', !checkboxEl.prop('checked'));
326                     } 338                     }
327  339 
328                     e.stopPropagation(); 340                     e.stopPropagation();
329                     e.preventDefault(); 341                     e.preventDefault();
330                     self.ajaxSubmit(link); 342                     self.ajaxSubmit(link);
331                 }); 343                 });
332  344 
333                 var checkbox = el.siblings(self.options.checkboxEl); 345                 var checkbox = el.siblings(self.options.checkboxEl);
334                 checkbox.bind('click', function (e) { 346                 checkbox.bind('click', function (e) {
335                     e.stopPropagation(); 347                     e.stopPropagation();
336                     self.ajaxSubmit(link); 348                     self.ajaxSubmit(link);
337                 }); 349                 });
338             }); 350             });
339  351 
340             var swatchElements = this.element.find('.swatch-attribute'); 352             var swatchElements = this.element.find('.swatch-attribute');
341             swatchElements.each(function (index) { 353             swatchElements.each(function (index) {
342                 var el = $(this); 354                 var el = $(this);
343                 var attCode = el.attr('attribute-code'); 355                 var attCode = el.attr('attribute-code');
344                 if (attCode) { 356                 if (attCode) {
345                     if (self.options.params.hasOwnProperty(attCode)) { 357                     if (self.options.params.hasOwnProperty(attCode)) {
346                         var attValues = self.options.params[attCode].split(","); 358                         var attValues = self.options.params[attCode].split(",");
347                         var swatchOptions = el.find('.swatch-option'); 359                         var swatchOptions = el.find('.swatch-option');
348                         swatchOptions.each(function (option) { 360                         swatchOptions.each(function (option) {
349                             var elOption = $(this); 361                             var elOption = $(this);
350                             if ($.inArray(elOption.attr('option-id'), attValues) !== -1) { 362                             if ($.inArray(elOption.attr('option-id'), attValues) !== -1) {
351                                 elOption.addClass('selected'); 363                                 elOption.addClass('selected');
352                             } 364                             }
353                         }); 365                         });
354                     } 366                     }
355                 } 367                 }
356             }); 368             });
357  369 
358             if(typeof enable_quickview != 'undefined' && enable_quickview == true) { 370             if(typeof enable_quickview != 'undefined' && enable_quickview == true) {
359                 requirejs(['jquery', 'weltpixel_quickview' ], 371                 requirejs(['jquery', 'weltpixel_quickview' ],
360                     function($, quickview) { 372                     function($, quickview) {
361                         $('.weltpixel-quickview').off('click').on('click', function() { 373                         $('.weltpixel-quickview').off('click').on('click', function() {
362                             var prodUrl = $(this).attr('data-quickview-url'); 374                             var prodUrl = $(this).attr('data-quickview-url');
363                             if (prodUrl.length) { 375                             if (prodUrl.length) {
364                                 quickview.displayContent(prodUrl); 376                                 quickview.displayContent(prodUrl);
365                             } 377                             }
366                         }); 378                         });
367                     }); 379                     });
368             } 380             }
369  381 
370             $(".products-grid .weltpixel-quickview").each(function(){ 382             $(".products-grid .weltpixel-quickview").each(function(){
371                 $(this).appendTo($(this).parents('.product-item-info').children(".product-item-photo")); 383                 $(this).appendTo($(this).parents('.product-item-info').children(".product-item-photo"));
372             }); 384             });
373             $("#layer-product-list img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"}); 385             $("#layer-product-list img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"});
374             if ($('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) { 386             if ($('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) {
375                 $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() { 387                 $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() {
376                     $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear'); 388                     $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear');
377                 }); 389                 });
378             } 390             }
379             if(isAjax) { 391             if(isAjax) {
380                 self.inFinite(); 392                 self.inFinite();
381             }else{ 393             }else{
382                 $('.infinite-loader').hide(); 394                 $('.infinite-loader').hide();
383             } 395             }
384     
385         }, 396         },
386  397 
387         selectSwatchOption: function (el) { 398         selectSwatchOption: function (el) {
388             var childEl = el.find('.swatch-option'); 399             var childEl = el.find('.swatch-option');
389             if (childEl.hasClass('selected')) { 400             if (childEl.hasClass('selected')) {
390                 childEl.removeClass('selected'); 401                 childEl.removeClass('selected');
391             } else { 402             } else {
392                 childEl.addClass('selected'); 403                 childEl.addClass('selected');
393             } 404             }
394         }, 405         },
395  406 
396         initSlider: function () { 407         initSlider: function () {
397             var self = this, 408             var self = this,
398                 slider = this.options.slider, 409                 slider = this.options.slider;
399                 isAjax = this.options.isAjax; 410 
400             for (var code in slider) { 411             for (var code in slider) {
401                 if (slider.hasOwnProperty(code)) { 412                 if (slider.hasOwnProperty(code)) {
402                     var sliderConfig = slider[code], 413                     var sliderConfig = slider[code],
403                         sliderElement = self.element.find(this.options.sliderElementPrefix + code), 414                         sliderElement = self.element.find(this.options.sliderElementPrefix + code),
404                         priceFormat = sliderConfig.hasOwnProperty('priceFormat') ? JSON.parse(sliderConfig.priceFormat) : null; 415                         priceFormat = sliderConfig.hasOwnProperty('priceFormat') ? JSON.parse(sliderConfig.priceFormat) : null;
405  416 
406                     if (sliderElement.length) { 417                     if (sliderElement.length) {
407                         sliderElement.slider({ 418                         sliderElement.slider({
408                             range: true, 419                             range: true,
409                             min: sliderConfig.minValue, 420                             min: sliderConfig.minValue,
410                             max: sliderConfig.maxValue, 421                             max: sliderConfig.maxValue,
411                             values: [sliderConfig.selectedFrom, sliderConfig.selectedTo], 422                             values: [sliderConfig.selectedFrom, sliderConfig.selectedTo],
412                             slide: function (event, ui) { 423                             slide: function (event, ui) {
413                                 self.displaySliderText(code, ui.values[0], ui.values[1], priceFormat); 424                                 self.displaySliderText(code, ui.values[0], ui.values[1], priceFormat);
414                             }, 425                             },
415                             change: function (event, ui) { 426                             change: function (event, ui) {
416                                 self.ajaxSubmit(self.getSliderUrl(sliderConfig.ajaxUrl, ui.values[0], ui.values[1])); 427                                 self.ajaxSubmit(self.getSliderUrl(sliderConfig.ajaxUrl, ui.values[0], ui.values[1]));
417                             } 428                             }
418                         }); 429                         });
419                     } 430                     }
420                     self.displaySliderText(code, sliderConfig.selectedFrom, sliderConfig.selectedTo, priceFormat); 431                     self.displaySliderText(code, sliderConfig.selectedFrom, sliderConfig.selectedTo, priceFormat);
421                 } 432                 }
422             } 433             }
423         }, 434         },
424  435 
425         displaySliderText: function (code, from, to, format) { 436         displaySliderText: function (code, from, to, format) {
426             var textElement = this.element.find(this.options.sliderTextElementPrefix + code); 437             var textElement = this.element.find(this.options.sliderTextElementPrefix + code);
427             if (textElement.length) { 438             if (textElement.length) {
428                 if (format !== null) { 439                 if (format !== null) {
429                     from = this.formatPrice(from, format); 440                     from = this.formatPrice(from, format);
430                     to = this.formatPrice(to, format); 441                     to = this.formatPrice(to, format);
431                 } 442                 }
432  443 
433                 textElement.html(from + ' - ' + to); 444                 textElement.html(from + ' - ' + to);
434             } 445             }
435         }, 446         },
436  447 
437         getSliderUrl: function (url, from, to) { 448         getSliderUrl: function (url, from, to) {
438             return url.replace('from-to', from + '-' + to); 449             return url.replace('from-to', from + '-' + to);
439         }, 450         },
440  451 
441         formatPrice: function (value, format) { 452         formatPrice: function (value, format) {
442             return ultil.formatPrice(value, format); 453             return ultil.formatPrice(value, format);
443         }, 454         },
444  455 
445         ajaxSubmit: function (submitUrl) { 456         ajaxSubmit: function (submitUrl) {
446             var isAjax = this.options.isAjax; 457             var isAjax = this.options.isAjax;
447             this.element.find(this.options.mobileShopbyElement).trigger('click'); 458             this.element.find(this.options.mobileShopbyElement).trigger('click');
448             if (isAjax) {
 459 
    460             if (isAjax) { 
449                 return submitFilterAction(submitUrl); 461                 return submitFilterAction(submitUrl);
450             } 462             }
451             location.href = submitUrl; 463             location.href = submitUrl;
452         }, 464         },
453  465 
454         checkUrl: function (url) { 466         checkUrl: function (url) {
455             var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/; 467             var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
    468 
456             return regex.test(url) ? url : null; 469             return regex.test(url) ? url : null;
457         }, 470         },
458  471 
459         //Handling 'add to wishlist' & 'add to compare' event 472         //Handling 'add to wishlist' & 'add to compare' event
460         initWishlistCompare: function () { 473         initWishlistCompare: function () {
461             var isAjax = this.options.isAjax; 474             var isAjax = this.options.isAjax;
462             var isCustomerLoggedIn = this.options.isCustomerLoggedIn, 475             var isCustomerLoggedIn = this.options.isCustomerLoggedIn,
463                 elClass = 'a.action.tocompare' + (isCustomerLoggedIn ? ',a.action.towishlist' : ''); 476                 elClass = 'a.action.tocompare' + (isCustomerLoggedIn ? ',a.action.towishlist' : '');
464             $(elClass).each(function () { 477             $(elClass).each(function () {
465                 var el = $(this); 478                 var el = $(this);
    479                 if (isAjax){
466                 $(el).bind('click', function (e) { 480                     $(el).bind('click', function (e) {
467                     var dataPost = $(el).data('post'), 481                         var dataPost = $(el).data('post'),
468                         formKey = $('input[name="form_key"]').val()
;
 482                             formKey = $('input[name="form_key"]').val(), method = 'post';
469                     if (formKey) { 483                         if (formKey) {
470                         dataPost.data.form_key = formKey; 484                             dataPost.data.form_key = formKey;
471                     } 485                         }
472  486 
473                     var paramData = $.param(dataPost.data), 487                         var paramData = $.param(dataPost.data),
474                         url = dataPost.action + (paramData.length ? '?' + paramData : ''); 488                             url = dataPost.action + (paramData.length ? '?' + paramData : '');
475  489 
476                     e.stopPropagation(); 490                         e.stopPropagation();
477                     e.preventDefault(); 491                         e.preventDefault();
478  492 
479                     if (isAjax && el.hasClass('towishlist')) { 493                         if (
el.hasClass('towishlist')) {
480                         submitFilterAction(url, true
);
 494                             submitFilterAction(url, true, method);
481                     } else if (isAjax) { 495                         } else
{
482                         submitFilterAction(url
);
 496                             submitFilterAction(url, true, method);
483                     } else location.href = url; 497                         }
484                 }); 498                     });
    499                 }
485             }) 500             })
486         }, 501         },
487  502 
488         //Selected attribute color after page load. 503         //Selected attribute color after page load.
489         selectedAttr: function () { 504         selectedAttr: function () {
490             var filterCurrent = $('.layered-filter-block-container .filter-current .items .item .filter-value'); 505             var filterCurrent = $('.layered-filter-block-container .filter-current .items .item .filter-value');
491  506 
492             filterCurrent.each(function(){ 507             filterCurrent.each(function(){
493                 var el         = $(this), 508                 var el         = $(this),
494                     colorLabel = el.html(), 509                     colorLabel = el.html(),
495                     colorAttr  = $('.filter-options .filter-options-item .color .swatch-option-link-layered .swatch-option'); 510                     swatchAttr  = $('.filter-options .filter-options-item .
swatch-option-link-layered .swatch-option');
496  511 
497                 colorAttr.each(function(){ 512                 swatchAttr.each(function(){
498                     var elA = $(this); 513                     var elA = $(this);
499                     if(elA.attr('data-option-label') === colorLabel && !elA.hasClass('selected')){ 514                     if(elA.attr('data-option-label') === colorLabel && !elA.hasClass('selected')){
500                         elA.addClass('selected'); 515                         elA.addClass('selected');
501                     } 516                     }
502                 }); 517                 });
503             }); 518             });
    519         },
    520 
    521         renderCategoryTree: function () {
    522             var iconExpand = this.element.find('.filter-options .icon-expand');
    523 
    524             iconExpand.each(function () {
    525                 var el = $(this);
    526 
    527                 el.nextAll('ol').each(function() {
    528                     if($(this).find('input[checked]').length !== 0
    529                         && !$(this).prevAll('.icon-expand').hasClass('active')
    530                     ) {
    531                         $(this).show();
    532                         $(this).prevAll('.icon-expand').toggleClass('active');
    533                     }
    534                 });
    535 
    536                 el.bind('click', function (e) {
    537                     el.nextAll('ol').toggle();
    538                     el.toggleClass('active');
    539                     e.stopPropagation();
    540                 });
    541             });
504         } 542         }
505     }); 543     });
506  544 
507     return $.mageplaza.layer; 545     return $.mageplaza.layer;
508 }); 546 });