PageSourceSearch

https://newportcanna.com/wp-content/plugins/leafbridge/public/js/leafbridge-public.js?ver=2026.10.06.06.31.50

js newportcanna.com collected 2026-10-06 06:56:46 UTC 29,185 bytes, 787 lines download raw bytes

1"use strict";
2// on history back , reload the page
3(function ($) {
4  /**
5   * All of the code for your public-facing JavaScript source
6   * should reside in this file.
7   *
8   * Note: It has been assumed you will write jQuery code here, so the
9   * $ function reference has been prepared for usage within the scope
10   * of this function.
11   *
12   * This enables you to define handlers, for when the DOM is ready:
13   *
14   * $(function() {
15   *
16   * });
17   *
18   * When the window is loaded:
19   *
20   * $( window ).load(function() {
21   *
22   * });
23   *
24   * ...and/or other possibilities.
25   *
26   * Ideally, it is not considered best practise to attach more than a
27   * single DOM-ready or window-load handler for a particular page.
28   * Although scripts in the WordPress core, Plugins and Themes may be
29   * practising this, we should strive to set a better example in our own work.
30   */
31
32  // this is for showing selected categories on product view - old version
33  $(document).on("click",".leafbridge_category_filter_list_items",
34    function (event) {
35      event.preventDefault();
36      var selected_filter = $(this).attr("data_category");
37      var selected_categories = [];
38      // $(this).closest('ul').find('.selected_cat').removeClass('selected_cat');
39      if (!$(this).hasClass("selected_cat")) {
40        $(this).addClass("selected_cat");
41      } else {
42        $(this).removeClass("selected_cat");
43      }
44
45      // go through all filter clickables and collect selected categories
46      $(
47        ".leafbridge_category_filter_list .leafbridge_category_filter_list_items"
48      ).each(function (index, el) {
49        if ($(this).hasClass("selected_cat")) {
50          selected_categories.push($(this).attr("data_category"));
51        }
52      });
53
54      if (selected_categories.length > 0) {
55        $(".leafbridge_prod_section_wrapper .leafbridge_product_section").each(
56          function (index, el) {
57            if (selected_categories.includes($(this).attr("data_category"))) {
58              $(this).fadeIn("250");
59            } else {
60              $(this).hide();
61            }
62          }
63        );
64      } else {
65        $(
66          ".leafbridge_prod_section_wrapper .leafbridge_product_section"
67        ).fadeIn("250");
68      }
69    }
70  );
71
72  // search bar Enter key
73  $("#products_search_input").keyup(function (event) {
74    if ($("#products_search_input").is(":focus") && event.key == "Enter") {
75      event.preventDefault();
76      $("#products_search_button").click();
77    }
78  });
79
80  // closing product modals
81  $(document).on("click",".leafbridge_product_modal_outer_bg , .leafbridge_product_modal_close",function (event) {
82      // $(this).closest('.leafbridge_product_modal_outer').hide();
83      $("#popup_container").html("");
84      $("#popup_container").removeClass("open_popup");
85    }
86  );
87
88  // This is for the wizard for customers selecting thier retailer and goes to viewing products
89
90  // enable age confirmation buttons after agreeing terms and conditions
91  $(document).on("click", "#LeafBridgeTandC", function (event) {
92    // event.preventDefault();
93    $(this).closest(".leafbridge_wizard_popup").find(".leafbridge_popup_box_grouped_inputs").toggleClass("disabled-btn-panel");
94    if (this.checked) {
95      $(".leafbridge_popup_box_grouped_inputs.wizard_box_button_group button").prop("disabled", false).removeClass("disabled-btn");
96    } else {
97      $(".leafbridge_popup_box_grouped_inputs.wizard_box_button_group button").prop("disabled", true).addClass("disabled-btn");
98    }
99  });
100
101  // age confirmation
102  $(document).on("click","#leafbridge_shop_wizard_popup .wizard_age",function () {
103      var cust_age = $(this).val();
104      if (cust_age == "yes") {
105        $(
106          "#leafbridge_shop_wizard_set_age .wizard_box_container_wrapper .error"
107        ).hide();
108        // $('#leafbridge_shop_wizard_popup').remove();
109        var leafbridge_wizard_data = JSON.parse(
110          localStorage.getItem("leafbridge_wizard_data")
111        );
112
113        if (leafbridge_wizard_data == null) {
114          // wizard will have this condition only default retailers are not set
115          var leafbridge_wizard_data = {
116            age_confirm: true,
117            created_time: new Date(),
118          };
119          var data_direction = $(this).attr("data_direction"); // works only when default retailers are not set
120          $(this).closest(".leafbridge_shop_wizard_step").hide();
121          $(data_direction).fadeIn("250");
122        } else {
123          leafbridge_wizard_data.age_confirm = true;
124          leafbridge_wizard_data.created_time = new Date();
125          $("#leafbridge_shop_wizard_popup").hide();
126        }
127        localStorage.setItem(
128          "leafbridge_wizard_data",
129          JSON.stringify(leafbridge_wizard_data)
130        );
131      } else if (cust_age == "no") {
132        $(
133          "#leafbridge_shop_wizard_set_age .wizard_box_container_wrapper .error"
134        ).fadeIn();
135      }
136    }
137  );
138
139  // go back and next buttons
140  $(document).on("click",".wizard_box_nav_buttons .wizard_box_button_group button",function () {
141      var data_direction = $(this).attr("data_direction");
142      if (data_direction) {
143        $(this).closest(".leafbridge_shop_wizard_step").hide();
144        $(data_direction).fadeIn("250");
145
146        if ($(this).attr("id") == "wizard_show_products") {
147          $("#leafbridge_shop_wizard_popup").hide();
148        }
149      }
150    }
151  );
152
153  // select menu type
154  $(document).on("click", ".wizardbox_tab_head", function () {
155    var target_content = $(this).attr("data_tab");
156    $(target_content).siblings(".wizardbox_tab_content").hide();
157    $(".active_btn").removeClass("active_btn");
158    $(target_content).fadeIn("250");
159    $(this).addClass("active_btn");
160  });
161
162  // select retailer
163  /*
164      * Since selecting whether delivery or store pickup is based on selection of the
165        retailer, it will require an ajax function. so this function is on leafbridge-public-ajax.js file
166      */
167
168  // show zipcode validation when delivery is selected
169  $(document).on("click", ".prod_collection_btn", function (event) {
170    event.preventDefault();
171    $(".error_zip_validation").hide();
172
173    $(this).siblings(".leaf_bridge_btn").removeClass("active_btn");
174    $(this).addClass("active_btn");
175
176    // if ($(this).val() == 'DELIVERY') {
177    // 	$('.wizardbox_zipcode_validation_wrapper').addClass('show_zipcode_validation');
178    // 	$(this).closest('.leafbridge_shop_wizard_step').find('button.next').hide();
179    // }
180    // else if ($(this).val() == 'PICKUP') {
181    // 	$('.wizardbox_zipcode_validation_wrapper').removeClass('show_zipcode_validation');
182    // 	$(this).closest('.leafbridge_shop_wizard_step').find('button.next').fadeIn('250');
183    // }
184    // else {
185    //
186    // }
187
188    // remove this when delivery zip is being validated
189    $(this)
190      .closest(".leafbridge_shop_wizard_step")
191      .find("button.next")
192      .fadeIn("250");
193
194    var leafbridge_wizard_data = JSON.parse(
195      localStorage.getItem("leafbridge_wizard_data")
196    );
197    leafbridge_wizard_data.collection_method = $(this).val();
198    localStorage.setItem(
199      "leafbridge_wizard_data",
200      JSON.stringify(leafbridge_wizard_data)
201    );
202  });
203
204  //  check availability is on ajax file
205
206  /*
207   * Reset reatiler , menu type and delivery selection
208   */
209  $(document).on("click", ".reset_retailer_selection", function () {
210    var close_button =
211      '<div class="leafbridge_wizard_popup_close"><svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg" class="close-button__StyledSvg-sc-1rp6nt-0 duhkda"><circle cx="18" cy="18" r="17.5" stroke="#1f2b49"></circle><path d="M22.8536 13.8539C23.0496 13.6578 23.0487 13.3407 22.8515 13.1456C22.6542 12.9506 22.3354 12.9516 22.1394 13.1477L13.1464 22.1461C12.9504 22.3422 12.9513 22.6593 13.1485 22.8544C13.3458 23.0494 13.6646 23.0484 13.8606 22.8523L22.8536 13.8539Z" fill="#1f2b49"></path><path d="M13.1464 13.8539C12.9504 13.6578 12.9513 13.3407 13.1485 13.1456C13.3458 12.9506 13.6646 12.9516 13.8606 13.1477L22.8536 22.1461C23.0496 22.3422 23.0487 22.6593 22.8515 22.8544C22.6542 23.0494 22.3354 23.0484 22.1394 22.8523L13.1464 13.8539Z" fill="#1f2b49"></path></svg></div>';
212
213    $("#leafbridge_shop_wizard_popup").fadeIn("250");
214    $("#leafbridge_shop_wizard_popup")
215      .siblings(".leafbridge_shop_wizard_step")
216      .hide();
217    $("#leafbridge_shop_wizard_popup .leafbridge_popup_box").fadeIn("250");
218    $("#leafbridge_shop_wizard_set_age").hide();
219    $("#leafbridge_shop_wizard_reset_selection_confirm").fadeIn("250");
220    $(
221      '#leafbridge_shop_wizard_reset_selection_confirm button[data_direction="#leafbridge_shop_wizard_set_age"]'
222    ).hide();
223    $("#leafbridge_shop_wizard_set_location	").hide();
224    if (
225      !$(
226        "#leafbridge_shop_wizard_popup .leafbridge_shop_wizard_container"
227      ).hasClass("leafbridge_wizard_popup_close")
228    ) {
229      // $('#leafbridge_shop_wizard_popup .leafbridge_shop_wizard_container').append(close_button);
230    }
231  });
232
233  // wizardpopup close
234  $(document).on("click", ".leafbridge_wizard_popup_close", function () {
235    $("#leafbridge_shop_wizard_popup").hide();
236  });
237
238  // disallow userss not to add more than available products
239  $(document).on("input change keydown keypress keyup",".add_to_cart_count",function (event) {
240      var input_val = parseInt($(this).val());
241      var max_val = parseInt($(this).attr("max"));
242      if (input_val > max_val) {
243        $(this).val(max_val);
244      } else {
245        $(this).val(input_val);
246      }
247    }
248  );
249
250  // open the cart button
251  // this function has been moved to ajax js
252
253  // close the cart button
254  $(document).on( "click", "#close_floating_cart , .floating_cart_bg",function () {
255      $("#floating_cart").removeClass("open_the_cart");
256  });
257
258  // toggle category menu on mobile devices
259  $(document).on("click",".class_toggle_category , #specials_tab_filter_background", function () {
260      $(".wizard_prods_categories").toggleClass("open_cats");
261      $("#specials_tab_filter_background").toggleClass("open_cats");
262      $(".specials_tab_filter").toggleClass("open_cats");
263  });
264
265  // open more data boxes on single product page
266  $(document).on("click", ".tab_toggler", function () {
267    $(this).closest(".lb_prod_single_tabs_inner").find(".lb_prod_single_tab_content").removeClass("active_tab");
268    var target_tab = $(this).attr("data_toggle");
269    $(target_tab).addClass("active_tab");
270    $(this).siblings(".tab_toggler").removeClass("active_tab");
271    $(this).addClass("active_tab");
272  });
273
274  $(document).on("click", ".info_icon", function (event) {
275    $(".sub_info_box_inner_collapse").removeClass("show_info");
276    $(this).closest(".sub_info_box").find(".sub_info_box_inner_collapse").addClass("show_info");
277    $(this).closest(".lb_prod_single_accordion_content").toggleClass("overflow_nope");
278  });
279  $(document).on("click", ".close_info", function (event) {
280    $(this).closest(".sub_info_box").find(".sub_info_box_inner_collapse").removeClass("show_info");
281  });
282
283  $(document).on("click", ".lb_categories_list p", function () {
284    $(this).closest(".lb_categories_list").toggleClass("expand_list");
285  });
286
287  $(document).on("change",".prods_filter_metric_selector_wrapper select",function (event) {
288      var selected_metric = $(this).val();
289      var target_metric = $(this)
290        .closest(".lb_prod_filter_attr_box")
291        .find(
292          '.lb_prod_filter_attr_range[metric_ref="' + selected_metric + '"]'
293        );
294      target_metric.siblings(".lb_prod_filter_attr_range").hide();
295      target_metric.css("display", "inline-flex");
296    }
297  );
298
299  $(document).on("click",".wizard_prods_inner .wizard_prods_categories .lb_prod_filter_attr_title",function () {
300      $(this).closest(".lb_prod_filter_attr_box").toggleClass("open_attr_box");
301    }
302  );
303
304  // highlihght empty dropdown on floating wizard`
305  $(document).on("click", "#header_stiky_wizard select", function () {
306    check_empty_wizard_dropdowns_and_hightlight();
307  });
308  function check_empty_wizard_dropdowns_and_hightlight() {
309    $("#header_stiky_wizard select").each(function (index, el) {
310      if ($(this).val() == "") {
311        $(this).addClass("empty");
312      } else {
313        $(this).removeClass("empty");
314      }
315    });
316  }
317
318  /*
319   * list grid view toggle
320   */
321  $(document).on("click", ".wizard_toggle_list_grid button", function () {
322    var view_type = $(this).val();
323    set_products_view_type(view_type);
324    localStorage.setItem("view_mode", view_type);
325  });
326
327  function set_products_view_type(view_type) {
328    $(".wizard_toggle_list_grid button[value=" + view_type + "]").siblings("button").removeClass("selected_view");
329    $(".wizard_toggle_list_grid button[value=" + view_type + "]").addClass("selected_view");
330
331    if (view_type == "list") {
332      $(".wizard_category_products_showcase").addClass("list");
333      $(".wizard_category_products_showcase").removeClass("grid");
334    } else if (view_type == "grid") {
335      $(".wizard_category_products_showcase").addClass("grid");
336      $(".wizard_category_products_showcase").removeClass("list");
337    }
338  }
339
340  // age popup on ticking t&c checkbox
341  $(document).on("change", ".age-popup-box #age-popup-tnc", function () {
342    if ($(this).is(":checked")) {
343      $(".age-popup-btn").removeAttr("disabled");
344    } else {
345      $(".age-popup-btn").attr("disabled", "disabled");
346    }
347  });
348
349  // age popup YES and NO Buttons
350  $(document).on("click", ".age-popup-box .age-popup-btn", function () {
351    var selected_age_option = $(this).val();
352    if (selected_age_option == "yes") {
353      var leafbridge_wizard_data = JSON.parse(
354        localStorage.getItem("leafbridge_wizard_data")
355      );
356      if (leafbridge_wizard_data == null) {
357        var leafbridge_wizard_data = {
358          age_confirm: true,
359          created_time: new Date(),
360        };
361      } else {
362        leafbridge_wizard_data.age_confirm = true;
363        leafbridge_wizard_data.created_time = new Date();
364      }
365      localStorage.setItem(
366        "leafbridge_wizard_data",
367        JSON.stringify(leafbridge_wizard_data)
368      );
369      $("#age-popup-box-overlay").hide();
370    } else if (selected_age_option == "no") {
371      $(".age-popup-warning").fadeIn();
372    }
373  });
374
375  // Position floating cart buttons
376  function position_floating_cart_modal_wizard() {
377    var floating_wizard_button = $("#floating_wizard_button");
378    var inject_location = floating_wizard_button.attr("data_inject_location");
379
380    if (inject_location) {
381      floating_wizard_button.remove();
382      var floating_wizard_button_html ='<div id="floating_wizard_button" class="injected">' +floating_wizard_button.html() +"</div>";
383      $(inject_location).append(floating_wizard_button_html);
384    }
385  }
386
387  function change_page_titles() {
388    $("h1:contains('Pre_rolls')").each(function () {
389      $(this).html(function (i, text) {
390        return text.replace("Pre_rolls", "Pre Rolls");
391      });
392    });
393    $("h2:contains('Pre_rolls')").each(function () {
394      $(this).html(function (i, text) {
395        return text.replace("Pre_rolls", "Pre Rolls");
396      });
397    });
398    $("h3:contains('Pre_rolls')").each(function () {
399      $(this).html(function (i, text) {
400        return text.replace("Pre_rolls", "Pre Rolls");
401      });
402    });
403    $("h4:contains('Pre_rolls')").each(function () {
404      $(this).html(function (i, text) {
405        return text.replace("Pre_rolls", "Pre Rolls");
406      });
407    });
408    $("h5:contains('Pre_rolls')").each(function () {
409      $(this).html(function (i, text) {
410        return text.replace("Pre_rolls", "Pre Rolls");
411      });
412    });
413    $("h6:contains('Pre_rolls')").each(function () {
414      $(this).html(function (i, text) {
415        return text.replace("Pre_rolls", "Pre Rolls");
416      });
417    });
418    $("p:contains('Pre_rolls')").each(function () {
419      $(this).html(function (i, text) {
420        return text.replace("Pre_rolls", "Pre Rolls");
421      });
422    });
423    $("div:contains('pre_rolls')").each(function () {
424      $(this).html(function (i, text) {
425        return text.replace("Pre_rolls", "Pre Rolls");
426      });
427    });
428    $("span:contains('Pre_rolls')").each(function () {
429      $(this).html(function (i, text) {
430        return text.replace("Pre_rolls", "Pre Rolls");
431      });
432    });
433    $("a:contains('Pre_rolls')").each(function () {
434      $(this).html(function (i, text) {
435        return text.replace("Pre_rolls", "Pre Rolls");
436      });
437    });
438  }
439
440  // add to cart warning icon
441  $(document).on("click", ".add_to_cart_warning", function (e) {
442    $(this).toggleClass("open_warning");
443  });
444
445  //popup close on 'Escape' key
446  $(document).keyup(function (event) {
447    if (event.key == "Escape") {
448      if ($("#popup_container").hasClass("open_popup")) {
449        event.preventDefault();
450        $(".leafbridge_product_modal_close").click();
451      }
452    }
453  });
454
455  // on click specials filter
456  $(document).on("click", ".specials_filter_attr_box ul li", function () {
457    var found_results = 0;
458
459    if ($(this).hasClass("selected")) {
460      $(this).removeClass("selected");
461    } else {
462      $(this).closest("ul").find("li").removeClass("selected");
463      $(this).addClass("selected");
464    }
465
466    var selection_array = {};
467    $(
468      ".specials_tab_filter .specials_tab_filter_inner .specials_filter_attr_box"
469    ).each(function (index, el) {
470      var this_attr_box = $(this);
471      var this_attr_name = $(this).find("ul").attr("filter_attr");
472      this_attr_box
473        .find("ul")
474        .find("li")
475        .each(function (index, el) {
476          if ($(this).hasClass("selected")) {
477            selection_array[this_attr_name] = $(this).attr("attr_value");
478          }
479        });
480    });
481
482    if (Object.keys(selection_array).length > 0) {
483      // $('.specials_tab_content_inner .leafbridge_product_card').hide();
484      $(".specials_tab_content_inner .leafbridge_product_card").each(function (
485        index,
486        el
487      ) {
488        // inside each prod box
489        var this_prod_box = $(this);
490        var pbfd = JSON.parse($(this).attr("filter_data")); //prod_box_filter_data
491        var flag_show = false;
492
493        // loop through selection array
494        for (const selection_array_attr in selection_array) {
495          var selected_option = selection_array[selection_array_attr];
496          // loop through product box's filter data and check if each selection matches
497          var pbfd_selected_attr = pbfd[selection_array_attr];
498          if (pbfd_selected_attr != null) {
499            if (pbfd_selected_attr.includes(selected_option)) {
500              this_prod_box.show();
501              this_prod_box.addClass("show_box");
502              found_results++;
503            } else {
504              this_prod_box.hide();
505              this_prod_box.removeClass("show_box");
506              break;
507            }
508          } else {
509            this_prod_box.hide();
510            break;
511          }
512        }
513      });
514    } else {
515      found_results++;
516      $(".specials_tab_content_inner .leafbridge_product_card").show();
517      $(".specials_tab_content_inner").css("display", "inline-grid");
518    }
519
520    if (
521      $(".specials_tab_content_inner .leafbridge_product_card.show_box")
522        .length == 0
523    ) {
524      if ($(".specials_tab_content_inner .filter_error").length == 0) {
525        $(".specials_tab_content_inner").append(
526          '<p class="filter_error">Sorry Could not find any matching products </p>'
527        );
528        $(".specials_tab_content_inner").css("display", "block");
529      }
530    } else {
531      $(".filter_error").remove();
532      $(".specials_tab_content_inner").css("display", "inline-grid");
533    }
534  });
535
536  // specials filter expand
537  $(document).on("click", ".specials_filter_attr_title", function (e) {
538    e.preventDefault();
539    $(this).closest(".specials_filter_attr_box").toggleClass("open_ul");
540  });
541
542  // searchbar shortcode functions
543  $(document).on("click", ".products_search_button_shortcode", function () {
544    var store_link = $(this).closest(".lb_search_products_input_wrapper_shortcode").attr("store_url");
545    var updated_url = store_link + "?products_search=" + $(this).siblings(".products_search_input_shortcode").val();
546    $(this).siblings(".products_search_input_shortcode").val() != "" ? (window.location.href = updated_url) : "";
547  });
548
549  $(document).on("click", ".products_clear_search_button_shortcode", function (e) {
550    e.preventDefault();
551    $(this).siblings("input.products_search_input_shortcode").val("");
552  });
553
554  // search bar Enter key
555  $(document).on("keyup", ".products_search_input_shortcode", function (event) {
556    if ($(this).is(":focus") && event.key == "Enter") {
557      event.preventDefault();
558      $(this).siblings(".products_search_button_shortcode").trigger("click");
559    }
560  });
561
562  // Product filter search bar Enter key
563  $(document).on("keyup", "#products_search_input", function (event) {
564    if ($(this).is(":focus") && event.key == "Enter") {
565      event.preventDefault();
566      $("#products_search_button").trigger("click");
567    }
568  });
569
570  // single product page "View Product Testing Data" accordion
571  $(document).on("click", ".lb_prod_single_accordion_title", function () {
572    $(this)
573      .closest(".lb_prod_single_accordion_wrapper")
574      .toggleClass("open_accordion");
575  });
576
577  $(window).on("load", function () {
578    /*
579     * Age Modal
580     */
581    var leafbridge_wizard_data = JSON.parse(
582      localStorage.getItem("leafbridge_wizard_data")
583    );
584    if (leafbridge_wizard_data != null) {
585      if (leafbridge_wizard_data.age_confirm == true) {
586        $("#age-popup-box-overlay").hide();
587      } else {
588        $("#age-popup-box").fadeIn();
589      }
590    } else {
591      $("#age-popup-box").fadeIn();
592    }
593    $(".age-popup-box .age-popup-btn").attr("disabled", "disabled");
594
595    /*
596     * Position floating cart buttons
597     */
598    position_floating_cart_modal_wizard();
599    /*
600     *  position sticky wizard
601     */
602    if ($("div").hasClass("header_stiky_wizard")) {
603      var wizard_shortcodes_arr = [];
604      var final_wizard_element = [];
605
606      // loop through all found wizard elements and store them in an array wizard_shortcodes_arr
607      $(".header_stiky_wizard").each(function (index, el) {
608        var parent_element = $(this).attr("parent_element");
609        var autoshow_wizard =
610          $(this).find(".header_stiky_wizard_inner").attr("autoshow_wizard") ==
611            "true"
612            ? true
613            : false;
614        var header_stiky_wizard = $(this).html();
615        var this_element = $(this);
616        var temp_arr = [];
617
618        temp_arr["element"] = this_element[0];
619        temp_arr["parent_element"] = parent_element;
620        temp_arr["autoshow_wizard"] = autoshow_wizard;
621
622        wizard_shortcodes_arr.push(temp_arr);
623      });
624
625      loop1: for (var i = 0; i < wizard_shortcodes_arr.length; i++) {
626        // loop through wizard_shortcodes_arr and find if there's any shortcode wizards.
627        var wizard_element_iteration = wizard_shortcodes_arr[i];
628        if (wizard_element_iteration["autoshow_wizard"]) {
629          // if there's wizard from link
630          var inject_location = wizard_element_iteration["parent_element"];
631          // before injecting, clear all wizard elements
632          $(".header_stiky_wizard").remove();
633
634          if (inject_location.length > 0) {
635            $(inject_location)
636              .first()
637              .append(wizard_element_iteration["element"]);
638          } else {
639            $("header").first().append(wizard_element_iteration["element"]);
640          }
641        } else {
642          // if there's wizard from shortcode,
643          // loop through the wizard shortcodes array again and remove all wizards made by link
644          for (var j = 0; j < wizard_shortcodes_arr.length; j++) {
645            var inner_wizard_element_iteration = wizard_shortcodes_arr[j];
646            if (inner_wizard_element_iteration["autoshow_wizard"]) {
647              inner_wizard_element_iteration["element"].remove();
648            }
649          }
650          break loop1;
651        }
652      }
653    }
654
655    var leafbridge_wizard_data = JSON.parse(
656      localStorage.getItem("leafbridge_wizard_data")
657    );
658    if (leafbridge_wizard_data) {
659      $("#leafbridge_shop_wizard_popup").fadeOut();
660    }
661
662    /*
663     *  when page is loaded check the localStorage and remove if they are over expiration time
664     */
665
666    // check wizard data and clear
667
668    // var current_time = new Date();
669    // if(localStorage.getItem('leafbridge_wizard_data')){
670    // 	var leafbridge_wizard_data = JSON.parse(localStorage.getItem('leafbridge_wizard_data'));
671    // 	var created_time = new Date(leafbridge_wizard_data.created_time);
672    // 	var lc_time_diff = ((current_time.getTime() - created_time.getTime()) / 1000) / 60 ;
673    //
674    // 	if(lc_time_diff>60){
675    // 		localStorage.removeItem('leafbridge_wizard_data');
676    // 		localStorage.removeItem('leafbridge_cart_data');
677    // 		$('#leafbridge_shop_wizard_popup .leafbridge_popup_box').fadeIn('250');
678    // 	}
679    //
680    // }
681    // else {
682    // 	$('#leafbridge_shop_wizard_popup .leafbridge_popup_box').fadeIn('250');
683    // }
684
685    // check age
686    var leafbridge_wizard_data = JSON.parse(
687      localStorage.getItem("leafbridge_wizard_data")
688    );
689    if (leafbridge_wizard_data) {
690      if (leafbridge_wizard_data.age_confirm) {
691        if (
692          !leafbridge_wizard_data.hasOwnProperty("retailer_id") ||
693          leafbridge_wizard_data.collection_method == "" ||
694          leafbridge_wizard_data.menu_type == ""
695        ) {
696          $("#leafbridge_shop_wizard_popup").fadeIn("250");
697          $("#leafbridge_shop_wizard_popup .leafbridge_popup_box").fadeIn(
698            "250"
699          );
700
701          $("#leafbridge_shop_wizard_set_age").hide();
702          $("#leafbridge_shop_wizard_set_location").fadeIn("250");
703        } else {
704          $("#leafbridge_shop_wizard_popup").hide();
705        }
706      } else {
707        $("#leafbridge_shop_wizard_popup").show();
708        $("#leafbridge_shop_wizard_popup .leafbridge_popup_box").fadeIn("250");
709      }
710    }
711
712    /*
713     * Set view grid / list view
714     */
715    if ($("div").hasClass("wizard_category_products_showcase")) {
716      var view_type = localStorage.getItem("view_mode");
717      view_type = view_type != null ? view_type : "grid";
718      set_products_view_type(view_type);
719    }
720
721    // js function if PHP WP hooks are not supporting any title change
722    change_page_titles();
723  });
724
725  // display brands
726  jQuery(document).ready(function ($) {
727    const retailerId = JSON.parse(localStorage.getItem('leafbridge_wizard_data'))?.retailer_id;
728
729    $(".brand-card").show();
730
731    if ($("#no-brands-found").length === 0) {
732        $("<div id='no-brands-found'>No brands found</div>").appendTo(".brand-search-container");
733    }
734
735    if (retailerId) {
736        $(".brand-card").each(function () {
737            const brandRetailerIds = $(this).data("retailer-ids").split(',');
738            if (!brandRetailerIds.includes(retailerId)) {
739                $(this).hide();
740            }
741        });
742        toggleNoBrandsFound();
743    }
744
745    $("#brand-search").on("input", function () {
746      const searchQuery = $(this).val().toLowerCase();
747        $(".brand-card").each(function () {
748            const title = $(this).data("title").toString().toLowerCase();
749            const brandRetailerIds = $(this).data("retailer-ids").split(',');
750            if (title.includes(searchQuery) && brandRetailerIds.includes(retailerId)) {
751                $(this).show();
752            } else {
753                $(this).hide();
754            }
755        });
756        toggleNoBrandsFound();
757    });
758
759    function toggleNoBrandsFound() {
760        if ($(".brand-card:visible").length === 0) {
761            $("#no-brands-found").show();
762        } else {
763            $("#no-brands-found").hide();
764        }
765    }
766
767
768  });
769
770  // hide subcategory filter if attribute is not available
771  jQuery(document).ready(function($) {
772    var $wizardWrapper = $('.leafbridge_shop_wizard_wrapper');
773    var subcategoryFromShortcode = $wizardWrapper.data('subcategory');
774    
775    if (!subcategoryFromShortcode) {
776        $(".lb_prod_filter_attr_box[filter_attr='subcategory']").addClass('hidden-filter');
777    }
778
779    var isCategoryPage = $('body').hasClass('archive');
780    if (isCategoryPage) {
781      $(".lb_prod_filter_attr_box[filter_attr='subcategory']").removeClass('hidden-filter');
782    }
783  });
784
785
786
787})(jQuery);

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.