PageSourceSearch

https://www.historytoday.com/themes/custom/historytoday/js/ht-header.js?tlv09c

js historytoday.com collected 2026-09-24 08:41:14 UTC 3,428 bytes, 100 lines download raw bytes

1(function($, Drupal) {
2  "use strict";
3
4  Drupal.behaviors.header = {
5    attach: function(context, settings) {
6      /* Check if we're on a Feature page */
7      if ($(".full-width-banner").length > 0) {
8        var navfromtop = $(".full-width-banner").offset().top;
9      } else {
10        var navfromtop = $("main").offset().top;
11      }
12      /* Add region-header-mini--sticky class if the user scrolls below the main nav */
13      $(window).scroll(function() {
14        showNavCheck();
15      });
16
17      $(document).ready(function() {
18        showNavCheck();
19      });
20
21      var search = $(this).closest("header").find("#block-exposedformsearchpage-1-header");
22
23      $(window).resize(function() {
24        if ($(window).width() >= 768) {
25          // reset mobile search (if on dekstop)
26          $("#block-exposedformsearchpage-1-header").css("height", '');
27          $('#block-exposedformsearchpage-1-header').removeClass('mobile-search--open')
28
29          // reset mobile menu (if on desktop)
30          $('#block-mainmenu').css('height', '')
31          $('header').removeClass('region-header-bottom--mobile-menu-open')
32        }
33      });
34
35      function showNavCheck() {
36        if ($(window).scrollTop() > navfromtop) {
37          $(".region-header-mini").addClass("region-header-mini--sticky");
38        } else {
39          $(".region-header-mini").removeClass("region-header-mini--sticky");
40        }
41      }
42
43      // toggleMobileMenu
44      $(once("mobile-menu__navbar-toggle", ".mobile-menu__navbar-toggle")).click(context, function() {
45        var header = $(this).closest("header");
46        var contentHeight = header.find("#block-mainmenu .menu").innerHeight();
47
48        header.toggleClass("region-header-bottom--mobile-menu-open");
49
50        if (header.hasClass("region-header-bottom--mobile-menu-open")) {
51          header.find("#block-mainmenu").height(contentHeight);
52        } else {
53          header.find("#block-mainmenu").height(0);
54        }
55      });
56
57      // toggleMobileSearch
58      $(once("mobile-menu__search-button",".mobile-menu__search-button")).click(context, function() {
59        var search = $(this).closest("header").find("#block-exposedformsearchpage-1-header");
60        var contentHeight = search.find("#views-exposed-form-search-page-1").innerHeight();
61
62        search.toggleClass("mobile-search--open");
63
64        if (search.hasClass("mobile-search--open")) {
65          search.height(contentHeight);
66        } else {
67          search.height(0);
68        }
69
70        return search.height();
71      });
72
73
74      // migrated from drupal 7 - this replaces the placeholder text
75      function headersearch() {
76        var searchbox = $("#block-exposedformsearchpage-1-header #edit-keys");
77        var searchtext = "Search";
78        var submitbutton = $('#block-exposedformsearchpage-1-header #edit-submit-search');
79        searchbox.attr("value", searchtext);
80        searchbox.focus(function() {
81          if (jQuery.trim($(this).attr("value")) == searchtext) {
82            $(this).attr("value", "");
83          }
84        });
85        searchbox.blur(function() {
86          if (jQuery.trim($(this).attr("value")) == "") {
87            $(this).attr("value", searchtext);
88          }
89        });
90        submitbutton.click(function() {
91          if (searchbox.val() == searchtext) {
92            searchbox.attr("value","");
93          }
94        });
95      }
96
97      headersearch();
98    }
99  };
100})(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.