1(function($) { 2 "use strict"; 3 class Elementor_Js_Wpbingo { 4 static getInstance() { 5 if (!Elementor_Js_Wpbingo.instance) { 6 Elementor_Js_Wpbingo.instance = new Elementor_Js_Wpbingo(); 7 } 8 return Elementor_Js_Wpbingo.instance; 9 } 10 constructor() { 11 $(window).on('elementor/frontend/init', () => { 12 this.init(); 13 }); 14 } 15 init() { 16 elementorFrontend.hooks.addAction('frontend/element_ready/bwp_filter_homepage.default', ($scope) => { 17 let bwpFilterHomepageElem = $scope.find('.bwp-filter-homepage'); 18 bwpFilterHomepageElem.each(function() { 19 var $element = $(this); 20 $(".bwp-filter-toggle",$element).click(function(){ 21 if($(this).hasClass('active')){ 22 $(this).removeClass('active'); 23 $(".bwp-filter-attribute",$element).slideUp(); 24 }else{ 25 $(this).addClass('active'); 26 $(".bwp-filter-attribute",$element).slideDown(); 27 } 28 }); 29 30 $("li",$element).click(function(){ 31 var $parent = $(this).parent(); 32 if($parent.hasClass('filter-orderby')){ 33 var order_text = $(this).text(); 34 $('.text-orderby').html(order_text); 35 } 36 37 if($parent.hasClass('filter-category') || $parent.hasClass('filter-orderby')) 38 $("li",$parent).removeClass('active'); 39 else 40 $(this).removeClass('active'); 41 42 if($(this).hasClass('active')){ 43 $(this).removeClass('active'); 44 }else{ 45 $(this).addClass('active'); 46 } 47 48 var count_loadmore = $(".count_loadmore",$element).data("default"); 49 $(".count_loadmore",$element).val(parseInt(count_loadmore)); 50 if($element.hasClass("tab-category") || $element.hasClass("tab-product")){ 51 var $value = $(this).data("value"); 52 if( $(".content-products-"+$value,$element).length > 0 ){ 53 $('.content-product-list',$element).addClass("hidden"); 54 $(".content-products-"+$value,$element).removeClass("hidden"); 55 }else{ 56 _eventFilterHomePage($element); 57 } 58 }else{ 59 _eventFilterHomePage($element); 60 } 61 }); 62 63 $(".loadmore",$element).click(function(){ 64 _eventFilterHomePage($element,true); 65 }); 66 67 68 $('.clear_all',$element).click(function(e){ 69 var $content_filter = $(".bwp-filter-attribute",$element); 70 var bwp_slider_price = $(".bwp_slider_price",$element); 71 $("li",$content_filter).removeClass('active'); 72 $(".price-filter-min-text",$element).val(bwp_slider_price.data("min")); 73 $(".price-filter-max-text",$element).val(bwp_slider_price.data("max")); 74 $(".text-price-filter-min-text",$element).html(bwp_slider_price.data("min")); 75 $(".text-price-filter-max-text",$element).html(bwp_slider_price.data("max")); 76 $(".ui-slider-range",bwp_slider_price).css({"left": "0px", "width": "100%"}); 77 $("span",bwp_slider_price).first().css("left","0px"); 78 $("span",bwp_slider_price).last().css("left","100%"); 79 _eventFilterHomePage($element); 80 }); 81 82 var min_price = $(".price-filter-min-text",$element).val(); 83 var max_price = $(".price-filter-max-text",$element).val(); 84 $(".bwp_slider_price",$element).slider({ 85 range:true, 86 min: $(".bwp_slider_price",$element).data('min'), 87 max: $(".bwp_slider_price",$element).data('max'), 88 values: [min_price,max_price], 89 slide : function( event, ui ) { 90 $(".text-price-filter-min-text",$element).html(ui.values[0]); 91 $(".text-price-filter-max-text",$element).html(ui.values[1]); 92 $(".price-filter-min-text",$element).val(ui.values[0]); 93 $(".price-filter-max-text",$element).val(ui.values[1]); 94 }, 95 change: function( event, ui ) { 96 _eventFilterHomePage($element); 97 } 98 99 }); 100 }); 101 }); 102 } 103 } 104 Elementor_Js_Wpbingo.getInstance(); 105 106 function _eventFilterHomePage($element,loadmore = false){ 107 if(loadmore){ 108 $('.loadmore',$element).addClass('loading'); 109 }else{ 110 $('.bwp-filter-content',$element).addClass('active'); 111 $('.bwp-filter-content',$element).append('<div class="loading loading-filter"></div>'); 112 } 113 var $filter = new Object();
114 var $ajax_url = filter_ajax.ajaxurl; 115 $filter.content_product = $element.data("content_product") ? $element.data("content_product") : "", 116 $filter.category = $(".filter-category li.active",$element).data("value"); 117 $filter.orderby = $(".filter-orderby li.active",$element).data("value"); 118 $filter.min_price = $(".price-filter-min-text",$element).val(); 119 $filter.max_price = $(".price-filter-max-text",$element).val(); 120 $filter.class_col = (!$element.hasClass("slider")) ? $element.data("class_col") : ""; 121 $filter.loadmore = (loadmore) ? 1 : 0; 122 $filter.item_row = $(".products-list",$element).data("item_row") ? $(".products-list",$element).data("item_row") : 1; 123 if(loadmore){ 124 $filter.paged = $(".count_loadmore",$element).val(); 125 }else{ 126 $filter.paged = 1; 127 } 128 $filter.product_count = $element.data("showmore"); 129 130 var atributes = $element.data("atributes"); 131 if(atributes){ 132 var atributes = atributes.split(','); 133 for(var i=0;i<atributes.length;i++){ 134 var atr = []; 135 $("."+atributes[i]+" li.active",$element).each(function(index){ 136 atr[index] = $(this).data("value"); 137 }); 138 $filter[atributes[i]] = atr; 139 } 140 } 141 142 var brands = []; 143 $(".filter-brand li.active",$element).each(function(index){ 144 brands[index] = $(this).data("value"); 145 }); 146 147 $filter.brand = brands; 148 149 jQuery.ajax({ 150 type: "POST", 151 url: $ajax_url, 152 dataType: 'json', 153 data: { 154 filter : $filter, 155 action : "bwp_filter_homepage_callback", 156 }, 157 success: function (result) { 158 if(loadmore){ 159 if (result.products) 160 $('.products-list',$element).append(result.products); 161 var count_loadmore = $(".count_loadmore",$element).val(); 162 $(".count_loadmore",$element).val(parseInt(count_loadmore) + 1); 163 }else{ 164 if($element.hasClass("tab-category") || $element.hasClass("tab-product")){ 165 if($element.hasClass("tab-category")){ 166 var $value = $filter.category; 167 }else{ 168 var $value = $filter.orderby; 169 } 170 if($element.hasClass("scroll-list")){ 171 var $content_parent = $('.content-product-list',$element).first(); 172 var $content_child = $content_parent.children().clone(); 173 if (result.products){ 174 var $product_list = $('.products-list',$content_parent).clone().html(result.products); 175 }else{ 176 var $product_list = $('.products-list',$content_parent).clone().html(''); 177 } 178 $('.products-list',$content_child).replaceWith($product_list); 179 $('.content-product-list',$element).addClass("hidden"); 180 $( ".content-product-list",$element).last().after( '<div class="content-product-list content-products-'+$value+'"></div>' ); 181 $(".content-products-"+$value,$element).html($content_child); 182 var $parent = $(".content-products-"+$value,$element); 183 $(".products-list",$parent).removeAttr("style"); 184 $(".handle",$parent).removeAttr("style"); 185 _wpbingo_drag_slider($(".list-product",$parent)); 186 }else{ 187 var $child_product = $('.content-product-list',$element).first(); 188 if (result.products){ 189 var $product_list = $('.products-list',$child_product).clone().html(result.products); 190 }else{ 191 var $product_list = $('.products-list',$child_product).clone().html(''); 192 } 193 $('.content-product-list',$element).addClass("hidden"); 194 $( ".content-product-list",$element).last().after( '<div class="content-product-list content-products-'+$value+'"></div>' ); 195 $(".content-products-"+$value,$element).html($product_list); 196 var $parent = $(".content-products-"+$value,$element); 197 if($element.hasClass("slider")){ 198 $(".products-list",$parent).removeClass("slick-slider slick-initialized"); 199 _wpbingo_slick_carousel($(".products-list",$parent)); 200 _check_nav_slick($(".products-list",$parent)); 201 } 202 } 203 _wpbingo_countdown_product($(".products-list",$parent)); 204 }else{ 205 if (result.products){ 206 $('.products-list',$element).html(result.products); 207 }else{ 208 $('.products-list',$element).html(''); 209 } 210 _wpbingo_countdown_product($(".products-list",$element)); 211 if($element.hasClass("slider")){ 212 $('.products-list',$element).removeClass("slick-slider slick-initialized"); 213 _wpbingo_slick_carousel($('.products-list',$element)); 214 _check_nav_slick($('.products-list',$element)); 215 } 216 } 217 _wpbingo_click_atribute_image(); 218 _wpbingo_click_add_to_cart(); 219 _wpbingo_event_quick_buy(); 220 } 221 222 _wpbingo_click_quickview_button(); 223 224 if (result.loadmore && result.loadmore == 1) 225 $(".products_loadmore",$element).show(); 226 else 227 $(".products_loadmore",$element).hide(); 228 229 if(loadmore){ 230 $('.loadmore',$element).removeClass('loading'); 231 }else{ 232 $('.bwp-filter-content',$element).removeClass('active'); 233 $('.loading',$element).remove(); 234 } 235 var $content_filter = $(".bwp-filter-attribute",$element); 236 237 if($("li.active",$content_filter).length > 0 || ($(".price-filter-min-text",$element).val() != $(".bwp_slider_price",$element).data("min")) || ($(".price-filter-max-text",$element).val() != $(".bwp_slider_price",$element).data("max"))) 238 $(".clear_all",$element).show(); 239 else 240 $(".clear_all",$element).hide(); 241 }, 242 error:function(jqXHR, textStatus, errorThrown) { 243 console.log("error " + textStatus); 244 console.log("incoming Text " + jqXHR.responseText); 245 } 246 }); 247 248 return false; 249 } 250 function _wpbingo_click_atribute_image(){ 251 $(".image-attribute",".product-attribute").on( "click", function() { 252 if(!$(this).hasClass("active")){ 253 $(".image-attribute",".product-attribute").removeClass("active"); 254 $(this).addClass("active"); 255 var $parent = $(this).closest(".products-entry"); 256 var $thumb = $(".product-thumb-hover", $parent); 257 var $image = $(this).data("image"); 258 $("img",$thumb).last().attr("src", $image); 259 } 260 }); 261 } 262 function _wpbingo_click_add_to_cart(){ 263 $(".cart-remove").on( "click", function() { 264 if( $(".flacio-topcart.popup").hasClass("active") ){ 265 $(".flacio-topcart.popup").removeClass("active"); 266 } 267 if( $("body").hasClass("not-scroll") ){ 268 $("body").removeClass("not-scroll"); 269 } 270 }); 271 $(".cart-icon").on( "click", function() { 272 if( !$("body").hasClass("not-scroll") && $(".flacio-topcart").hasClass("popup") ){ 273 $("body").addClass("not-scroll"); 274 } 275 }); 276 $(".remove-cart-shadow").on( "click", function() { 277 if( $(".flacio-topcart.popup").hasClass("active") ){ 278 $(".flacio-topcart.popup").removeClass("active"); 279 } 280 if( $("body").hasClass("not-scroll") ){ 281 $("body").removeClass("not-scroll"); 282 } 283 }); 284 } 285 function _wpbingo_event_quick_buy(){
286 var $form_cart = $('form.cart'); 287 if ($('.quick-buy',$form_cart).length <=0){ 288 return; 289 } 290 var $variations = $('.variations_form'); 291 $variations.on('show_variation', function (event,variation,allow){ 292 event.preventDefault(); 293 if (allow){ 294 $variations.find('.quick-buy').removeClass('disabled'); 295 }else{ 296 $variations.find('.quick-buy').addClass('disabled'); 297 } 298 }); 299 $variations.on('hide_variation', function (event){ 300 event.preventDefault(); 301 $variations.find('.quick-buy').addClass('disabled'); 302 }); 303 $('.quick-buy',$form_cart).on( "click", function(event){ 304 event.preventDefault(); 305 var $disabled = $(this).is(':disabled'); 306 if (!$disabled){ 307 $form_cart.append('<input type="hidden" name="quick_buy" value="1" />'); 308 $(this).parent().find('.single_add_to_cart_button').trigger('click'); 309 } 310 }); 311 } 312 function _wpbingo_slick_carousel($element){ 313 var _body = $( 'body' ); 314 $element.slick({ 315 arrows: $element.data("nav") ? true : false , 316 dots: $element.data("dots") ? true : false , 317 draggable : $element.data("draggable") ? false : true , 318 prevArrow: '<i class="slick-arrow fa fa-angle-left"></i>', 319 nextArrow: '<i class="slick-arrow fa fa-angle-right"></i>', 320 slidesToScroll:$element.data("slidestoscroll") ? $element.data("columns") : 1, 321 slidesToShow: $element.data("columns"), 322 asNavFor: $element.data("asnavfor") ? $element.data("asnavfor") : false , 323 vertical: $element.data("vertical") ? true : false , 324 verticalSwiping: $element.data("verticalswiping") ? $element.data("verticalswiping") : false , 325 rtl: (_body.hasClass("rtl") && !$element.data("vertical")) ? true : false , 326 centerMode: $element.data("centermode") ? $element.data("centermode") : false , 327 focusOnSelect: $element.data("focusonselect") ? $element.data("focusonselect") : false , 328 responsive: [ 329 { 330 breakpoint: 1441, 331 settings: { 332 slidesToShow: $element.data("columns1440") ? $element.data("columns1440") : $element.data("columns"), 333 slidesToScroll: $element.data("columns1440") ? $element.data("columns1440") : $element.data("columns"), 334 } 335 }, 336 { 337 breakpoint: 1200, 338 settings: { 339 slidesToShow: $element.data("columns1"), 340 slidesToScroll: $element.data("columns1"), 341 } 342 }, 343 { 344 breakpoint: 1024, 345 settings: { 346 slidesToShow: $element.data("columns2"), 347 slidesToScroll: $element.data("columns2"), 348 } 349 }, 350 { 351 breakpoint: 768, 352 settings: { 353 slidesToShow: $element.data("columns3"), 354 slidesToScroll: $element.data("columns3"), 355 vertical: false, 356 verticalSwiping : false, 357 } 358 }, 359 { 360 breakpoint: 480, 361 vertical: false, 362 verticalSwiping : false, 363 settings: { 364 slidesToShow: $element.data("columns4"), 365 slidesToScroll: $element.data("columns4"), 366 vertical: false, 367 verticalSwiping : false, 368 } 369 } 370 ] 371 }); 372 } 373 374 function _check_nav_slick($element){ 375 if($(".slick-arrow",$element).length > 0){ 376 var $prev = $(".fa-angle-left",$element).clone(); 377 $(".fa-angle-left",$element).remove(); 378 if($element.parent().find(".fa-angle-left").length == 0){ 379 $prev.prependTo($element.parent()); 380 } 381 $prev.click(function() { 382 $element.slick('slickPrev'); 383 }); 384 385 var $next = $(".fa-angle-right",$element).clone(); 386 $(".fa-angle-right",$element).remove(); 387 if($element.parent().find(".fa-angle-right").length == 0){ 388 $next.appendTo($element.parent()); 389 } 390 $next.click(function() { 391 $element.slick('slickNext'); 392 }); 393 }else{ 394 $(".fa-angle-left",$element.parent()).remove(); 395 $(".fa-angle-right",$element.parent()).remove(); 396 } 397 } 398 399 function _wpbingo_click_quickview_button(){ 400 $('.quickview-button').on( "click", function(e) { 401 e.preventDefault(); 402 var product_id = $(this).data('product_id'); 403 $(".quickview-"+product_id).addClass("loading"); 404 $.ajax({ 405 url: filter_ajax.ajaxurl, 406 data: { 407 "action" : "flacio_quickviewproduct", 408 'product_id' : product_id 409 }, 410 success: function(results) { 411 $('.bwp-quick-view').empty().html(results).addClass("active"); 412 $(".quickview-"+product_id).removeClass("loading"); 413 $("#quickview-slick-carousel .slick-carousel").each(function(){ 414 _wpbingo_slick_carousel($(this)); 415 });
416 if( typeof jQuery.fn.tawcvs_variation_swatches_form != 'undefined' ) { 417 jQuery('.variations_form').tawcvs_variation_swatches_form(); 418 jQuery(document.body).trigger('tawcvs_initialized'); 419 }else{ 420 var form_variation = $(".bwp-quick-view").find('.variations_form'); 421 var form_variation_select = $(".bwp-quick-view").find('.variations_form .variations select'); 422 form_variation.wc_variation_form(); 423 form_variation_select.change(); 424 } 425 _wpbingo_click_close_quickview(); 426 }, 427 error: function(errorThrown) { console.log(errorThrown); }, 428 }); 429 }); 430 } 431 432 function _wpbingo_click_close_quickview(){ 433 $('.quickview-close').on( "click", function(e) { 434 e.preventDefault(); 435 $('.bwp-quick-view').empty().removeClass("active"); 436 }); 437 } 438 439 function _wpbingo_countdown_product($element){ 440 $('.product-countdown',$element).each(function(event){ 441 var $this = $(this); 442 var $id = $(this).data("id"); 443 var $current_time = new Date().getTime(); 444 var $sttime = $(this).data('sttime'); 445 var $countdown_time = $this.data('cdtime'); 446 var $day = $this.data('day') ? $this.data('day') : "D"; 447 var $hour = $this.data('hour') ? $this.data('hour') : "H"; 448 var $min = $this.data('min') ? $this.data('min') : "M"; 449 var $sec = $this.data('sec') ? $this.data('sec') : "S"; 450 var $austDay = new Date(); 451 $austDay = new Date( $countdown_time * 1000 ); 452 if( $sttime > $current_time ){ 453 $this.remove(); 454 return ; 455 } 456 if( $countdown_time.length > 0 && $current_time > $countdown_time ){ 457 $this.remove(); 458 return ; 459 } 460 if( $countdown_time.length <= 0 ){ 461 $this.remove(); 462 return ; 463 } 464 $this.countdown($austDay, function(event) { 465 $(this).html( 466 event.strftime('<span class="countdown-content"><span class="days"><span class="countdown-amount">%D</span><span class="countdown-text">'+$day+'</span></span><span class="countdown-section hours"><span class="countdown-amount">%H</span><span class="countdown-text">'+$hour+'</span></span><span class="countdown-section mins"><span class="countdown-amount">%M</span><span class="countdown-text">'+$min+'</span></span><span class="countdown-section secs"><span class="countdown-amount">%S</span><span class="countdown-text">'+$sec+'</span></span></span>') 467 ); 468 }).on('finish.countdown', function(event){ 469 $this.remove(); 470 $id = $this.data( 'id' ); 471 $target = this; 472 $this.hide('slow', function(){ $(this).remove(); }); 473 $price = $this.data( 'price' ); 474 $('#' + $id + ' .item-price > span').hide('slow', function(){ $('#' + $id + ' .item-price > span').remove(); }); 475 $('#' + $id + ' .item-price' ).append( '<span><span class="amount">' + $price + '</span></span>' ); 476 }); 477 }); 478 } 479 function _wpbingo_drag_slider($element){ 480 var _window = $( window ); 481 var $wrap = $element.parent(); 482 var $content = $element.closest(".scroll-list"); 483 if(_window.width() >= 1200){ 484 var $width = Math.ceil($content.width()/($element.data("columns"))); 485 }else if( _window.width() < 1200 && _window.width() >= 998 ){ 486 var $width = Math.ceil($content.width()/($element.data("columns1"))); 487 }else if( _window.width() < 998 && _window.width() >= 768 ){ 488 var $width = Math.ceil($content.width()/($element.data("columns2"))); 489 }else{ 490 var $width = Math.ceil($content.width()/($element.data("columns3"))); 491 } 492 $element.find('.item-product').css("width",$width); 493 var options = { 494 horizontal: 1, 495 itemNav: 'basic', 496 smart: 1, 497 activateOn: 'click', 498 mouseDragging: 1, 499 touchDragging: 1, 500 releaseSwing: 1, 501 startAt: 0, 502 scrollBar: $wrap.find('.scrollbar'), 503 scrollBy: 1, 504 pagesBar: $wrap.find('.pages'), 505 activatePageOn: 'click', 506 speed: 300, 507 elasticBounds: 1, 508 dragHandle: 1, 509 dynamicHandle: 1, 510 clickBar: 1, 511 prevPage: $wrap.find('.prev'), 512 nextPage: $wrap.find('.next'), 513 disabledClass: 'disabled' 514 }; 515 $element.sly(options); 516 } 517 //Load more Product 518 519 $( ".bwp_product_list.load_more" ).each(function() { 520 var $element = $(this); 521 $(".loadmore",$element).click(function(e) { 522 e.preventDefault(); 523 var paged = $(".count_loadmore", $element).val(); 524 $.ajax({
525 type: "POST", 526 url: $element.data("url"), 527 dataType: 'json', 528 data: { 529 action : "bwp_load_more_callback", 530 category : $element.data("category"), 531 orderby : $element.data("orderby"), 532 order : $element.data("order"), 533 numberposts : $element.data("numberposts"), 534 source : $element.data("source"), 535 attributes : $element.data("attributes"), 536 total : $element.data("total"), 537 content_product : $element.data("content_product") ? $element.data("content_product") : "", 538 paged : paged, 539 }, 540 beforeSend: function() { 541 $('.loadmore',$element).addClass('loading'); 542 }, 543 success: function (result) { 544 if (result.products){ 545 $('.products-list',$element).append(result.products); 546 paged = parseInt(paged) + 1; 547 $('.count_loadmore',$element).val(paged); 548 _wpbingo_click_quickview_button(); 549 _wpbingo_countdown_product($(".products-list",$element)); 550 } 551 if(result.check_loadmore == 1) 552 $('.products_loadmore',$element).hide(); 553 $('.loadmore',$element).removeClass('loading'); 554 } 555 }); 556 }); 557 }); 558})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.