1/** 2 * @file 3 * Global utilities. 4 * 5 */ 6 7(function ($, Drupal) { 8 "use strict"; 9 10 Drupal.behaviors.cocktail = { 11 attach: function (context, settings) { 12 $(context) 13 .find("#initCarouselVideo") 14 .click(function () { 15 let carousel = $(this).closest(".carousel"); 16 let videoPlayer = $(this) 17 .closest(".carousel-item") 18 .find(".heroVideoPlayer"); 19 let iframe = videoPlayer.find("iframe"); 20 let clicked = false; 21 22 if (videoPlayer.length && iframe.length) { 23 iframe.attr("src", videoPlayer.data("source")); 24 carousel.carousel("pause"); 25 videoPlayer.fadeIn(1500); 26 } 27 28 carousel.on("slide.bs.carousel", function () { 29 if (iframe.length && iframe.attr("src") && !clicked) return false; 30 31 clicked = false; 32 33 if (videoPlayer.length) { 34 videoPlayer.find("iframe").removeAttr("src"); 35 videoPlayer.fadeOut(1500); 36 carousel.carousel("cycle"); 37 } 38 }); 39 40 carousel.find(".carousel-indicators li").on("click", function () { 41 clicked = true; 42 }); 43 }); 44 45 $(once("carousel", ".multi-item-carousel .carousel-item")).each( 46 function () { 47 var next = $(this).next(); 48 49 if (!next.length) next = $(this).siblings(":first"); 50 51 next.children(":first-child").clone().appendTo($(this)); 52 jQuery(this).children(".col-6").removeAttr("style"); 53 } 54 ); 55 $(once("carousel", "#heroVideoCloseBtn", context)).click(function () { 56 let videoPlayer = $(this) 57 .closest(".carousel-item") 58 .find(".heroVideoPlayer"); 59 videoPlayer.find("iframe").removeAttr("src"); 60 videoPlayer.fadeOut(1500); 61 }); 62 63 // Gallery-img-carousel image height for controls btn 64 let imgHeight = 360; 65 setTimeout(function () { 66 imgHeight = $(context) 67 .find(".gallery-img-carousel .carousel-item img") 68 .height(); 69 $(context) 70 .find(".article-gallery-cta") 71 .css("top", "" + imgHeight + "px"); 72 }, 500); 73 74 //This funcation used to animate the grids 75 function animate() { 76 // Animation on scroll 77 var isMobile = 78 /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( 79 navigator.userAgent 80 ); 81 if (isMobile === false) { 82 $("[data-animation]").each(function () { 83 var $this = $(this); 84 $this.addClass("animation"); 85 86 if ( 87 !$("html").hasClass("no-csstransitions") && 88 $(window).width() > 767 89 ) { 90 $this.appear( 91 function () { 92 var delay = $this.attr("data-animation-delay") 93 ? $this.attr("data-animation-delay") 94 : 200; 95 96 if (delay > 1) $this.css("animation-delay", delay + "ms"); 97 $this.addClass($this.attr("data-animation")); 98 99 setTimeout(function () { 100 $this.addClass("animation-visible"); 101 }, delay); 102 }, 103 { accX: 0, accY: -100 } 104 ); 105 } else { 106 $this.addClass("animation-visible"); 107 } 108 }); 109 } else { 110 $("[data-animation]").each(function () { 111 var $this = $(this); 112 $this.addClass("animation-visible"); 113 }); 114 } 115 } 116 animate(); 117 let currentURL = window.location.href; 118 let urlArray = currentURL.split("/"); 119 if (urlArray["3"] == "user") { 120 $(document).ready(function () { 121 // Check if any element currently has focus 122 if (document.activeElement) { 123 // Do something, like get the ID of the focused element 124 var focusedElementId = document.activeElement.id; 125 } 126 $("#edit-name").blur(); 127 $("#dummy-link").focus(); 128 $("#dummy-link").remove(); 129 // Check which element has focus 130 var focusedElement = document.activeElement; 131 // Log the focused element to the console 132 }); 133 } else { 134 $("#dummy-link").remove(); 135 if (document.activeElement) { 136 // Do something, like get the ID of the focused element 137 var focusedElementId = document.activeElement.id; 138 } 139 } 140 //Scroll to top 141 $(".back-to-top-block").click(function (e) { 142 e.preventDefault(); 143 $("html, body").animate({ scrollTop: 0 }, "slow"); 144 return false;
145 }); 146 147 //Show back to top only when page has scroll 148 if ($("body").height() > $(window).height()) { 149 $(".back-to-top-block").show(); 150 } else { 151 $(".back-to-top-block").hide(); 152 } 153 154 //For saved recipes delete functionality 155 $(".recipe-delete-btn").on("click", function (e) { 156 e.preventDefault(); 157 $(this) 158 .parents(".utility-button-group") 159 .children(".recipe-delete-block") 160 .show(); 161 }); 162 163 $(".cancel-recipe-delete").on("click", function (e) { 164 e.preventDefault(); 165 $(this) 166 .parents(".utility-button-group") 167 .children(".recipe-delete-block") 168 .hide(); 169 }); 170 171 $(".confirm-recipe-delete").on("click", function (e) { 172 e.preventDefault(); 173 $(this) 174 .parents(".utility-button-group") 175 .children(".flag-save") 176 .children("a") 177 .click(); 178 $(this) 179 .parents(".saved-recipe.receipe-grid-items") 180 .parent() 181 .hide("slow"); 182 setTimeout(function () { 183 location.reload(); 184 }, 1000); 185 }); 186 187 $("#edit-shopping-list-switch") 188 .off() 189 .on("click", function (e) { 190 e.preventDefault(); 191 if ("edit" == $.trim($(this).text().toLowerCase())) { 192 $(".incredible-recipes").removeClass("hide"); 193 $(this).html('Done<span class="fa fa-check"></span>'); 194 } else { 195 $(".incredible-recipes").addClass("hide"); 196 $(this).html('Edit<span class="fa fa-th-large"></span>'); 197 location.reload(); 198 } 199 return false; 200 }); 201 $(".skip-link").on("click", function (e) { 202 e.preventDefault(); 203 $("#main-content").focus(); 204 }); 205 206 $(".remove-from-shooping-list").on("click", function (e) { 207 e.preventDefault(); 208 $(this).parent().children(".flag-shopping-list").children("a").click(); 209 var parentEl = $(this) 210 .parents(".saved-recipe.receipe-grid-items") 211 .parent(); 212 parentEl.hide("slow"); 213 parentEl.remove(); 214 }); 215 216 //Play video 217 var adjustMargin = 61; 218 $(".video-play-button").click(function (e) { 219 e.preventDefault(); 220 221 var $videoPlayerContainer = $("#videoPlayerContainer"); 222 var vidTarget = $(this).data("videotarget"); 223 var mq = window.matchMedia("(max-width: 767px)"); 224 225 if (mq.matches) { 226 adjustMargin = 48; 227 } 228 229 $(".video-info-wrapper").hide(); 230 231 // Stop playing of all videos 232 $(".video-info-wrapper").find("iframe").attr("src", ""); 233 234 //To make video auto play of recipe detail page 235 $("#" + vidTarget) 236 .find("#videoPlayFrame") 237 .attr( 238 "src", 239 $("#" + vidTarget) 240 .find("#videoPlayFrame") 241 .data("source") 242 .replace("autoplay=0", "autoplay=1") 243 ); 244 $("#" + vidTarget).fadeIn("slow"); 245 246 //Open collapse panel 247 $videoPlayerContainer.collapse("show"); 248 249 // scroll page 250 $("html,body").animate( 251 { 252 scrollTop: $videoPlayerContainer.offset().top - adjustMargin, 253 }, 254 1000 255 ); 256 return false; 257 }); 258 259 if (!$("#block-quicktabsvideostabs .content .select-tabs-list").length) { 260 // Start: The bar page Mobile Jump Menu 261 $("<select />") 262 .attr("class", "select-tabs-list") 263 .insertBefore("#block-quicktabsvideostabs ul.nav-tabs") 264 .attr("aria-label", "Videos menu dropdown"); 265 266 $("#block-quicktabsvideostabs ul.nav-tabs li.active") 267 .find("a") 268 .addClass("active"); 269 270 // Videos tabs 271 $("#block-quicktabsvideostabs ul.nav-tabs a").each(function (index) { 272 // selecting first default tab 273 if (index === 0) { 274 $("<option />", { 275 selected: "selected", 276 value: index, 277 text: $(this).text(), 278 }).appendTo("#block-quicktabsvideostabs select.select-tabs-list"); 279 } else { 280 $("<option />", { 281 value: index, 282 text: $(this).text(), 283 }).appendTo("#block-quicktabsvideostabs select.select-tabs-list"); 284 } 285 }); 286 287 // To make dropdown actually work 288 $("#block-quicktabsvideostabs .content .select-tabs-list").change( 289 function () { 290 const tabSelectId = $(this).find("option:selected").val(); 291 $( 292 '#block-quicktabsvideostabs .nav-tabs a[href="#quicktabs-tabpage-videos_tabs-' + 293 tabSelectId + 294 '"]' 295 ).click(); 296 } 297 ); 298 } 299 300 // Scroll up page on close of recipe supportive video 301 $("#videoCloseBtn").on("click", function (e) { 302 $("html, body").animate( 303 {
304 scrollTop: $(".supportive-video-block").offset().top - adjustMargin, 305 }, 306 1000 307 ); 308 //Stop playing of video on close of section 309 $(".video-info-wrapper").find("iframe").attr("src", ""); 310 }); 311 312 // Scroll up page on close of Our Story video 313 $("#ourStoryVideoCloseBtn").on("click", function (e) { 314 $("html, body").animate( 315 { 316 scrollTop: $(".brand-story").offset().top - adjustMargin, 317 }, 318 1000 319 ); 320 //Stop playing of video on close of section 321 $(".video-info-wrapper").find("iframe").attr("src", ""); 322 }); 323 324 $( 325 "#block-views-block-featured-video-block img, #block-views-block-featured-video-block .icons-play-btn" 326 ).on("click", function () { 327 $("#block-views-block-featured-video-block iframe").attr("src", ""); 328 let videoId = ""; 329 if ($(this).attr("data-vid")) { 330 videoId = $(this).data("vid"); 331 } else { 332 videoId = $(this).siblings(".icons-play-btn").data("vid"); 333 } 334 $("#block-views-block-featured-video-block iframe").attr( 335 "src", 336 "https://www.youtube.com/embed/" + 337 videoId + 338 "?rel=0&autoplay=1&wmode=opaque" 339 ); 340 $("#block-views-block-featured-video-block .feature-vid-player").show(); 341 }); 342 343 $(".feature-vid-close").on("click", function () { 344 $("#block-views-block-featured-video-block #vid-player").attr( 345 "src", 346 "" 347 ); 348 $("#block-views-block-featured-video-block .feature-vid-player").hide(); 349 }); 350 351 $("#block-quicktabsvideostabs .videos-grid-item .item-image").on( 352 "click", 353 function (e) { 354 let vidContainer = $(this).parents(".videos-grid-item"); 355 let vidContainerWrp = vidContainer.parent(); 356 let videoId = vidContainer.data("vid-id"); 357 358 if (vidContainer.hasClass("active")) { 359 return false; 360 } 361 362 $("#block-quicktabsvideostabs .videos-grid-item").removeClass( 363 "active" 364 ); 365 vidContainer.addClass("active"); 366 367 $("#block-quicktabsvideostabs .gallery-expander.show").collapse( 368 "hide" 369 ); 370 $("#block-quicktabsvideostabs .views-row").css("height", "auto"); 371 $( 372 "#block-quicktabsvideostabs .gallery-expander-contents iframe" 373 ).attr("src", ""); 374 375 if (vidContainerWrp.find("iframe").attr("src") === "") { 376 if (typeof Storage !== "undefined") { 377 if (localStorage.getItem("viewed_" + videoId) !== "true") { 378 jQuery.post( 379 base_path + "/video-view/add", 380 { vid: videoId }, 381 function (response) { 382 localStorage.setItem("viewed_" + videoId, "true"); 383 vidContainerWrp 384 .find(".youtube-video-views") 385 .html(encodeURI(response)); 386 } 387 ); 388 } 389 } 390 391 $("html, body").animate( 392 { 393 scrollTop: vidContainer.offset().top, 394 }, 395 1000 396 ); 397 398 $(".feature-vid-close").trigger("click"); 399 vidContainerWrp 400 .find("iframe") 401 .attr( 402 "src", 403 "https://www.youtube.com/embed/" + 404 videoId + 405 "?rel=0&autoplay=1&wmode=opaque" 406 ); 407 } 408 409 let heightContainer = 410 vidContainerWrp.height() + 411 vidContainerWrp.find(".gallery-expander").height() + 412 20; 413 vidContainerWrp.css("height", heightContainer + "px"); 414 vidContainerWrp.find(".gallery-expander").collapse("show"); 415 } 416 ); 417 418 $("#block-quicktabsvideostabs .gallery-expander-contents .close").on( 419 "click", 420 function () { 421 $("#block-quicktabsvideostabs .gallery-expander.show").collapse( 422 "hide" 423 ); 424 $("#block-quicktabsvideostabs .views-row").css("height", "auto"); 425 $( 426 "#block-quicktabsvideostabs .gallery-expander-contents iframe" 427 ).attr("src", ""); 428 $("#block-quicktabsvideostabs .videos-grid-item").removeClass( 429 "active" 430 ); 431 } 432 ); 433 434 /* --- INITIATE VIDEO ON ABOUT US PAGE --- */ 435 $(once("carousel", "#iniAboutVideo", context)).click(function () { 436 const carousel = $(this).closest(".carousel"); 437 let videoPlayer = $(this) 438 .closest(".about-video") 439 .find(".aboutVideoPlayer"); 440 let iframe = videoPlayer.find("iframe"); 441 442 if (videoPlayer.length && iframe.length) { 443 iframe.attr("src", videoPlayer.data("source")); 444 videoPlayer.fadeIn(1500); 445 carousel.carousel("pause"); 446 } 447 carousel.on("slide.bs.carousel", function () { 448 if (videoPlayer.length) { 449 videoPlayer.find("iframe").removeAttr("src"); 450 videoPlayer.fadeOut(1500); 451 carousel.carousel({ pause: false }); 452 } 453 }); 454 }); 455 $(once("video-close", "#aboutVideoCloseBtn", context)).click(function () { 456 let videoPlayer = $(this) 457 .closest(".about-video") 458 .find(".aboutVideoPlayer"); 459 videoPlayer.find("iframe").removeAttr("src"); 460 videoPlayer.fadeOut(1500); 461 $(this).closest(".carousel").carousel(); 462 }); 463 // End here 464 465 /* --- INITIATE VIDEO ON BRAND LOUNGE PAGE --- */ 466 $(once("carousel", ".initMultiVideo", context)).click(function () { 467 const carousel = $(this).closest(".carousel"); 468 let video_id = $(this).data("vid"); 469 let videoPlayer = $(this) 470 .closest(".heroVideo") 471 .find(".heroVideoPlayer"); 472 let iframe = videoPlayer.find("iframe"); 473 let clicked = false;
474 475 if (videoPlayer.length && iframe.length) { 476 iframe.attr("src", videoPlayer.data("source")); 477 videoPlayer.fadeIn(1500); 478 carousel.carousel("pause"); 479 } 480 carousel.on("slide.bs.carousel", function () { 481 if (iframe.length && iframe.attr("src") && !clicked) return false; 482 483 clicked = false; 484 485 if (videoPlayer.length) { 486 videoPlayer.find("iframe").removeAttr("src"); 487 videoPlayer.fadeOut(1500); 488 // carousel.carousel({'pause': false}); 489 carousel.carousel("cycle"); 490 } 491 }); 492 493 carousel.find(".carousel-indicators li").on("click", function () { 494 clicked = true; 495 }); 496 }); 497 498 $(context) 499 .find(".heroVideoCloseBtn") 500 .click(function () { 501 let videoPlayer = $(this) 502 .closest(".heroVideo") 503 .find(".heroVideoPlayer"); 504 videoPlayer.find("iframe").removeAttr("src"); 505 videoPlayer.fadeOut(1500); 506 $(this).closest(".carousel").carousel(); 507 }); 508 // End here 509 510 /* --- INITIATE VIDEO ON BRAND LOUNGE PAGE ON VIDEOS PLAY BANNER BLOCK --- */ 511 $(once("carousel", "#iniVideoOnlyVideo", context)).click(function () { 512 let videoPlayer = $(this) 513 .closest(".video-only") 514 .find(".videoOnlyVideoPlayer"); 515 let iframe = videoPlayer.find("iframe"); 516 517 if (videoPlayer.length && iframe.length) { 518 iframe.attr("src", videoPlayer.data("source")); 519 videoPlayer.fadeIn(1500); 520 } 521 }); 522 $(once("feature-link", ".featurelink", context)).click(function () { 523 $(".image-style-brand-featured-video-image").css("display", "none"); 524 }); 525 $(context) 526 .find(".videoOnlyCloseBtn") 527 .click(function () { 528 let videoPlayer = $(this) 529 .closest(".video-only") 530 .find(".videoOnlyVideoPlayer"); 531 videoPlayer.find("iframe").removeAttr("src"); 532 videoPlayer.fadeOut(1500); 533 setTimeout(function () { 534 $(".videoOnlyVideoPlayer").css("display", "none"); 535 $(".image-style-brand-featured-video-image").css( 536 "display", 537 "block" 538 ); 539 }, 200); 540 }); 541 $(context).find(".brand-featured-video img").removeAttr("height"); 542 $(context) 543 .find(".about-page .page-header-image img") 544 .removeAttr("height"); 545 $(context).find(".view-article-page-slider img").removeAttr("height"); 546 $(context).find(".article-page-wrapper img").removeAttr("height"); 547 $(context) 548 .find(".featured-brand-icon img,.brand-page .brand-image img") 549 .removeAttr("height") 550 .removeAttr("width"); 551 // End here 552 553 /* --- INITIATE select2 LIBRARIES FOR FORMS AVAILABLE ---*/ 554 $(context).find(".form-select").select2(); 555 $(context).find("#sort-by-mobile").select2(); 556 // End here 557 558 // Floating navigation 559 let list = $("#float-nav"); 560 if (list.length) { 561 $(once("list-group", ".recipe-landing-img .group")).each(function () { 562 let item = $("<a />") 563 .html("<span>" + $(this).data("recipegroup") + "</span>") 564 .addClass("list-group-item list-group-item-action") 565 .attr("href", "#" + $(this).attr("id")); 566 list.append(item); 567 }); 568 569 $("body").scrollspy({ 570 target: "#float-nav", 571 offset: list.position().top, 572 }); 573 574 setTimeout(function () { 575 $( 576 once("list-group-active", ".list-group-item.active", list) 577 ).removeClass("active"); 578 }, 400); 579 580 $(once("list-group-click", ".list-group-item", list)).click(function ( 581 e 582 ) { 583 if ($(this).parent().hasClass("all")) { 584 list.removeClass("all"); 585 } else { 586 e.preventDefault(); 587 list.addClass("all"); 588 $(this).removeClass("active"); 589 } 590 }); 591 } 592 593 if ($(context).find(".recipe-landing-total").length) { 594 let timerID = null; 595 596 $(document).scroll(function () { 597 doFixedElement(".recipe-landing-total", ".main-content"); 598 doFixedElement("#do-search", "#mobile-facets-wrapper"); 599 600 if (timerID) { 601 clearTimeout(timerID); 602 list.find(".active").css("visibility", "visible"); 603 } 604 605 timerID = setTimeout(function () { 606 list.find(".active").css("visibility", "hidden"); 607 }, 5000); 608 609 if (list.hasClass("all")) list.removeClass("all"); 610 }); 611 612 function doFixedElement(selector, parentSelector) { 613 if ($(selector)[0].getBoundingClientRect().top < 0) 614 $(selector).css({ 615 position: "fixed", 616 width: $("#content")[0].clientWidth, 617 }); 618 619 if ($(parentSelector)[0].getBoundingClientRect().top >= 0) { 620 $(selector).css({ 621 position: "static", 622 width: "100%", 623 }); 624 } 625 } 626 } 627 628 // View expodes filter search-recipes/recipe landings block (make it autosubmit) 629 $(once("auto-submit", ".auto-submit-filter", context)).change( 630 function () { 631 let form = $(this).find("form"); 632 form.attr( 633 "action", 634 window.location.pathname + window.location.search 635 ); 636 form.submit(); 637 } 638 ); 639 640 // Change icon on facets to determine if facet expanded or collapsed 641 $(once("facets-click", ".facets-widget-links")).click(function () { 642 let icon = $(this).find(".facet-title-collaps .icon"); 643 if ($(this).find(".list-wrapper.collapse").hasClass("show")) 644 icon.html('<span class="fa fa-plus"></span>'); 645 else icon.html('<span class="fa fa-minus"></span>'); 646 }); 647 648 if ($(context).find(".facets-widget-links").length) { 649 const landingPages = [ 650 "/drink-type", 651 "/spirits", 652 "/occasions", 653 "/drink-flavor", 654 ]; 655 if ($.inArray(window.location.pathname, landingPages) > -1) { 656 const allOption = $( 657 once( 658 "facets-links", 659 'a[href="' + window.location.pathname.trim() + '"]', 660 ".facets-widget-links" 661 ) 662 ); 663 if (allOption.length) { 664 allOption.addClass("is-active"); 665 allOption 666 .closest(".facets-widget-links") 667 .find(".list-wrapper") 668 .collapse("show"); 669 } 670 } 671 } 672 // End here 673 674 // Open operation for Sort&Filter popup 675 $(once("facets-mobile-click-open", "#mobile-facets-open")).click( 676 function () { 677 $("html, body").animate( 678 { 679 scrollTop: $("#mobile-facets").offset().top, 680 }, 681 1000 682 ); 683 $("#mobile-facets").show(); 684 let facetCount = $("#facet-result-count").text(); 685 let strCnt = facetCount.replace(/[()]/g, ""); 686 $("#mobile-facet-result-count").text(strCnt + " results"); 687 688 // Check for the querystring from current URL (optional - location.search) 689 if (getUrlVars()["sort_by"] == "created") { 690 $("#sort-newest").addClass("is-active"); 691 $("#sort-val").val(getUrlVars()["sort_by"]); 692 } else if (getUrlVars()["sort_by"] == "title") { 693 $("#sort-name").addClass("is-active"); 694 $("#sort-val").val(getUrlVars()["sort_by"]); 695 } else { 696 $("#sort-newest").addClass("is-active"); 697 $("#sort-val").val("created"); 698 } 699 700 // Displays applied filter as tags on mobile filter popup 701 let flavor = [], 702 skill = [], 703 color = [], 704 brand = []; 705 $("#mobile-facets .facet-flavor_profiles ul") 706 .find("li.facet-item a") 707 .each(function () { 708 if ($(this).hasClass("is-active")) { 709 flavor.push($(this).find("span.item").text()); 710 } 711 }); 712 $("#mobile-facets .facet-skill_level ul") 713 .find("li.facet-item a") 714 .each(function () { 715 if ($(this).hasClass("is-active")) { 716 skill.push($(this).find("span.item").text()); 717 } 718 }); 719 $("#mobile-facets .facet-drink_color ul") 720 .find("li.facet-item a") 721 .each(function () { 722 if ($(this).hasClass("is-active")) { 723 color.push($(this).find("span.item").text()); 724 } 725 }); 726 $("#mobile-facets .facet-brand ul") 727 .find("li.facet-item a") 728 .each(function () { 729 if ($(this).hasClass("is-active")) { 730 brand.push($(this).find("span.item").text()); 731 } 732 }); 733 } 734 ); 735 736 // Close operation for Sort&Filter popup 737 $(once("facets-mobile-click-close", "#mobile-facets-close")).click( 738 function () { 739 $("#mobile-facets").hide(); 740 $("#mobile-facet-result-count").text(""); 741 $("html, body").animate( 742 {
743 scrollTop: $(".recipe-landing-total").offset().top, 744 }, 745 1000 746 ); 747 } 748 ); 749 750 // Mobile facet popup sort order active-inactive 751 $(once("sort-newest-click", "#sort-newest")).click(function () { 752 $("#sort-name").removeClass("is-active"); 753 $("#sort-newest").addClass("is-active"); 754 let newest = $("#sort-newest").data("newest"); 755 $("#sort-val").val(newest); 756 }); 757 $(once("sort-name-click", "#sort-name")).click(function () { 758 $("#sort-newest").removeClass("is-active"); 759 $("#sort-name").addClass("is-active"); 760 let name = $("#sort-name").data("name"); 761 $("#sort-val").val(name); 762 }); 763 764 // Mobile facet links behaviour 765 const mfacets = $("#mobile-facets"); 766 if (mfacets.length) { 767 $(once("mobile-facets", mfacets)) 768 .find("a[data-drupal-facet-item-id] *") 769 .click(function (e) { 770 $(this).closest("a").toggleClass("is-active"); 771 e.stopPropagation(); 772 e.preventDefault(); 773 return false; 774 }); 775 776 let newFacetUrl = null; 777 $(once("search-click", "#do-search")).click(function () { 778 let facetLinks = []; 779 780 mfacets 781 .find("a[data-drupal-facet-item-id].is-active") 782 .each(function () { 783 facetLinks.push($(this).data("item-link")); 784 }); 785 786 let facetUrl = facetLinks.join("/"); 787 let hiddVal = $("#sort-val").val(); 788 if (hiddVal === "created") { 789 newFacetUrl = facetUrl + "?sort_by=created"; 790 } else if (hiddVal === "title") { 791 newFacetUrl = facetUrl + "?sort_by=title"; 792 } else { 793 newFacetUrl = facetUrl; 794 } 795 location.href = encodeURI( 796 drupalSettings.base_url + "/search-recipes/" + newFacetUrl 797 ); 798 }); 799 } 800 801 // Read a page GET URL variables and return them as an associative array. 802 function getUrlVars() { 803 var vars = [], 804 hash; 805 var hashes = window.location.href 806 .slice(window.location.href.indexOf("?") + 1) 807 .split("&"); 808 for (var i = 0; i < hashes.length; i++) { 809 hash = hashes[i].split("="); 810 vars.push(hash[0]); 811 vars[hash[0]] = hash[1]; 812 } 813 return vars; 814 } 815 816 // Desktop facet links behaviour 817 $( 818 once( 819 "facet-item-aside-click", 820 "aside .block-facets a[data-drupal-facet-item-id] *" 821 ) 822 ).click(function (e) { 823 $(this).closest("a").addClass("is-active"); 824 }); 825 826 /* --- QUICKTAB <select> TAG ADD FOR DEVICE SPECIFIC SELECTION --- */ 827 if (!$("#block-quicktabsarticles .content .select-tabs-list").length) { 828 $("<select />") 829 .attr("class", "select-tabs-list") 830 .insertBefore("#block-quicktabsarticles ul.nav-tabs"); 831 $("#block-quicktabsarticles ul.nav-tabs li.active") 832 .find("a") 833 .addClass("active"); 834 $("#block-quicktabsarticles ul.nav-tabs a").each(function (index) { 835 if (index === 0) { 836 $("<option />", { 837 selected: "selected", 838 value: index, 839 text: $(this).text(), 840 }).appendTo("#block-quicktabsarticles select.select-tabs-list"); 841 } else { 842 $("<option />", { 843 value: index, 844 text: $(this).text(), 845 }).appendTo("#block-quicktabsarticles select.select-tabs-list"); 846 } 847 }); 848 $("#block-quicktabsarticles .content .select-tabs-list").change( 849 function () { 850 const tabSelectId = $(this).find("option:selected").val(); 851 $( 852 '#block-quicktabsarticles .nav-tabs a[href="#quicktabs-tabpage-articles-' + 853 tabSelectId + 854 '"]' 855 ).click(); 856 } 857 ); 858 } 859 860 /* --- QUICKTAB ARTICLE LIST PAGE OPERATION --- */ 861 let pathname = window.location.pathname; 862 if (pathname == "/user/register") { 863 setTimeout(function () { 864 var starimg = "<span> *</span>"; 865 $(context) 866 .find(".register-pass-cnfpass .confirm-parent .form-required") 867 .append(starimg); 868 }, 500); 869 } 870 871 if (pathname == "/tips-and-tricks") { 872 $(context).find(".select-tabs-list").select2(); 873 874 // Placing breadrum to another location 875 // let breadcrum_text = $('.breadcrum').clone(); 876 // $('#block-quicktabsarticles .content ul.nav-tabs').after('<div class="newbreadcrum"></div>'); 877 // $(context).find('.newbreadcrum').html(breadcrum_text); 878 // $(context).find('.newbreadcrum .breadcrum').removeClass('breadcrum-hidden'); 879 880 // Check for active tab id 881 let activeTab = window.location.hash; 882 if (activeTab) { 883 // Set active for ul li element. 884 $("#block-quicktabsarticles ul.nav.nav-tabs li") 885 .find("a") 886 .removeAttr("class", "active"); 887 $("#block-quicktabsarticles ul.nav.nav-tabs li") 888 .find('a[href="' + activeTab + '"]') 889 .addClass("active"); 890 891 // Set active for content div element. 892 $(context).find(".tab-content div").removeClass("active"); 893 $(context).find(activeTab).addClass("active show"); 894 895 // Article tab in devices - Code by Gayatri 896 $(".select2-selection__rendered").click(function () { 897 let selectedText = $(this).text(); 898 $("ul.select2-results__options li:contains(" + selectedText + ")") 899 .addClass("select2-results__option--highlighted") 900 .siblings() 901 .removeClass("select2-results__option--highlighted"); 902 $("ul.select2-results__options li:contains(" + selectedText + ")") 903 .attr("aria-selected", "true") 904 .siblings() 905 .attr("aria-selected", "false"); 906 }); 907 908 $(".select2-selection__arrow").click(function () { 909 let selectedText = $(".select2-selection__rendered").text(); 910 $("ul.select2-results__options li:contains(" + selectedText + ")") 911 .addClass("select2-results__option--highlighted") 912 .siblings() 913 .removeClass("select2-results__option--highlighted"); 914 $("ul.select2-results__options li:contains(" + selectedText + ")") 915 .attr("aria-selected", "true") 916 .siblings() 917 .attr("aria-selected", "false"); 918 }); 919 } else { 920 $(context).find("#quicktabs-tabpage-articles-0").addClass("show"); 921 } 922 923 // Set active tab while on pagination load 924 if ( 925 $( 926 "#block-quicktabsarticles div#quicktabs-tabpage-articles-0" 927 ).hasClass("active") 928 ) { 929 let content = $("#block-quicktabsarticles") 930 .find(".tab-content div.active") 931 .attr("id"); 932 let tabs = $( 933 "#block-quicktabsarticles ul.nav.nav-tabs li a.active" 934 ).attr("href"); 935 936 if (content != tabs) { 937 $("#block-quicktabsarticles ul.nav.nav-tabs li") 938 .find("a") 939 .removeAttr("class", "active"); 940 $("#block-quicktabsarticles ul.nav.nav-tabs li") 941 .find('a[href="#quicktabs-tabpage-articles-0"]') 942 .addClass("active"); 943 } 944 } 945 946 // Set active tab on devices 947 let content1 = $( 948 "#block-quicktabsarticles ul.nav.nav-tabs li a.active" 949 ).text(); 950 $("#block-quicktabsarticles .select2-selection__rendered").text( 951 content1 952 ); 953 $("#block-quicktabsarticles .select2-selection__rendered").attr( 954 "title", 955 "" + content1 + "" 956 ); 957 958 // Pagination hide - Code by Gayatri 959 $("#block-quicktabsarticles ul.pagination li a span") 960 .addClass("hidden-pagination") 961 .parent("a") 962 .hide(); 963 } 964 // End here 965 966 /* --- INITIATE VIDEO ON ARTICLE PAGE --- */ 967 $(once("article-video-play", ".articlePageVideoPlay", context)).click( 968 function () { 969 let videoPlayer = $(this) 970 .closest(".articleVideo") 971 .find(".articleVideoPlayer"); 972 let iframe = videoPlayer.find("iframe"); 973 974 if (videoPlayer.length && iframe.length) { 975 iframe.attr("src", videoPlayer.data("source")); 976 videoPlayer.fadeIn(10); 977 } 978 } 979 ); 980 $(context) 981 .find("#articleVideoCloseBtn") 982 .click(function () { 983 let videoPlayer = $(this) 984 .closest(".articleVideo") 985 .find(".articleVideoPlayer"); 986 videoPlayer.find("iframe").removeAttr("src"); 987 videoPlayer.fadeOut(10); 988 }); 989 // End here 990 991 // Article video actions 992 $(context) 993 .find(".articleVideo .btn-play") 994 .click(function () { 995 $(context).find(".articleVideo").addClass("articleWrapper"); 996 }); 997 $(context) 998 .find(".articleVideoloseBtn") 999 .click(function () { 1000 $(context).find(".articleVideo").removeClass("articleWrapper"); 1001 }); 1002 // End here 1003 1004 /* --- INITIATE GALLERY IMAGE SLIDER ON ARTICLE PAGE --- */ 1005 let totalItems = $("#slider-field_subtitle_block_gallery").find( 1006 ".carousel-item" 1007 ).length; 1008 let currentIndex = $("div.active").index() + 1; 1009 $(".num").html("" + currentIndex + " of " + totalItems + ""); 1010 1011 $("#slider-field_subtitle_block_gallery").carousel({ 1012 interval: false, 1013 }); 1014 1015 $("#slider-field_subtitle_block_gallery").on( 1016 "slid.bs.carousel", 1017 function () { 1018 currentIndex = $(this).find("div.active").index() + 1; 1019 $(".num").html("" + currentIndex + " of " + totalItems + ""); 1020 } 1021 ); 1022 // End here 1023 1024 if ($(once("block-facets", ".block-facets")).length) { 1025 $(".main-menu").css({ position: "absolute" }); 1026 } 1027 1028 // Bourbon Video 1029 $(once("bourbon-play", ".show-bourbon-video", context)).click( 1030 function () { 1031 const videoPlayer = $("#bourbon-time").find(".bourbon-player"); 1032 let iframe = videoPlayer.find("iframe"); 1033 iframe.attr("src", videoPlayer.data("source")); 1034 videoPlayer.css("display", "flex").animate({ opacity: 1 }, 1500); 1035 } 1036 ); 1037 1038 $(once("bourbon-close", ".bourbon-player-close", context)).click( 1039 function () { 1040 const videoPlayer = $("#bourbon-time").find(".bourbon-player"); 1041 videoPlayer.find("iframe").removeAttr("src"); 1042 videoPlayer.fadeOut(1500); 1043 } 1044 ); 1045 // End here 1046 1047 /* --- Quicktab Article Detail Page Operations --- */ 1048 if (pathname != "/tips-and-tricks") { 1049 let category = $("input[type=hidden]").val(); 1050 $("#article-page-quicktabs ul.nav.nav-tabs") 1051 .find("li") 1052 .each(function () { 1053 let cat_name = jQuery(this).find("a").text(); 1054 if (category == cat_name) { 1055 var hrefId = jQuery(this).find("a").attr("href"); 1056 $(this).find("a").addClass("active"); 1057 $("#article-page-quicktabs") 1058 .find(".tab-content div") 1059 .removeClass("active"); 1060 $("#article-page-quicktabs").find(hrefId).addClass("active show"); 1061 } 1062 }); 1063 1064 /* --- Article Page QUICKTAB <select> - Code by Gayatri --- */ 1065 if (!$("#article-page-quicktabs .content .select-tabs-list").length) { 1066 $("<select />") 1067 .attr("class", "select-tabs-list") 1068 .insertBefore("#article-page-quicktabs ul.nav-tabs"); 1069 $("#article-page-quicktabs ul.nav-tabs li a").each(function (index) { 1070 if (index === 0) { 1071 $("<option />", { 1072 selected: "selected", 1073 value: index, 1074 text: $(this).text(), 1075 }).appendTo("#article-page-quicktabs select.select-tabs-list"); 1076 } else { 1077 $("<option />", { 1078 value: index, 1079 text: $(this).text(), 1080 }).appendTo("#article-page-quicktabs select.select-tabs-list"); 1081 } 1082 }); 1083 $("#article-page-quicktabs .content .select-tabs-list").change( 1084 function () { 1085 const tabSelectId = $(this).find("option:selected").val(); 1086 $( 1087 '#article-page-quicktabs .nav-tabs a[href="#quicktabs-tabpage-article_page-' + 1088 tabSelectId + 1089 '"]' 1090 ).click(); 1091 } 1092 ); 1093 } 1094 1095 $(context).find("#article-page-quicktabs .select-tabs-list").select2(); 1096 $(context) 1097 .find("#block-quicktabsvideostabs .select-tabs-list") 1098 .select2(); 1099 1100 // Article tab in devices - Code by Gayatri 1101 $(".select2-selection__rendered").click(function () { 1102 let selectedText = $(this).text(); 1103 $("ul.select2-results__options li:contains(" + selectedText + ")") 1104 .addClass("select2-results__option--highlighted") 1105 .siblings() 1106 .removeClass("select2-results__option--highlighted"); 1107 $("ul.select2-results__options li:contains(" + selectedText + ")") 1108 .attr("aria-selected", "true") 1109 .siblings() 1110 .attr("aria-selected", "false"); 1111 }); 1112 $(".select2-selection__arrow").click(function () { 1113 let selectedText = $(".select2-selection__rendered").text(); 1114 $("ul.select2-results__options li:contains(" + selectedText + ")") 1115 .addClass("select2-results__option--highlighted") 1116 .siblings() 1117 .removeClass("select2-results__option--highlighted"); 1118 $("ul.select2-results__options li:contains(" + selectedText + ")") 1119 .attr("aria-selected", "true") 1120 .siblings() 1121 .attr("aria-selected", "false"); 1122 }); 1123 1124 // Set active tab on devices - Code by Gayatri 1125 let content1 = $( 1126 "#article-page-quicktabs ul.nav.nav-tabs li a.active" 1127 ).text(); 1128 $("#article-page-quicktabs .select2-selection__rendered").text( 1129 content1 1130 ); 1131 $("#article-page-quicktabs .select2-selection__rendered").attr( 1132 "title", 1133 "" + content1 + "" 1134 ); 1135 } 1136 // End here 1137 1138 // User profile form 1139 if ($(context).find("#user-form").length) { 1140 function ufStateCountry() { 1141 const selectedCountry = ( 1142 $("#edit-field-country option:selected").text() || "" 1143 ).toLowerCase(); 1144 1145 if (selectedCountry != "united states") { 1146 $("#edit-field-state").val("_none"); 1147 $("#edit-field-state").trigger("change.select2"); 1148 $("#edit-field-state").attr("disabled", "disabled"); 1149 } else { 1150 $("#edit-field-state").removeAttr("disabled"); 1151 } 1152 } 1153 1154 if ($("#user-form").length) { 1155 ufStateCountry(); 1156 } 1157 $(once("edit-country", "#edit-field-country", context)).on( 1158 "change", 1159 function () { 1160 ufStateCountry(); 1161 } 1162 ); 1163 $("#user-form").on("submit", function () { 1164 // Allow submit "_none" value 1165 $("#edit-field-state").removeAttr("disabled"); 1166 }); 1167 } 1168 // End here 1169 1170 // Age-gate popup start 1171 $("#edit-submit").click(function () { 1172 $("body.not-logged-in").css("height", "auto"); 1173 }); 1174 // End here 1175 $(document).ready(function () { 1176 $("#dring_smart_logo").keydown(function (event) { 1177 if (event.which === 9) { 1178 // Check if the pressed key is Tab 1179 setTimeout(function () { 1180 $("#edit-month-of-birth").focus(); 1181 }, 100); 1182 // Your code here 1183 } 1184 if (event.shiftKey && event.keyCode == 9) { 1185 // Check if the pressed key is Tab 1186 setTimeout(function () { 1187 $(".age_gate_footer").find("a:last").focus(); 1188 }, 100); 1189 // Your code here 1190 } 1191 }); 1192 $("#remember").keydown(function (event) { 1193 if (event.shiftKey && event.keyCode == 9) { 1194 // Check if the
1194 pressed key is Tab 1195 setTimeout(function () { 1196 $("#year_of_birth").focus(); 1197 }, 100); 1198 // Your code here 1199 } 1200 }); 1201 if ($("#onetrust-policy-text").length) { 1202 $("#onetrust-policy-text a").focus(); 1203 } 1204 // }); 1205 }); 1206 // Pagination 1207 $(context) 1208 .find("#views-bootstrap-article-slider-block img") 1209 .removeAttr("height"); 1210 1211 // Login/Register Form 1212 $(context) 1213 .find(".register-section") 1214 .parent(".content") 1215 .addClass("register-wrapper"); 1216 $(context) 1217 .find(".form-item-field-birthmonth-0-value input") 1218 .addClass("reg-birthmonth"); 1219 $(context) 1220 .find(".form-item-field-birthdate-0-value input") 1221 .addClass("reg-birthdate"); 1222 $(context) 1223 .find(".form-item-field-birthyear-0-value input") 1224 .addClass("reg-birthyear"); 1225 $(context) 1226 .find(".register-wrapper") 1227 .parent() 1228 .nextUntil("region-content-bottom") 1229 .addClass("whyjoin-wrapper"); 1230 1231 // Open main-menu 1232 $(".btn-mainmenu").on("click", function () { 1233 $(".mob-main-home .close-btn").removeClass("hidden"); 1234 $(this).addClass("hidden"); 1235 $("#page.row-offcanvas-left").addClass("active"); 1236 }); 1237 1238 // Close main menu 1239 $(".mob-main-home .close-btn").on("click", function () { 1240 $(this).addClass("hidden"); 1241 $(".btn-mainmenu").removeClass("hidden"); 1242 $("#page.row-offcanvas-left").removeClass("active"); 1243 }); 1244 1245 // Toggle User Menu Mobile 1246 $(".user-menu-toggle-open").on("click", function () { 1247 $(this).addClass("d-none"); 1248 $(".user-menu-toggle-close").removeClass("d-none"); 1249 $("#page .row-offcanvas-right").addClass("active"); 1250 }); 1251 1252 $(".user-menu-toggle-close").on("click", function () { 1253 $(this).addClass("d-none"); 1254 $(".user-menu-toggle-open").removeClass("d-none"); 1255 $("#page .row-offcanvas-right").removeClass("active"); 1256 }); 1257 1258 if (!$("#block-quicktabssitesearchtabs .content .ul.nav-tabs").length) { 1259 // Set site search default tab 1260 $("#block-quicktabssitesearchtabs ul.nav-tabs li.active") 1261 .find("a") 1262 .addClass("active"); 1263 $("#block-quicktabssitesearchtabs div.tab-content") 1264 .find(".tab-pane.active") 1265 .addClass("show"); 1266 } 1267 // End here 1268 1269 // OnKeyPress event for Login Form 1270 $("#user-register-form #edit-mail").keyup(function () { 1271 let mailInput = $(this).val(); 1272 $("#edit-name").val(mailInput); 1273 }); 1274 $("#user-register-form .form-item-name").hide(); 1275 1276 // Skinnygirl-cocktails brand page 1277 if (pathname == "/brand-lounge/skinnygirl-cocktails") { 1278 $(context).find(".brand-image").addClass("small-brand-image"); 1279 } 1280 1281 // Superscript Trademark, Registered, Copyright 1282 $("body :not(script,sup)") 1283 .contents() 1284 .filter(function () { 1285 return this.nodeType === 3; 1286 }) 1287 .replaceWith(function () { 1288 return this.nodeValue.replace( 1289 /[â¢Â®]/g, 1290 "<small><sup>$&</sup></small>" 1291 ); 1292 }); 1293 1294 // Highlighting active class for dashboard menu 1295 if ( 1296 pathname == "/user/saved-recipes" || 1297 pathname == "/user/shopping-lists" || 1298 pathname == "/user/favorite-recipes" 1299 ) { 1300 $("#block-userdashboard ul.nav li a:first") 1301 .first() 1302 .removeClass("active"); 1303 } 1304 1305 // Removing featured recipe block for user/*/ pages 1306 if ( 1307 pathname == "/user/login" || 1308 pathname == "/user/register" || 1309 pathname == "/user/password" || 1310 pathname == "/user/*/edit" 1311 ) { 1312 $("#block-views-block-featured-recipes-block-1").hide(); 1313 } 1314 1315 // Header placement in device user/login/ pages 1316 if (pathname == "/user/login") { 1317 $("#header").addClass("addposition"); 1318 } 1319 1320 // Removing featured recipe block for user/*/edit page 1321 if (window.location.href.indexOf("edit") > -1) { 1322 $("#block-views-block-featured-recipes-block-1").hide(); 1323 $("#block-userdashboard ul.nav li a:first") 1324 .first() 1325 .removeClass("active"); 1326 } 1327 1328 // Adding required * to the user/register confirm password title 1329 if (pathname == "/user/register") { 1330 var starimg = "<span> *</span>"; 1331 $(".confirm-parent .form-required").append(starimg); 1332 } 1333 1334 // Recipe Spotlight Video 1335 $(once("recipe-play", ".show-recipe-video", context)).click(function () { 1336 const videoPlayer = $(".recipe-cocktail-spotlight-video").find( 1337 ".recipe-video" 1338 ); 1339 let iframe = videoPlayer.find("iframe"); 1340 iframe.attr("src", videoPlayer.data("source")); 1341 videoPlayer.css("display", "flex").animate({ opacity: 1 }, 1500); 1342 }); 1343 1344 $(once("recipe-close", ".recipe-player-close", context)).click( 1345 function () { 1346 const videoPlayer = $(".recipe-cocktail-spotlight-video").find( 1347 ".recipe-video" 1348 ); 1349 videoPlayer.find("iframe").removeAttr("src"); 1350 videoPlayer.fadeOut(1500); 1351 } 1352 ); 1353 1354 // Hode print button from contact and emial form page 1355 $('.node_view ul li.print a[href="/node/3421/printable/print"]') 1356 .parent("li") 1357 .css("display", "none"); 1358 $('.node_view ul li.print a[href="/node/5052/printable/print"]') 1359 .parent("li") 1360 .css("display", "none"); 1361 1362 // Behind bar page featured block 1363 $(context) 1364 .find(".behind-the-bar-page .image-style-brand-slider-image") 1365 .removeAttr("height"); 1366 var numItemsBehind = $(".behind-feature-wrapper .field__item").length; 1367 if (numItemsBehind % 2 != 0) { 1368 $(".behind-feature-wrapper .field__item:last").addClass("feildlast"); 1369 } 1370 //end behind bar page featured block 1371 1372 // View expodes filter article category block (make it autosubmit) 1373 $( 1374 '.view-article-category .view-filters form select[name="sort_by"]' 1375 ).change(function () { 1376 let form = $("#views-exposed-form-article-category-cat-block"); 1377 form.submit(); 1378 }); 1379 1380 // View expodes filter ask a bartender block (make it autosubmit) 1381 jQuery( 1382 '.view-ask-a-bartender .view-filters form select[name="sort_by"]' 1383 ).change(function () { 1384 let form = jQuery("#views-exposed-form-ask-a-bartender-block-1"); 1385 form.submit(); 1386 }); 1387 1388 // Recipe page layout change 1389 $(context) 1390 .find(".read-decription .read-des") 1391 .click(function () { 1392 $(context).find(".recipe-info-wrapper").removeClass("desktop-only"); 1393 $(this).addClass("hide"); 1394 $(context).find(".read-decription .close-des").removeClass("hide"); 1395 }); 1396 $(context) 1397 .find(".read-decription .close-des") 1398 .click(function () { 1399 $(context).find(".recipe-info-wrapper").addClass("desktop-only"); 1400 $(this).addClass("hide"); 1401 $(context).find(".read-decription .read-des").removeClass("hide"); 1402 }); 1403 1404 /* --- Site Search Page --- */ 1405 let search_tab_recipes = $( 1406 "#quicktabs-tabpage-site_search_tabs-0 .view-site-search .view-header div.search-count" 1407 ); 1408 let search_tab_article = $( 1409 "#quicktabs-tabpage-site_search_tabs-1 .view-site-search .view-header div.search-count" 1410 ); 1411 if (search_tab_recipes.text() != "") { 1412 search_tab_recipes.appendTo( 1413 "#block-quicktabssitesearchtabs ul li a[href='#quicktabs-tabpage-site_search_tabs-0']" 1414 ); 1415 } 1416 if (search_tab_article.text() != "") { 1417 search_tab_article.appendTo( 1418 "#block-quicktabssitesearchtabs ul li a[href='#quicktabs-tabpage-site_search_tabs-1']" 1419 ); 1420 } 1421 1422 let search_recipes = $( 1423 "#block-quicktabssitesearchtabs ul li a[href='#quicktabs-tabpage-site_search_tabs-0'] div.search-count" 1424 ); 1425 let search_article = $( 1426 "#block-quicktabssitesearchtabs ul li a[href='#quicktabs-tabpage-site_search_tabs-1'] div.search-count" 1427 ); 1428 if (search_recipes.text() != "" && search_article.text() != "") { 1429 let tot_cnt = 1430 parseInt(search_recipes.text().replace(/[{()}]/g, "")) + 1431 parseInt(search_article.text().replace(/[{()}]/g, "")); 1432 $("#search-tot-count").text("(" + tot_cnt + ")"); 1433 } else { 1434 if (search_recipes.text() != "" && search_article.text() == "") { 1435 $("#search-tot-count").text(search_recipes.text()); 1436 } else if (search_recipes.text() == "" && search_article.text() != "") { 1437 $("#search-tot-count").text(search_article.text()); 1438 } else { 1439 $("#search-tot-count").text(); 1440 $("#search-head-title").hide(); 1441 $(".search-blank-page").show(); 1442 $("#block-quicktabssitesearchtabs").hide(); 1443 } 1444 } 1445 if ($("#search-tot-count").text() != "") { 1446 $("#block-views-block-trending-recipes-block-2").hide(); 1447 } 1448 // End here 1449 1450 jQuery("#site-search-form .icons-search-newtab").click(function () { 1451 let form = jQuery("#site-search-form"); 1452 form.submit(); 1453 }); 1454 1455 jQuery("#site-search-form--2 .icons-search-newtab").click(function () { 1456 let form = jQuery("#site-search-form--2"); 1457 form.submit(); 1458 }); 1459 1460 /* --- Quicktab For Site Search Page --- */ 1461 if (window.location.href.indexOf("?search_api_fulltext=") > 0) { 1462 if (getUrlVars()["search_api_fulltext"] != "") { 1463 // Set active for ul li element. 1464 $( 1465 '#block-quicktabssitesearchtabs ul.nav.nav-tabs li a[href="#quicktabs-tabpage-site_search_tabs-0"]' 1466 ).click(function (event) { 1467 event.preventDefault(); 1468 $( 1469 '#block-quicktabssitesearchtabs ul.nav.nav-tabs li a[href="#quicktabs-tabpage-site_search_tabs-1"]' 1470 ).removeClass("active"); 1471 $( 1472 '#block-quicktabssitesearchtabs ul.nav.nav-tabs li a[href="#quicktabs-tabpage-site_search_tabs-0"]' 1473 ).addClass("active"); 1474 $( 1475 "#block-quicktabssitesearchtabs div.tab-content #quicktabs-tabpage-site_search_tabs-1" 1476 ).removeClass("in show active"); 1477 $( 1478 "#block-quicktabssitesearchtabs div.tab-content #quicktabs-tabpage-site_search_tabs-0" 1479 ).addClass("in show active"); 1480 }); 1481 1482 $( 1483 '#block-quicktabssitesearchtabs ul.nav.nav-tabs li a[href="#quicktabs-tabpage-site_search_tabs-1"]' 1484 ).click(function (event) { 1485 event.preventDefault(); 1486 $( 1487 '#block-quicktabssitesearchtabs ul.nav.nav-tabs li a[href="#quicktabs-tabpage-site_search_tabs-0"]' 1488 ).removeClass("active"); 1489 $( 1490 '#block-quicktabssitesearchtabs ul.nav.nav-tabs li a[href="#quicktabs-tabpage-site_search_tabs-1"]' 1491 ).addClass("active"); 1492 $( 1493 "#block-quicktabssitesearchtabs div.tab-content #quicktabs-tabpage-site_search_tabs-0" 1494 ).removeClass("in show active"); 1495 $( 1496 "#block-quicktabssitesearchtabs div.tab-content #quicktabs-tabpage-site_search_tabs-1" 1497 ).addClass("in show active"); 1498 }); 1499 } 1500 } 1501 //Allows user to navigate through carousel using carousel indicators 1502 $(".carousel-indicators>li").focus(function () { 1503 var e = !1; 1504 $(this).on("keydown", function (t) { 1505 "Enter" !== t.code || e || ($(this).click(), (e = !0)); 1506 }); 1507 }); 1508 //adds hover functionallity on focus visible of megamenu items 1509 $(".cr-megamenu>a").focus(function () { 1510 $(".cr-megamenu-wrap").removeAttr("style"); 1511 $(this).parent(".cr-megamenu").children(".cr-megamenu-wrap").css({ 1512 visibility: "visible", 1513 opacity: "1", 1514 "z-index": "999999", 1515 transform: "scaleY(1)", 1516 }); 1517 $(this) 1518 .off("keydown")
1519 .on("keydown", function (e) { 1520 if (e.key === "Tab" && e.shiftKey) { 1521 $(".cr-megamenu-wrap").removeAttr("style"); 1522 } 1523 }); 1524 }); 1525 //adds hover functionality on focus visible on recipe cards 1526 $(".recipe-card-orange-btn") 1527 .focusin(function () { 1528 $(this).parents(".item-detail").attr("style", "opacity: 1"); 1529 }) 1530 .focusout(function () { 1531 $(this).parents(".item-detail").removeAttr("style"); 1532 }); 1533 //back to top when enter is pressed on back to top icon 1534 $(".icons-back-to-top-desktop").focus(function () { 1535 var e = !1; 1536 $(this).on("keydown", function (t) { 1537 "Enter" !== t.code || 1538 e || 1539 $("html, body").animate({ scrollTop: 0 }, 800); 1540 }); 1541 }); 1542 //Focus visible on see recipe button in seasonal recipe 1543 $(".btn.btn-white-lg.double-border") 1544 .focus(function () { 1545 $(this) 1546 .parent(".feed-wrapper") 1547 .siblings("img") 1548 .css({ opacity: "0.9" }); 1549 $(this).css({ color: "#000", "background-color": "#fff" }); 1550 $(this) 1551 .off("keydown") 1552 .on("keydown", function (t) { 1553 if ("Enter" === t.code) { 1554 var recipeUrl = $(this) 1555 .parent(".feed-wrapper") 1556 .siblings(".seasonal-recipe-link") 1557 .attr("href"); 1558 if (recipeUrl) { 1559 window.location.href = recipeUrl; 1560 } 1561 } 1562 }); 1563 }) 1564 .focusout(function () { 1565 $(this).parent(".feed-wrapper").siblings("img").removeAttr("style"); 1566 $(this).removeAttr("style"); 1567 }); 1568 // End here 1569 }, 1570 }; 1571})(jQuery, Drupal);
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.