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