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