PageSourceSearch

https://morleyradio.co.uk/wp-content/themes/morley-radio/js/site.js?ver=1.0.5

js morleyradio.co.uk collected 2026-10-04 00:20:23 UTC 5,907 bytes, 185 lines download raw bytes

1
2//Run in no conflict mode
3$(document).ready(function($) {	
4	
5// Prevents body scroll on mobile only (including iOS)
6// https://webflow.com/website/Lock-Body-Scroll-Including-iOS?s=body-scroll-lock
7(function () {
8    var _overlay = document.getElementById('navbarMainMenu');
9    var _clientY = null; // remember Y position on touch start
10
11    _overlay.addEventListener('touchstart', function (event) {
12        if (event.targetTouches.length === 1) {
13            // detect single touch
14            _clientY = event.targetTouches[0].clientY;
15        }
16    }, false);
17
18    _overlay.addEventListener('touchmove', function (event) {
19        if (event.targetTouches.length === 1) {
20            // detect single touch
21            disableRubberBand(event);
22        }
23    }, false);
24
25    function disableRubberBand(event) {
26        var clientY = event.targetTouches[0].clientY - _clientY;
27
28        if (_overlay.scrollTop === 0 && clientY > 0) {
29            // element is at the top of its scroll
30            event.preventDefault();
31        }
32
33        if (isOverlayTotallyScrolled() && clientY < 0) {
34            //element is at the top of its scroll
35            event.preventDefault();
36             }
37    }
38
39    function isOverlayTotallyScrolled() {
40        // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
41        return _overlay.scrollHeight - _overlay.scrollTop <= _overlay.clientHeight;
42    }
43}())
44	
45	
46//Animate fixed menu
47var startY=100;$(window).scroll(function(){checkY();});function checkY(){if($(window).scrollTop()>startY){$('header').addClass('nav-scroll',2000)}else{$('header').removeClass('nav-scroll','slow');}}
48checkY();
49
50//Element.matches polyfill
51if (!Element.prototype.matches) {
52  Element.prototype.matches = 
53  Element.prototype.matchesSelector || 
54  Element.prototype.mozMatchesSelector ||
55  Element.prototype.msMatchesSelector || 
56  Element.prototype.oMatchesSelector || 
57  Element.prototype.webkitMatchesSelector ||
58  function(s) {
59    var matches = (this.document || this.ownerDocument).querySelectorAll(s),
60        i = matches.length;
61    while (--i >= 0 && matches.item(i) !== this) {}
62    return i > -1;            
63  };
64}
65
66	
67/* ===================================
68 * Menu overlay button controls
69====================================== */
70// Set active class to change toggle button
71$('.nav-toggler').click(function () {
72   "use strict";
73   $(this).addClass('active');
74   $('body').addClass('nav-open');
75   //e.stopPropagation();
76});
77
78// Close Menu Button
79$('.close-menu').click(function (e) {
80   "use strict";
81   $('.nav-toggler').removeClass('active');
82   $('body').removeClass('nav-open');
83   $('.nav-collapse').removeClass('show');
84   e.stopPropagation();
85   e.preventDefault();
86});
87	
88// Toggle Dropdown on mobile to bypass <a> tag	
89$('li.dropdown span').click(function (e) {
90   "use strict";
91   var parent = $(this).closest('li.dropdown').toggleClass('show');
92   parent.find('ul.dropdown-menu').toggleClass('show');
93   e.stopPropagation();
94   e.preventDefault();
95});
96	
97	
98/* ===================================
99 * Initialise Radioco Player plugin
100====================================== */
101$('.radioplayer').radiocoPlayer();
102$('.play').click(function (e) {
103	window.open("https://embed.radio.co/player/7a95ee6.html","Morley Radio","menubar=no,resizable=no,width=425px,height=545px,top=0,left=0");
104	e.stopPropagation();
105	e.preventDefault();
106});
107
108	
109/* ===================================
110 * Show/Hide Arrow on Filter Dropdowns
111====================================== */
112$('.sf-input-select').change(function(e) {
113    var select = e.target;
114    var option = select.options[select.selectedIndex];
115    if (!$(option).hasClass('sf-item-0')) {
116        $(select).addClass('selected');
117    } else {
118        $(select).removeClass('selected');
119    }
120});
121	
122$('.search-filter-reset').click(function (e) {
123	$('.sf-input-select').removeClass('selected');
124	e.preventDefault();
125});
126	
127	
128/* ===================================
129 * Switch Search Results & Carousels on Search Button Click
130====================================== */
131$(document).ready(function(){
132
133	var results = document.querySelector('#programme-search-results');
134	var carousels = document.querySelector('#programmes');
135	document.addEventListener('click', function (event) {
136
137		if (event.target.matches('.searchandfilter .sf-field-submit input[type=submit]')) {
138			results.removeAttribute('hidden');
139			results.classList.remove('fadeOutDown', 'hidden');
140			results.classList.add('fadeInDown');
141			
142			carousels.setAttribute('hidden', 'true');
143			carousels.classList.remove('fadeIn');
144			carousels.classList.add('fadeOutDown', 'hidden');
145		}
146		
147		if (event.target.matches('.searchandfilter .sf-field-reset input[type=submit]')) {
148			carousels.removeAttribute('hidden');
149			carousels.classList.remove('fadeOutDown', 'hidden');
150			carousels.classList.add('fadeIn');
151			
152			results.setAttribute('hidden', 'true');
153			results.classList.remove('fadeInDown', 'hidden');
154			results.classList.add('fadeOutDown', 'hidden');
155		}
156	}, false);
157});
158
159/* ===================================
160 * Have player links open as small pop up
161====================================== */
162$('.page-template-tpl-schedule').find('.schedule-listing a').click(function (){
163    var url = $(this).attr('href');
164    if(url.indexOf('embed.') !== -1){
165        window.open(url,'windowNew','width=425, height=544');
166        return false;
167    }
168});
169
170/* ===================================
171 * Have external links open in new tab
172====================================== */
173
174$('a').each(function() {
175    var a = new RegExp('/' + window.location.host + '/');
176    if(!a.test(this.href) && this.href.indexOf('embed.') === -1 && this.href.indexOf('/') !== 0) {
177        $(this).click(function(event) {
178            event.preventDefault();
179            event.stopPropagation();
180            window.open(this.href, '_blank');
181        });
182    }
183});
184
185});

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.