PageSourceSearch

https://www.think.gov.uk/wp-content/themes/ht-think-main/assets/js/scripts.js

js think.gov.uk collected 2026-10-04 00:26:07 UTC 3,571 bytes, 134 lines download raw bytes

1jQuery(document).ready(function (jQuery) {
2
3	jQuery('.more-filters').click(function (e) {
4		e.preventDefault();
5		jQuery('.filters-wrap').slideToggle();
6	});
7
8	// scroll to top
9	jQuery(window).scroll(function () {
10		if (jQuery(this).scrollTop() > 100) {
11			jQuery('.scrollup').fadeIn();
12		} else {
13			jQuery('.scrollup').fadeOut();
14		}
15	});
16
17	jQuery('.scrollup').click(function () {
18		jQuery("html, body").animate({
19			scrollTop: 0
20		}, 600);
21		return false;
22	});
23
24
25	jQuery('.sidebar-filter .oc-btn').click(function () {
26		var clicks = jQuery(this).data('clicks');
27		if (clicks) {
28			jQuery('.sidebar-filter .card-body').slideUp();
29		} else {
30			jQuery('.sidebar-filter .card-body').slideDown();
31		}
32		jQuery(this).data("clicks", !clicks);
33	});
34
35	jQuery('.container').fitVids();
36
37	jQuery('.match-height').matchHeight();
38
39	// Let search be restricted to age sections.
40	jQuery('#siteSearch').on('click', 'a', function (e) {
41		var destinationURL = jQuery(this).attr('href');
42		var destination = jQuery(this).text();
43		jQuery(this).closest('form').attr('action', destinationURL);
44		jQuery('#siteSearchChoice').text(destination);
45		jQuery('#s').attr('name', 'keyword');
46		e.preventDefault();
47	});
48
49	jQuery('.copyClipboard').on('click', function (e) {
50		e.preventDefault();
51		console.log('Link copied to clipboard');
52	});
53
54	// Front-end validation for comment fields.
55	if (jQuery('#comments').length) {
56
57		jQuery('#commentform').on('submit', function (e) {
58
59			if (!jQuery('#comment').val().length) {
60				e.preventDefault();
61				jQuery('#comment').addClass('is-invalid');
62				alert('Please enter a comment');
63			} else {
64				jQuery('#comment').addClass('is-valid');
65				jQuery('#comment').removeClass('is-invalid');
66			}
67
68			if (jQuery('#author').length && !jQuery('#author').val().length) {
69				e.preventDefault();
70				jQuery('#author').addClass('is-invalid');
71				alert('Please enter your name');
72			} else {
73				jQuery('#author').addClass('is-valid');
74				jQuery('#author').removeClass('is-invalid');
75			}
76
77			if (jQuery('#email').length && !jQuery('#email').val().length) {
78				e.preventDefault();
79				jQuery('#email').addClass('is-invalid');
80				alert('Please enter your email address');
81			} else {
82				jQuery('#email').addClass('is-valid');
83				jQuery('#email').removeClass('is-invalid');
84			}
85
86		})
87
88	}
89
90
91});
92
93jQuery(window).on('load resize scroll', function () {
94	if (jQuery(window).width() > 991) {
95		jQuery(".sidebar-filter .card-body").show();
96	}
97});
98
99// anchor link on accordion
100// Panel / accordian functions.
101if (jQuery('#accordion').length) {
102
103	// When a panel is shown - collapse others and update URL #.
104	jQuery('#accordion .card').on('show.bs.collapse', function (e) {
105		// Hide others.
106		jQuery('.collapse.show').collapse('hide');
107		// Update hash.
108		var datatarget = jQuery(e.target).prev().find('a').data('target');
109		window.location.hash = datatarget;
110	}).on('shown.bs.collapse', function (e) {
111		// Scroll to top when animation complete.
112		var datatarget = jQuery(e.target).prev().find('a').data('target');
113		jQuery('html, body').animate({
114			scrollTop: jQuery(jQuery(datatarget).parent()).offset().top + -10
115		}, 1000);
116	});
117
118	// When a panel is hidden - remove hash.
119	jQuery('.panel').on('hide.bs.collapse', function () {
120		window.location = window.location.href.split('#')[0];
121	})
122
123	// On load, if there's a hash then open the corresponding panel.
124	var hash = window.location.hash;
125	if (jQuery(hash).length) {
126		// Hide any open panels.
127		jQuery('.collapse.show').collapse('hide');
128		// Show requested panel.
129		jQuery(hash).collapse('show');
130	}
131
132}
133
134

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.