PageSourceSearch

https://draytonhall.org/wp-content/themes/drayton-hall/js/scripts.js?v=20260925135829

js draytonhall.org collected 2026-09-25 14:00:20 UTC 12,519 bytes, 453 lines download raw bytes

1jQuery(function($){
2	
3	resizeWindow();
4	
5	scrollWindow();
6	  		
7 	$(window).resize(resizeWindow);
8	
9	$(window).scroll(scrollWindow);
10	
11	$(window).load(function(){
12		var hashtag = location.hash.replace('#','');
13		if(hashtag != '' && !$("#event-list").length){
14			$('html, body').animate({ scrollTop: $('#' + hashtag).offset().top - 100}, 1000);
15		}
16	});
17	
18	$('li.scrollto a, a.scrollto').click(function(e) {
19									  
20		e.preventDefault();
21
22		var current = window.location.href.split('#')[0];
23		var lastCharCurrent = current.substr(current.length - 1);
24		if (lastCharCurrent != '/') {
25			current = current + '/';
26		}
27		
28		var href = $(this).attr('href').split('#')[0];
29		var lastCharHref = href.substr(href.length - 1);
30		if (lastCharHref != '/') {
31			href = href + '/';
32		}
33		
34		var url = $(this).attr('href');
35		var hashtag = url.substring(url.indexOf('#')+1);
36		
37		if (current == href || href == '/') {
38			$('html, body').animate({ scrollTop: $('#' + hashtag).offset().top - 100}, 1000);
39		} else {
40			window.location = url;	
41		}
42		
43	});
44
45	if ($('#home_top_mobile .owl-carousel').length) {
46		$('#home_top_mobile .owl-carousel').owlCarousel({
47			loop:true,
48			nav:true,
49			center:true,
50			responsiveClass:true,
51			responsive:{
52				0:{
53					items:1
54				}
55			}
56		});
57	}
58
59	if ($('#home_explore .owl-carousel').length) {
60		$('#home_explore .owl-carousel').owlCarousel({
61			loop:true,
62			nav:true,
63			center:true,
64			responsiveClass:true,
65			responsive:{
66				0:{
67					items:1
68				},
69				768:{
70					items:3
71				}
72			}
73		});
74	}
75	
76	if ($('#home_collections .owl-carousel').length) {
77		$('#home_collections .owl-carousel').owlCarousel({
78			loop:true,
79			center:true,
80			animateOut:'fadeOut',
81			items:1,
82			autoplay:true,
83			autoplayTimeout:6000
84		});
85	}
86	
87	if ($('#visit_included').length) {
88		$('#visit_included .tabnav a').click(function(e) {
89			e.preventDefault();
90			var selected = $(this).attr('rel');
91			$('#visit_included a.active').removeClass('active');
92			$('#visit_included .tab.selected').hide(0, function() {
93				$(this).removeClass('selected');
94				$('#visit_included .tab.tab_' + selected).fadeIn(300).addClass('selected');
95			});
96			$(this).addClass('active');
97		});
98	}
99	
100	if ($('#levels .level .tabs').length) {
101		$('#levels .level .tabs .tabnav a').click(function(e) {
102			e.preventDefault();
103			var level = $(this).parent().parent().parent();
104			var selected = $(this).attr('rel');
105			level.find('.tabnav a.active').removeClass('active');
106			level.find('.tab.selected').hide(0, function() {
107				$(this).removeClass('selected');
108				level.find('.tab.tab_' + selected).fadeIn(300).addClass('selected');
109			});
110			$(this).addClass('active');
111		});
112	}
113	
114	if ($('#collection .tabs').length) {
115		$('#collection .tabnav a').click(function(e) {
116			e.preventDefault();
117			var selected = $(this).attr('rel');
118			$('#collection .tabnav a.active').removeClass('active');
119			$('#collection .tabs .tab.selected').hide(0, function() {
120				$(this).removeClass('selected');
121				$('#collection .tabs .tab.tab_' + selected).fadeIn(300).addClass('selected');
122			});
123			$(this).addClass('active');
124		});
125	}
126	
127	if ($('#gallery .grid').length) {
128		var $grid = $('#gallery .grid').imagesLoaded(function() {
129			$grid.masonry();
130		});		
131	}
132	
133	if ($('#image_featured').length) {
134		$('#image_featured').imagesLoaded(function() {
135			$('#image_featured .owl-carousel').owlCarousel({
136				loop:true,
137				nav:true,
138				autoWidth:true,
139				responsiveClass:true,
140				center:true,
141				items:1
142			});
143		});
144	}
145	
146	$('.grid-item.gallery_lightbox').click(function(e) {
147		e.preventDefault();
148		var startRel = $(this).attr('rel');
149		$('html,body').css('overflow','hidden');
150		$('#gallery_lightbox').fadeIn(300, function() {
151			$('#gallery_lightbox').imagesLoaded(function() {
152				$('#gallery_lightbox .owl-carousel').owlCarousel({
153					loop: true,
154					nav: true,
155					responsiveClass: true,
156					center: true,
157					responsive:{
158						0: {
159							items: 1
160						}
161					}
162				}).trigger('to.owl.carousel', startRel);
163			});										
164		});
165	});
166	
167	$('#gallery_lightbox a.close').click(function(e) {
168		e.preventDefault();
169		$('#gallery_lightbox').fadeOut(300, function() {
170			$('html,body').css('overflow','initial');									 
171		});
172	});
173													   
174	if ($('.section.accordion .item .title').length) {
175		$('.section.accordion .item .title').click(function() {
176			$(this).toggleClass('open');
177			$(this).next('.contents').slideToggle('fast');
178		});
179	}
180	
181	// promo close
182	$('#promo a.close').click(function(e) {
183		e.preventDefault();
184        $('#promo').hide(0, function() {
185			localStorage.draytonShowPromo = 1;							 
186		});
187    });
188	
189	// promo open
190	if ($('#promo').length) {
191      $(window).load(function(){
192        if(typeof(Storage) !== "undefined") {
193          // Code for localStorage/sessionStorage.
194          if (localStorage.draytonShowPromo != 1) {
195              $('#promo').show(0);
196          } 				
197        } else {
198          // Sorry! No Web Storage support..
199        }
200      });
201    }
202		 		
203	// reservation forms
204	if ($('.post .form form').length) {
205		$('.post .form form').validate({
206			debug: false,
207			errorPlacement: function errorPlacement(error, element) {
208				if (element.attr('type') == 'radio' || element.attr('type') == 'checkbox') {
209					var elementParent = element.parent();
210					error.insertBefore(elementParent);
211				} else {
212					error.insertAfter(element);
213				}
214			},
215			rules: {
216				cemail: {
217					email:true
218				}
219			},
220			submitHandler: function(form) {
221				$('.post .form').append('<p class="neutra_demi" style="margin-top:20px;font-style:italic;">Working...</p>');
222				$.post(ajax_dir + 'form-submit.php', $('.post .form form').serialize(), function(data) {
223					$('.post p').hide(0);
224					$('.post .form').html(data).fadeIn(300);
225				});	
226			}
227		});
228	}
229	
230	// newsletter form
231	if ($('.newsletter_form').length) {
232		$('.newsletter_form form').each(function() {
233			var $this = $(this);
234			$this.validate({
235				debug: false,
236				rules: {
237					cemail: {
238						required:true,
239						email:true
240					}
241				},
242				submitHandler: function(form) {
243					$.post(ajax_dir + 'subscribe.php', $this.serialize(), function(data) {
244						$this.parent().parent('.form_response').html(data).fadeIn(300);
245					});	
246				}
247			});
248		});
249	}
250	
251	// #nav mobile nav
252	$('#nav .mobile_toggle').click(function(e) {
253		e.preventDefault();
254		$('#nav .mobile_nav').slideToggle('fast');
255	});
256	$('#nav .mobile_close').click(function(e) {
257		e.preventDefault();
258		$('#nav .mobile_nav').slideToggle('fast');
259	});
260	
261	// #sticky mobile nav
262	$('#sticky .mobile_toggle').click(function(e) {
263		e.preventDefault();
264		$('#sticky .mobile_nav').slideToggle('fast');
265	});
266	$('#sticky .mobile_close').click(function(e) {
267		e.preventDefault();
268		$('#sticky .mobile_nav').slideToggle('fast');
269	});
270	
271	// events calendar
272	var PN_CALENDAR = function() {
273		var self = {
274			init: function() {
275				//***
276				jQuery.fn.life = function(types, data, fn) {
277					"use strict";
278					jQuery(this.context).on(types, this.selector, data, fn);
279					return this;
280				};
281				//***
282				jQuery('#sscal_prev_month, #sscal_next_month').life('click', function() {
283					self.redraw({'month': jQuery(this).data('month'), 'year': jQuery(this).data('year')});
284				});
285				//***
286				jQuery('#sscal_year_selector').life('change', function() {
287					jQuery('#sscal_month_selector').prop('disabled', true);
288					self.redraw({'month': jQuery('#sscal_current_month').val(), 'year': jQuery(this).val()});
289				});
290				//***
291				jQuery('#sscal_month_selector').life('change', function() {
292					jQuery('#sscal_year_selector').prop('disabled', true);
293					self.redraw({'month': jQuery(this).val(), 'year': jQuery('#sscal_current_year').val()});
294				});
295				//***
296				jQuery('.sscal_view_day').life('click', function() {
297					jQuery('#sscal_details').html('').css('margin-bottom','20px');
298					self.details({'date': jQuery(this).data('date'), 'events': jQuery(this).data('events')});
299				});
300				//***
301				jQuery('#sscal_details .sscal_event_date span').life('click', function() {
302					jQuery('#sscal_details').html('').css('margin-bottom','0');
303				});
304				return false;
305			},
306			redraw: function(values) {
307				var data = {
308					action: "sscal_action",
309					currMonth: values.month,
310					currYear: values.year
311				};
312				jQuery.post(sscal_ajax_url, data, function(response) {
313					jQuery('#sscal_ajax_wrapper').html(response);
314				});
315			},
316			details: function(values) {
317				
318				jQuery('#sscal_details').append('<div class="sscal_event_date bebas_regular">' + values.date + '<span></span></div>');
319				
320				var eventsArray = values.events;				
321				jQuery.each(eventsArray,function(i){
322					var data = {
323						action: "sscal_details_action",
324						event_id: eventsArray[i]
325					};
326					jQuery.post(sscal_ajax_details_url, data, function(response) {
327						jQuery('#sscal_details').append(response);
328					});
329					
330				});				
331			}
332		};
333		return self;
334	};
335	
336	var sscal_ajax_url = template_dir + 'functions/sscal.php';
337	var sscal_ajax_details_url = template_dir + 'functions/sscal-details.php';
338	var sscal_cal = null;
339	jQuery(function() {
340		sscal_cal = new PN_CALENDAR();
341		sscal_cal.init();
342	});
343	/************/
344		
345	$('.widget a.show_more').click(function(e) {
346		e.preventDefault();
347		$(this).hide(0);
348		$(this).parent('.widget').find('li.hidden').show(0);
349	});
350});
351
352function resizeWindow() {
353
354	var ww = $(window).width();
355			
356	if (ww > 1024) {
357		
358		$('.mobile_nav').hide(0);
359		
360		if ($('#home_top').length) {
361		
362			if ($('#promo').length) {
363				var nav = $('#nav').outerHeight();
364				var promo = $('#promo').outerHeight();
365				var total = nav + promo + 50;
366			} else {
367				var total = $('#nav').outerHeight() + 50;
368			}
369			var wh = $(window).height();
370			var colsHeight = wh - total;
371			$('#home_top .cols').css('height', colsHeight + 'px');
372		}
373		  
374	}
375	
376	if ($('.section.header .wrapper .prev').length) { 
377		$('.section.header .wrapper').imagesLoaded(function() {
378			var wrapperHeight = $('.section.header .wrapper').outerHeight();
379			$('.section.header .wrapper .prev').css('width',wrapperHeight + 'px');
380			$('.section.header .wrapper .next').css('width',wrapperHeight + 'px');
381		});
382	}
383				
384}
385
386function scrollWindow() {
387
388	var scrolltop = $(window).scrollTop();
389
390	if ($('#promo').length) {
391		var nav = $('#nav').height();
392		var promo = $('#promo').height();
393		var total = nav + promo;
394	} else {
395		var total = $('#nav').height();
396	}
397	
398	if(scrolltop >= total) {
399		$('#sticky').css({'top':'0','opacity':'1'});
400	} else {
401		$('#sticky').css({'top':'-9999px','opacity':'0'});
402	}
403			
404}
405
406/* The Great Hall Restoration */
407function startTickers() {
408  const tracks = document.querySelectorAll('.js-ticker-track');
409  if (!tracks.length) return;
410
411  tracks.forEach(track => {
412    // Clone content for seamless loop
413    const content = Array.from(track.children).map(node => node.cloneNode(true));
414    content.forEach(node => track.appendChild(node));
415
416    let trackWidth = track.offsetWidth / 2; // width of original content
417    let offset = 0;
418    const speed = 60; // pixels per second
419
420    function animate() {
421      offset += speed / 60; // assuming ~60fps
422
423      if (offset >= trackWidth) {
424        offset -= trackWidth; // wrap seamlessly
425      }
426
427      track.style.transform = `translateX(${-offset}px)`;
428      requestAnimationFrame(animate);
429    }
430
431    animate();
432
433    // Recalculate width on resize
434    window.addEventListener('resize', () => {
435      trackWidth = track.offsetWidth / 2;
436    });
437  });
438}
439
440// Initialize all tickers
441startTickers();
442
443// Fix bug for shopify-store page jumping to top on previous/next click
444document.addEventListener('click', function (e) {
445  // only pagination buttons inside the shopify-store element
446  if (e.target.closest('shopify-store .pagination-button, .shopify-store .pagination-button, #shopify-store .pagination-button')) {
447    var original = window.scrollTo;
448    window.scrollTo = function () {};       // disable it for this click
449    setTimeout(function () {                // restore right after
450      window.scrollTo = original;
451    }, 0);
452  }
453}, true); // capture phase: runs BEFORE the button's onclick

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.