1'use strict'; 2var woof_redirect = ''; //if we use redirect attribute in shortcode [woof] 3var woof_reset_btn_action = false; 4var woof_additional_fields = {}; 5jQuery(function () { 6 try { 7 woof_current_values = JSON.parse(woof_current_values); 8 } catch (e) { 9 woof_current_values = null; 10 } 11 if (woof_current_values == null || woof_current_values.length == 0) { 12 woof_current_values = {}; 13 } 14}); 15 16//*** 17if (typeof woof_lang_custom == 'undefined') { 18 var woof_lang_custom = {}; /*!!important*/ 19} 20if (typeof woof_ext_filter_titles != 'undefined') { 21 woof_lang_custom = Object.assign( 22 {}, 23 woof_lang_custom, 24 woof_ext_filter_titles 25 ); 26} 27 28jQuery(function ($) { 29 jQuery('body').append( 30 '<div id="woof_html_buffer" class="woof_info_popup" style="display: none;"></div>' 31 ); 32 //http://stackoverflow.com/questions/2389540/jquery-hasparent 33 jQuery.extend(jQuery.fn, { 34 within: function (pSelector) { 35 // Returns a subset of items using jQuery.filter 36 return this.filter(function () { 37 // Return truthy/falsey based on presence in parent 38 return jQuery(this).closest(pSelector).length; 39 }); 40 }, 41 }); 42 43 //fix for swoof shortcode [woof_form_builder] (one form on one page) 44 let forms = document.querySelectorAll('.woof[data-slug]'); 45 if (forms.length) { 46 forms.forEach((f) => { 47 if (f.dataset.slug.length > 0) { 48 swoof_search_slug = f.dataset.slug; 49 } 50 }); 51 } 52 53 //+++ 54 55 if (jQuery('#woof_results_by_ajax').length > 0) { 56 woof_is_ajax = 1; 57 } 58 59 //listening attributes in shortcode [woof] 60 woof_autosubmit = parseInt(jQuery('.woof').eq(0).data('autosubmit'), 10); 61 woof_ajax_redraw = parseInt(jQuery('.woof').eq(0).data('ajax-redraw'), 10); 62 63 //+++ 64 65 woof_ext_init_functions = JSON.parse(woof_ext_init_functions); 66 67 //fix for native woo price range 68 woof_init_native_woo_price_filter(); 69 70 jQuery('body').on('price_slider_change', function (event, min, max) { 71 if ( 72 woof_autosubmit && 73 !woof_show_price_search_button && 74 jQuery('.price_slider_wrapper').length < 3 75 ) { 76 jQuery('.woof .widget_price_filter form').trigger('submit'); 77 } else { 78 var min_price = jQuery(this) 79 .find('.price_slider_amount #min_price') 80 .val(); 81 var max_price = jQuery(this) 82 .find('.price_slider_amount #max_price') 83 .val(); 84 woof_current_values.min_price = min_price; 85 woof_current_values.max_price = max_price; 86 } 87 }); 88 89 jQuery('body').on('change', '.woof_price_filter_dropdown', function () { 90 var val = jQuery(this).val(); 91 if (parseInt(val, 10) == -1) { 92 delete woof_current_values.min_price; 93 delete woof_current_values.max_price; 94 } else { 95 var val = val.split('-'); 96 woof_current_values.min_price = val[0]; 97 woof_current_values.max_price = val[1]; 98 } 99 100 if (woof_autosubmit || jQuery(this).within('.woof').length == 0) { 101 woof_submit_link(woof_get_submit_link()); 102 } 103 }); 104 105 //change value in textinput price filter if WOOCS is installed 106 woof_recount_text_price_filter(); 107 //+++ 108 jQuery('body').on('change', '.woof_price_filter_txt', function () { 109 var from = parseInt( 110 jQuery(this).parent().find('.woof_price_filter_txt_from').val(), 111 10 112 ); 113 var to = parseInt( 114 jQuery(this).parent().find('.woof_price_filter_txt_to').val(), 115 10 116 ); 117 118 if (to < from || from < 0) { 119 delete woof_current_values.min_price; 120 delete woof_current_values.max_price; 121 } else { 122 if (typeof woocs_current_currency !== 'undefined') {
123 from = Math.ceil( 124 from / parseFloat(woocs_current_currency.rate) 125 ); 126 to = Math.ceil(to / parseFloat(woocs_current_currency.rate)); 127 } 128 129 woof_current_values.min_price = from; 130 woof_current_values.max_price = to; 131 } 132 133 if (woof_autosubmit || jQuery(this).within('.woof').length == 0) { 134 woof_submit_link(woof_get_submit_link()); 135 } 136 }); 137 138 //*** 139 140 jQuery('body').on('click', '.woof_open_hidden_li_btn', function () { 141 var state = jQuery(this).data('state'); 142 var type = jQuery(this).data('type'); 143 144 if (state == 'closed') { 145 jQuery(this) 146 .parents('.woof_list') 147 .find('.woof_hidden_term') 148 .addClass('woof_hidden_term2'); 149 jQuery(this) 150 .parents('.woof_list') 151 .find('.woof_hidden_term') 152 .removeClass('woof_hidden_term'); 153 if (type == 'image') { 154 jQuery(this) 155 .find('img') 156 .attr('src', jQuery(this).data('opened')); 157 } else { 158 jQuery(this).html(jQuery(this).data('opened')); 159 } 160 161 jQuery(this).data('state', 'opened'); 162 } else { 163 jQuery(this) 164 .parents('.woof_list') 165 .find('.woof_hidden_term2') 166 .addClass('woof_hidden_term'); 167 jQuery(this) 168 .parents('.woof_list') 169 .find('.woof_hidden_term2') 170 .removeClass('woof_hidden_term2'); 171 172 if (type == 'image') { 173 jQuery(this) 174 .find('img') 175 .attr('src', jQuery(this).data('closed')); 176 } else { 177 jQuery(this).text(jQuery(this).data('closed')); 178 } 179 180 jQuery(this).data('state', 'closed'); 181 } 182 183 return false; 184 }); 185 //open hidden block 186 woof_open_hidden_li(); 187 188 //*** woocommerce native "AVERAGE RATING" widget synchronizing 189 jQuery('.widget_rating_filter li.wc-layered-nav-rating a').on( 190 'click', 191 function () { 192 var is_chosen = jQuery(this).parent().hasClass('chosen'); 193 var parsed_url = woof_parse_url(jQuery(this).attr('href')); 194 var rate = 0; 195 if (parsed_url.query !== undefined) { 196 if (parsed_url.query.indexOf('min_rating') !== -1) { 197 var arrayOfStrings = parsed_url.query.split('min_rating='); 198 rate = parseInt(arrayOfStrings[1], 10); 199 } 200 } 201 jQuery(this).parents('ul').find('li').removeClass('chosen'); 202 if (is_chosen) { 203 delete woof_current_values.min_rating; 204 } else { 205 woof_current_values.min_rating = rate; 206 jQuery(this).parent().addClass('chosen'); 207 } 208 209 woof_submit_link(woof_get_submit_link()); 210 211 return false; 212 } 213 ); 214 215 //WOOF start filtering button action 216 jQuery('body').on('click', '.woof_start_filtering_btn', function () { 217 var shortcode = jQuery(this).parents('.woof').data('shortcode'); 218 jQuery(this).html(woof_lang_loading); 219 jQuery(this).addClass('woof_start_filtering_btn2'); 220 jQuery(this).removeClass('woof_start_filtering_btn'); 221 //redrawing [woof ajax_redraw=1] only 222 var data = { 223 action: 'woof_draw_products', 224 page: 1, 225 shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only 226 woof_shortcode: shortcode, 227 nonce_filter: woof_front_nonce, 228 }; 229 230 jQuery.post(woof_ajaxurl, data, function (content) { 231 content = JSON.parse(content); 232 jQuery('div.woof_redraw_zone').replaceWith( 233 jQuery(content.form).find('.woof_redraw_zone') 234 ); 235 woof_mass_reinit(); 236 woof_init_tooltip(); 237 }); 238 239 return false; 240 });
241 242 //*** 243 244 window.addEventListener('pageshow', function (event) { 245 var woof_check_history = 246 event.persisted || 247 (typeof window.performance != 'undefined' && 248 window.performance.navigation.type === 2); 249 if (woof_check_history) { 250 woof_hide_info_popup(); 251 woof_submit_link_locked = false; 252 } 253 }); 254 255 var str = window.location.href; 256 window.onpopstate = function (event) { 257 try { 258 if (Object.keys(woof_current_values).length) { 259 var temp = str.split('?'); 260 var get1 = ''; 261 if (temp[1] != undefined) { 262 get1 = temp[1].split('#'); 263 } 264 var str2 = window.location.href; 265 var temp2 = str2.split('?'); 266 if (temp2[1] == undefined) { 267 //return false; 268 var get2 = {0: '', 1: ''}; 269 } else { 270 var get2 = temp2[1].split('#'); 271 } 272 273 if (get2[0] != get1[0]) { 274 woof_show_info_popup(woof_lang_loading); 275 window.location.reload(); 276 } 277 return false; 278 } 279 } catch (e) { 280 console.log(e); 281 } 282 }; 283 //*** 284 285 //ion-slider price range slider 286 woof_init_ion_sliders(); 287 288 //*** 289 290 woof_init_show_auto_form(); 291 woof_init_hide_auto_form(); 292 293 //*** 294 woof_remove_empty_elements(); 295 woof_unblur_filter(); 296 297 woof_init_search_form(); 298 woof_init_pagination(); 299 woof_init_orderby(); 300 woof_init_reset_button(); 301 woof_init_beauty_scroll(); 302 //+++ 303 woof_draw_products_top_panel(); 304 woof_shortcode_observer(); 305 306 //tooltip 307 woof_init_tooltip(); 308 309 //mobile filter 310 woof_init_mobile_filter(); 311 312 //+++ 313 //if we use redirect attribute in shortcode [woof is_ajax=0] 314 //not for ajax, for redirect mode only 315 if (!woof_is_ajax) { 316 woof_redirect_init(); 317 } 318 319 woof_init_toggles(); 320}); 321 322//if we use redirect attribute in shortcode [woof is_ajax=0] 323//not for ajax, for redirect mode only 324function woof_redirect_init() { 325 try { 326 if (jQuery('.woof').length) { 327 //https://wordpress.org/support/topic/javascript-error-in-frontjs?replies=1 328 if (undefined !== jQuery('.woof').val()) { 329 woof_redirect = jQuery('.woof').eq(0).data('redirect'); //default value 330 if (woof_redirect.length > 0) { 331 woof_shop_page = woof_current_page_link = woof_redirect; 332 } 333 return woof_redirect; 334 } 335 } 336 } catch (e) { 337 console.log(e); 338 } 339} 340 341function woof_init_orderby() { 342 jQuery('body').on('submit', 'form.woocommerce-ordering', function () { 343 /* woo3.3 */ 344 if (!jQuery('#is_woo_shortcode').length) { 345 return false; 346 } 347 /* +++ */ 348 }); 349 jQuery('body').on( 350 'change', 351 'form.woocommerce-ordering select.orderby', 352 function () { 353 /* woo3.3 */ 354 if (!jQuery('#is_woo_shortcode').length) { 355 woof_current_values.orderby = jQuery(this).val(); 356 woof_ajax_page_num = 1; 357 woof_submit_link(woof_get_submit_link(), 0); 358 return false; 359 } 360 /* +++ */ 361 } 362 ); 363} 364 365function woof_init_reset_button() { 366 jQuery('body').on('click', '.woof_reset_search_form', function () { 367 //var link = jQuery(this).data('link'); 368 woof_ajax_page_num = 1; 369 woof_ajax_redraw = 0; 370 woof_reset_btn_action = true; 371 if (woof_is_permalink) { 372 woof_current_values = {}; 373 woof_submit_link(woof_get_submit_link().split('page/')[0]); 374 } else { 375 var link = woof_shop_page; 376 if (woof_current_values.hasOwnProperty('page_id')) { 377 link = 378 location.protocol + 379 '//' + 380 location.host + 381 '/?page_id=' + 382 woof_current_values.page_id; 383 woof_current_values = {page_id: woof_current_values.page_id}; 384 woof_get_submit_link(); 385 } 386 //*** 387 woof_submit_link(link); 388 if (woof_is_ajax) { 389 history.pushState({}, '', link); 390 if (woof_current_values.hasOwnProperty('page_id')) { 391 woof_current_values = { 392 page_id: woof_current_values.page_id, 393 }; 394 } else { 395 woof_current_values = {}; 396 } 397 } 398 } 399 return false; 400 });
401} 402 403function woof_init_pagination() { 404 if (woof_is_ajax === 1) { 405 //jQuery('.woocommerce-pagination ul.page-numbers a.page-numbers').life('click', function () { 406 jQuery('body').on( 407 'click', 408 '.woocommerce-pagination a.page-numbers', 409 function () { 410 var l = jQuery(this).attr('href'); 411 412 if (woof_ajax_first_done) { 413 //wp-admin/admin-ajax.php?paged=2 414 var res = l.split('paged='); 415 if (typeof res[1] !== 'undefined') { 416 woof_ajax_page_num = parseInt(res[1]); 417 } else { 418 woof_ajax_page_num = 1; 419 } 420 var res2 = l.split('product-page='); 421 if (typeof res2[1] !== 'undefined') { 422 woof_ajax_page_num = parseInt(res2[1]); 423 } 424 } else { 425 var res = l.split('page/'); 426 if (typeof res[1] !== 'undefined') { 427 woof_ajax_page_num = parseInt(res[1]); 428 } else { 429 woof_ajax_page_num = 1; 430 } 431 var res2 = l.split('product-page='); 432 if (typeof res2[1] !== 'undefined') { 433 woof_ajax_page_num = parseInt(res2[1]); 434 } 435 } 436 437 //+++ 438 439 { 440 woof_submit_link(woof_get_submit_link(), 0); 441 } 442 443 return false; 444 } 445 ); 446 } 447} 448 449function woof_init_search_form() { 450 woof_init_checkboxes(); 451 woof_init_mselects(); 452 woof_init_radios(); 453 woof_price_filter_radio_init(); 454 woof_init_selects(); 455 456 //for extensions 457 if (woof_ext_init_functions !== null) { 458 jQuery.each(woof_ext_init_functions, function (type, func) { 459 eval(func + '()'); 460 }); 461 } 462 463 //+++ 464 jQuery('.woof_submit_search_form').on('click', function () { 465 if (woof_ajax_redraw) { 466 //[woof redirect="http://test-all/" autosubmit=1 ajax_redraw=1 is_ajax=1 tax_only="locations" by_only="none"] 467 woof_ajax_redraw = 0; 468 woof_is_ajax = 0; 469 } 470 //*** 471 woof_submit_link(woof_get_submit_link()); 472 return false; 473 }); 474 475 //*** 476 jQuery('ul.woof_childs_list').parent('li').addClass('woof_childs_list_li'); 477 478 //*** 479 480 woof_remove_class_widget(); 481 woof_checkboxes_slide(); 482 483 document.dispatchEvent( 484 new CustomEvent('woof_init_search_form', {detail: {}}) 485 ); 486} 487 488var woof_submit_link_locked = false; 489function woof_submit_link(link, ajax_redraw) { 490 if (woof_submit_link_locked) { 491 return; 492 } 493 if (typeof WoofTurboMode != 'undefined') { 494 WoofTurboMode.woof_submit_link(link); 495 496 return; 497 } 498 if (typeof ajax_redraw == 'undefined') { 499 ajax_redraw = woof_ajax_redraw; 500 } 501 502 woof_submit_link_locked = true; 503 504 woof_show_info_popup(woof_lang_loading); 505 506 if (woof_is_ajax === 1 && !ajax_redraw) { 507 woof_ajax_first_done = true; 508 var data = { 509 action: 'woof_draw_products', 510 link: link, 511 page: woof_ajax_page_num, 512 shortcode: jQuery('#woof_results_by_ajax').data('shortcode'), 513 woof_shortcode: jQuery('div.woof').data('shortcode'), 514 nonce_filter: woof_front_nonce, 515 }; 516 517 jQuery.post(woof_ajaxurl, data, function (content) { 518 content = JSON.parse(content); 519 520 woof_before_ajax_form_redrawing(); 521 522 if (jQuery('.woof_results_by_ajax_shortcode').length) { 523 if (typeof content.products != 'undefined') { 524 jQuery('#woof_results_by_ajax').replaceWith( 525 content.products 526 ); 527 528 /* compatibility found products count*/ 529 var found_count = jQuery('.woof_found_count'); 530 jQuery(found_count).show(); 531 if (found_count.length > 0) { 532 var count_prod = jQuery('#woof_results_by_ajax').data( 533 'count' 534 ); 535 if (typeof count_prod != 'undefined') { 536 jQuery(found_count).text(count_prod); 537 } 538 } 539 } 540 } else { 541 if (typeof content.products != 'undefined') { 542 jQuery('.woof_shortcode_output').replaceWith( 543 content.products 544 ); 545 } 546 } 547 if (typeof content.additional_fields != 'undefined') { 548 jQuery.each( 549 content.additional_fields, 550 function (selector, html_data) { 551 if ( 552 typeof woof_additional_fields[selector] == 553 'undefined' 554 ) { 555 woof_additional_fields[selector] = jQuery(selector); 556 } 557 jQuery(selector).replaceWith(html_data); 558 } 559 ); 560 //draw old values 561 jQuery.each( 562 woof_additional_fields, 563 function (selector, html_data_old) { 564 if ( 565 typeof content.additional_fields[selector] == 566 'undefined' 567 ) { 568 jQuery(selector).replaceWith(html_data_old); 569 } 570 } 571 ); 572 } 573 574 jQuery('div.woof_redraw_zone').replaceWith( 575 jQuery(content.form).find('.woof_redraw_zone') 576 ); 577 woof_draw_products_top_panel(); 578 woof_mass_reinit(); 579 woof_submit_link_locked = false; 580 //removing id woof_results_by_ajax - multi in ajax mode sometimes 581 //when uses shorcode woof_products in ajax and in settings try ajaxify shop is Yes 582 jQuery.each( 583 jQuery('#woof_results_by_ajax'), 584 function (index, item) { 585 if (index == 0) { 586 return; 587 } 588 589 jQuery(item).removeAttr('id'); 590 } 591 ); 592 /*mobile behavior*/ 593 //jQuery('.woof_hide_mobile_filter').trigger('click'); 594 jQuery('.woof').removeClass('woof_show_filter_for_mobile'); 595 596 //infinite scroll 597 woof_infinite();
598 //*** script after ajax loading here 599 woof_js_after_ajax_done(); 600 //*** change link in button "add to cart" 601 woof_change_link_addtocart(); 602 603 /*tooltip*/ 604 woof_init_tooltip(); 605 606 document.dispatchEvent( 607 new CustomEvent('woof-ajax-form-redrawing', { 608 detail: { 609 link: link, 610 }, 611 }) 612 ); 613 }); 614 } else { 615 if (ajax_redraw) { 616 //redrawing [woof ajax_redraw=1] only 617 var data = { 618 action: 'woof_draw_products', 619 link: link, 620 page: 1, 621 shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only 622 woof_shortcode: jQuery('div.woof').eq(0).data('shortcode'), 623 nonce_filter: woof_front_nonce, 624 }; 625 jQuery.post(woof_ajaxurl, data, function (content) { 626 woof_before_ajax_form_redrawing(); 627 628 content = JSON.parse(content); 629 jQuery('div.woof_redraw_zone').replaceWith( 630 jQuery(content.form).find('.woof_redraw_zone') 631 ); 632 woof_mass_reinit(); 633 woof_submit_link_locked = false; 634 /*tooltip*/ 635 woof_init_tooltip(); 636 637 document.dispatchEvent( 638 new CustomEvent('woof-ajax-form-redrawing', { 639 detail: { 640 link: link, 641 }, 642 }) 643 ); 644 }); 645 } else { 646 // Delay redirect to avoid conflicts with other scripts (Kadence, etc.) 647 //https://pluginus.net/support/topic/text-search-shortcode-enter-key-reloads-page-instead-of-redirecting-to-shop-page 648 setTimeout(() => { 649 window.location = link; 650 }, 100); 651 woof_show_info_popup(woof_lang_loading); 652 } 653 } 654} 655 656function woof_remove_empty_elements() { 657 // lets check for empty drop-downs 658 jQuery.each(jQuery('.woof_container select'), function (index, select) { 659 var size = jQuery(select).find('option').length; 660 if (size === 0) { 661 jQuery(select).parents('.woof_container').remove(); 662 } 663 }); 664 //+++ 665 // lets check for empty checkboxes, radio, color conatiners 666 jQuery.each(jQuery('ul.woof_list'), function (index, ch) { 667 var size = jQuery(ch).find('li').length; 668 if (size === 0) { 669 jQuery(ch).parents('.woof_container').remove(); 670 } 671 }); 672 jQuery.each(jQuery('.woof_container .woof_list_sd'), function (index, ch) { 673 var size = jQuery(ch).find('.woof-sd-ie').length; 674 if (size === 0) { 675 jQuery(ch).parents('.woof_container').remove(); 676 } 677 }); 678} 679 680function woof_get_submit_link() { 681 //filter woof_current_values values 682 683 if (woof_is_ajax) { 684 woof_current_values.page = woof_ajax_page_num; 685 } 686 //+++ 687 if (Object.keys(woof_current_values).length > 0) { 688 jQuery.each(woof_current_values, function (index, value) { 689 if (index == swoof_search_slug) { 690 delete woof_current_values[index]; 691 } 692 if (index == 's') { 693 delete woof_current_values[index]; 694 } 695 if (index == 'product') { 696 //for single product page (when no permalinks) 697 delete woof_current_values[index]; 698 } 699 if (index == 'really_curr_tax') { 700 delete woof_current_values[index]; 701 } 702 }); 703 } 704 705 //*** 706 if (Object.keys(woof_current_values).length === 2) { 707 if ( 708 'min_price' in woof_current_values && 709 'max_price' in woof_current_values 710 ) { 711 woof_current_page_link = woof_current_page_link.replace( 712 new RegExp(/page\/(\d+)/), 713 '' 714 ); 715 var l = 716 woof_current_page_link + 717 '?min_price=' + 718 woof_current_values.min_price + 719 '&max_price=' + 720 woof_current_values.max_price; 721 if (woof_is_ajax) { 722 history.pushState({}, '', l); 723 } 724 return l; 725 } 726 } 727 728 //*** 729 730 if (Object.keys(woof_current_values).length === 0) { 731 if (woof_is_ajax) { 732 history.pushState({}, '', woof_current_page_link); 733 } 734 return woof_current_page_link; 735 } 736 //+++ 737 if (Object.keys(woof_really_curr_tax).length > 0) { 738 woof_current_values['really_curr_tax'] = 739 woof_really_curr_tax.term_id + '-' + woof_really_curr_tax.taxonomy; 740 } 741 //+++ 742 var link = woof_current_page_link + '?' + swoof_search_slug + '
742=1'; 743 744 //just for the case when no permalinks enabled 745 if (!woof_is_permalink) { 746 if (woof_redirect.length > 0) { 747 link = woof_redirect + '?' + swoof_search_slug + '=1'; 748 if (woof_current_values.hasOwnProperty('page_id')) { 749 delete woof_current_values.page_id; 750 } 751 } else { 752 link = 753 location.protocol + 754 '//' + 755 location.host + 756 '?' + 757 swoof_search_slug + 758 '=1'; 759 } 760 } 761 762 //any trash for different sites, useful for quick support 763 var woof_exclude_accept_array = ['path']; 764 765 if (Object.keys(woof_current_values).length > 0) { 766 jQuery.each(woof_current_values, function (index, value) { 767 if (index == 'page' && woof_is_ajax) { 768 index = 'paged'; //for right pagination if copy/paste this link and send somebody another by email for example 769 } 770 if (index == 'product-page') { 771 return; 772 } 773 774 //http://dev.products-filter.com/?swoof=1&woof_author=3&woof_sku&woof_text=single 775 //avoid links where values is empty 776 if (typeof value !== 'undefined') { 777 if ( 778 (typeof value && value.length > 0) || 779 typeof value == 'number' 780 ) { 781 if ( 782 jQuery.inArray(index, woof_exclude_accept_array) == -1 783 ) { 784 link = link + '&' + index + '=' + value; 785 } 786 } 787 } 788 }); 789 } 790 791 //+++ 792 //remove wp pagination like 'page/2' 793 link = link.replace(new RegExp(/page\/(\d+)/), ''); 794 if (woof_is_ajax) { 795 history.pushState({}, '', link); 796 } 797 798 return link; 799} 800 801function woof_show_info_popup(text) { 802 if (woof_overlay_skin == 'default') { 803 jQuery('#woof_html_buffer').text(text); 804 jQuery('#woof_html_buffer').fadeTo(200, 0.9); 805 } else {
806 //http://jxnblk.com/loading/ 807 switch (woof_overlay_skin) { 808 case 'loading-balls': 809 case 'loading-bars': 810 case 'loading-bubbles': 811 case 'loading-cubes': 812 case 'loading-cylon': 813 case 'loading-spin': 814 case 'loading-spinning-bubbles': 815 case 'loading-spokes': 816 jQuery('body').plainOverlay('show', { 817 progress: function () { 818 //img style should be inlined 819 return jQuery( 820 '<div id="woof_svg_load_container"><img style="height: 100%; width: 100%" src="' + 821 woof_link + 822 'img/loading-master/' + 823 woof_overlay_skin + 824 '.svg" alt=""></div>' 825 ); 826 }, 827 }); 828 break; 829 default: 830 jQuery('body').plainOverlay('show', {duration: -1}); 831 break; 832 } 833 } 834} 835 836function woof_hide_info_popup() { 837 if (woof_overlay_skin == 'default') { 838 window.setTimeout(function () { 839 jQuery('#woof_html_buffer').fadeOut(400); 840 }, 200); 841 } else { 842 jQuery('body').plainOverlay('hide'); 843 } 844} 845 846function woof_draw_products_top_panel() { 847 if (woof_is_ajax) { 848 jQuery('#woof_results_by_ajax') 849 .prev('.woof_products_top_panel') 850 .remove(); 851 } 852 853 var panel = jQuery('.woof_products_top_panel'); 854 855 panel.html(''); 856 if (Object.keys(woof_current_values).length > 0) { 857 panel.show(); 858 panel.html('<ul></ul>'); 859 panel.find('ul').attr('class', 'woof_products_top_panel_ul'); 860 var is_price_in = false; 861 //lets show this on the panel 862 863 jQuery.each(woof_current_values, function (index, value) { 864 //lets filter data for the panel 865 866 if ( 867 jQuery.inArray(index, woof_accept_array) == -1 && 868 jQuery.inArray(index.replace('rev_', ''), woof_accept_array) == 869 -1 870 ) { 871 return; 872 } 873 874 //*** 875 876 if ((index == 'min_price' || index == 'max_price') && is_price_in) { 877 return; 878 } 879 880 if ( 881 (index == 'min_price' || index == 'max_price') && 882 !is_price_in 883 ) { 884 is_price_in = true; 885 index = 'price'; 886 value = woof_lang_pricerange; 887 } 888 889 //tax slider fix 890 var is_range = false; 891 var range_txt = jQuery( 892 "input[data-anchor='woof_n_" + index + "_all_range']" 893 ).val(); 894 895 if (typeof range_txt != 'undefined') { 896 is_range = true; 897 } 898 899 //+++ 900 value = value.toString().trim(); 901 if (value.search(',')) { 902 value = value.split(','); 903 } 904 //+++ 905 if (!is_range) { 906 jQuery.each(value, function (i, v) { 907 if (index == 'page') { 908 return; 909 } 910 911 if (index == 'post_type') { 912 return; 913 } 914 915 var txt = v; 916 if (index == 'orderby') { 917 if (woof_lang[v] !== undefined) { 918 txt = woof_lang.orderby + ': ' + woof_lang[v]; 919 } else { 920 txt = woof_lang.orderby + ': ' + v; 921 } 922 } else if (index == 'perpage') { 923 txt = woof_lang.perpage; 924 } else if (index == 'price') { 925 txt = woof_lang.pricerange; 926 } else { 927 var is_in_custom = false; 928 if (Object.keys(woof_lang_custom).length > 0) { 929 jQuery.each(woof_lang_custom, function (i, tt) { 930 if (i == index) { 931 is_in_custom = true; 932 txt = tt; 933 if (index == 'woof_sku') { 934 txt += ' ' + v; //because search by SKU can by more than 1 value 935 } 936 } 937 }); 938 } 939 if (!is_in_custom) { 940 try { 941 txt = jQuery( 942 "input[data-anchor='woof_n_" + 943 index + 944 '_' + 945 v + 946 "']" 947 ).val(); 948 } catch (e) { 949 console.log(e); 950 } 951 952 if (typeof txt === 'undefined') { 953 txt = v; 954 } 955 } 956 } 957 958 if (typeof woof_filter_titles[index] != 'undefined') { 959 var cont_item = panel.find( 960 'ul.woof_products_top_panel_ul li ul[data-container=' + 961 index + 962 ']' 963 ); 964 965 if (cont_item.length) { 966 cont_item.append( 967 jQuery('<li>').append( 968 jQuery('<a>') 969 .attr('href', '') 970 .attr('data-tax', index) 971 .attr('data-slug', v) 972 .attr('rel', 'nofollow') 973 .append( 974 jQuery('<span>') 975 .attr( 976 'class', 977 'woof_remove_ppi' 978 ) 979 .append(txt) 980 ) 981 ) 982 ); 983 } else { 984 panel.find('ul.woof_products_top_panel_ul').append( 985 jQuery('<li>').append( 986 jQuery('<ul>') 987 .attr('data-container', index) 988 .append( 989 jQuery('<li>').text( 990 woof_filter_titles[index] + ':' 991 ) 992 ) 993 .append( 994 jQuery('<li>').append( 995 jQuery('<a>') 996 .attr('href', '') 997 .attr('data-tax', index) 998 .attr('data-slug', v) 999 .attr('rel', 'nofollow') 1000 .append( 1001 jQuery('<span>') 1002 .attr( 1003 'class', 1004 'woof_remove_ppi' 1005 ) 1006 .append(txt) 1007 ) 1008 ) 1009 ) 1010 ) 1011 ); 1012 } 1013 } else { 1014 panel 1015 .find('ul.woof_products_top_panel_ul') 1016 .append( 1017 jQuery('<li>').append( 1018 jQuery('<a>') 1019 .attr('href', '') 1020 .attr('data-tax', index) 1021 .attr('data-slug', v) 1022 .attr('rel', 'nofollow') 1023 .append( 1024 jQuery('<span>') 1025 .attr( 1026 'class', 1027 'woof_remove_ppi' 1028 ) 1029 .append(txt) 1030 ) 1031 ) 1032 ); 1033 } 1034 }); 1035 } else { 1036 if (typeof woof_filter_titles[index] != 'undefined') { 1037 var cont_item = panel.find( 1038 'ul.woof_products_top_panel_ul li ul[data-container=' + 1039 index + 1040 ']' 1041 ); 1042 1043 if (cont_item.length) { 1044 cont_item.append( 1045 jQuery('<li>').append( 1046 jQuery('<a>') 1047 .attr('href', '') 1048 .attr('data-tax', index) 1049 .attr('data-slug', 'all_range') 1050 .attr('rel', 'nofollow') 1051 .append( 1052 jQuery('<span>') 1053 .attr('class', 'woof_remove_ppi') 1054 .append(range_txt) 1055 ) 1056 ) 1057 ); 1058 } else { 1059 panel.find('ul.woof_products_top_panel_ul').append( 1060 jQuery('<li>').append( 1061 jQuery('<ul>') 1062 .attr('data-container', index) 1063 .append( 1064 jQuery('<li>').text( 1065 woof_filter_titles[index] + ':' 1066 ) 1067 ) 1068 .append( 1069 jQuery('<li>').append( 1070 jQuery('<a>') 1071 .attr('href', '') 1072 .attr('data-tax', index) 1073 .attr('data-slug', 'all_range') 1074 .attr('rel', 'nofollow') 1075 .append( 1076 jQuery('<span>') 1077 .attr( 1078 'class', 1079 'woof_remove_ppi' 1080 ) 1081 .append(range_txt) 1082 ) 1083 ) 1084 ) 1085 ) 1086 ); 1087 } 1088 } else { 1089 panel 1090 .find('ul.woof_products_top_panel_ul') 1091 .append( 1092 jQuery('<li>').append( 1093 jQuery('<a>') 1094 .attr('href', '') 1095 .attr('data-tax', index) 1096 .attr('data-slug', 'all_range') 1097 .attr('rel', 'nofollow') 1098 .append( 1099 jQuery('<span>') 1100 .attr('class', 'woof_remove_ppi') 1101 .append(range_txt) 1102 ) 1103 ) 1104 ); 1105 } 1106 } 1107 }); 1108 } 1109 1110 if ( 1111 jQuery(panel).find('li').length == 0 || 1112 !jQuery('.woof_products_top_panel').length 1113 ) { 1114 panel.hide(); 1115 } else { 1116 panel 1117 .find('ul.woof_products_top_panel_ul') 1118 .prepend( 1119 jQuery('<li>').append( 1120 jQuery('<button>') 1121 .attr('class', 'woof_reset_button_2') 1122 .append(woof_lang.clear_all) 1123 ) 1124 ); 1125 } 1126 1127 jQuery('.woof_reset_button_2').on('click', function () { 1128 woof_ajax_page_num = 1; 1129 woof_ajax_redraw = 0; 1130 woof_reset_btn_action = true; 1131 1132 if (woof_is_permalink) { 1133 woof_current_values = {}; 1134 woof_submit_link(woof_get_submit_link().split('page/')[0]); 1135 } else { 1136 var link = woof_shop_page; 1137 if (woof_current_values.hasOwnProperty('page_id')) { 1138 link = 1139 location.protocol + 1140 '//' + 1141 location.host + 1142 '/?page_id=' + 1143 woof_current_values.page_id; 1144 woof_current_values = {page_id: woof_current_values.page_id}; 1145 woof_get_submit_link(); 1146 } 1147 //*** 1148 woof_submit_link(link); 1149 if (woof_is_ajax) { 1150 history.pushState({}, '', link); 1151 if (woof_current_values.hasOwnProperty('page_id')) { 1152 woof_current_values = { 1153 page_id: woof_current_values.page_id, 1154 }; 1155 } else { 1156 woof_current_values = {}; 1157 } 1158 } 1159 } 1160 return false; 1161 });
1162 //+++ 1163 jQuery('.woof_remove_ppi') 1164 .parent() 1165 .on('click', function (event) { 1166 event.preventDefault(); 1167 var tax = jQuery(this).data('tax'); 1168 var name = jQuery(this).data('slug'); 1169 1170 //*** 1171 1172 if (name == 'all_range') { 1173 delete woof_current_values[tax]; 1174 } else if (tax != 'price') { 1175 var values = woof_current_values[tax]; 1176 values = values.split(','); 1177 var tmp = []; 1178 jQuery.each(values, function (index, value) { 1179 if (value != name) { 1180 tmp.push(value); 1181 } 1182 }); 1183 values = tmp; 1184 1185 if (values.length) { 1186 woof_current_values[tax] = values.join(','); 1187 } else { 1188 delete woof_current_values[tax]; 1189 } 1190 } else { 1191 delete woof_current_values['min_price']; 1192 delete woof_current_values['max_price']; 1193 } 1194 woof_ajax_page_num = 1; 1195 woof_reset_btn_action = true; 1196 { 1197 woof_submit_link(woof_get_submit_link()); 1198 } 1199 jQuery('.woof_products_top_panel') 1200 .find("[data-tax='" + tax + "'][href='" + name + "']") 1201 .hide(333); 1202 return false; 1203 }); 1204} 1205 1206//control conditions if proucts shortcode uses on the page 1207function woof_shortcode_observer() { 1208 var redirect = true; 1209 if ( 1210 jQuery('.woof_shortcode_output').length || 1211 (jQuery('.woocommerce .products, .woocommerce .products-loop').length && 1212 !jQuery('.single-product').length) 1213 ) { 1214 redirect = false; 1215 } 1216 if (jQuery('.woocommerce .woocommerce-info').length) { 1217 redirect = false; 1218 } 1219 if (typeof woof_not_redirect !== 'undefined' && woof_not_redirect == 1) { 1220 redirect = false; 1221 } 1222 1223 if (jQuery('.woot-data-table').length) { 1224 redirect = false; 1225 } 1226 1227 if (!redirect) { 1228 woof_current_page_link = 1229 location.protocol + '//' + location.host + location.pathname; 1230 } 1231 1232 if (jQuery('#woof_results_by_ajax').length) { 1233 woof_is_ajax = 1; 1234 } 1235} 1236 1237function woof_init_beauty_scroll() { 1238 if (woof_use_beauty_scroll) { 1239 try { 1240 var anchor = 1241 '.woof_section_scrolled, .woof_sid_auto_shortcode .woof_container'; 1242 jQuery('' + anchor).addClass('woof_use_beauty_scroll'); 1243 } catch (e) { 1244 console.log(e); 1245 } 1246 } 1247} 1248 1249//just for inbuilt price range widget 1250function woof_remove_class_widget() { 1251 jQuery('.woof_container_inner').find('.widget').removeClass('widget'); 1252} 1253 1254function woof_init_show_auto_form() { 1255 jQuery('.woof_show_auto_form').off('click'); 1256 1257 if (jQuery('.woof_show_auto_form.woof_btn').length) { 1258 jQuery('.woof_btn_default').remove(); 1259 } 1260 1261 jQuery('.woof_show_auto_form').on('click', function () { 1262 var _this = this; 1263 jQuery(_this) 1264 .addClass('woof_hide_auto_form') 1265 .removeClass('woof_show_auto_form'); 1266 jQuery(_this) 1267 .parent() 1268 .find('.woof_auto_show') 1269 .show() 1270 .animate( 1271 { 1272 height: 1273 jQuery(_this) 1274 .parent() 1275 .find('.woof_auto_show_indent') 1276 .height() + 1277 20 + 1278 'px', 1279 opacity: 0.96, 1280 }, 1281 377, 1282 function () { 1283 woof_init_hide_auto_form(); 1284 jQuery(_this) 1285 .parent() 1286 .find('.woof_auto_show') 1287 .removeClass('woof_overflow_hidden'); 1288 jQuery(_this) 1289 .parent() 1290 .find('.woof_auto_show_indent') 1291 .removeClass('woof_overflow_hidden'); 1292 jQuery(_this) 1293 .parent() 1294 .find('.woof_auto_show') 1295 .height('auto'); 1296 } 1297 ); 1298 1299 return false; 1300 });
1301} 1302 1303//for woof_auto_show closing on blank place click 1304document.addEventListener('click', function (e) { 1305 let opened = document.querySelectorAll('.woof_auto_show'); 1306 let target = e.target; 1307 let close = !target.classList.contains('woof_sid'); 1308 if (close) { 1309 close = !target.closest('.woof_sid'); 1310 } 1311 1312 //this close btn self 1313 if (target.classList.contains('woof_show_auto_form')) { 1314 return true; 1315 } 1316 1317 if (close && Array.from(opened).length > 0) { 1318 Array.from(opened).forEach(function (item) { 1319 if (item.parentNode.querySelector('.woof_hide_auto_form')) { 1320 item.parentNode.querySelector('.woof_hide_auto_form').click(); 1321 } 1322 }); 1323 } 1324 1325 return true; 1326}); 1327 1328function woof_init_hide_auto_form() { 1329 jQuery('.woof_hide_auto_form').off('click'); 1330 jQuery('.woof_hide_auto_form').on('click', function () { 1331 var _this = this; 1332 jQuery(_this) 1333 .addClass('woof_show_auto_form') 1334 .removeClass('woof_hide_auto_form'); 1335 jQuery(_this) 1336 .parent() 1337 .find('.woof_auto_show') 1338 .show() 1339 .animate( 1340 { 1341 height: '1px', 1342 opacity: 0, 1343 }, 1344 377, 1345 function () { 1346 jQuery(_this) 1347 .parent() 1348 .find('.woof_auto_show') 1349 .addClass('woof_overflow_hidden'); 1350 jQuery(_this) 1351 .parent() 1352 .find('.woof_auto_show_indent') 1353 .addClass('woof_overflow_hidden'); 1354 woof_init_show_auto_form(); 1355 } 1356 ); 1357 1358 return false; 1359 }); 1360} 1361 1362//if we have mode - child checkboxes closed - append openers buttons by js 1363function woof_checkboxes_slide() { 1364 if (woof_checkboxes_slide_flag) { 1365 var childs = jQuery('ul.woof_childs_list'); 1366 if (childs.length) { 1367 jQuery.each(childs, function (index, ul) { 1368 if (jQuery(ul).parents('.woof_no_close_childs').length) { 1369 return; 1370 } 1371 if (jQuery(ul).find('input').length == 0) { 1372 return; 1373 } 1374 1375 var span_class = 'woof_is_closed'; 1376 if (woof_supports_html5_storage()) { 1377 //test mode from 06.11.2017 1378 var preulstate = localStorage.getItem( 1379 jQuery(ul).closest('li').attr('class') 1380 ); 1381 if (preulstate && preulstate == 'woof_is_opened') { 1382 var span_class = 'woof_is_opened'; 1383 jQuery(ul).show(); 1384 } 1385 jQuery(ul) 1386 .parent('li') 1387 .children('label') 1388 .after( 1389 '<a href="javascript:void(0);" rel="nofollow" class="woof_childs_list_opener" title="' + 1390 woof_lang.list_opener + 1391 '" ><span class="' + 1392 span_class + 1393 '"></span></a>' 1394 ); 1395 //++ 1396 } else { 1397 if ( 1398 jQuery(ul) 1399 .find('input[type=checkbox],input[type=radio]') 1400 .is(':checked') 1401 ) { 1402 jQuery(ul).show(); 1403 span_class = 'woof_is_opened'; 1404 } 1405 jQuery(ul) 1406 .parent('li') 1407 .children('label') 1408 .after( 1409 '<a href="javascript:void(0);" rel="nofollow" class="woof_childs_list_opener" title="' + 1410 woof_lang.list_opener + 1411 '" ><span class="' + 1412 span_class + 1413 '"></span></a>' 1414 ); 1415 } 1416 }); 1417 1418 jQuery.each( 1419 jQuery('a.woof_childs_list_opener span'), 1420 function (index, a) { 1421 jQuery(a).on('click', function () { 1422 var span = jQuery(this); 1423 var this_ = jQuery(this).parent( 1424 '.woof_childs_list_opener' 1425 ); 1426 if (span.hasClass('woof_is_closed')) { 1427 //lets open 1428 jQuery(this_) 1429 .parent() 1430 .find('ul.woof_childs_list') 1431 .first() 1432 .show(333); 1433 span.removeClass('woof_is_closed'); 1434 span.addClass('woof_is_opened'); 1435 } else { 1436 //lets close 1437 jQuery(this_) 1438 .parent() 1439 .find('ul.woof_childs_list') 1440 .first() 1441 .hide(333); 1442 span.removeClass('woof_is_opened'); 1443 span.addClass('woof_is_closed'); 1444 } 1445 1446 if (woof_supports_html5_storage()) { 1447 //test mode from 06.11.2017 1448 var ullabel = jQuery(this_) 1449 .closest('li') 1450 .attr('class'); 1451 var ullstate = jQuery(this_) 1452 .children('span') 1453 .attr('class'); 1454 localStorage.setItem(ullabel, ullstate); 1455 } 1456 return false; 1457 }); 1458 } 1459 ); 1460 } 1461 } 1462} 1463 1464function woof_init_ion_sliders() { 1465 jQuery.each(jQuery('.woof_range_slider'), function (index, input) { 1466 try { 1467 jQuery(input).ionRangeSlider({ 1468 min: jQuery(input).data('min'), 1469 max: jQuery(input).data('max'), 1470 from: jQuery(input).data('min-now'), 1471 to: jQuery(input).data('max-now'), 1472 type: 'double', 1473 prefix: jQuery(input).data('slider-prefix'), 1474 postfix: jQuery(input).data('slider-postfix'), 1475 prettify: true, 1476 prettify_separator: jQuery(input).data('thousand-separator'), 1477 prettify_enabled: true, 1478 hideMinMax: false, 1479 hideFromTo: false, 1480 grid: true, 1481 step: jQuery(input).data('step'), 1482 onFinish: function (ui) { 1483 var tax = jQuery(input).data('taxes'); 1484 1485 woof_current_values.min_price = 1486 parseFloat(ui.from, 10) / tax; 1487 woof_current_values.max_price = parseFloat(ui.to, 10) / tax; 1488 //woocs adaptation 1489 if (typeof woocs_current_currency !== 'undefined') { 1490 woof_current_values.min_price = 1491 woof_current_values.min_price / 1492 parseFloat(woocs_current_currency.rate); 1493 woof_current_values.max_price = 1494 woof_current_values.max_price / 1495 parseFloat(woocs_current_currency.rate); 1496 } 1497 //*** 1498 woof_ajax_page_num = 1; 1499 if ( 1500 woof_autosubmit || 1501 jQuery(input).within('.woof').length == 0 1502 ) { 1503 woof_submit_link(woof_get_submit_link()); 1504 } 1505 return false; 1506 }, 1507 onChange: function (data) { 1508 if (jQuery('.woof_price_filter_txt')) { 1509 var tax = jQuery(input).data('taxes'); 1510 1511 jQuery('.woof_price_filter_txt_from').val( 1512 parseInt(data.from, 10) / tax 1513 ); 1514 jQuery('.woof_price_filter_txt_to').val( 1515 parseInt(data.to, 10) / tax 1516 ); 1517 //woocs adaptation 1518 if (typeof woocs_current_currency !== 'undefined') { 1519 jQuery('.woof_price_filter_txt_from').val( 1520 Math.ceil( 1521 jQuery( 1522 '.woof_price_filter_txt_from' 1523 ).val() / 1524 parseFloat(woocs_current_currency.rate) 1525 ) 1526 ); 1527 jQuery('.woof_price_filter_txt_to').val( 1528 Math.ceil( 1529 jQuery('.woof_price_filter_txt_to').val() / 1530 parseFloat(woocs_current_currency.rate) 1531 ) 1532 ); 1533 } 1534 } 1535 }, 1536 }); 1537 } catch (e) { 1538 } 1539 });
1540} 1541 1542function woof_init_native_woo_price_filter() { 1543 jQuery('.widget_price_filter form').off('submit'); 1544 jQuery('.widget_price_filter form').on('submit', function () { 1545 var min_price = jQuery(this) 1546 .find('.price_slider_amount #min_price') 1547 .val(); 1548 var max_price = jQuery(this) 1549 .find('.price_slider_amount #max_price') 1550 .val(); 1551 woof_current_values.min_price = min_price; 1552 woof_current_values.max_price = max_price; 1553 woof_ajax_page_num = 1; 1554 // if (woof_autosubmit) { 1555 //comment next code row to avoid endless ajax requests 1556 woof_submit_link(woof_get_submit_link()); 1557 // } 1558 return false; 1559 }); 1560} 1561 1562//we need after ajax redrawing of the search form 1563function woof_reinit_native_woo_price_filter() { 1564 // woocommerce_price_slider_params is required to continue, ensure the object exists 1565 if (typeof woocommerce_price_slider_params === 'undefined') { 1566 return false; 1567 } 1568 1569 // Get markup ready for slider 1570 jQuery('input#min_price, input#max_price').hide(); 1571 jQuery('.price_slider, .price_label').show(); 1572 1573 // Price slider uses jquery ui 1574 var min_price = jQuery('.price_slider_amount #min_price').data('min'), 1575 max_price = jQuery('.price_slider_amount #max_price').data('max'), 1576 current_min_price = parseInt(min_price, 10), 1577 current_max_price = parseInt(max_price, 10); 1578 1579 if (woof_current_values.hasOwnProperty('min_price')) { 1580 current_min_price = parseInt(woof_current_values.min_price, 10); 1581 current_max_price = parseInt(woof_current_values.max_price, 10); 1582 } else { 1583 if (woocommerce_price_slider_params.min_price) { 1584 current_min_price = parseInt( 1585 woocommerce_price_slider_params.min_price, 1586 10 1587 ); 1588 } 1589 if (woocommerce_price_slider_params.max_price) { 1590 current_max_price = parseInt( 1591 woocommerce_price_slider_params.max_price, 1592 10 1593 ); 1594 } 1595 } 1596 1597 //*** 1598 1599 var currency_symbol = woocommerce_price_slider_params.currency_symbol; 1600 if (typeof currency_symbol == 'undefined') { 1601 currency_symbol = 1602 woocommerce_price_slider_params.currency_format_symbol; 1603 } 1604 1605 jQuery(document.body).on( 1606 'price_slider_create price_slider_slide', 1607 function (event, min, max) { 1608 if (typeof woocs_current_currency !== 'undefined') { 1609 var label_min = min; 1610 var label_max = max; 1611 if (typeof currency_symbol == 'undefined') { 1612 currency_symbol = woocs_current_currency.symbol; 1613 } 1614 1615 if (woocs_current_currency.rate !== 1) { 1616 label_min = Math.ceil( 1617 label_min * parseFloat(woocs_current_currency.rate) 1618 ); 1619 label_max = Math.ceil( 1620 label_max * parseFloat(woocs_current_currency.rate) 1621 ); 1622 } 1623 1624 //+++ 1625 label_min = woof_front_number_format(label_min, 2, '.', ','); 1626 label_max = woof_front_number_format(label_max, 2, '.', ','); 1627 if ( 1628 jQuery.inArray( 1629 woocs_current_currency.name, 1630 woocs_array_no_cents 1631 ) || 1632 woocs_current_currency.hide_cents == 1 1633 ) { 1634 label_min = label_min.replace('.00', ''); 1635 label_max = label_max.replace('.00', ''); 1636 } 1637 //+++ 1638 1639 if (woocs_current_currency.position === 'left') { 1640 jQuery('.price_slider_amount span.from').html( 1641 currency_symbol + label_min 1642 ); 1643 jQuery('.price_slider_amount span.to').html( 1644 currency_symbol + label_max 1645 ); 1646 } else if (woocs_current_currency.position === 'left_space') { 1647 jQuery('.price_slider_amount span.from').html( 1648 currency_symbol + ' ' + label_min 1649 ); 1650 jQuery('.price_slider_amount span.to').html( 1651 currency_symbol + ' ' + label_max 1652 ); 1653 } else if (woocs_current_currency.position === 'right') { 1654 jQuery('.price_slider_amount span.from').html( 1655 label_min + currency_symbol 1656 ); 1657 jQuery('.price_slider_amount span.to').html( 1658 label_max + currency_symbol 1659 ); 1660 } else if (woocs_current_currency.position === 'right_space') { 1661 jQuery('.price_slider_amount span.from').html( 1662 label_min + ' ' + currency_symbol 1663 ); 1664 jQuery('.price_slider_amount span.to').html( 1665 label_max + ' ' + currency_symbol 1666 ); 1667 } 1668 } else { 1669 if (woocommerce_price_slider_params.currency_pos === 'left') { 1670 jQuery('.price_slider_amount span.from').html( 1671 currency_symbol + min 1672 ); 1673 jQuery('.price_slider_amount span.to').html( 1674 currency_symbol + max 1675 ); 1676 } else if ( 1677 woocommerce_price_slider_params.currency_pos === 1678 'left_space' 1679 ) { 1680 jQuery('.price_slider_amount span.from').html( 1681 currency_symbol + ' ' + min 1682 ); 1683 jQuery('.price_slider_amount span.to').html( 1684 currency_symbol + ' ' + max 1685 ); 1686 } else if ( 1687 woocommerce_price_slider_params.currency_pos === 'right' 1688 ) { 1689 jQuery('.price_slider_amount span.from').html( 1690 min + currency_symbol 1691 ); 1692 jQuery('.price_slider_amount span.to').html( 1693 max + currency_symbol 1694 ); 1695 } else if ( 1696 woocommerce_price_slider_params.currency_pos === 1697 'right_space' 1698 ) { 1699 jQuery('.price_slider_amount span.from').html( 1700 min + ' ' + currency_symbol 1701 ); 1702 jQuery('.price_slider_amount span.to').html( 1703 max + ' ' + currency_symbol 1704 ); 1705 } 1706 } 1707 1708 jQuery(document.body).trigger('price_slider_updated', [min, max]); 1709 } 1710 ); 1711 1712 jQuery('.price_slider').slider({ 1713 range: true, 1714 animate: true, 1715 min: min_price, 1716 max: max_price, 1717 values: [current_min_price, current_max_price], 1718 create: function () { 1719 jQuery('.price_slider_amount #min_price').val(current_min_price); 1720 jQuery('.price_slider_amount #max_price').val(current_max_price); 1721 1722 jQuery(document.body).trigger('price_slider_create', [ 1723 current_min_price, 1724 current_max_price, 1725 ]); 1726 }, 1727 slide: function (event, ui) { 1728 jQuery('input#min_price').val(ui.values[0]); 1729 jQuery('input#max_price').val(ui.values[1]); 1730 1731 jQuery(document.body).trigger('price_slider_slide', [ 1732 ui.values[0], 1733 ui.values[1], 1734 ]); 1735 }, 1736 change: function (event, ui) { 1737 jQuery(document.body).trigger('price_slider_change', [ 1738 ui.values[0], 1739 ui.values[1], 1740 ]); 1741 }, 1742 });
1743 1744 //*** 1745 woof_init_native_woo_price_filter(); 1746} 1747 1748function woof_mass_reinit() { 1749 woof_remove_empty_elements(); 1750 woof_open_hidden_li(); 1751 woof_init_search_form(); 1752 woof_hide_info_popup(); 1753 woof_init_beauty_scroll(); 1754 woof_init_ion_sliders(); 1755 woof_reinit_native_woo_price_filter(); //native woo price range slider reinit 1756 woof_recount_text_price_filter(); 1757 woof_draw_products_top_panel(); 1758 woof_unblur_filter(); 1759} 1760function woof_unblur_filter() { 1761 jQuery('.woof_redraw_zone.woof_blur_redraw_zone').removeClass( 1762 'woof_blur_redraw_zone' 1763 ); 1764} 1765 1766function woof_recount_text_price_filter() { 1767 //change value in textinput price filter if WOOCS is installed 1768 if (typeof woocs_current_currency !== 'undefined') { 1769 jQuery.each( 1770 jQuery('.woof_price_filter_txt_from, .woof_price_filter_txt_to'), 1771 function (i, item) { 1772 jQuery(this).val(Math.ceil(jQuery(this).data('value'))); 1773 } 1774 ); 1775 } 1776} 1777 1778function woof_init_toggles() { 1779 jQuery('body').off('click', '.woof_front_toggle'); 1780 jQuery('body').on('click', '.woof_front_toggle', function () { 1781 if (jQuery(this).data('condition') == 'opened') { 1782 jQuery(this).removeClass('woof_front_toggle_opened'); 1783 jQuery(this).addClass('woof_front_toggle_closed'); 1784 jQuery(this).data('condition', 'closed'); 1785 1786 if (woof_toggle_type == 'text') { 1787 jQuery(this).text(woof_toggle_closed_text); 1788 } else { 1789 jQuery(this).find('img').prop('src', woof_toggle_closed_image); 1790 } 1791 } else { 1792 jQuery(this).addClass('woof_front_toggle_opened'); 1793 jQuery(this).removeClass('woof_front_toggle_closed'); 1794 jQuery(this).data('condition', 'opened'); 1795 if (woof_toggle_type == 'text') { 1796 jQuery(this).text(woof_toggle_opened_text); 1797 } else { 1798 jQuery(this).find('img').prop('src', woof_toggle_opened_image); 1799 } 1800 } 1801 1802 jQuery(this) 1803 .parents('.woof_container_inner') 1804 .find('.woof_block_html_items') 1805 .slideToggle(500); 1806 1807 /* fix for chosen*/ 1808 var is_chosen_here = jQuery(this) 1809 .parents('.woof_container_inner') 1810 .find('.chosen-container'); 1811 if ( 1812 is_chosen_here.length && 1813 jQuery(this).hasClass('woof_front_toggle_opened') 1814 ) { 1815 jQuery(this) 1816 .parents('.woof_container_inner') 1817 .find('select') 1818 .chosen('destroy') 1819 .trigger('liszt:updated'); 1820 jQuery(this) 1821 .parents('.woof_container_inner') 1822 .find('select') 1823 .chosen(/*{disable_search_threshold: 10}*/); 1824 } 1825 if (jQuery(this).hasClass('woof_front_toggle_opened')) { 1826 woof_reinit_selects(); 1827 } 1828 1829 return false; 1830 }); 1831} 1832 1833//for "Show more" blocks 1834function woof_open_hidden_li() { 1835 if (jQuery('.woof_open_hidden_li_btn').length > 0) { 1836 jQuery.each(jQuery('.woof_open_hidden_li_btn'), function (i, b) { 1837 if ( 1838 jQuery(b) 1839 .parents('ul') 1840 .find( 1841 'li.woof_hidden_term input[type=checkbox],li.woof_hidden_term input[type=radio]' 1842 ) 1843 .is(':checked') 1844 ) { 1845 jQuery(b).trigger('click'); 1846 } 1847 }); 1848 } 1849} 1850 1851//http://stackoverflow.com/questions/814613/how-to-read-get-data-from-a-url-using-javascript 1852function $_woof_GET(q, s) { 1853 s = s ? s : window.location.search; 1854 var re = new RegExp('&' + q + '=([^&]*)', 'i'); 1855 return (s = s.replace(/^\?/, '&').match(re)) ? (s = s[1]) : (s = ''); 1856} 1857 1858function woof_parse_url(url) { 1859 var pattern = RegExp( 1860 '^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?' 1861 ); 1862 var matches = url.match(pattern); 1863 return { 1864 scheme: matches[2], 1865 authority: matches[4], 1866 path: matches[5], 1867 query: matches[7], 1868 fragment: matches[9], 1869 }; 1870} 1871 1872// woof price radio; 1873function woof_price_filter_radio_init() { 1874 if (icheck_skin != 'none') { 1875 jQuery('.woof_price_filter_radio').iCheck('destroy'); 1876 1877 let icheck_selector = '.woof_price_filter_radio'; 1878 let skin = jQuery(icheck_selector) 1879 .parents('.woof_redraw_zone') 1880 .eq(0) 1881 .data('icheck-skin'); 1882 if (skin) { 1883 skin = skin.split('_'); 1884 jQuery(icheck_selector).iCheck({ 1885 radioClass: 'iradio_' + skin[0] + '-' + skin[1], 1886 }); 1887 } else { 1888 jQuery(icheck_selector).iCheck({ 1889 radioClass:
1890 'iradio_' + icheck_skin.skin + '-' + icheck_skin.color, 1891 }); 1892 } 1893 1894 //*** 1895 1896 jQuery('.woof_price_filter_radio') 1897 .siblings('div') 1898 .removeClass('checked'); 1899 1900 jQuery('.woof_price_filter_radio').off('ifChecked'); 1901 jQuery('.woof_price_filter_radio').on('ifChecked', function (event) { 1902 jQuery(this).attr('checked', true); 1903 jQuery('.woof_radio_price_reset').removeClass( 1904 'woof_radio_term_reset_visible' 1905 ); 1906 jQuery(this) 1907 .parents('.woof_list') 1908 .find('.woof_radio_price_reset') 1909 .removeClass('woof_radio_term_reset_visible'); 1910 jQuery(this) 1911 .parents('.woof_list') 1912 .find('.woof_radio_price_reset') 1913 .hide(); 1914 jQuery(this) 1915 .parents('li') 1916 .eq(0) 1917 .find('.woof_radio_price_reset') 1918 .eq(0) 1919 .addClass('woof_radio_term_reset_visible'); 1920 var val = jQuery(this).val(); 1921 if (parseInt(val, 10) == -1) { 1922 delete woof_current_values.min_price; 1923 delete woof_current_values.max_price; 1924 jQuery(this).removeAttr('checked'); 1925 jQuery(this) 1926 .siblings('.woof_radio_price_reset') 1927 .removeClass('woof_radio_term_reset_visible'); 1928 } else { 1929 var val = val.split('-'); 1930 woof_current_values.min_price = val[0]; 1931 woof_current_values.max_price = val[1]; 1932 jQuery(this) 1933 .siblings('.woof_radio_price_reset') 1934 .addClass('woof_radio_term_reset_visible'); 1935 jQuery(this).attr('checked', true); 1936 } 1937 if (woof_autosubmit || jQuery(this).within('.woof').length == 0) { 1938 woof_submit_link(woof_get_submit_link()); 1939 } 1940 }); 1941 } else { 1942 jQuery('body').on('change', '.woof_price_filter_radio', function () { 1943 var val = jQuery(this).val(); 1944 jQuery('.woof_radio_price_reset').removeClass( 1945 'woof_radio_term_reset_visible' 1946 ); 1947 if (parseInt(val, 10) == -1) { 1948 delete woof_current_values.min_price; 1949 delete woof_current_values.max_price; 1950 jQuery(this).removeAttr('checked'); 1951 jQuery(this) 1952 .siblings('.woof_radio_price_reset') 1953 .removeClass('woof_radio_term_reset_visible'); 1954 } else { 1955 var val = val.split('-'); 1956 woof_current_values.min_price = val[0]; 1957 woof_current_values.max_price = val[1]; 1958 jQuery(this) 1959 .siblings('.woof_radio_price_reset') 1960 .addClass('woof_radio_term_reset_visible'); 1961 jQuery(this).attr('checked', true); 1962 } 1963 if (woof_autosubmit || jQuery(this).within('.woof').length == 0) { 1964 woof_submit_link(woof_get_submit_link()); 1965 } 1966 }); 1967 } 1968 //*** 1969 jQuery('.woof_radio_price_reset').on('click', function () { 1970 delete woof_current_values.min_price; 1971 delete woof_current_values.max_price; 1972 jQuery(this).siblings('div').removeClass('checked'); 1973 jQuery(this) 1974 .parents('.woof_list') 1975 .find('input[type=radio]') 1976 .removeAttr('checked'); 1977 1978 jQuery(this).removeClass('woof_radio_term_reset_visible'); 1979 if (woof_autosubmit) { 1980 woof_submit_link(woof_get_submit_link()); 1981 } 1982 return false; 1983 }); 1984} 1985// END woof price radio; 1986 1987function woof_serialize(serializedString) { 1988 var str = decodeURI(serializedString); 1989 var pairs = str.split('&'); 1990 var obj = {}, 1991 p, 1992 idx, 1993 val; 1994 for (var i = 0, n = pairs.length; i < n; i++) { 1995 p = pairs[i].split('='); 1996 idx = p[0]; 1997 1998 if (idx.indexOf('[]') == idx.length - 2) { 1999 // Eh um vetor 2000 var ind = idx.substring(0, idx.length - 2); 2001 if (obj[ind] === undefined) { 2002 obj[ind] = []; 2003 } 2004 obj[ind].push(p[1]); 2005 } else { 2006 obj[idx] = p[1]; 2007 } 2008 } 2009 return obj;
2010} 2011 2012//compatibility with YITH Infinite Scrolling 2013function woof_infinite() { 2014 if (typeof yith_infs_premium !== 'undefined' && yith_infs_premium.options) { 2015 woof_change_ajax_next_link(); 2016 return false; 2017 } 2018 2019 if (typeof yith_infs === 'undefined') { 2020 return; 2021 } 2022 2023 //*** 2024 var infinite_scroll1 = { 2025 //'nextSelector': ".woof_infinity .nav-links .next", 2026 nextSelector: '.woocommerce-pagination li .next', 2027 navSelector: yith_infs.navSelector, 2028 itemSelector: yith_infs.itemSelector, 2029 contentSelector: yith_infs.contentSelector, 2030 loader: '<img src="' + yith_infs.loader + '">', 2031 is_shop: yith_infs.shop, 2032 }; 2033 woof_change_ajax_next_link(); 2034 jQuery(window).off('yith_infs_start'), 2035 jQuery(yith_infs.contentSelector).yit_infinitescroll(infinite_scroll1); 2036} 2037 2038function woof_change_ajax_next_link() { 2039 if (!jQuery('.woocommerce-pagination li .next').length) { 2040 return false; 2041 } 2042 var curr_l = window.location.href; 2043 var curr_link = curr_l.split('?'); 2044 var get = ''; 2045 if (curr_link[1] != undefined) { 2046 var temp = woof_serialize(curr_link[1]); 2047 delete temp['paged']; 2048 get = decodeURIComponent(jQuery.param(temp)); 2049 } 2050 2051 var page_link = jQuery('.woocommerce-pagination li .next').attr('href'); 2052 2053 if (page_link == undefined) { 2054 page_link = curr_link + 'page/1/'; 2055 } 2056 2057 var ajax_link = page_link.split('?'); 2058 var page = ''; 2059 if (ajax_link[1] != undefined) { 2060 var temp1 = woof_serialize(ajax_link[1]); 2061 if (temp1['paged'] != undefined) { 2062 page = '/page/' + temp1['paged'] + '/'; 2063 } 2064 } 2065 2066 page_link = curr_link[0].replace(/\/$/, '') + page + '?' + get; 2067 2068 jQuery('.woocommerce-pagination li .next').attr('href', page_link); 2069} 2070//End infinity scroll 2071 2072//fix if woof - is ajax and cart - is redirect 2073function woof_change_link_addtocart() { 2074 if (!woof_is_ajax) { 2075 return; 2076 } 2077 jQuery('.add_to_cart_button').each(function (i, elem) { 2078 var link = jQuery(elem).attr('href'); 2079 if (link) { 2080 var link_items = link.split('?'); 2081 var site_link_items = window.location.href.split('?'); 2082 if (link_items[1] != undefined) {
2083 link = site_link_items[0] + '?' + link_items[1]; 2084 jQuery(elem).attr('href', link); 2085 } 2086 } 2087 }); 2088} 2089//https://github.com/kvz/phpjs/blob/master/functions/strings/number_format.js 2090function woof_front_number_format(number, decimals, dec_point, thousands_sep) { 2091 number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); 2092 var n = !isFinite(+number) ? 0 : +number, 2093 prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), 2094 sep = typeof thousands_sep === 'undefined' ? ',' : thousands_sep, 2095 dec = typeof dec_point === 'undefined' ? '.' : dec_point, 2096 s = '', 2097 toFixedFix = function (n, prec) { 2098 var k = Math.pow(10, prec); 2099 return '' + (Math.round(n * k) / k).toFixed(prec); 2100 }; 2101 // Fix for IE parseFloat(0.55).toFixed(0) = 0; 2102 s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); 2103 if (s[0].length > 3) { 2104 s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); 2105 } 2106 if ((s[1] || '').length < prec) { 2107 s[1] = s[1] || ''; 2108 s[1] += new Array(prec - s[1].length + 1).join('0'); 2109 } 2110 return s.join(dec); 2111} 2112 2113//additional function to check local storage 2114function woof_supports_html5_storage() { 2115 if (typeof woof_save_state_checkbox !== 'undefined' && woof_save_state_checkbox === 0) { 2116 return false; 2117 } 2118 try { 2119 return 'localStorage' in window && window['localStorage'] !== null; 2120 } catch (e) { 2121 return false; 2122 } 2123} 2124 2125function woof_init_tooltip() { 2126 var tooltips = jQuery('.woof_tooltip_header'); 2127 2128 if (tooltips.length) { 2129 jQuery(tooltips).tooltipster({ 2130 theme: 'tooltipster-noir', 2131 side: 'right', 2132 trigger: 'click', 2133 }); 2134 } 2135} 2136function woof_before_ajax_form_redrawing() { 2137 if (woof_select_type == 'selectwoo') { 2138 try { 2139 jQuery('select.woof_mselect').selectWoo('destroy'); 2140 jQuery('select.woof_meta_mselect').selectWoo('destroy'); 2141 } catch (e) { 2142 return false; 2143 } 2144 } 2145} 2146function woof_reinit_selects() { 2147 if (woof_select_type == 'chosen') { 2148 try { 2149 jQuery('select.woof_select, select.woof_mselect') 2150 .chosen('destroy') 2151 .trigger('liszt:updated'); 2152 jQuery( 2153 'select.woof_select, select.woof_mselect' 2154 ).chosen(/*{disable_search_threshold: 10}*/); 2155 jQuery('select.woof_meta_select, select.woof_meta_mselect') 2156 .chosen('destroy') 2157 .trigger('liszt:updated'); 2158 jQuery( 2159 'select.woof_meta_select, select.woof_meta_mselect' 2160 ).chosen(/*{disable_search_threshold: 10}*/); 2161 } catch (e) { 2162 } 2163 } else if (woof_select_type == 'selectwoo') { 2164 try { 2165 jQuery('select.woof_select, select.woof_mselect').selectWoo( 2166 'destroy' 2167 ); 2168 jQuery('select.woof_select, select.woof_mselect').selectWoo(); 2169 jQuery( 2170 'select.woof_meta_select, select.woof_meta_mselect' 2171 ).selectWoo('destroy'); 2172 jQuery( 2173 'select.woof_meta_select, select.woof_meta_mselect' 2174 ).selectWoo(); 2175 } catch (e) { 2176 } 2177 } 2178} 2179function woof_init_mobile_filter() { 2180 var show_btn = jQuery('.woof_show_mobile_filter'); 2181 var show_btn_container = jQuery('.woof_show_mobile_filter_container'); 2182 var def_container = jQuery(woof_m_b_container); 2183 if (!show_btn_container.length) { 2184 show_btn_container = def_container; 2185 } 2186 if (show_btn && show_btn_container) { 2187 jQuery(show_btn_container).append(show_btn); 2188 } 2189 2190 jQuery('.woof_show_mobile_filter').on('click', function (e) { 2191 var sid = jQuery(this).data('sid'); 2192 2193 if (jQuery('.woof.woof_sid_front_builder').length > 0) { 2194 //front builder adaptation 2195 sid = 'front_builder'; 2196 jQuery('.woof.woof_sid_' + sid).toggleClass( 2197 'woof_show_filter_for_mobile' 2198 ); 2199 } else { 2200 jQuery('.woof.woof_sid_' + sid).toggleClass( 2201 'woof_show_filter_for_mobile' 2202 ); 2203 } 2204 2205 setTimeout(function () { 2206 try { 2207 jQuery('.woof.woof_sid_' + sid) 2208 .find('select.woof_mselect') 2209 .chosen('destroy'); 2210 jQuery('.woof.woof_sid_' + sid) 2211 .find('select.woof_select') 2212 .chosen('destroy'); 2213 jQuery('.woof.woof_sid_' + sid) 2214 .find('select.woof_mselect') 2215 .chosen(); 2216 jQuery('.woof.woof_sid_' + sid) 2217 .find('select.woof_select') 2218 .chosen(); 2219 } catch (e) { 2220 //*** 2221 } 2222 }, 300); 2223 });
2224 2225 jQuery('.woof_hide_mobile_filter').on('click', function (e) { 2226 jQuery(this) 2227 .parents('.woof') 2228 .toggleClass('woof_show_filter_for_mobile'); 2229 }); 2230}
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.