PageSourceSearch

https://www.theshowtimesmagazine.com/assets/33441b5c/javascripts/theme.js

js theshowtimesmagazine.com collected 2026-09-26 09:02:28 UTC 5,095 bytes, 155 lines download raw bytes

1//#########################################################################
2// 
3// THEME.JS
4// 
5//#########################################################################
6
7
8//============================================================
9//  Header Height
10//============================================================
11
12(function() {
13  var html = document.getElementsByTagName('html')[0];
14  function siteHeaderHeight() {
15    var siteHeaderHeight = document.getElementsByClassName('site-header')[0].offsetHeight;
16    html.setAttribute('style','--siteHeaderHeight: '+siteHeaderHeight+'px');
17  }
18  siteHeaderHeight();
19  window.addEventListener('resize', function(){
20    html.classList.remove('has-scrolled');
21    siteHeaderHeight();
22  });
23})();
24
25
26//============================================================
27//  Has Scrolled
28//============================================================
29
30(function() {
31  var html = document.getElementsByTagName('html')[0];
32  var siteHeader = document.getElementsByClassName('site-header')[0];
33  var siteHeaderHeight = document.getElementsByClassName('site-header')[0].offsetHeight;
34  var lastScrollTop = 0;
35  var scrollClass = 'has-scrolled';
36  var scrollClassUp = 'has-scrolled-up';
37  var scrollClassDown = 'has-scrolled-down';
38  window.addEventListener('scroll', function(){ 
39    st = window.pageYOffset;
40    if (st > lastScrollTop){
41        html.classList.add(scrollClassDown);
42        html.classList.remove(scrollClassUp);
43        siteHeader.classList.add(scrollClassDown);
44        siteHeader.classList.remove(scrollClassUp);
45    } else {
46        html.classList.add(scrollClassUp);
47        html.classList.remove(scrollClassDown);
48        siteHeader.classList.add(scrollClassUp);
49        siteHeader.classList.remove(scrollClassDown);
50    }
51    if (st >= siteHeaderHeight){
52        html.classList.add(scrollClass);
53        siteHeader.classList.add(scrollClass);
54    } else {
55        html.classList.remove(scrollClass);
56        html.classList.remove(scrollClassUp);
57        html.classList.remove(scrollClassDown);
58        siteHeader.classList.remove(scrollClass);
59        siteHeader.classList.remove(scrollClassUp);
60        siteHeader.classList.remove(scrollClassDown);
61
62    }
63    lastScrollTop = st <= 0 ? 0 : st;
64  });
65})();
66
67
68//============================================================
69//  Nav active
70//============================================================
71
72function navActive() {
73  var current = location.href;
74  var anchor = document.querySelectorAll('.nav a');
75  var activeClass = 'active';
76
77  for (var i = 0; i < anchor.length; i++) {
78    anchor[i].classList.remove(activeClass);
79    anchor[i].setAttribute('aria-current','');
80    if(anchor[i].href == current) {
81       anchor[i].classList.add(activeClass);
82       anchor[i].setAttribute('aria-current','page');
83    }
84  }
85}
86
87(function() {
88  navActive();
89})();
90
91
92//============================================================
93//  Navbar toggle
94//============================================================
95
96(function() {
97  var html = document.getElementsByTagName('html')[0];
98  var navbarCollapse = document.getElementById('navbarSupportedContent');
99  var navbarOpenClass = ('navbar-open');
100  $(navbarCollapse).on('show.bs.collapse', function () {
101    this.classList.add(navbarOpenClass);
102    html.classList.add(navbarOpenClass);
103    navbarCollapse.addEventListener('click', function(e){ 
104      if (e.target !== this)
105      return;
106      $(navbarCollapse).collapse('hide');
107    });
108  });
109  $(navbarCollapse).on('hide.bs.collapse', function () {
110    this.classList.remove(navbarOpenClass);
111    html.classList.remove(navbarOpenClass);
112  });
113})();
114
115
116//============================================================
117//  Object Fit Fallback
118//  Must include .bg-* (or the deprecated .image-*) styles from _images.scss partial
119//============================================================
120
121(function() {
122  if('objectFit' in document.documentElement.style === false) {
123    var objectFitContainer = document.querySelectorAll('[class*=" bg-cover"], [class^="bg-cover"], [class*=" bg-contain"], [class^="bg-contain"], [class*=" image-"], [class^="image-"]');
124    for (var i = 0; i < objectFitContainer.length; i++) {
125      var obj = objectFitContainer[i];
126      var img = obj.querySelector('img');
127      if(obj.contains(img)) {
128        if (img.hasAttribute('data-src')) {
129          var imgSrc = img.getAttribute('data-src');
130        } else {
131          var imgSrc = img.getAttribute('src');
132        }
133        obj.setAttribute('style','background-image: url('+imgSrc+')');
134        img.setAttribute('style','opacity: 0');
135      }
136    }
137  }
138})();
139
140
141//============================================================
142//  Loader
143//============================================================
144
145(function() {
146  var html = document.getElementsByTagName('html')[0];
147  window.addEventListener('load',function(){
148    // html.classList.add('site-loaded');
149    // html.classList.remove('site-loading');
150
151      // for menu animation
152	  html.classList.add('menu-loaded');
153	  html.classList.remove('menu-loading');
154  });
155})();

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.