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