PageSourceSearch

https://www.nrcpd.org.uk/js/custom.js

js nrcpd.org.uk collected 2026-10-02 04:19:23 UTC 5,348 bytes, 215 lines download raw bytes

1$( document ).ready(function() {
2	
3	//initiate mobile menu
4	$('#simple-menu').sidr();
5	
6	//resize thing
7	$( window ).resize(function() {
8		$.sidr('close', 'sidr');
9		//console.log($( window ).width());
10	});
11	
12	//close side menu if anywhere else in body is clicked
13	$("body").on("click",function(e) {
14        $.sidr('close','sidr');
15    });
16	
17	//prevent clicking within side menu doing anything we dont want
18    $("#sidr").on("click",function(e) {
19        e.stopPropagation();
20    });
21	
22	//show the submenus on the mobile side menu
23	$( ".sidr ul li a.top-link" ).click(function() {
24		var mobnav = $(this).attr('id');
25		if($("."+mobnav).is(":visible")){
26			$(".sub-mobnav").slideUp();
27		} else {
28			$(".sub-mobnav").slideUp();
29			$("."+mobnav).slideToggle();
30		}
31	});
32	
33	//rotate the little arrow and show the concertina 
34	//section if there is an #anchor tag in the URL
35	var hash = window.location.hash;
36	if(hash != ""){
37		$(hash).find('.glyphicon-chevron-right').addClass('span-rotate');
38		$($(hash).parent().attr('data-target')).addClass('in');
39	}
40	
41	//rotating the little arrows in concertina content
42	$( ".clickable" ).click(function() {
43		var x = $(this).find('.glyphicon-chevron-right');
44		if(x.hasClass('span-rotate')){
45			$(document).find('.glyphicon-chevron-right').removeClass('span-rotate');
46			$(this).find('.glyphicon-chevron-right').removeClass('span-rotate');
47		} else {
48			$(document).find('.glyphicon-chevron-right').removeClass('span-rotate');
49			$(this).find('.glyphicon-chevron-right').addClass('span-rotate');
50		}
51	});
52	
53    $("#signup_news").click(function(e){
54		var email = $("#signup_email").val();
55		var name = $("#signup_name").val();
56		var reason = $("#signup_reason").val();
57		if (valid2(email, name, reason)){
58		    $.ajax({
59		        url : 'news-signup.php',
60		        type: "POST",
61		        data : { name: name, email: email, reason: reason },
62		        success:function(data) {
63		            $("#signup_email").val("");
64		            $("#signup_name").val("");
65		            $("#signup_reason").val("");
66		            alert("Thank you for registering");
67		        },
68		        error: function(data) {
69		            //if fails  
70					console.log('error ' + data);
71		        }
72		    }); 
73	    } else {
74			alert("Please complete all fields");
75	    }
76		e.stopPropagation(); 
77	});
78    
79    $(document).on('submit','#contactform',function(e){
80		$('.alert-danger').hide();
81		
82		e.preventDefault(); //STOP default action
83	    var postData = $(this).serializeArray();
84		var email = $("#email").val();
85		var name = $("#name").val();
86		var msg = $("#message").val();
87		if (valid(email, name, msg)){
88	    $.ajax({
89	        url : 'contact-request.php',
90	        type: "POST",
91	        data : postData,
92	        success:function(data, textStatus, jqXHR) {
93	            //data: return data from server
94	            $('#emailform').hide();
95				$('.alert-success').show();
96				$("#email").val("");
97				$("#name").val("");
98				$("#message").val("");
99	        },
100	        error: function(jqXHR, textStatus, errorThrown) {
101	            //if fails  
102				$('.alert-danger').show();
103	        }
104	    });
105		
106		}
107	    e.stopPropagation();
108	}); 
109	
110	//detect modal close and reset video
111	$('.modal').on('hide.bs.modal', function () {
112		$("video").each(function () { this.pause(); this.currentTime = 0.0 });
113	});
114
115	
116	  var hash = window.location.hash;
117
118	  if (hash) {
119		var $tabLink = $('a[href="' + hash + '"][data-toggle="tab"]');
120
121		if ($tabLink.length) {
122		  // Remove active class from all tab panes and nav items
123		  $('.tab-pane').removeClass('active');
124		  $('.nav-pills li').removeClass('active');
125
126		  // Add active class to the selected nav item and tab pane
127		  $tabLink.parent('li').addClass('active');
128		  $(hash).addClass('active');
129
130		  // Activate tab via Bootstrap
131		  $tabLink.tab('show');
132		}
133	  }
134	
135	$(function () {
136  $('#sidr').on('click', '.sidr-toggle', function () {
137    var $btn = $(this),
138        open = $btn.attr('aria-expanded') === 'true',
139        $sub = $('#' + $btn.attr('aria-controls'));
140
141    $btn.attr('aria-expanded', String(!open));
142    $sub.stop(true, true).slideToggle(200);
143  });
144});
145	
146});
147
148function valid(email, name, msg){
149	if(name.length){
150		//return true;
151	} else {
152		$('.alert-danger span').html("Name can't be blank");
153		$('.alert-danger').show();
154		return false;
155	}
156	
157	if(email.length){
158		//return true;
159	} else {
160		$('.alert-danger span').html("Email can't be blank");
161		$('.alert-danger').show();
162		return false;
163	}
164	
165	if (email.match(/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/)){ 
166		//return true;
167	} else {
168		$('.alert-danger span').html('Your email address is invalid, please verify your email address.');
169		$('.alert-danger').show();
170		return false;
171	}
172	
173	if(msg.length){
174		//return true;
175	} else {
176		$('.alert-danger span').html("Message can't be blank");
177		$('.alert-danger').show();
178		return false;
179	}
180	
181	return true;
182}
183
184function valid2(email, name, reason){
185	if(name.length){
186		//return true;
187	} else {
188		return false;
189	}
190	
191	if(email.length){
192		//return true;
193	} else {
194		return false;
195	}
196	
197	if (email.match(/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/)){ 
198		//return true;
199	} else {
200		return false;
201	}
202	
203	if(reason.length){
204		//return true;
205	} else {
206		return false;
207	}
208	
209	return true;
210}
211
212function emailformshow(){
213    $('#emailform').show();
214	$('.alert-success').hide();
215}

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.