1var woof_redirect = '';//if we use redirect attribute in shortcode [woof] 2//*** 3jQuery(function ($) { 4 jQuery('body').append('<div id="woof_html_buffer" class="woof_info_popup" style="display: none;"></div>'); 5 jQuery.fn.life = function (types, data, fn) { 6 jQuery(this.context).on(types, this.selector, data, fn); 7 return this; 8 }; 9 10 //http://stackoverflow.com/questions/2389540/jquery-hasparent 11 jQuery.extend(jQuery.fn, { 12 within: function (pSelector) { 13 // Returns a subset of items using jQuery.filter 14 return this.filter(function () { 15 // Return truthy/falsey based on presence in parent 16 return jQuery(this).closest(pSelector).length; 17 }); 18 } 19 }); 20 21 //+++ 22 23 if (jQuery('#woof_results_by_ajax').length > 0) { 24 woof_is_ajax = 1; 25 } 26 27 //listening attributes in shortcode [woof] 28 woof_autosubmit = parseInt(jQuery('.woof').eq(0).data('autosubmit'), 10); 29 woof_ajax_redraw = parseInt(jQuery('.woof').eq(0).data('ajax-redraw'), 10); 30 31 32 33 //+++ 34 35 woof_ext_init_functions = jQuery.parseJSON(woof_ext_init_functions); 36 37 //fix for native woo price range 38 woof_init_native_woo_price_filter(); 39 40 41 jQuery('body').bind('price_slider_change', function (event, min, max) { 42 if (woof_autosubmit && !woof_show_price_search_button && jQuery('.price_slider_wrapper').length < 2) { 43 jQuery('.woof .widget_price_filter form').trigger('submit'); 44 } else { 45 var min_price = jQuery(this).find('.price_slider_amount #min_price').val(); 46 var max_price = jQuery(this).find('.price_slider_amount #max_price').val(); 47 woof_current_values.min_price = min_price; 48 woof_current_values.max_price = max_price; 49 } 50 }); 51 52 jQuery('.woof_price_filter_dropdown').life('change', function () { 53 var val = jQuery(this).val(); 54 if (parseInt(val, 10) == -1) { 55 delete woof_current_values.min_price; 56 delete woof_current_values.max_price; 57 } else { 58 var val = val.split("-"); 59 woof_current_values.min_price = val[0]; 60 woof_current_values.max_price = val[1]; 61 } 62 63 if (woof_autosubmit || jQuery(this).within('.woof').length == 0) { 64 woof_submit_link(woof_get_submit_link()); 65 } 66 }); 67 68 69 70 //change value in textinput price filter if WOOCS is installed 71 woof_recount_text_price_filter(); 72 //+++ 73 jQuery('.woof_price_filter_txt').life('change', function () { 74 75 var from = parseInt(jQuery(this).parent().find('.woof_price_filter_txt_from').val(), 10); 76 var to = parseInt(jQuery(this).parent().find('.woof_price_filter_txt_to').val(), 10); 77 78 if (to < from || from === 0) { 79 delete woof_current_values.min_price; 80 delete woof_current_values.max_price; 81 } else { 82 if (typeof woocs_current_currency !== 'undefined') { 83 from = Math.ceil(from / parseFloat(woocs_current_currency.rate)); 84 to = Math.ceil(to / parseFloat(woocs_current_currency.rate)); 85 } 86 87 woof_current_values.min_price = from; 88 woof_current_values.max_price = to; 89 } 90 91 if (woof_autosubmit || jQuery(this).within('.woof').length == 0) { 92 woof_submit_link(woof_get_submit_link()); 93 } 94 }); 95 96 97 //*** 98 99 jQuery('.woof_open_hidden_li_btn').life('click', function () { 100 var state = jQuery(this).data('state'); 101 var type = jQuery(this).data('type'); 102 103 if (state == 'closed') { 104 jQuery(this).parents('.woof_list').find('.woof_hidden_term').addClass('woof_hidden_term2'); 105 jQuery(this).parents('.woof_list').find('.woof_hidden_term').removeClass('woof_hidden_term'); 106 if (type == 'image') { 107 jQuery(this).find('img').attr('src', jQuery(this).data('opened')); 108 } else { 109 jQuery(this).html(jQuery(this).data('opened')); 110 } 111 112 jQuery(this).data('state', 'opened'); 113 } else { 114 jQuery(this).parents('.woof_list').find('.woof_hidden_term2').addClass('woof_hidden_term'); 115 jQuery(this).parents('.woof_list').find('.woof_hidden_term2').removeClass('woof_hidden_term2'); 116 117 if (type == 'image') { 118 jQuery(this).find('img').attr('src', jQuery(this).data('closed')); 119 } else { 120 jQuery(this).text(jQuery(this).data('closed')); 121 } 122 123 jQuery(this).data('state', 'closed'); 124 } 125 126 127 return false;
128 }); 129 //open hidden block 130 woof_open_hidden_li(); 131 132 //*** woocommerce native "AVERAGE RATING" widget synchronizing 133 jQuery('.widget_rating_filter li.wc-layered-nav-rating a').click(function () { 134 var is_chosen = jQuery(this).parent().hasClass('chosen'); 135 var parsed_url = woof_parse_url(jQuery(this).attr('href')); 136 var rate = 0; 137 if (parsed_url.query !== undefined) { 138 if (parsed_url.query.indexOf('min_rating') !== -1) { 139 var arrayOfStrings = parsed_url.query.split('min_rating='); 140 rate = parseInt(arrayOfStrings[1], 10); 141 } 142 } 143 jQuery(this).parents('ul').find('li').removeClass('chosen'); 144 if (is_chosen) { 145 delete woof_current_values.min_rating; 146 } else { 147 woof_current_values.min_rating = rate; 148 jQuery(this).parent().addClass('chosen'); 149 } 150 151 woof_submit_link(woof_get_submit_link()); 152 153 return false; 154 }); 155 156 //WOOF start filtering button action 157 jQuery('.woof_start_filtering_btn').life('click', function () { 158 159 var shortcode = jQuery(this).parents('.woof.woof_sid').data('shortcode'); 160 jQuery(this).html(woof_lang_loading); 161 jQuery(this).addClass('woof_start_filtering_btn2'); 162 jQuery(this).removeClass('woof_start_filtering_btn'); 163 //redrawing [woof ajax_redraw=1] only 164 var data = { 165 action: "woof_draw_products", 166 page: 1, 167 shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only 168 woof_shortcode: shortcode 169 }; 170 jQuery.post(woof_ajaxurl, data, function (content) { 171 content = jQuery.parseJSON(content); 172 jQuery('div.woof_redraw_zone').replaceWith(jQuery(content.form).find('.woof_redraw_zone')); 173 woof_mass_reinit(); 174 }); 175 176 177 return false; 178 }); 179 180 //*** 181 window.onpopstate = function (event) { 182 try { 183 if (Object.keys(woof_current_values).length) { 184 woof_show_info_popup(woof_lang_loading); 185 window.location.reload(); 186 return false; 187 } 188 } catch (e) { 189 console.log(e); 190 } 191 192 }; 193 //*** 194 195 //ion-slider price range slider 196 woof_init_ion_sliders(); 197 198 //*** 199 200 woof_init_show_auto_form(); 201 woof_init_hide_auto_form(); 202 203 //*** 204 woof_remove_empty_elements(); 205 206 woof_init_search_form(); 207 woof_init_pagination(); 208 woof_init_orderby(); 209 woof_init_reset_button(); 210 woof_init_beauty_scroll(); 211 //+++ 212 woof_draw_products_top_panel(); 213 woof_shortcode_observer(); 214 215 216//+++ 217 //if we use redirect attribute in shortcode [woof is_ajax=0] 218 //not for ajax, for redirect mode only 219 if (!woof_is_ajax) { 220 woof_redirect_init(); 221 } 222 223 woof_init_toggles(); 224 225}); 226 227//if we use redirect attribute in shortcode [woof is_ajax=0] 228//not for ajax, for redirect mode only 229function woof_redirect_init() { 230 231 try { 232 if (jQuery('.woof').length) { 233 //https://wordpress.org/support/topic/javascript-error-in-frontjs?replies=1 234 if (undefined !== jQuery('.woof').val()) { 235 woof_redirect = jQuery('.woof').eq(0).data('redirect');//default value 236 if (woof_redirect.length > 0) { 237 woof_shop_page = woof_current_page_link = woof_redirect; 238 } 239 240 241 //*** 242 /* 243 var events = ['click', 'change', 'ifChecked', 'ifUnchecked']; 244 245 for (var i = 0; i < events.length; i++) { 246 247 jQuery('div.woof input, div.woof option, div.woof div, div.woof label').live(events[i], function (e) { 248 try { 249 if (jQuery(this).parents('.woof').data('redirect').length > 0) { 250 woof_redirect = jQuery(this).parents('.woof').data('redirect'); 251 } 252 } catch (e) { 253 console.log('Error: attribute redirection doesn works!'); 254 } 255 e.stopPropagation(); 256 }); 257 258 } 259 */ 260 //*** 261 262 263 return woof_redirect; 264 } 265 } 266 } catch (e) { 267 console.log(e); 268 } 269 270} 271 272function woof_init_orderby() { 273 jQuery('form.woocommerce-ordering').life('submit', function () { 274 return false;
275 }); 276 jQuery('form.woocommerce-ordering select.orderby').life('change', function () { 277 woof_current_values.orderby = jQuery(this).val(); 278 woof_ajax_page_num = 1; 279 woof_submit_link(woof_get_submit_link()); 280 return false; 281 }); 282} 283 284function woof_init_reset_button() { 285 jQuery('.woof_reset_search_form').life('click', function () { 286 //var link = jQuery(this).data('link'); 287 woof_ajax_page_num = 1; 288 if (woof_is_permalink) { 289 woof_current_values = {}; 290 woof_submit_link(woof_get_submit_link().split("page/")[0]); 291 //woof_submit_link(woof_get_submit_link()); 292 } else { 293 var link = woof_shop_page; 294 if (woof_current_values.hasOwnProperty('page_id')) { 295 link = location.protocol + '//' + location.host + "/?page_id=" + woof_current_values.page_id; 296 woof_current_values = {'page_id': woof_current_values.page_id}; 297 woof_get_submit_link(); 298 } 299 //*** 300 woof_submit_link(link); 301 if (woof_is_ajax) { 302 history.pushState({}, "", link); 303 if (woof_current_values.hasOwnProperty('page_id')) { 304 woof_current_values = {'page_id': woof_current_values.page_id}; 305 } else { 306 woof_current_values = {}; 307 } 308 } 309 } 310 return false; 311 }); 312} 313 314function woof_init_pagination() { 315 if (woof_is_ajax === 1) { 316 //jQuery('.woocommerce-pagination ul.page-numbers a.page-numbers').life('click', function () { 317 jQuery('a.page-numbers').life('click', function () { 318 var l = jQuery(this).attr('href'); 319 320 if (woof_ajax_first_done) { 321 //http://woocommerce-filter.pluginus.net/wp-admin/admin-ajax.php?paged=2 322 var res = l.split("paged="); 323 if (typeof res[1] !== 'undefined') { 324 woof_ajax_page_num = parseInt(res[1]); 325 } else { 326 woof_ajax_page_num = 1; 327 } 328 } else { 329 //http://woocommerce-filter.pluginus.net/tester/page/2/ 330 var res = l.split("page/"); 331 if (typeof res[1] !== 'undefined') { 332 woof_ajax_page_num = parseInt(res[1]); 333 } else { 334 woof_ajax_page_num = 1; 335 } 336 } 337 338 //+++ 339 340 //if (woof_autosubmit) - pagination doesn need pressing any submit button!! 341 { 342 woof_submit_link(woof_get_submit_link()); 343 } 344 345 return false; 346 }); 347 } 348} 349 350function woof_init_search_form() { 351 woof_init_checkboxes(); 352 woof_init_mselects(); 353 woof_init_radios(); 354 woof_init_selects(); 355 356 357 //for extensions 358 if (woof_ext_init_functions !== null) { 359 jQuery.each(woof_ext_init_functions, function (type, func) { 360 eval(func + '()'); 361 }); 362 } 363 //+++ 364 //var containers = jQuery('.woof_container'); 365 366 //+++ 367 jQuery('.woof_submit_search_form').click(function () { 368 if (woof_ajax_redraw) { 369 //[woof redirect="http://www.dev.woocommerce-filter.com/test-all/" autosubmit=1 ajax_redraw=1 is_ajax=1 tax_only="locations" by_only="none"] 370 woof_ajax_redraw = 0; 371 woof_is_ajax = 0; 372 } 373 //*** 374 woof_submit_link(woof_get_submit_link()); 375 return false; 376 }); 377 378 379 380 //*** 381 jQuery('ul.woof_childs_list').parent('li').addClass('woof_childs_list_li'); 382 383 //*** 384 385 woof_remove_class_widget(); 386 woof_checkboxes_slide(); 387} 388 389var woof_submit_link_locked = false; 390function woof_submit_link(link) { 391 392 if (woof_submit_link_locked) { 393 return; 394 } 395 396 woof_submit_link_locked = true; 397 398 woof_show_info_popup(woof_lang_loading); 399 if (woof_is_ajax === 1 && !woof_ajax_redraw) { 400 woof_ajax_first_done = true; 401 var data = { 402 action: "woof_draw_products", 403 link: link, 404 page: woof_ajax_page_num, 405 shortcode: jQuery('#woof_results_by_ajax').data('shortcode'), 406 woof_shortcode: jQuery('div.woof').data('shortcode') 407 }; 408 jQuery.post(woof_ajaxurl, data, function (content) { 409 content = jQuery.parseJSON(content); 410 if (jQuery('.woof_results_by_ajax_shortcode').length) { 411 jQuery('#woof_results_by_ajax').replaceWith(content.products); 412 } else { 413 jQuery('.woof_shortcode_output').replaceWith(content.products); 414 } 415 416 jQuery('div.woof_redraw_zone').replaceWith(jQuery(content.form).find('.woof_redraw_zone')); 417 woof_draw_products_top_panel(); 418 woof_mass_reinit(); 419 woof_submit_link_locked = false;
420 //removing id woof_results_by_ajax - multi in ajax mode sometimes 421 //when uses shorcode woof_products in ajax and in settings try ajaxify shop is Yes 422 jQuery.each(jQuery('#woof_results_by_ajax'), function (index, item) { 423 if (index == 0) { 424 return; 425 } 426 427 jQuery(item).removeAttr('id'); 428 }); 429 430 //*** script after ajax loading here 431 woof_js_after_ajax_done(); 432 }); 433 } else { 434 if (woof_ajax_redraw) { 435 //redrawing [woof ajax_redraw=1] only 436 var data = { 437 action: "woof_draw_products", 438 link: link, 439 page: 1, 440 shortcode: 'woof_nothing', //we do not need get any products, seacrh form data only 441 woof_shortcode: jQuery('div.woof').eq(0).data('shortcode') 442 }; 443 jQuery.post(woof_ajaxurl, data, function (content) { 444 content = jQuery.parseJSON(content); 445 jQuery('div.woof_redraw_zone').replaceWith(jQuery(content.form).find('.woof_redraw_zone')); 446 woof_mass_reinit(); 447 woof_submit_link_locked = false; 448 }); 449 } else { 450 window.location = link; 451 } 452 } 453} 454 455function woof_remove_empty_elements() { 456 // lets check for empty drop-downs 457 jQuery.each(jQuery('.woof_container select'), function (index, select) { 458 var size = jQuery(select).find('option').size(); 459 if (size === 0) { 460 jQuery(select).parents('.woof_container').remove(); 461 } 462 }); 463 //+++ 464 // lets check for empty checkboxes, radio, color conatiners 465 jQuery.each(jQuery('ul.woof_list'), function (index, ch) { 466 var size = jQuery(ch).find('li').size(); 467 if (size === 0) { 468 jQuery(ch).parents('.woof_container').remove(); 469 } 470 }); 471} 472 473function woof_get_submit_link() { 474//filter woof_current_values values 475 if (woof_is_ajax) { 476 woof_current_values.page = woof_ajax_page_num; 477 } 478//+++ 479 if (Object.keys(woof_current_values).length > 0) { 480 jQuery.each(woof_current_values, function (index, value) { 481 if (index == swoof_search_slug) { 482 delete woof_current_values[index]; 483 } 484 if (index == 's') { 485 delete woof_current_values[index]; 486 } 487 if (index == 'product') { 488//for single product page (when no permalinks) 489 delete woof_current_values[index]; 490 } 491 if (index == 'really_curr_tax') { 492 delete woof_current_values[index]; 493 } 494 }); 495 } 496 497 498 //*** 499 if (Object.keys(woof_current_values).length === 2) { 500 if (('min_price' in woof_current_values) && ('max_price' in woof_current_values)) { 501 var l = woof_current_page_link + '?min_price=' + woof_current_values.min_price + '&max_price=' + woof_current_values.max_price; 502 if (woof_is_ajax) { 503 history.pushState({}, "", l); 504 } 505 return l; 506 } 507 } 508 509 510 511 //*** 512 513 if (Object.keys(woof_current_values).length === 0) { 514 if (woof_is_ajax) { 515 history.pushState({}, "", woof_current_page_link); 516 } 517 return woof_current_page_link; 518 } 519 //+++ 520 if (Object.keys(woof_really_curr_tax).length > 0) { 521 woof_current_values['really_curr_tax'] = woof_really_curr_tax.term_id + '-' + woof_really_curr_tax.taxonomy; 522 } 523 //+++ 524 var link = woof_current_page_link + "?" + swoof_search_slug + "=1"; 525 //console.log(woof_current_page_link); 526 //just for the case when no permalinks enabled 527 if (!woof_is_permalink) { 528 529 if (woof_redirect.length > 0) { 530 link = woof_redirect + "?" + swoof_search_slug + "=1"; 531 if (woof_current_values.hasOwnProperty('page_id')) { 532 delete woof_current_values.page_id; 533 } 534 } else { 535 link = location.protocol + '//' + location.host + "?" + swoof_search_slug + "=1"; 536 /* 537 if (!woof_is_ajax) { 538 link = location.protocol + '//' + location.host + "?" + swoof_search_slug + "=1"; 539 } 540 541 if (woof_current_values.hasOwnProperty('page_id')) { 542 link = location.protocol + '//' + location.host + "?" + swoof_search_slug + "=1"; 543 } 544 */ 545 } 546 } 547 //console.log(link); 548 //throw('STOP!'); 549 550 //any trash for different sites, useful for quick support 551 var woof_exclude_accept_array = ['path']; 552 553 if (Object.keys(woof_current_values).length > 0) { 554 jQuery.each(woof_current_values, function (index, value) { 555 if (index == 'page' && woof_is_ajax) { 556 index = 'paged';//for right pagination if copy/paste this link and send somebody another by email for example 557 } 558 559 //http://www.dev.woocommerce-filter.com/?swoof=1&woof_author=3&woof_sku&woof_text=single 560 //avoid links where values is empty 561 if (typeof value !== 'undefined') { 562 if ((typeof value && value.length > 0) || typeof value == 'number') 563 { 564 if (jQuery.inArray(index, woof_exclude_accept_array) == -1) { 565 link = link + "&" + index + "=" + value; 566 } 567 } 568 } 569 570 }); 571 } 572 573 //+++ 574 //remove wp pagination like 'page/2' 575 link = link.replace(new RegExp(/page\/(\d+)\//), ""); 576 if (woof_is_ajax) { 577 history.pushState({}, "", link); 578 } 579 580 //throw ("STOP!"); 581 return link; 582} 583 584function woof_show_info_popup(text) { 585 if (woof_overlay_skin == 'default') { 586 jQuery("#woof_html_buffer").text(text); 587 jQuery("#woof_html_buffer").fadeTo(200, 0.9); 588 } else {
589 //http://jxnblk.com/loading/ 590 switch (woof_overlay_skin) { 591 case 'loading-balls': 592 case 'loading-bars': 593 case 'loading-bubbles': 594 case 'loading-cubes': 595 case 'loading-cylon': 596 case 'loading-spin': 597 case 'loading-spinning-bubbles': 598 case 'loading-spokes': 599 jQuery('body').plainOverlay('show', {progress: function () { 600 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>'); 601 }}); 602 break; 603 default: 604 jQuery('body').plainOverlay('show', {duration: -1}); 605 break; 606 } 607 } 608} 609 610 611function woof_hide_info_popup() { 612 if (woof_overlay_skin == 'default') { 613 window.setTimeout(function () { 614 jQuery("#woof_html_buffer").fadeOut(400); 615 }, 200); 616 } else { 617 jQuery('body').plainOverlay('hide'); 618 } 619} 620 621function woof_draw_products_top_panel() { 622 623 if (woof_is_ajax) { 624 jQuery('#woof_results_by_ajax').prev('.woof_products_top_panel').remove(); 625 } 626 627 var panel = jQuery('.woof_products_top_panel'); 628 629 panel.html(''); 630 if (Object.keys(woof_current_values).length > 0) { 631 panel.show(); 632 panel.html('<ul></ul>'); 633 var is_price_in = false; 634 //lets show this on the panel 635 jQuery.each(woof_current_values, function (index, value) { 636 637 //lets filter data for the panel 638 if (jQuery.inArray(index, woof_accept_array) == -1) { 639 return; 640 } 641 642 643 //*** 644 645 646 if ((index == 'min_price' || index == 'max_price') && is_price_in) { 647 return; 648 } 649 650 if ((index == 'min_price' || index == 'max_price') && !is_price_in) { 651 is_price_in = true; 652 index = 'price'; 653 value = woof_lang_pricerange; 654 } 655 //+++ 656 value = value.toString().trim(); 657 if (value.search(',')) { 658 value = value.split(','); 659 } 660 //+++ 661 jQuery.each(value, function (i, v) { 662 if (index == 'page') { 663 return; 664 } 665 666 if (index == 'post_type') { 667 return; 668 } 669 670 var txt = v; 671 if (index == 'orderby') { 672 if (woof_lang[v] !== undefined) { 673 txt = woof_lang.orderby + ': ' + woof_lang[v]; 674 } else { 675 txt = woof_lang.orderby + ': ' + v; 676 } 677 } else if (index == 'perpage') { 678 txt = woof_lang.perpage; 679 } else if (index == 'price') { 680 txt = woof_lang.pricerange; 681 } else { 682 683 var is_in_custom = false; 684 if (Object.keys(woof_lang_custom).length > 0) { 685 jQuery.each(woof_lang_custom, function (i, tt) { 686 if (i == index) { 687 is_in_custom = true; 688 txt = tt; 689 if (index == 'woof_sku') { 690 txt += " " + v;//because search by SKU can by more than 1 value 691 } 692 } 693 }); 694 } 695 696 if (!is_in_custom) { 697 try { 698 //txt = jQuery('.woof_n_' + index + '_' + v).val(); 699 txt = jQuery("input[data-anchor='woof_n_" + index + '_' + v + "']").val(); 700 } catch (e) { 701 console.log(e); 702 } 703 704 if (typeof txt === 'undefined') 705 { 706 txt = v; 707 } 708 } 709 710 711 /* hidden feature 712 if (jQuery('input[name=woof_t_' + index + ']').length > 0) { 713 txt = jQuery('input[name=woof_t_' + index + ']').val() + ': ' + txt; 714 } 715 */ 716 717 718 } 719 720 panel.find('ul').append( 721 jQuery('<li>').append( 722 jQuery('<a>').attr('href', v).attr('data-tax', index).append( 723 jQuery('<span>').attr('class', 'woof_remove_ppi').append(txt) 724 ))); 725 726 }); 727 728 729 }); 730 } 731 732 733 if (jQuery(panel).find('li').size() == 0 || !jQuery('.woof_products_top_panel').length) { 734 panel.hide(); 735 } 736 737 //+++ 738 jQuery('.woof_remove_ppi').parent().click(function () { 739 var tax = jQuery(this).data('tax'); 740 var name = jQuery(this).attr('href'); 741 742 //*** 743 744 if (tax != 'price') { 745 values = woof_current_values[tax]; 746 values = values.split(','); 747 var tmp = []; 748 jQuery.each(values, function (index, value) { 749 if (value != name) { 750 tmp.push(value); 751 } 752 }); 753 values = tmp; 754 if (values.length) { 755 woof_current_values[tax] = values.join(','); 756 } else { 757 delete woof_current_values[tax]; 758 } 759 } else { 760 delete woof_current_values['min_price']; 761 delete woof_current_values['max_price']; 762 } 763 764 woof_ajax_page_num = 1; 765 //if (woof_autosubmit) 766 { 767 woof_submit_link(woof_get_submit_link()); 768 } 769 jQuery('.woof_products_top_panel').find("[data-tax='" + tax + "'][href='" + name + "']").hide(333); 770 return false;
771 }); 772 773} 774 775//control conditions if proucts shortcode uses on the page 776function woof_shortcode_observer() { 777 if (jQuery('.woof_shortcode_output').length) { 778 woof_current_page_link = location.protocol + '//' + location.host + location.pathname; 779 } 780 781 if (jQuery('#woof_results_by_ajax').length) { 782 woof_is_ajax = 1; 783 } 784} 785 786 787 788function woof_init_beauty_scroll() { 789 if (woof_use_beauty_scroll) { 790 try { 791 var anchor = ".woof_section_scrolled, .woof_sid_auto_shortcode .woof_container_radio .woof_block_html_items, .woof_sid_auto_shortcode .woof_container_checkbox .woof_block_html_items, .woof_sid_auto_shortcode .woof_container_label .woof_block_html_items"; 792 jQuery("" + anchor).mCustomScrollbar('destroy'); 793 jQuery("" + anchor).mCustomScrollbar({ 794 scrollButtons: { 795 enable: true 796 }, 797 advanced: { 798 updateOnContentResize: true, 799 updateOnBrowserResize: true 800 }, 801 theme: "dark-2", 802 horizontalScroll: false, 803 mouseWheel: true, 804 scrollType: 'pixels', 805 contentTouchScroll: true 806 }); 807 } catch (e) { 808 console.log(e); 809 } 810 } 811} 812 813//just for inbuilt price range widget 814function woof_remove_class_widget() { 815 jQuery('.woof_container_inner').find('.widget').removeClass('widget'); 816} 817 818function woof_init_show_auto_form() { 819 jQuery('.woof_show_auto_form').unbind('click'); 820 jQuery('.woof_show_auto_form').click(function () { 821 var _this = this; 822 jQuery(_this).addClass('woof_hide_auto_form').removeClass('woof_show_auto_form'); 823 jQuery(".woof_auto_show").show().animate( 824 { 825 height: (jQuery(".woof_auto_show_indent").height() + 20) + "px", 826 opacity: 1 827 }, 377, function () { 828 //jQuery(_this).text(woof_lang_hide_products_filter); 829 woof_init_hide_auto_form(); 830 jQuery('.woof_auto_show').removeClass('woof_overflow_hidden'); 831 jQuery('.woof_auto_show_indent').removeClass('woof_overflow_hidden'); 832 jQuery(".woof_auto_show").height('auto'); 833 }); 834 835 836 return false; 837 }); 838 839 840} 841 842function woof_init_hide_auto_form() { 843 jQuery('.woof_hide_auto_form').unbind('click'); 844 jQuery('.woof_hide_auto_form').click(function () { 845 var _this = this; 846 jQuery(_this).addClass('woof_show_auto_form').removeClass('woof_hide_auto_form'); 847 jQuery(".woof_auto_show").show().animate( 848 { 849 height: "1px", 850 opacity: 0 851 }, 377, function () { 852 //jQuery(_this).text(woof_lang_show_products_filter); 853 jQuery('.woof_auto_show').addClass('woof_overflow_hidden'); 854 jQuery('.woof_auto_show_indent').addClass('woof_overflow_hidden'); 855 woof_init_show_auto_form(); 856 }); 857 858 return false; 859 }); 860 861 862} 863 864//if we have mode - child checkboxes closed - append openers buttons by js 865function woof_checkboxes_slide() { 866 if (woof_checkboxes_slide_flag == true) { 867 var childs = jQuery('ul.woof_childs_list'); 868 if (childs.size()) { 869 jQuery.each(childs, function (index, ul) { 870 871 if (jQuery(ul).parents('.woof_no_close_childs').length) { 872 return; 873 } 874 875 var span_class = 'woof_is_closed'; 876 if (jQuery(ul).find('input[type=checkbox],input[type=radio]').is(':checked')) { 877 jQuery(ul).show(); 878 span_class = 'woof_is_opened'; 879 } 880 881 jQuery(ul).before('<a href="javascript:void(0);" class="woof_childs_list_opener"><span class="' + span_class + '"></span></a>'); 882 }); 883 884 jQuery.each(jQuery('a.woof_childs_list_opener'), function (index, a) { 885 jQuery(a).click(function () { 886 var span = jQuery(this).find('span'); 887 if (span.hasClass('woof_is_closed')) { 888 //lets open 889 jQuery(this).parent().find('ul.woof_childs_list').first().show(333); 890 span.removeClass('woof_is_closed'); 891 span.addClass('woof_is_opened'); 892 } else { 893 //lets close 894 jQuery(this).parent().find('ul.woof_childs_list').first().hide(333); 895 span.removeClass('woof_is_opened'); 896 span.addClass('woof_is_closed'); 897 } 898 899 return false;
900 }); 901 }); 902 } 903 } 904} 905 906function woof_init_ion_sliders() { 907 jQuery.each(jQuery('.woof_range_slider'), function (index, input) { 908 try { 909 jQuery(input).ionRangeSlider({ 910 min: jQuery(input).data('min'), 911 max: jQuery(input).data('max'), 912 from: jQuery(input).data('min-now'), 913 to: jQuery(input).data('max-now'), 914 type: 'double', 915 prefix: jQuery(input).data('slider-prefix'), 916 postfix: jQuery(input).data('slider-postfix'), 917 prettify: true, 918 hideMinMax: false, 919 hideFromTo: false, 920 grid: true, 921 step: jQuery(input).data('step'), 922 onFinish: function (ui) { 923 woof_current_values.min_price = parseInt(ui.from, 10); 924 woof_current_values.max_price = parseInt(ui.to, 10); 925 //woocs adaptation 926 if (typeof woocs_current_currency !== 'undefined') { 927 woof_current_values.min_price = Math.ceil(woof_current_values.min_price / parseFloat(woocs_current_currency.rate)); 928 woof_current_values.max_price = Math.ceil(woof_current_values.max_price / parseFloat(woocs_current_currency.rate)); 929 } 930 //*** 931 woof_ajax_page_num = 1; 932 //jQuery(input).within('.woof').length -> if slider is as shortcode 933 if (woof_autosubmit || jQuery(input).within('.woof').length == 0) { 934 woof_submit_link(woof_get_submit_link()); 935 } 936 return false; 937 } 938 }); 939 } catch (e) { 940 941 } 942 }); 943} 944 945function woof_init_native_woo_price_filter() { 946 jQuery('.widget_price_filter form').unbind('submit'); 947 jQuery('.widget_price_filter form').submit(function () { 948 var min_price = jQuery(this).find('.price_slider_amount #min_price').val(); 949 var max_price = jQuery(this).find('.price_slider_amount #max_price').val(); 950 woof_current_values.min_price = min_price; 951 woof_current_values.max_price = max_price; 952 woof_ajax_page_num = 1; 953 if (woof_autosubmit || jQuery(input).within('.woof').length == 0) { 954 //comment next code row to avoid endless ajax requests 955 woof_submit_link(woof_get_submit_link()); 956 } 957 return false; 958 }); 959 960} 961 962//we need after ajax redrawing of the search form 963function woof_reinit_native_woo_price_filter() { 964 965 // woocommerce_price_slider_params is required to continue, ensure the object exists 966 if (typeof woocommerce_price_slider_params === 'undefined') { 967 return false; 968 } 969 970 // Get markup ready for slider 971 jQuery('input#min_price, input#max_price').hide(); 972 jQuery('.price_slider, .price_label').show(); 973 974 // Price slider uses jquery ui 975 var min_price = jQuery('.price_slider_amount #min_price').data('min'), 976 max_price = jQuery('.price_slider_amount #max_price').data('max'), 977 current_min_price = parseInt(min_price, 10), 978 current_max_price = parseInt(max_price, 10); 979 980 if (woof_current_values.hasOwnProperty('min_price')) { 981 current_min_price = parseInt(woof_current_values.min_price, 10); 982 current_max_price = parseInt(woof_current_values.max_price, 10); 983 } else { 984 if (woocommerce_price_slider_params.min_price) { 985 current_min_price = parseInt(woocommerce_price_slider_params.min_price, 10); 986 } 987 if (woocommerce_price_slider_params.max_price) { 988 current_max_price = parseInt(woocommerce_price_slider_params.max_price, 10); 989 } 990 } 991 992 //*** 993 994 jQuery(document.body).bind('price_slider_create price_slider_slide', function (event, min, max) { 995 996 if (typeof woocs_current_currency !== 'undefined') { 997 var label_min = min; 998 var label_max = max; 999 1000 if (woocs_current_currency.rate !== 1) { 1001 label_min = Math.ceil(label_min * parseFloat(woocs_current_currency.rate)); 1002 label_max = Math.ceil(label_max * parseFloat(woocs_current_currency.rate)); 1003 } 1004 1005 //+++ 1006 label_min = number_format(label_min, 2, '.', ','); 1007 label_max = number_format(label_max, 2, '.', ','); 1008 if (jQuery.inArray(woocs_current_currency.name, woocs_array_no_cents) || woocs_current_currency.hide_cents == 1) { 1009 label_min = label_min.replace('.00', ''); 1010 label_max = label_max.replace('.00', ''); 1011 } 1012 //+++ 1013 1014 if (woocs_current_currency.position === 'left') { 1015 1016 jQuery('.price_slider_amount span.from').html(woocommerce_price_slider_params.currency_symbol + label_min); 1017 jQuery('.price_slider_amount span.to').html(woocommerce_price_slider_params.currency_symbol + label_max); 1018 1019 } else if (woocs_current_currency.position === 'left_space') { 1020 1021 jQuery('.price_slider_amount span.from').html(woocommerce_price_slider_params.currency_symbol + " " + label_min); 1022 jQuery('.price_slider_amount span.to').html(woocommerce_price_slider_params.currency_symbol + " " + label_max); 1023 1024 } else if (woocs_current_currency.position === 'right') { 1025 1026 jQuery('.price_slider_amount span.from').html(label_min + woocommerce_price_slider_params.currency_symbol); 1027 jQuery('.price_slider_amount span.to').html(label_max + woocommerce_price_slider_params.currency_symbol); 1028 1029 } else if (woocs_current_currency.position === 'right_space') { 1030 1031 jQuery('.price_slider_amount span.from').html(label_min + " " + woocommerce_price_slider_params.currency_symbol); 1032 jQuery('.price_slider_amount span.to').html(label_max + " " + woocommerce_price_slider_params.currency_symbol); 1033 1034 } 1035 1036 } else { 1037 1038 if (woocommerce_price_slider_params.currency_pos === 'left') { 1039 1040 jQuery('.price_slider_amount span.from').html(woocommerce_price_slider_params.currency_symbol + min); 1041 jQuery('.price_slider_amount span.to').html(woocommerce_price_slider_params.currency_symbol + max); 1042 1043 } else if (woocommerce_price_slider_params.currency_pos === 'left_space') { 1044 1045 jQuery('.price_slider_amount span.from').html(woocommerce_price_slider_params.currency_symbol + ' ' + min); 1046 jQuery('.price_slider_amount span.to').html(woocommerce_price_slider_params.currency_symbol + ' ' + max); 1047 1048 } else if (woocommerce_price_slider_params.currency_pos === 'right') { 1049 1050 jQuery('.price_slider_amount span.from').html(min + woocommerce_price_slider_params.currency_symbol); 1051 jQuery('.price_slider_amount span.to').html(max + woocommerce_price_slider_params.currency_symbol); 1052 1053 } else if (woocommerce_price_slider_params.currency_pos === 'right_space') { 1054 1055 jQuery('.price_slider_amount span.from').html(min + ' ' + woocommerce_price_slider_params.currency_symbol); 1056 jQuery('.price_slider_amount span.to').html(max + ' ' + woocommerce_price_slider_params.currency_symbol); 1057 1058 } 1059 } 1060 1061 jQuery(document.body).trigger('price_slider_updated', [min, max]); 1062 }); 1063 1064 jQuery('.price_slider').slider({ 1065 range: true, 1066 animate: true, 1067 min: min_price, 1068 max: max_price, 1069 values: [current_min_price, current_max_price], 1070 create: function () { 1071 1072 jQuery('.price_slider_amount #min_price').val(current_min_price); 1073 jQuery('.price_slider_amount #max_price').val(current_max_price); 1074 1075 jQuery(document.body).trigger('price_slider_create', [current_min_price, current_max_price]); 1076 }, 1077 slide: function (event, ui) { 1078 1079 jQuery('input#min_price').val(ui.values[0]); 1080 jQuery('input#max_price').val(ui.values[1]); 1081 1082 jQuery(document.body).trigger('price_slider_slide', [ui.values[0], ui.values[1]]); 1083 }, 1084 change: function (event, ui) { 1085 jQuery(document.body).trigger('price_slider_change', [ui.values[0], ui.values[1]]); 1086 } 1087 }); 1088 1089 1090 //*** 1091 woof_init_native_woo_price_filter(); 1092} 1093 1094function woof_mass_reinit() { 1095 woof_remove_empty_elements(); 1096 woof_open_hidden_li(); 1097 woof_init_search_form(); 1098 woof_hide_info_popup(); 1099 woof_init_beauty_scroll(); 1100 woof_init_ion_sliders(); 1101 woof_reinit_native_woo_price_filter();//native woo price range slider reinit 1102 woof_recount_text_price_filter(); 1103 woof_draw_products_top_panel(); 1104} 1105 1106function woof_recount_text_price_filter() { 1107 //change value in textinput price filter if WOOCS is installed 1108 if (typeof woocs_current_currency !== 'undefined') { 1109 jQuery.each(jQuery('.woof_price_filter_txt_from, .woof_price_filter_txt_to'), function (i, item) { 1110 jQuery(this).val(Math.ceil(jQuery(this).data('value'))); 1111 }); 1112 } 1113} 1114 1115function woof_init_toggles() { 1116 jQuery('.woof_front_toggle').life('click', function () { 1117 if (jQuery(this).data('condition') == 'opened') { 1118 jQuery(this).removeClass('woof_front_toggle_opened'); 1119 jQuery(this).addClass('woof_front_toggle_closed'); 1120 jQuery(this).data('condition', 'closed'); 1121 if (woof_toggle_type == 'text') { 1122 jQuery(this).text(woof_toggle_closed_text); 1123 } else { 1124 jQuery(this).find('img').prop('src', woof_toggle_closed_image); 1125 } 1126 } else { 1127 jQuery(this).addClass('woof_front_toggle_opened'); 1128 jQuery(this).removeClass('woof_front_toggle_closed'); 1129 jQuery(this).data('condition', 'opened'); 1130 if (woof_toggle_type == 'text') { 1131 jQuery(this).text(woof_toggle_opened_text); 1132 } else { 1133 jQuery(this).find('img').prop('src', woof_toggle_opened_image); 1134 } 1135 } 1136 1137
1138 jQuery(this).parents('.woof_container_inner').find('.woof_block_html_items').toggle(500); 1139 return false; 1140 }); 1141} 1142 1143//for "Show more" blocks 1144function woof_open_hidden_li() { 1145 if (jQuery('.woof_open_hidden_li_btn').length > 0) { 1146 jQuery.each(jQuery('.woof_open_hidden_li_btn'), function (i, b) { 1147 if (jQuery(b).parents('ul').find('li.woof_hidden_term input[type=checkbox],li.woof_hidden_term input[type=radio]').is(':checked')) { 1148 jQuery(b).trigger('click'); 1149 } 1150 }); 1151 } 1152} 1153 1154//http://stackoverflow.com/questions/814613/how-to-read-get-data-from-a-url-using-javascript 1155function $_woof_GET(q, s) { 1156 s = (s) ? s : window.location.search; 1157 var re = new RegExp('&' + q + '=([^&]*)', 'i'); 1158 return (s = s.replace(/^\?/, '&').match(re)) ? s = s[1] : s = ''; 1159} 1160 1161function woof_parse_url(url) { 1162 var pattern = RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"); 1163 var matches = url.match(pattern); 1164 return { 1165 scheme: matches[2], 1166 authority: matches[4], 1167 path: matches[5], 1168 query: matches[7], 1169 fragment: matches[9] 1170 }; 1171} 1172 1173 1174
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.