PageSourceSearch

https://childrenscancernorth.org.uk/wp-content/themes/ccn/js/scripts.js?v=1790895712

js childrenscancernorth.org.uk collected 2026-10-02 10:22:53 UTC 7,941 bytes, 310 lines download raw bytes

1(function($) {
2
3
4	/*	---------------------------------------------------------------------------------------
5		Generic Responsive / Resize handler
6		---------------------------------------------------------------------------------------
7	*/
8    handle_responsive($);
9
10    $(window).resize(function() {
11        handle_responsive($);
12
13		 handleBottom($);
14    });
15
16	/*	---------------------------------------------------------------------------------------
17		Sub menu
18		---------------------------------------------------------------------------------------
19	*/
20	$('ul.sub-menu').wrap('<div class="sub-menu-wrap"></div>')
21	$('li.has-sub').append('<span></span>');
22
23	$(document).on('click', 'li.has-sub span', function(){
24		$(this).parent().toggleClass('subopen');
25		return false;
26	});
27
28	$(document).on('click', '.date-filter-list .filter-btn', function(){
29		$(this).toggleClass('selected');
30		$(this).parent().find('.filter-wrap').toggleClass('open');
31		return false;
32	});
33
34	/*	---------------------------------------------------------------------------------------
35		Fitvids plugin / used on iframes
36		---------------------------------------------------------------------------------------
37	*/
38
39	$('.videowrap, .form-embed').fitVids();
40
41	if($('.text-content iframe').length){
42		$('.text-content iframe').each(function(){
43			$(this).parent().addClass('fitvids');
44			$('.fitvids').fitVids();
45		});
46	}
47
48	/*	---------------------------------------------------------------------------------------
49		Mobile menu
50		---------------------------------------------------------------------------------------
51	*/
52	$('.menu-toggle').click(function(){
53		$('body').toggleClass('expanded menuopen');
54		return false;
55	});
56
57
58	/*	---------------------------------------------------------------------------------------
59		Sub bar menu
60		---------------------------------------------------------------------------------------
61	*/
62	$('.sub-nav-toggle').click(function(){
63		$('.sub-nav-bar').toggleClass('open');
64	});
65
66	/*	---------------------------------------------------------------------------------------
67		FAQ toggle items
68		---------------------------------------------------------------------------------------
69	*/
70	$('.faq-item > h3').click(function(){
71		$(this).parent().toggleClass('open');
72		$(this).parent().find('.faq-answer').slideToggle(500);
73	});
74
75	/*	---------------------------------------------------------------------------------------
76		Fixed menu
77		---------------------------------------------------------------------------------------
78	*/
79	$(document).on('scroll',function(){
80
81		if($(document).scrollTop() > 400 &&  $(window).outerWidth() > 1050)
82		{
83			if(!$('body').hasClass('fixedheader')){
84				$('body').addClass('fixedheader');
85			}
86		} else {
87			if($('body').hasClass('fixedheader')){
88				$('body').removeClass('fixedheader');
89			}
90		}
91
92		 handleBottom($);
93	});
94
95
96
97	/*	---------------------------------------------------------------------------------------
98		Carousels
99		---------------------------------------------------------------------------------------
100	*/
101
102	//hero
103	$('.slideselement').slick({
104		centerMode: true,
105		centerPadding: '0px',
106		slidesToShow: 1,
107		draggable: false,
108		dots: true,
109		appendDots: $('.dots-wrapper .inner'),
110		arrows: false,
111		fade: true
112	});
113
114	//carousel block
115	$('.carousel-slides').each(function(){
116
117		var n = $(this).parent().find('.slick-next');
118		var p = $(this).parent().find('.slick-prev');
119
120		$(this).slick({
121			centerMode: false,
122			slidesToShow: 1,
123			draggable: false,
124			slide: '.slide',
125			prevArrow: p,
126			nextArrow: n,
127			adaptiveHeight: true,
128			fade: true
129		});
130	});
131
132	//gallery
133	$('.gallery-slides').slick({
134		slidesToShow: 1,
135		draggable: false,
136		slide: '.slide',
137		fade: true
138	});
139
140	/*	---------------------------------------------------------------------------------------
141		Back to top
142		---------------------------------------------------------------------------------------
143	*/
144	$('.top-link').click(function(){
145		windowAnimateTo($,'body');
146		return false;
147	});
148
149
150	/*	---------------------------------------------------------------------------------------
151		Filter bar
152		---------------------------------------------------------------------------------------
153	*/
154	$('.filter-toggle').click(function(){
155		$(this).parent().toggleClass('open');
156		return false;
157	});
158
159	/*	---------------------------------------------------------------------------------------
160		Mailing list modal
161		---------------------------------------------------------------------------------------
162	*/
163
164	$(document).on('click','.ml-trigger',function(){
165		$('.ml-popup-link').hide();
166		$('body').addClass('modalopen');
167	});
168
169	$(document).on('click','.close-modal',function(){
170		$('body').removeClass('modalopen');
171		setMlCookie();
172	});
173
174	$(document).on('click','.ml-popup-link .dismiss',function(){
175		$('.ml-popup-link').hide();
176		setMlCookie();
177	});
178
179	/* Mailing list scroll */
180
181	/*	---------------------------------------------------------------------------------------
182		Cart toggle
183		---------------------------------------------------------------------------------------
184	*/
185	$('.cart-toggle').click(function(){
186	//	$('body').toggleClass('show-cart');
187		//return false;
188	});
189
190	
191	
192	
193})( jQuery );
194
195
196
197/*	---------------------------------------------------------------------------------------
198	Resize / Responsive handler
199	---------------------------------------------------------------------------------------
200*/
201function handle_responsive($)
202{
203
204	var winwidth = $(window).outerWidth();
205	var winheight = $(window).outerHeight();
206
207	//dev only
208	//document.title = winwidth +  ' / ' + winheight;
209
210	if(winwidth > 1050)
211	{
212		$('body').removeClass('fixedheader');
213	}
214
215	if($('.form-embed').length){
216
217		setTimeout(function(){ $('#etapIframe').fitVids(); console.log('frameresized');}, 2000);
218	}
219
220
221}
222
223/*	---------------------------------------------------------------------------------------
224	Animate the window to a point
225	---------------------------------------------------------------------------------------
226*/
227function windowAnimateTo($,point)
228{
229
230	disable_scroll();
231	{
232		$('html, body').stop().animate({
233			scrollTop: $(point).offset().top
234			},
235			800,
236			function() {
237			enable_scroll();
238			}
239		);
240	}
241}
242
243
244// left: 37, up: 38, right: 39, down: 40,
245// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
246var keys = [37, 38, 39, 40];
247
248function keydown(e) {
249    for (var i = keys.length; i--;) {
250        if (e.keyCode === keys[i]) {
251            preventDefault(e);
252            return;
253        }
254    }
255}
256
257function preventDefault(e) {
258  e = e || window.event;
259  if (e.preventDefault)
260      e.preventDefault();
261  e.returnValue = false;
262}
263
264function wheel(e) {
265  preventDefault(e);
266}
267
268function disable_scroll() {
269  if (window.addEventListener) {
270      window.addEventListener('DOMMouseScroll', wheel, false);
271  }
272  window.onmousewheel = document.onmousewheel = wheel;
273  document.onkeydown = keydown;
274}
275
276function enable_scroll() {
277    if (window.removeEventListener) {
278        window.removeEventListener('DOMMouseScroll', wheel, false);
279    }
280    window.onmousewheel = document.onmousewheel = document.onkeydown = null;
281}
282
283/*	---------------------------------------------------------------------------------------
284	Hide the mailing list popup if the footer is visible
285	---------------------------------------------------------------------------------------
286*/
287function handleBottom($)
288{
289    var pageheight = $(document).height() - $('.pagefooter').height();
290
291    if ($(window).height() + $(window).scrollTop() < pageheight)
292    {
293        $('.ml-popup-link').removeClass('slidedown');
294    }
295    else
296    {
297        $('.ml-popup-link').addClass('slidedown');
298    }
299}
300
301function setMlCookie()
302{
303    var d = new Date();
304	var exdays = 90;
305	var cname = 'neccr-ml-popup=1';
306	d.setTime(d.getTime() + (exdays*24*60*60*1000));
307	var expires = "expires="+ d.toUTCString();
308	document.cookie = cname + ";" + expires + ";path=/";
309}
310

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.