PageSourceSearch

https://prisonreformtrust.org.uk/wp-content/themes/chd/js/scripts.js?ver=7.1.1

js prisonreformtrust.org.uk collected 2026-09-24 09:30:29 UTC 8,617 bytes, 274 lines download raw bytes

1function mobileDrop() {
2	(function($) {
3		$('#mobile-menu').click(function() {
4			$('body').toggleClass('lock sidebar-open');
5			if($(this).hasClass('active')) {
6				$('#menu-text').text('Menu');
7				$('#site-navigation-nav').fadeOut().removeClass('active');
8				$('body').removeClass('fixed');
9			} else {
10				$('#menu-text').text('Close');
11				$('#site-navigation-nav').fadeIn().addClass('active');
12				$('body').addClass('fixed');
13			}
14			$(this).toggleClass('active');
15		})
16	})(jQuery);
17}
18
19function CHD_scripts() {
20	(function($) {
21
22		$(function() {
23			var root = $('html, body');
24            $('a[href*="#"]:not([href="#"])').click(function(e) {
25                if ($('.using-mouse').length && $(this).attr('href').match("^#")) {
26                    var extraHeight = 300;
27                    // if($(window).width() <= 991) {
28                    if ($('.progress-bar-header').length) {
29                        var currentExtra = extraHeight;
30                        extraHeight = $('.progress-bar-header').height() + 50;
31                    }
32                    // }
33
34                    e.preventDefault();
35                    var href = $(this).attr('href');
36                    if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
37                        if (href) {
38                            root.animate({
39                                scrollTop: ($(href).offset().top - extraHeight)
40                            }, 1000, function() {
41                                // window.location.hash = href;
42                            });
43                            return false;
44                        }
45                    }
46                }
47            });
48		});
49
50		if ($('.flex-elements-wrap').length) {
51			if ($('.flex-elements-wrap .constrained').length || $('#sidebar-menu').length) {
52		    $('.flex-elements-wrap').addClass('margins-container constrained mega');
53		  }
54		}
55
56		if ($('#search-top-nav.hidden').length) {
57			$('#search-top-nav.hidden').appendTo('#menu-main-header').removeClass('hidden');
58			$('#menu-main-header .menu-item:last').appendTo('#menu-main-header');
59		}
60
61		if ($('#search-top-nav button').length) {
62			$('#search-top-nav button').on('click', function() {
63				$('.header-search').fadeIn();
64				$('.header-search .search-form input').focus();
65			})
66			$('.close-search').on('click', function() {
67				$('.header-search').fadeOut();
68			})
69		}
70
71
72		$('.add-bug').on('click', function() {
73			if ($('.full-bug-wrap').hasClass('open')) {
74				$('.full-bug-wrap').removeClass('open').fadeOut();
75				$('.add-bug').text('Log an issue');
76			} else {
77				$('.full-bug-wrap').addClass('open').fadeIn();
78				$('.add-bug').text('Cancel');
79			}
80		})
81
82		// Let the document know when the mouse is being used
83		document.body.addEventListener('mousedown', function() {
84			document.body.classList.add('using-mouse');
85		});
86		document.body.addEventListener('keydown', function() {
87			document.body.classList.remove('using-mouse');
88		});
89
90		// Fade In
91		$('.lazy').lazyload({
92			effect : "fadeIn"
93		});
94
95		// Handle ordered list start attribute
96		$('ol[start]').each(function() {
97			var startValue = parseInt($(this).attr('start'));
98			if (!isNaN(startValue) && startValue > 1) {
99				// Reset the counter to start from the specified value
100				$(this).css('counter-reset', 'item ' + (startValue - 1));
101			}
102		});
103
104		if ($('.page-home').length > 0) {
105			$('.stacked_title_and_links').each(function() {
106				if ($(this).next().hasClass('image_link_cards')) {
107					var stacked_title_and_links_id = $(this).attr('id');
108					var image_link_cards_id = $(this).next().attr('id');
109					$('#'+ stacked_title_and_links_id + ', #' + image_link_cards_id).find('.margins-container').removeClass('margins-container');
110					$('#'+ stacked_title_and_links_id + ', #' + image_link_cards_id).wrapAll('<div class="homepage-flex-wrap flex-module margins-container" />')
111				}
112			})
113		}
114
115		if ($('.read-more-link').on('click', function() {
116			if ($(this).hasClass('expanded')) {
117				$(this).removeClass('expanded');
118				$(this).parent().parent().find('.expand-text-read-more').slideUp();
119				$(this).text('Read More +');
120				$(this).parent().parent().find('.ellipsis').css('display', 'inline');
121			} else {
122				$(this).addClass('expanded');
123				$(this).parent().parent().find('.expand-text-read-more').slideDown().css('display', 'inline');
124				$(this).text('Read Less -');
125				$(this).parent().parent().find('.ellipsis').css('display', 'none');
126			}
127		}))
128
129		if ($('.accordion-trigger').length > -1) {
130			$('.accordion-trigger').on('click', function() {
131				if ($(this).hasClass('open')) {
132					$(this).parent().find('.accordion-content').slideUp();
133					$(this).attr('aria-expanded', 'false');
134					$(this).removeClass('open');
135					$(this).find('.fake-link span').text('+ Show answer');
136				} else {
137					$(this).parent().find('.accordion-content').slideDown();
138					$(this).attr('aria-expanded', 'true');
139					$(this).addClass('open');
140					$(this).find('.fake-link span').text('- Hide answer');
141				}
142			})
143		}
144
145		$.fn.isInViewport = function() {
146		    var elementTop = $(this).offset().top;
147		    var elementBottom = elementTop + $(this).outerHeight();
148
149		    var viewportTop = $(window).scrollTop();
150		    var viewportBottom = viewportTop + $(window).height();
151
152		    return elementBottom > viewportTop && elementTop < viewportBottom;
153		};
154
155
156	})(jQuery);
157}
158
159function on_scroll(isFixed, secondTop) {
160	(function($) {
161
162		windowHeight = $(window).height();
163		scrollTop = $(window).scrollTop();
164
165		if ($('#sidebar-menu').length) {
166			var sidebarpos = $('#sidebar-menu .label').scrollTop();
167			var sidebarHeight = $('#sidebar-menu ol').height();
168			if ((scrollTop > sidebarpos + sidebarHeight + windowHeight - 200) && $(window).width() > 991) {
169				$('.back-to-nav').fadeIn();
170			} else {
171				$('.back-to-nav').fadeOut();
172			}
173		}
174
175
176		if ($("#sidebar-menu").length) {
177			var left =	$("#sidebar-menu").offset().left;
178
179			var footerVisible = $('footer').isInViewport();
180
181			if (scrollTop > 400 & ! footerVisible) {
182					$("#sidebar-menu").addClass('fixed');
183				$("#sidebar-menu").css('left', left);
184			} else if (footerVisible || scrollTop < 400) {
185				$("#sidebar-menu").removeClass('fixed');
186				$("#sidebar-menu").css('left', 0);
187			}
188		}
189
190		// if ($(window).width() > 991) {
191			var headerHeight = $('.site-header').outerHeight();
192			var secondHit = secondTop - (scrollTop + headerHeight);
193			$('.header-fix').height(headerHeight);
194			if (scrollTop > 130) {
195				$('header').addClass('fixed');
196
197				if(!isFixed) {
198					$('.header-fix').addClass('active');
199				}
200				// if ($('.toolkit-sidebar').length) {
201				// 	$('.toolkit-sidebar').addClass('scrolled');
202				// }
203			}
204			if (scrollTop < 1) {
205				$('header').removeClass('fixed');
206				if(!isFixed) {
207					$('.header-fix').removeClass('active');
208				}
209				if ($('.toolkit-sidebar').length) {
210					$('.toolkit-sidebar').removeClass('scrolled');
211				}
212			}
213			// if (scrollTop > 130) {
214			// 	$('header').addClass('fixed');
215			// }
216			// if (scrollTop < 1) {
217			// 	$('header').removeClass('fixed');
218			// }
219		// }
220
221	})(jQuery);
222}
223
224jQuery(document).ready(function() {
225	CHD_scripts();
226	mobileDrop();
227   var myDate = jQuery("#month").attr('data-date');
228
229
230jQuery('#month').datepicker({
231    yearRange: "-20:+0",
232    maxDate: '-1M',
233    changeMonth: true,
234    changeYear: true,
235    setDate: myDate,
236    showButtonPanel: false,
237    dateFormat: 'MM yy',
238    onClose: function(dateText, inst) {
239        var month = jQuery("#ui-datepicker-div .ui-datepicker-month :selected").val();
240        var year = jQuery("#ui-datepicker-div .ui-datepicker-year :selected").val();
241        jQuery(this).datepicker('setDate', new Date(year, month, 1));
242    }
243});
244   jQuery('#month').datepicker('setDate', myDate);
245	 jQuery('.ui-corner-all').on('mouseover', function() {
246		 jQuery('.ui-datepicker-prev, .ui-datepicker-next').removeClass('ui-state-hover')
247	 })
248});
249
250
251jQuery(window).scroll(function() {
252	on_scroll();
253});
254
255// Enhanced ordered list start attribute handler
256function handleOrderedListStart() {
257	jQuery('ol[start]').each(function() {
258		var startValue = parseInt(jQuery(this).attr('start'));
259		if (!isNaN(startValue) && startValue > 1) {
260			// Reset the counter to start from the specified value
261			jQuery(this).css('counter-reset', 'item ' + (startValue - 1));
262		}
263	});
264}
265
266// Run on document ready
267jQuery(document).ready(function() {
268	handleOrderedListStart();
269});
270
271// Run when content is dynamically loaded (for AJAX content)
272jQuery(document).on('DOMNodeInserted', 'ol[start]', function() {
273	handleOrderedListStart();
274});

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.