PageSourceSearch

https://www.amrita.edu/wp-content/themes/amrita/js/common.js?ver=1790849029

js amrita.edu collected 2026-10-01 10:29:45 UTC 23,315 bytes, 851 lines download raw bytes

1// moved from footer.php -- 22 Aug 19
2function CheckSlugValidity(slug) {
3  return slug.indexOf(window.location.pathname) == 0;
4}
5//if(!CheckSlugValidity("/leadsquare-test")){ }
6$(document).ready(function () {
7  $(".preloader").fadeOut();
8  var timeoutID = null;
9  function findMember(str) {
10    $.ajax({
11      type: "POST",
12      url: ajax_url,
13      data: { action: "my_action", str: str },
14      async: false,
15      beforeSend: function () {
16        $("#loading").css("display", "block");
17        $(".srch-box .prm-sec").hide();
18      },
19      success: function (result) {
20        if (result) {
21          resdata = JSON.parse(result);
22          //   $("section.thanks").slideDown();
23
24          if (resdata.program == "") {
25            $(".prm-sec").hide();
26          } else {
27            $(".prm-sec").show();
28          }
29          if (resdata.news == "") {
30            $(".nws-sec.nwslist-outer").hide();
31          } else {
32            $(".nws-sec.nwslist-outer").show();
33          }
34          if (resdata.search == "") {
35            $(".nws-sec.search-sec").hide();
36          } else {
37            $(".nws-sec.search-sec").show();
38          }
39          $(".prm-list").html(resdata.program).show();
40          $(".nws-sec.nwslist-outer .nws-list").html(resdata.news).show();
41          $(".nws-sec.search-sec .nws-list").html(resdata.search).show();
42          $("#loading").css("display", "none");
43        } else {
44          // $(".srch-box #loading").hide();
45          //   $("div.status", form).html(result).show();
46          $("#loading").css("display", "none");
47        }
48        var srchurl = site_url + "/?s=" + str;
49        $("a.prm-link").prop("href", srchurl);
50      },
51    });
52  }
53  $("#srch_input").keyup(function (e) {
54    clearTimeout(timeoutID);
55    $(".srch-box .prm-sec").hide();
56    $(".srch-box .nws-sec").hide();
57    $("#loading").css("display", "block");
58
59    //timeoutID = setTimeout(findMember.bind(undefined, e.target.value), 1000);
60    timeoutID = setTimeout(() => findMember(e.target.value), 1000);
61  });
62});
63
64// campus header slider
65if ($(".main-slider").length) {
66  var slideWrapper = $(".main-slider"),
67    iframes = slideWrapper.find(".embed-player"),
68    lazyImages = slideWrapper.find(".slide-image"),
69    lazyCounter = 0;
70
71  // POST commands to YouTube or Vimeo API
72  function postMessageToPlayer(player, command) {
73    if (player == null || command == null) return;
74    player.contentWindow.postMessage(JSON.stringify(command), "*");
75  }
76
77  // When the slide is changing
78  function playPauseVideo(slick, control) {
79    var currentSlide, slideType, startTime, player, video;
80
81    currentSlide = slick.find(".slick-current");
82    slideType = currentSlide.attr("class").split(" ")[1];
83    player = currentSlide.find("iframe").get(0);
84    startTime = currentSlide.data("video-start");
85
86    if (slideType === "vimeo") {
87      switch (control) {
88        case "play":
89          if (
90            startTime != null &&
91            startTime > 0 &&
92            !currentSlide.hasClass("started")
93          ) {
94            currentSlide.addClass("started");
95            postMessageToPlayer(player, {
96              method: "setCurrentTime",
97              value: startTime,
98            });
99          }
100          postMessageToPlayer(player, {
101            method: "play",
102            value: 1,
103          });
104          break;
105        case "pause":
106          postMessageToPlayer(player, {
107            method: "pause",
108            value: 1,
109          });
110          break;
111      }
112    } else if (slideType === "youtube") {
113      switch (control) {
114        case "play":
115          postMessageToPlayer(player, {
116            event: "command",
117            func: "mute",
118          });
119          postMessageToPlayer(player, {
120            event: "command",
121            func: "playVideo",
122          });
123          break;
124        case "pause":
125          postMessageToPlayer(player, {
126            event: "command",
127            func: "pauseVideo",
128          });
129          break;
130      }
131    } else if (slideType === "video") {
132      video = currentSlide.children("video").get(0);
133      if (video != null) {
134        if (control === "play") {
135          video.play();
136        } else {
137          video.pause();
138        }
139      }
140    }
141  }
142
143  // Resize player
144  function resizePlayer(iframes, ratio) {
145    if (!iframes[0]) return;
146    var win = $(".main-slider"),
147      width = win.width(),
148      playerWidth,
149      height = win.height(),
150      playerHeight,
151      ratio = ratio || 16 / 9;
152
153    iframes.each(function () {
154      var current = $(this);
155      if (width / ratio < height) {
156        playerWidth = Math.ceil(height * ratio);
157        current
158          .width(playerWidth)
159          .height(height)
160          .css({
161            left: (width - playerWidth) / 2,
162            top: 0,
163          });
164      } else {
165        playerHeight = Math.ceil(width / ratio);
166        current
167          .width(width)
168          .height(playerHeight)
169          .css({
170            left: 0,
171            top: (height - playerHeight) / 2,
172          });
173      }
174    });
175  }
176
177  // DOM Ready
178  $(function () {
179    // Initialize
180    slideWrapper.on("init", function (slick) {
181      slick = $(slick.currentTarget);
182      setTimeout(function () {
183        playPauseVideo(slick, "play");
184      }, 1000);
185      resizePlayer(iframes, 16 / 9);
186    });
187    slideWrapper.on("beforeChange", function (event, slick) {
188      slick = $(slick.$slider);
189      playPauseVideo(slick, "pause");
190    });
191    slideWrapper.on("afterChange", function (event, slick) {
192      slick = $(slick.$slider);
193      playPauseVideo(slick, "play");
194    });
195    slideWrapper.on("lazyLoaded", function (event, slick, image, imageSource) {
196      lazyCounter++;
197      if (lazyCounter === lazyImages.length) {
198        lazyImages.addClass("show");
199        // slideWrapper.slick("slickPlay");
200      }
201    });
202
203    //start the slider
204    slideWrapper.slick({
205      // fade:true,
206      autoplaySpeed: 4000,
207      lazyLoad: "progressive",
208      speed: 1000,
209      arrows: false,
210      dots: true,
211      //autoplay: true,
212      cssEase: "cubic-bezier(0.87, 0.03, 0.41, 0.9)",
213    });
214  });
215
216  // Resize event
217  $(window).on("resize.slickVideoPlayer", function () {
218    resizePlayer(iframes, 16 / 9);
219  });
220}
221$(document).ready(function () {
222  var ua = window.navigator.userAgent;
223  var isIE = /MSIE|Trident/.test(ua);
224
225  if (isIE) {
226    //IE specific code goes here
227    $("body").addClass("ie-browser");
228  }
229
230  // $('.search-toggler a').on('click', function(e){
231  // 	e.preventDefault();
232  // 	$(this).parents('.search-form-wrap').addClass('search-visible');
233  // });
234  // $(document).mouseup(function(e){
235  //     var container = $(".search-form-wrap");
236
237  //     // if the target of the click isn't the container nor a descendant of the container
238  //     if (!container.is(e.target) && container.has(e.target).length === 0)
239  //     {
240  //         container.removeClass('search-visible');
241  //     }
242  // });
243
244  $(document).on("click", ".menu-toggler", function (e) {
245    e.preventDefault();
246    $(".mobile-menu-wrap").fadeIn();
247    $("body").addClass("overhide");
248  });
249
250  /* $(document).on('click', '.menu-dropdown>a', function (e) {
251		e.preventDefault();
252		var getLinkText = $(this).text();
253		$(this).parent().find('.sub-menu').first().addClass('show-submenu');
254		$('.mobile-menu-wrap').addClass('submenu-showing');
255		$('.submenu-title').html(getLinkText);
256	}); */
257
258  $(document).on("click", ".drop-arrw", function (e) {
259    e.preventDefault();
260    var _this = $(this);
261    // if()
262    var getLinkText = _this.closest('li').find('> a.menu-link').text();
263    // console.log(getLinkText);
264    
265    _this
266      .closest(".menu-dropdown")
267      .find(".sub-menu")
268      .first()
269      .addClass("show-submenu");
270    $(".mobile-menu-wrap").addClass("submenu-showing");
271    $(".submenu-title").html(getLinkText);
272    e.preventDefault();
273  });
274
275  $(document).on("click", ".has-children", function (e) {
276    if($(this).attr('href') == '#'){
277      e.preventDefault();
278      var getLinkText = $(this).text();
279      $(this)
280        .closest(".menu-dropdown")
281        .find(".sub-menu")
282        .first()
283        .addClass("show-submenu");
284      $(".mobile-menu-wrap").addClass("submenu-showing");
285      $(".submenu-title").html(getLinkText);
286      e.preventDefault();
287    }
288  });
289
290  $(document).on("click", ".close-mob-menu", function (e) {
291    e.preventDefault();
292    $("ul.show-submenu").removeClass("show-submenu");
293    $(".mobile-menu-wrap").removeClass("submenu-showing");
294    $(".mobile-menu-wrap").fadeOut();
295    $("body").removeClass("overhide");
296  });
297
298  $(document).on("click", ".menu-mob-back", function (e) {
299    e.preventDefault();
300    $("ul.show-submenu:visible:last").removeClass("show-submenu");
301    // console.log($('ul.show-submenu:visible:last'));
302    // alert(($('ul.sub-menu.show-submenu').length));
303    // alert((!$('ul.sub-menu.show-submenu').length));
304    if (!$("ul.sub-menu.show-submenu").length) {
305      $(".mobile-menu-wrap").removeClass("submenu-showing");
306    } else {
307      if ($("ul.sub-menu.show-submenu").length == 3) {
308        var newTitle = $("ul.show-submenu")
309          .closest(".menu-dropdown")
310          .find("a")
311          .first()
312          .text();
313        $(".submenu-title").html(newTitle);
314      } else if ($("ul.sub-menu.show-submenu").length == 2) {
315        var newTitle = $("ul.show-submenu:visible:last")
316          .closest(".menu-dropdown")
317          .find("a")
318          .first()
319          .text();
320        $(".submenu-title").html(newTitle);
321      } else {
322        var newTitle = $("ul.show-submenu")
323          .closest(".menu-dropdown")
324          .find("a")
325          .first()
326          .text();
327        $(".submenu-title").html(newTitle);
328      }
329    }
330  });
331
332  $(document).on("click", ".prog-list-toggler", function () {
333    $(this).parent().find(".prog-list-content").fadeIn();
334    $("body").addClass("overhide");
335  });
336  $(document).on("click", ".prog-close", function () {
337    $(".prog-list-content").fadeOut();
338    $("body").removeClass("overhide");
339  });
340
341  // explore video slider
342  $(".sm-video-slider").slick({
343    autoplay: true,
344    infinite: false,
345    dots: false,
346    arrows: false,
347    speed: 1000,
348    slidesToShow: 4,
349    slidesToScroll: 1,
350    responsive: [
351      {
352        breakpoint: 991,
353        settings: {
354          slidesToShow: 3,
355        },
356      },
357      {
358        breakpoint: 767,
359        settings: {
360          slidesToShow: 1,
361          dots: true,
362        },
363      },
364    ],
365  });
366
367  // ranking slider
368  $(".ranking-slider").slick({
369    autoplay: true,
370    infinite: true,
371    dots: true,
372    arrows: false,
373    slidesToShow: 1,
374    speed: 1000,
375    slidesToScroll: 1,
376    appendDots: ".ranking-dots",
377  });
378
379  $(".video-pop").magnificPopup({
380    disableOn: 0,
381    type: "iframe",
382    mainClass: "mfp-fade",
383    removalDelay: 160,
384    preloader: false,
385    fixedContentPos: true,
386    fixedBgPos: true,
387    callbacks: {
388      open: function () {
389        new YT.Player("player", {
390          events: {
391            onStateChange: onPlayerStateChange,
392          },
393        });
394      },
395    },
396  });
397  function onPlayerStateChange(event) {
398    if (event.data == YT.PlayerState.ENDED) {
399      $.magnificPopup.close();
400    }
401  }
402
403  //sumoselect sample
404  $(".top-select select").SumoSelect();
405});
406
407// Check distance to top and display back-to-top.
408$(window).scroll(function () {
409  if ($(this).scrollTop() > 800) {
410    $(".back-to-top").addClass("show-back-to-top");
411  } else {
412    $(".back-to-top").removeClass("show-back-to-top");
413  }
414});
415
416// Click event to scroll to top.
417$(".back-to-top").click(function (e) {
418  e.preventDefault();
419  $("html, body").animate({ scrollTop: 0 }, 800);
420  return false;
421});
422
423// $(window).load(function () {
424//   var s = skrollr.init({
425//     forceHeight: false,
426//   });
427
428//   if (s.isMobile()) {
429//     s.destroy();
430//   }
431// });
432
433window.addEventListener("scroll", function () {
434
435  let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
436
437  let header = document.querySelector(".header-main");
438  let secondary = document.querySelector(".secondary-nav");
439
440  /* header-main */
441  if (header) {
442    let value = 0;
443
444    if (scrollTop >= 400) {
445      value = 2;
446    } else if (scrollTop >= 300) {
447      value = 1;
448    }
449
450    header.setAttribute("myattr", value);
451  }
452
453  /* secondary-nav */
454  if (window.innerWidth > 1000) {
455    if (secondary) {
456      let value = 0;
457
458      if (scrollTop >= 700) {
459        value = 3;
460      } else if (scrollTop >= 300) {
461        value = 1;
462      }
463
464      secondary.setAttribute("myattr", value);
465    }
466  }
467
468});
469
470jQuery(function ($) {
471  // Function which adds the 'animated' class to any '.animatable' in view
472  var doAnimations = function () {
473    // Calc current offset and get all animatables
474    var offset = $(window).scrollTop() + $(window).height(),
475      $animatables = $(".animatable");
476
477    // Unbind scroll handler if we have no animatables
478    if ($animatables.size() == 0) {
479      $(window).off("scroll", doAnimations);
480    }
481
482    // Check all animatables and animate them if necessary
483    $animatables.each(function (i) {
484      var $animatable = $(this);
485      if ($animatable.offset().top + $animatable.height() - 100 < offset) {
486        $animatable.removeClass("animatable").addClass("animated");
487      }
488    });
489  };
490
491  // Hook doAnimations on scroll, and trigger a scroll
492  $(window).on("scroll", doAnimations);
493  $(window).trigger("scroll");
494
495  $("#srch-btn").click(function (e) {
496    e.preventDefault();
497    $(".srch-box").toggleClass("show-searchbox");
498    $("body").toggleClass("searching");
499    $("header .srch-box input").focus();
500  });
501  $("html").click(function (event) {
502    if ($(event.target).closest(".search-form-wrap").length === 0) {
503      $(".srch-box").removeClass("show-searchbox");
504      $("body").removeClass("searching");
505    }
506  });
507
508  // campus scripts
509  $(".header-slider").slick({
510    arrows: false,
511    dots: true,
512    autoplay: true,
513    speed: 1000,
514  });
515  $(".wp-block-uagb-section .int-desc").slick({
516    arrows: false,
517    dots: true,
518    autoplay: true,
519    speed: 1000,
520    slidesToShow: 4,
521    slidesToScroll: 4,
522    responsive: [
523      {
524        breakpoint: 1024,
525        settings: {
526          slidesToShow: 3,
527          slidesToScroll: 3,
528        },
529      },
530      {
531        breakpoint: 768,
532        settings: {
533          slidesToShow: 2,
534          slidesToScroll: 2,
535        },
536      },
537      {
538        breakpoint: 600,
539        settings: {
540          slidesToShow: 1,
541          slidesToScroll: 1,
542        },
543      },
544    ],
545  });
546
547  // department slider - better to load on respective pages only
548  $(".facility-slider").slick({
549    dots: false,
550    arrows: true,
551    speed: 1000,
552    appendArrows: ".slick-arrows",
553    nextArrow: '<span class="arrow-next">Next</span>',
554    prevArrow: '<span class="arrow-prev">Prev</span>',
555  });
556
557  if ($(".top-select ul").length) {
558    $(".top-select").each(function () {
559      var getList = $(this).find("ul");
560      new SimpleBar($(getList)[0]);
561    });
562  }
563
564  if ($(".med-toggler").length) {
565    $(document).on("click", ".med-toggler", function () {
566      if ($(this).hasClass("active")) {
567        $(".med-links").slideUp(function () {
568          $(".med-toggler").removeClass("active");
569        });
570      } else {
571        $(".med-links").slideDown();
572        $(this).addClass("active");
573      }
574    });
575  }
576});
577
578equalheight = (function (container) {
579  var currentTallest = 0,
580    currentRowStart = 0,
581    rowDivs = new Array(),
582    $el,
583    topPosition = 0;
584  $(container).each(function () {
585    $el = $(this);
586    $($el).height("auto");
587    topPostion = $el.position().top;
588
589    if (currentRowStart != topPostion) {
590      for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
591        rowDivs[currentDiv].height(currentTallest);
592      }
593      rowDivs.length = 0; // empty the array
594      currentRowStart = topPostion;
595      currentTallest = $el.height();
596      rowDivs.push($el);
597    } else {
598      rowDivs.push($el);
599      currentTallest =
600        currentTallest < $el.height() ? $el.height() : currentTallest;
601    }
602    for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
603      rowDivs[currentDiv].height(currentTallest);
604    }
605  });
606})(
607  // jQuery('#prg-srch-form').keydown(function(e) {
608  //   var key = e.which;
609  //   if (key == 13) {
610  //      if((jQuery("#prg-srch").val()) == '' || ((jQuery("#prg-srch").val()) == undefined)){
611  //       event.preventDefault();
612  //         return false;
613  //     }
614  //   }
615  // });
616  //jQuery('#prg-srch').validate();
617
618  (function ($) {
619    // the sameHeight functions makes all the selected elements of the same height
620    $.fn.sameHeight = function () {
621      var selector = this;
622      var heights = [];
623
624      // Save the heights of every element into an array
625      selector.each(function () {
626        var height = $(this).height();
627        heights.push(height);
628      });
629
630      // Get the biggest height
631      var maxHeight = Math.max.apply(null, heights);
632      // Show in the console to verify
633      // console.log(heights,maxHeight);
634
635      // Set the maxHeight to every selected element
636      selector.each(function () {
637        $(this).height(maxHeight);
638      });
639    };
640  })(jQuery)
641);
642
643/*-------- Instagram slider -------------*/
644//if ($(".insta-feed")[0]){
645$(document).ready(function () {
646  if ($(".insta-outer").length) {
647    $(".insta-slider1").slick({
648      dots: false,
649      infinite: true,
650      speed: 800,
651      slidesToShow: 6,
652      autoplay: true,
653      swipeToSlide: true,
654      arrows: false,
655      // variableWidth: true,
656      responsive: [
657        {
658          breakpoint: 2750,
659          settings: {
660            slidesToShow: 10,
661            slidesToScroll: 1,
662          },
663        },
664        {
665          breakpoint: 2400,
666          settings: {
667            slidesToShow: 9,
668            slidesToScroll: 1,
669          },
670        },
671        {
672          breakpoint: 2100,
673          settings: {
674            slidesToShow: 8,
675            slidesToScroll: 1,
676          },
677        },
678        {
679          breakpoint: 1800,
680          settings: {
681            slidesToShow: 7,
682            slidesToScroll: 1,
683          },
684        },
685        {
686          breakpoint: 1500,
687          settings: {
688            slidesToShow: 6,
689            slidesToScroll: 1,
690          },
691        },
692        {
693          breakpoint: 1200,
694          settings: {
695            slidesToShow: 5,
696            slidesToScroll: 1,
697          },
698        },
699
700        {
701          breakpoint: 1024,
702          settings: {
703            slidesToShow: 4,
704            slidesToScroll: 1,
705          },
706        },
707        {
708          breakpoint: 992,
709          settings: {
710            slidesToShow: 3,
711            slidesToScroll: 1,
712          },
713        },
714        {
715          breakpoint: 768,
716          settings: {
717            slidesToShow: 2,
718            slidesToScroll: 1,
719          },
720        },
721        {
722          breakpoint: 415,
723          settings: {
724            slidesToShow: 1,
725            slidesToScroll: 1,
726          },
727        },
728      ],
729    });
730  }
731});
732
733function appendUTMParameters(url) {
734  var urlParams = window.location.search;
735  var separator = "";
736  if (urlParams && urlParams.charAt(0) === "?") {
737    // Remove the leading "?"
738    urlParams = urlParams.slice(1);
739    // Check if the URL already contains a query string
740    var separator = url.includes("?") ? "&" : "?";
741  }
742
743  // Append UTM parameters to the URL
744  var updatedUrl = url + separator + urlParams;
745  updatedUrl = updatedUrl.replaceAll(/\s/g, "");
746  return updatedUrl;
747}
748
749// UTM capture on Demo urls, only when added class "utmlink" to a tag.
750function updateUtmLinkHref() {
751  var utmLinks = document.querySelectorAll(".utmlink");
752
753  // Loop through each element and update the href value
754  utmLinks.forEach(function (link) {
755    // Get the current href value
756    var currentHref = link.getAttribute("href");
757
758    // Append UTM parameters to the href value
759    var updatedHref = appendUTMParameters(currentHref);
760
761    // Update the href value of the link
762    link.setAttribute("href", updatedHref);
763  });
764}
765
766//   window.onload = function () {
767// 	updateUtmLinkHref();
768//   }
769
770
771document.addEventListener("DOMContentLoaded", function() {
772  const years = document.querySelectorAll(".press-media-year");
773  
774  years.forEach(year => {
775    year.addEventListener("click", function() {
776      // Toggle active class on the year
777      this.classList.toggle("active");
778      
779      // Get the next element (months list)
780      const months = this.nextElementSibling;
781      
782      // Toggle the months display
783      if (months.classList.contains("active")) {
784          months.classList.remove("active");
785      } else {
786          months.classList.add("active");
787      }
788      
789      // Close other open year sections
790      years.forEach(otherYear => {
791          if (otherYear !== year && otherYear.classList.contains("active")) {
792              otherYear.classList.remove("active");
793              otherYear.nextElementSibling.classList.remove("active");
794          }
795      });
796    });
797  });
798  
799  // Open the first year by default
800  if (years.length > 0) {
801      years[0].click();
802  }
803});
804
805
806document.addEventListener('wpcf7mailsent', function (event) {
807
808    const apiResponse = event.detail.apiResponse;
809
810    // Download PDF
811    if (apiResponse.aoc_download) {
812
813        fetch(apiResponse.aoc_download)
814        .then(response => response.blob())
815        .then(blob => {
816
817            const url = window.URL.createObjectURL(blob);
818
819            const a = document.createElement("a");
820            a.href = url;
821
822            // Extract filename from URL
823            const filename = apiResponse.aoc_download.split('/').pop() || 'Brochure.pdf';
824            a.download = filename;
825
826            document.body.appendChild(a);
827            a.click();
828            a.remove();
829
830            window.URL.revokeObjectURL(url);
831
832            // Redirect after download
833            if (apiResponse.aoc_redirect) {
834                window.location.href = apiResponse.aoc_redirect;
835            }
836
837        }).catch(err => {
838            console.error('Download failed:', err);
839
840            // Still redirect if download fails
841            if (apiResponse.aoc_redirect) {
842                window.location.href = apiResponse.aoc_redirect;
843            }
844        });
845
846    } else if (apiResponse.aoc_redirect) {
847        // No download, only redirect
848        window.location.href = apiResponse.aoc_redirect;
849    }
850
851}, false);

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.