PageSourceSearch

https://www.tntech.edu/_resources/2023-theme/js/lnm.js?v=1.30

js tntech.edu collected 2026-09-24 09:26:57 UTC 19,236 bytes, 591 lines download raw bytes

1var LnmNavigation = {
2  initTopNav: function () {
3    $(".mobile-top-nav-2").empty();
4    $(".tt-nav-container .nav-3 a").each(function () {
5      if (!$(this).hasClass(".search-start")) {
6        $(".mobile-top-nav-2").append(
7          '<li><a href="' +
8            $(this).attr("href") +
9            '">' +
10            $(this).html() +
11            "</a></li>"
12        );
13      }
14    });
15  },
16  initTertiaryNav: function () {
17    var menuItemMarkup = "";
18    var $menuItemMega = null;
19    var counter = 0;
20    $(".tt-mobile-gray-menu").empty();
21    $(".tt-nav-container .nav-2 a").each(function () {
22      menuItemMarkup +=
23        '<li><a href="' +
24        $(this).attr("href") +
25        '">' +
26        $(this).text() +
27        '</a><ul class="menu vertical nested">';
28      $menuItemMega = $(
29        ".gray-dd-container .content-" + $(this).attr("data-content")
30      );
31      $menuItemMega.find(".cell").each(function () {
32        counter = 0;
33        $(this)
34          .find("p")
35          .each(function () {
36            if (counter == 0 && $(this).find("a").length == 0) {
37              menuItemMarkup += "<li><p>" + $(this).html() + "</p></li>";
38            } else {
39              menuItemMarkup += "<li>" + $(this).html() + "</li>";
40            }
41            counter++;
42          });
43      });
44      menuItemMarkup += "</ul></li>";
45    });
46    $(".tt-mobile-gray-menu").append(menuItemMarkup);
47    $(".tt-mobile-gray-menu").append(
48      '<li><a href="' +
49        $(".nav-2-container > a").attr("href") +
50        '">' +
51        $(".nav-2-container > a").html() +
52        "</a></li>"
53    );
54  },
55  initMainNav: function () {
56    var menuItemMarkup = "";
57    var $cells = null;
58    $(".tt-mobile-sub-menu").empty();
59    $(".tt-nav-main > ul > li").each(function () {
60      menuItemMarkup +=
61        '<li><a href="' +
62        $(this).find("> a").attr("href") +
63        '">' +
64        $(this).find("> a").html() +
65        "</a>";
66      $cells = $(this).find(".cell:not(.subnav-first)");
67      if ($cells.length) {
68        menuItemMarkup += '<ul class="menu vertical nested">';
69        $cells.each(function () {
70          menuItemMarkup += $(this).find("ul").html();
71        });
72        menuItemMarkup += "</ul>";
73      }
74      menuItemMarkup += "</li>";
75    });
76    $(".tt-mobile-sub-menu").html(menuItemMarkup);
77  },
78  initSectionNav: function () {
79    var menuItemMarkup = "";
80    var $cells = null;
81    var $ul = null;
82    var $a = null;
83    var mCount = 0;
84    var cCount = 0;
85    var topLink = "";
86    var theText = "";
87
88    if ($(".section-nav-output").length) {
89      // build desktop nav from ounav output
90      menuItemMarkup +=
91        '<ul class="dropdown menu" data-dropdown-menu="data-dropdown-menu">';
92      $(".section-nav-output > li").each(function () {
93
94        if(mCount < 6) {
95          $a = $(this).find(">a");
96          $ul = $(this).find(">ul");
97
98          if($a.length === 0) {
99            theText = $(this).contents().filter(function() {
100              return this.nodeType === 3; // Filter for text nodes only
101            }).first().text().trim();
102            topLink = '<a href="#">' + theText + '</a>';
103            if ($ul != null) {
104              topLink += '<ul>' + $ul.html() + '</ul>';
105            }
106            $(this).html(topLink);
107            $a = $(this).find(">a");
108            $ul = $(this).find(">ul");
109          }
110
111          $liList = $ul.find(">li");
112
113          menuItemMarkup += '<li class="mega-menu">';
114          if ($ul == null) {
115            menuItemMarkup +=
116              '<a data-toggle="sn-mega-menu-' +
117              mCount +
118              '" href="' +
119              $a.attr("href") +
120              '" target="' +
121              ((typeof $a.attr("target") === 'undefined') ? '_self' : $a.attr("target")) +
122              '">' +
123              $a.text() +
124              "</a>";
125          } else {
126            cCount = 0;
127            menuItemMarkup +=
128              '<a href="' +
129              $a.attr("href") +
130              '" target="' + ((typeof $a.attr("target") === 'undefined') ? '_self' : $a.attr("target")) + '" data-toggle="sn-mega-menu-' +
131              mCount +
132              '" class="is-open">'; //Ensure everything starts visible.
133            if($liList.length) {
134              menuItemMarkup += "<span>" + $a.text() + "</span>";
135              menuItemMarkup += '<i class="far fa-chevron-right"></i>';
136              menuItemMarkup += '<i class="far fa-chevron-down"></i>';
137            } else {
138              menuItemMarkup += $a.text();
139            }
140            menuItemMarkup += "</a>";
141
142            if($liList.length) {
143              menuItemMarkup += '<div class="dropdown-pane bottom" id="sn-mega-menu-' + mCount + '" data-dropdown="data-dropdown" data-options="hover: true; hoverPane: true;">';
144              menuItemMarkup += '<div class="grid-container">';
145              menuItemMarkup += '<div class="grid-x grid-padding-x small-up-5 tt-desktop-nav-grid">';
146              $liList.each(function (index) {
147                if (index % 3 === 0) {
148                  if (index !== 0) {
149                    menuItemMarkup += "</ul>";
150                    menuItemMarkup += "</div>";
151                  }
152                  menuItemMarkup += '<div class="cell">';
153                  menuItemMarkup += '<ul class="menu vertical">';
154                }
155              
156                menuItemMarkup +=
157                  '<li><a href="' +
158                  $(this).find('a').attr("href") +
159                  '" target="' +
160                  (typeof $(this).find('a').attr("target") === 'undefined' ? '_self' : $(this).find('a').attr("target")) +
161                  '">' +
162                  $(this).find('a').text() +
163                  "</a></li>";
164              
165                if (index === $liList.length - 1) {
166                  menuItemMarkup += "</ul>";
167                  menuItemMarkup += "</div>";
168                }
169              });
170              menuItemMarkup += "</div>";
171              menuItemMarkup += "</div>";
172              menuItemMarkup += "</div>";
173            }
174
175          }
176          menuItemMarkup += "</li>";
177          mCount++;
178        }
179
180      });
181      menuItemMarkup += "</ul>";
182      $(".section-nav-output").replaceWith(menuItemMarkup);
183
184      // build mobile nav from desktop nav
185      menuItemMarkup = "";
186      $cells = null;
187      $(".tt-mobile-section-menu").empty();
188      $(".tt-desktop-new-subnav > ul > li").each(function () {
189        menuItemMarkup +=
190          '<li><a href="' +
191          $(this).find("> a").attr("href") +
192          '" target="' +
193          ((typeof $(this).find('> a').attr("target") === 'undefined') ? '_self' : $(this).find('> a').attr("target")) +
194          '">' +
195          $(this).find("> a").text() +
196          "</a>";
197        $cells = $(this).find(".cell:not(.subnav-first)");
198        if ($cells.length) {
199          menuItemMarkup += '<ul class="menu vertical nested">';
200          $cells.each(function () {
201            menuItemMarkup += $(this).find("ul").html();
202          });
203          menuItemMarkup += "</ul>";
204        }
205        menuItemMarkup += "</li>";
206      });
207      $(".tt-mobile-section-menu").html(menuItemMarkup);
208    }
209  },
210};
211
212var LnmComponents = {
213  initComponents: function() {
214
215    $("div.comp-d + div.comp-d").prev(":first").addClass("comp-d-stacked");
216      
217    // cleanup empty paragraphs
218    $('div.component-2023theme p,div.component-2023theme h2,div.component-2023theme h3,div.component-2023theme h4').each(function(){
219      if( $(this).html().length === 0 ) {
220        $(this).remove();
221      }
222    });
223
224    // cleanup empty links
225    $('div.component-2023theme a').each(function(){
226      if( $(this).attr('href').length === 0 || $(this).html().length === 0 ) {
227        $(this).remove();
228      }
229    });
230
231    // cleanup empty images
232    $('div.component-2023theme img').each(function(){
233      if( $(this).attr('src').length === 0 ) {
234        $(this).remove();
235      }
236    });
237    
238    // cleanup component overlays
239    $('div.comp-f .tt-card').each(function(){
240      if( !$(this).hasClass('overlay-area') ) {
241        $(this).find('.overlay').remove();
242      }
243    });
244
245    // cleanup separated components
246    var $componentThemeDivs = $('div.component-2023theme');
247    $componentThemeDivs.each(function () {
248      var $currentDiv = $(this);
249      var $nextDiv = $currentDiv.parent().next().find('div.component-2023theme');
250      if ($nextDiv.length > 0) {
251        $currentDiv.unwrap();
252        $currentDiv.parent().after($nextDiv);
253        $nextDiv.unwrap();
254      }
255    });
256
257  }
258};
259
260$(document).on("mouseleave", function (e) {
261  // Check if the cursor's Y-coordinate is less than 0 (above the browser window)
262  if (e.clientY < 0) {
263    // Trigger the mouse leave event for .gray-dd-container
264    $(".gray-dd-container").trigger("mouseleave");
265  }
266});
267
268$(document).ready(function () {
269  $(".nav-2 a svg.hidden-init").removeClass("hidden-init");
270
271  LnmNavigation.initTopNav();
272  LnmNavigation.initTertiaryNav();
273  LnmNavigation.initMainNav();
274  LnmNavigation.initSectionNav();
275  LnmComponents.initComponents();
276
277  $(".btnBackToTop").click(function (e) {
278    e.preventDefault();
279	$('html, body').animate({
280		scrollTop: -50
281	}, 'fast'); 
282	return false;
283  });
284	
285  $('.comp-slider').slick({
286    infinite: true,
287    slidesToShow: 3,
288    arrows: false,
289    slidesToScroll: 1,
290	swipeToSlide: true, 
291	touchThreshold: 10, 
292    responsive: [
293    {
294      breakpoint: 1024,
295      settings: {
296        slidesToShow: 2,
297        arrows:true
298      }
299    }
300    // You can unslick at a given breakpoint now by adding:
301    // settings: "unslick"
302    // instead of a settings object
303  ]
304  });
305
306  $("main p").each(function () {
307    if ($.trim($(this).html()).length == 0) {
308      $(this).remove();
309    }
310  });
311
312  $(document).foundation();
313
314  var isHovered = false; // Variable to track whether the mouse is hovering over .tt-desktop-nav or .tt-desktop-subnav
315
316  // // Mouse enters .tt-desktop-nav
317  //$(".tt-desktop-nav a").on("mouseenter", function () {
318 //   isHovered = true;
319 //   showSubnav(); // Show .tt-desktop-subnav
320//  });
321	
322  //Update hide/show functions for mouse events to trigger off of is-open/is-visible instead of .hide()/.show()
323  $(".tt-desktop-nav > ul > li").on("mouseenter", function() {
324	  isHovered = true;
325	  var targetPaneId = $(this).find("> a").attr("data-toggle");
326	  if (targetPaneId) {
327		  $(".dropdown-pane").not("#" + targetPaneId).removeClass('is-open').addClass('is-closed');
328		  $("#" + targetPaneId).removeClass('is-closed').addClass('is-open');
329	  } else {
330		  $(".dropdown-pane").removeClass('is-open').addClass('is-closed');
331	  }
332	  $(this).find("> a").addClass("on");
333	  $(".tt-desktop-nav > ul > li > a").not($(this).find("> a")).removeClass("on");
334  });
335
336  // Mouse leaves .tt-desktop-nav
337  $(".tt-desktop-nav").on("mouseleave", function () {
338    isHovered = false;
339    setTimeout(hideSubnav, 66); // Hide .tt-desktop-subnav
340  });
341
342  // Mouse enters .tt-desktop-subnav
343  $(".tt-desktop-subnav").on("mouseenter", function () {
344    isHovered = true;
345    showSubnav(); // Show .tt-desktop-subnav
346  });
347
348  // Mouse leaves .tt-desktop-subnav
349  $(".tt-desktop-subnav").on("mouseleave", function () {
350    isHovered = false;
351    setTimeout(hideSubnav, 66); // Hide .tt-desktop-subnav
352  });
353	
354	// Updated function to show .tt-desktop-subnav
355  function showSubnav() {
356    $(".dropdown-pane").removeClass('is-closed').addClass('is-open');
357  }
358
359  // Updated function to hide .tt-desktop-subnav
360  function hideSubnav() {
361      //$(".dropdown-pane").hide();
362      $(".dropdown-pane").removeClass("is-open").addClass("is-closed");
363	  $(".tt-desktop-nav > ul > li > a").removeClass("on");
364  }
365
366  $(".slider-arrows > .s-next").click(function () {
367    $(".comp-slider").slick("slickNext");
368    return false;
369  });
370  $(".slider-arrows > .s-prev").click(function () {
371    $(".comp-slider").slick("slickPrev");
372    return false;
373  });
374  $(".tt-mobile-section-nav > a").click(function () {
375    $(".tt-mobile-section-menu").slideToggle();
376    $(".tt-mobile-section-nav a .fa-chevron-down").toggle();
377    $(".tt-mobile-section-nav a .fa-chevron-right").toggle();
378    return false;
379  });
380  $(".tt-mm").click(function () {
381    $(this).toggleClass("active");
382    $(".tt-mobile-search-container").hide();
383    $(".tt-mobile-sub-menu-container").fadeToggle();
384    return false;
385  });
386  $(".search-start-mobile").click(function () {
387    $(this).toggleClass("active");
388    $(".tt-mobile-sub-menu-container").hide();
389    $(".tt-mobile-search-container").fadeToggle();
390    $(".tt-mm").removeClass("active");
391	$('.searchFormMobile input').focus();
392    return false;
393  });
394
395  $(".search-start").on("click", function () {
396    $(".search-bar-container").css({
397      right: "0", // Slide in from the right
398      opacity: "1", // Fade in
399    });
400    $(".nav-3").hide();
401	$('.search-bar input').focus();
402  });
403
404  $(".search-icon").on("click", function () {
405    $(".search-bar-container").css({
406      right: "-300px", // Slide out to the right
407      opacity: "0", // Fade out
408    });
409    $(".nav-3").show();
410  });
411
412  $(".tt-desktop-nav > ul > li > a").on("mouseenter", function () {
413    $(this).addClass("on");
414    $(".tt-desktop-nav a").not(this).removeClass("on");
415  });
416
417  // Variable to track whether the gray-dd-container is currently showing
418  var isContainerShowing = false;
419  var isNav2Hovered = false; // Initialize a variable to track mouse hover
420
421  // Mouse enters .nav-2
422  $(".nav-2").on("mouseenter", function () {
423    isNav2Hovered = true;
424    console.log(isNav2Hovered);
425  });
426
427  // Mouse leaves .nav-2
428  $(".nav-2").on("mouseleave", function () {
429    isNav2Hovered = false;
430  });
431  $(".nav-2 a").on("mouseenter", function () {
432    var contentToShow = $(this).data("content");
433	$(".gray-dd-container").removeClass('is-closed').addClass('is-open');
434    $(".gray-dd-container span").each(function () {
435      if ($(this).hasClass("content-" + contentToShow)) {
436         $(this).removeClass('is-closed').addClass('is-open');
437      } else {
438        $(this).removeClass('is-open').addClass('is-closed');
439      }
440    });
441
442    $(this).addClass("on");
443    $(".nav-2 a").not(this).removeClass("on");
444
445    // Check if the gray-dd-container is currently hidden
446    if (!isContainerShowing) {
447      $(".gray-dd-container").slideDown(200); // Slide down in 200 milliseconds
448      isContainerShowing = true; // Update the flag to indicate that the container is showing
449    }
450  });
451
452  // Use the mouseleave event on .gray-dd-container
453  $(".gray-dd-container").on("mouseleave", function () {
454    // Delay the slide up by 100 milliseconds
455    setTimeout(
456      function () {
457        // Slide up only if it's currently showing
458        if (isContainerShowing && !isNav2Hovered) {
459          $(this).slideUp(200); // Slide up in 200 milliseconds
460          $(".nav-2 a").removeClass("on");
461          isContainerShowing = false; // Update the flag to indicate that the container is hidden
462          $(".gray-dd-container").removeClass('is-open').addClass('is-closed');
463		  $(".gray-dd-container span").each(function () {
464            $(this).removeClass('is-open').addClass('is-closed');
465          });
466        }
467      }.bind(this),
468      50
469    ); // Adjust the delay time as needed
470  });
471
472  // Add a touchstart event listener to the document
473  $(document).on("touchstart", function (event) {
474    // Check if the touch event target is not within .nav-2 or .gray-dd-container
475    if (!$(event.target).closest(".nav-2, .gray-dd-container").length) {
476      isNav2Hovered = false;
477      closeGrayDDContainer();
478    }
479  });
480
481  // Add a click event listener to the document
482  $(document).on("click", function (event) {
483    // Check if the click event target is not within .nav-2 or .gray-dd-container
484    if (!$(event.target).closest(".nav-2, .gray-dd-container").length) {
485      isNav2Hovered = false;
486      closeGrayDDContainer();
487    }
488  });
489
490  // Function to close gray-dd-container
491  function closeGrayDDContainer() {
492    // Delay the slide up by 100 milliseconds
493    setTimeout(function () {
494      // Slide up only if it's currently showing
495      if (isContainerShowing && !isNav2Hovered) {
496        $(".gray-dd-container").slideUp(200); // Slide up .gray-dd-container in 200 milliseconds
497        $(".nav-2 a").removeClass("on");
498        isContainerShowing = false; // Update the flag to indicate that the container is hidden
499		$(".gray-dd-container").removeClass('is-open').addClass('is-closed');
500        $(".gray-dd-container span").each(function () {
501          $(this).removeClass('is-open').addClass('is-closed');
502        });
503      }
504    }, 50); // Adjust the delay time as needed
505  }
506
507  // Use the mouseleave event on .gray-dd-container
508  $(".gray-dd-container").on("mouseleave", function () {
509    // Prevent mouseleave event from closing the container prematurely
510    event.stopPropagation();
511  });
512});
513
514// Keyboard navigation functionality
515
516$(document).ready(function() { 
517	$(".tt-desktop-nav a").on("keydown", function(event) {
518	if (event.which === 40) {
519		event.preventDefault();
520		var targetPaneId = $(this).attr("data-toggle");
521		if (targetPaneId) {
522			$(".dropdown-pane").not("#" + targetPaneId).removeClass('is-open').addClass('is-closed');
523			$("#" + targetPaneId).removeClass('is-closed').addClass('is-open');
524			$(this).addClass("on");
525			$(".tt-desktop-nav a").not(this).removeClass("on");
526		}
527	}
528});
529
530$(".tt-desktop-nav a").on("keydown", function(event) {
531	if (event.which === 38) {
532		$(this).closest('li').find('.dropdown-pane').removeClass('is-open').addClass('is-closed');
533	}
534});
535
536$(".tt-desktop-new-subnav a").on("keydown", function(event) {
537	if (event.which === 40) {
538		event.preventDefault();
539		$(this).closest('li').find('.dropdown-pane').removeClass('is-closed').addClass('is-open');
540	}
541});
542
543$(".tt-desktop-new-subnav a").on("keydown", function(event) {
544	if (event.which === 38) {
545		$(this).closest('li').find('.dropdown-pane').removeClass('is-open').addClass('is-closed');
546	}
547});
548
549$(".nav-2 a").on("keydown", function(event) {
550	var isContainerShowing = false;
551	const dataContent = $(this).attr('data-content');
552	const selector = `.content-${dataContent}`;
553	if (event.which === 40) {
554		event.preventDefault(); 
555		$(".gray-dd-container").removeClass('is-closed').addClass('is-open');
556		$(".gray-dd-container span").each(function () {
557			if ($(this).hasClass("content-" + dataContent)) {
558				$(this).removeClass('is-closed').addClass('is-open');
559			} else {
560				$(this).removeClass('is-open').addClass('is-closed');
561			}
562		})
563		$(this).addClass("on");
564		$(".nav-2 a").not(this).removeClass("on");
565		if (!isContainerShowing) {
566		  $(".gray-dd-container").slideDown(200); 
567		  isContainerShowing = true;
568		}
569	} else if (event.which === 38) {
570		$(this).removeClass("on");
571		$(".gray-dd-container").slideUp(200);
572		isContainerShowing = false;
573		$(".gray-dd-container").removeClass('is-open').addClass('is-closed');
574		$(".gray-dd-container span").each(function () {
575            $(this).removeClass('is-open').addClass('is-closed');
576          });
577	}
578  });
579
580
581  // Function to hide .tt-desktop-subnav
582  function hideSubnav() {
583	  if (!isHovered) {
584		  $(".tt-desktop-nav a").removeClass("is-open").addClass("is-closed");
585		  $(".tt-desktop-nav > ul > li > a").removeClass("on");
586	  }
587      
588  }
589});
590
591

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.