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