PageSourceSearch

https://www.theguildrestaurant.com/wp-content/themes/ob-core/js/theme-scripts.js?ver=2.4.1

js theguildrestaurant.com collected 2026-09-26 11:14:54 UTC 13,422 bytes, 365 lines download raw bytes

1/*-----------------------------------------------------------*/
2// Theme Scripts
3/*-----------------------------------------------------------*/
4
5//add Bootstrap styles to hard-to-reach WordPress places
6jQuery(document).ready(function() {
7	//comment form fields
8	jQuery('#commentform').find('input[type="text"], textarea').addClass('form-control');
9	//submit comment button
10	jQuery('#comments').find('input[type="submit"]').addClass('btn btn-default');
11	//edit post link
12	jQuery('a.post-edit-link').addClass('btn btn-default btn-xs');
13});
14
15//scroll menu
16jQuery(document).ready(function() {
17	var scrollMenu = jQuery('#scroll-menu');
18	var headerComponent = jQuery('.component.header');
19	if (headerComponent.length > 0) {
20		headerHeight = headerComponent.outerHeight();
21	} else {
22		headerHeight = 250;
23	}
24	jQuery(window).on('scroll', function() {
25		var scrollTop = jQuery(window).scrollTop();
26		if (scrollTop > headerHeight) {
27			if (Modernizr.csstransitions && Modernizr.csstransforms) {
28				scrollMenu.addClass('in');
29			} else {
30				scrollMenu.stop(true, false).fadeIn(200);
31			}
32		} else {
33			if (Modernizr.csstransitions && Modernizr.csstransforms) {
34				scrollMenu.removeClass('in');
35			} else {
36				scrollMenu.stop(true, false).fadeOut(200);
37			}
38		}
39	});
40});
41
42//deep linking
43jQuery(window).load(function() {
44	var targetID = window.location.hash
45	var targetTabTrigger = jQuery('a[data-toggle="tab"][href="'+ targetID +'"]');
46	var targetModalTrigger = jQuery('a[data-toggle="modal"][href="'+ targetID +'"]');
47	if (targetTabTrigger.length > 0) {
48		if (jQuery('body').hasClass('admin-bar')) {
49			var offset = targetTabTrigger.offset().top - 132;
50		} else {
51			var offset = targetTabTrigger.offset().top - 100;
52		}
53		jQuery(window).scrollTop(offset);
54		targetTabTrigger.trigger('click');
55	} else if (targetModalTrigger.length > 0) {
56		targetModalTrigger.first().trigger('click');
57	} else if (targetID != '') {
58		targetID = targetID == '#home-menus' ? '#menus' : targetID;
59		var target = jQuery(targetID);
60		if (target.length > 0 && jQuery('#scroll-menu').length > 0 && jQuery('#scroll-menu').is(':visible')) {
61			if (jQuery('body').hasClass('admin-bar')) {
62				var offset = target.offset().top - (jQuery('#scroll-menu').outerHeight()) - 32;
63			} else {
64				var offset = target.offset().top - (jQuery('#scroll-menu').outerHeight());
65			}
66			jQuery(window).scrollTop(offset);
67		}
68	}
69});
70
71//scroll to anchor
72jQuery(document).ready(function() {
73	jQuery('a[href*="#"]:not([href="#"]):not([data-toggle])').on('click', function(event) {
74		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
75			var target = jQuery(this.hash);
76			target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
77			if (target.length > 0 && jQuery('#scroll-menu').length > 0 && jQuery('#scroll-menu').is(':visible')) {
78				if (jQuery('body').hasClass('admin-bar')) {
79					var offset = target.offset().top - (jQuery('#scroll-menu').outerHeight()) - 32;
80				} else {
81					var offset = target.offset().top - (jQuery('#scroll-menu').outerHeight());
82				}
83				jQuery('html, body').animate({
84					scrollTop: offset
85				}, 1000);
86				return false;
87			}
88		}
89	});
90});
91
92/**
93 * Text Slider
94 */
95
96jQuery(window).load(function() {
97	var textSliders = jQuery('.text-slider-layout');
98	textSliders.each(function() {
99		var textSlider = jQuery(this);
100		var textSliderID = textSlider.attr('data-slider-id');
101		var textSliderControls = textSlider.attr('data-controls');
102		var textSliderControlNav = true;
103		var textSliderDirectionNav = false;
104		var textSliderSlideshow = textSlider.attr('data-slideshow');
105		if (textSliderSlideshow !== undefined) {
106			textSliderSlideshow = true;
107		} else {
108			textSliderSlideshow = false;
109		}
110
111		switch(textSliderControls) {
112			case 'paging':
113				textSliderControlNav = true;
114				textSliderDirectionNav = false;
115				break;
116			case 'direction':
117				textSliderControlNav = false;
118				textSliderDirectionNav = true;
119				break;
120			case 'both':
121				textSliderControlNav = true;
122				textSliderDirectionNav = true;
123				break;
124			case 'none':
125				textSliderControlNav = false;
126				textSliderDirectionNav = false;
127				break;
128		}
129		//init slider
130		textSlider.flexslider({
131			animation: 'fade',
132			animationLoop: true,
133			multipleKeyboard: true,
134			slideshow: textSliderSlideshow,
135			controlsContainer: '.controls-'+ textSliderID,
136			directionNav: textSliderDirectionNav,
137			controlNav: textSliderControlNav,
138		});
139	});
140});
141
142
143/**
144* Open table widget
145*/
146jQuery(document).ready(function() {
147	setupDatepickers();
148});
149
150function setupDatepickers(){
151	//date pickers
152	var now = new Date();
153	var currentDate = now.getDate();
154	if (currentDate < 10) { currentDate = '0' + currentDate; }
155	var currentMonth = now.getMonth()+1;
156	if (currentMonth < 10) { currentMonth = '0' + currentMonth; }
157
158	var today = currentDate + '/' + currentMonth + '/' + now.getFullYear();
159
160	jQuery('.openTableForm').each(function() {
161
162		var bookingDate = jQuery(this).find('.bs-datepicker[name="startDate"]');
163
164		bookingDate.val(today);
165
166		bookingDate.datepicker({
167			format: 'dd/mm/yyyy',
168			startDate: now,
169			autoclose: true
170		}).data('datepicker');
171	});
172
173	//mobile datepickers
174	var mobileStartDate = moment();
175
176	mobileBookingFieldString = moment(mobileStartDate).format('DD/MM/YYYY');
177	var mobileBookingForm = jQuery('.openTableForm');
178
179	mobileBookingForm.each(function() {
180		var currentForm = jQuery(this);
181		var bookingField = currentForm.find('.mobile_feedFormfieldCalendar[type="date"]');
182		var bookingDate = currentForm.find('.bs-datepicker[name="startDate"]');
183
184		bookingField.val(mobileBookingFieldString);
185
186		bookingField.on('change', function() {
187			var newBookingDateVal = jQuery(this).val();
188			var newBookingDate = moment(newBookingDateVal).format('DD/MM/YYYY');
189			bookingDate.val(newBookingDate);
190		});
191	});
192}
193
194/**
195 * Notifications
196 */
197
198//Notifications - Title & CTA layout
199jQuery(document).ready(function() {
200	notificationBars = jQuery('.ad-layout-notifications.ob_bar');
201	notificationBars.each(function() {
202		var notification = jQuery(this);
203		notification.closest('.col-sm-12').css('min-height','0px');
204		var notificationsClose = notification.find('.notifications-bar-close');
205		notificationsClose.on('click', function(event) {
206			event.preventDefault();
207			notification.toggleClass('putaway');
208			//setTimeout(function() {
209				//notification.remove();
210			//}, 310);
211			var dismissID = jQuery(this).parent().attr('data-notification-id');
212			if (dismissID) {
213				document.cookie = 'notification'+dismissID+'=closed; path=/';
214			}
215		});
216		//ie8 fix
217		if (jQuery('html').hasClass('lt-ie9')) {
218			notification.find('.ad-layout-notification > a').each(function() {
219				jQuery(this).after('<span class="ie8-notification-mask-light"></span><span class="ie8-notification-mask-dark"></span>');
220			});
221		}
222
223		var notificationsSliders = jQuery(notification).find('.flexslider');
224		notificationsSliders.each(function() {
225			var notificationsSlider = jQuery(this);
226			var notificationsSliderID = jQuery(this).attr('data-slider-id');
227			var dismissID = jQuery(this).parent().attr('data-notification-id');
228			notificationsSlider.flexslider({
229				animation: 'fade',
230				slideshow: true,
231				multipleKeyboard: true,
232				pauseOnAction: false,
233				controlsContainer: '.controls-'+notificationsSliderID,
234				controlNav: false,
235				start:function(slider) {
236					if (getCookie('notification'+dismissID) != '') {
237						slider.closest('.ad-layout-notifications').remove();
238					} else {
239						slider.closest('.ad-layout-notifications').removeClass('dismissed');
240					}
241				}
242			});
243		});
244	});
245	//track notification clicks
246	jQuery('.ad-layout-notifications.ob_bar .ad-layout-notification a').on('click',function(event){
247		var post_id = jQuery(this).parent().data('notification-id');
248		notificationClickCount(post_id);
249	});
250});
251
252function getCookie(cname) {
253    var name = cname + "=";
254    var ca = document.cookie.split(';');
255    for(var i=0; i<ca.length; i++) {
256        var c = ca[i];
257        while (c.charAt(0)==' ') c = c.substring(1);
258        if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
259    }
260    return "";
261}
262
263//Mobile Nav Tabs
264jQuery(document).ready(function(){
265	var tabContainer = jQuery('.ad-layout-tabs-container');
266	tabContainer.each(function(){
267		var tabNav = jQuery(this).find('.nav-tabs');
268		var tabLists = tabNav.find('li');
269		tabLists.on('click', function() {
270			var activeTab = jQuery(this);
271			if (activeTab.hasClass('active')) {
272				activeTab.toggleClass('open-tab');
273				tabLists.not(activeTab).toggleClass('expanded');
274			} else {
275				tabLists.removeClass('expanded');
276				tabLists.removeClass('open-tab');
277			}
278		});
279	});
280});
281
282//Quick Bar back to top
283jQuery(document).ready(function() {
284	var backToTop = jQuery('#mobile-back-to-top');
285	jQuery(window).on('scroll', function() {
286		var scrollTop = jQuery(window).scrollTop();
287		if (scrollTop > 300) {
288			backToTop.addClass('in');
289		} else {
290			backToTop.removeClass('in');
291		}
292	});
293/*
294	if (Modernizr.touch) {
295		var lastY;
296		jQuery(document).bind('touchmove', function (e){
297			var currentY = e.originalEvent.touches[0].clientY;
298			if(currentY > lastY){
299				backToTop.addClass('in');
300			} else if(currentY < lastY){
301				backToTop.removeClass('in');
302			}
303			lastY = currentY;
304		});
305	}
306*/
307	backToTop.on('click', function(event) {
308		event.preventDefault();
309		jQuery('html, body').animate({
310			scrollTop : 0
311		}, 500);
312	});;
313});
314
315/* Contact Form 7 show recaptcha */
316jQuery(document).ready(function() {
317	var contactForm = jQuery('.ad-layout-contact-form');
318	contactForm.find('input, textarea').on('click', function () {
319		contactForm.find('.contact-recaptcha').addClass('active');
320	});
321});
322
323/**
324 * Google Analytics Event Tracking
325 */
326
327jQuery(document).ready(function() {
328	//newsletter signup
329	jQuery('form[name="mc-embedded-subscribe-form"]').on('submit', function() {
330		//send event to GA tracking
331		if (jQuery(this).closest('.notifications-popover').length > 0) {
332			ga('send','event','Forms','Submit','Popover Newsletter Signup');
333		} else {
334			ga('send','event','Forms','Submit','Newsletter Signup');
335		}
336	});
337	//reservations
338	jQuery('#OT_searchWrapperAll').on('submit', 'form', function() {
339		//send event to GA tracking
340		ga('send','event','Forms','Submit','Reservations');
341	});
342	//reservations
343	jQuery('.fsnOpenTableForm').on('submit', function() {
344		//send event to GA tracking
345		ga('send','event','Forms','Submit','Reservations');
346	});
347	//contact form submissions
348	document.addEventListener( 'wpcf7mailsent', function(e) {
349		ga('send','event','Forms','Submit','Contact Form Submission');
350	}, false );
351});
352
353//IE8 placeholders
354jQuery(document).ready(function() {
355	if (!Modernizr.placeholder) {
356
357		/* HTML5 Placeholder jQuery Plugin - v2.1.1
358		 * Copyright (c)2015 Mathias Bynens
359		 * 2015-02-19
360		 */
361		!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){function b(b){var c={},d=/^jQuery\d+$/;return a.each(b.attributes,function(a,b){b.specified&&!d.test(b.name)&&(c[b.name]=b.value)}),c}function c(b,c){var d=this,f=a(d);if(d.value==f.attr("placeholder")&&f.hasClass(m.customClass))if(f.data("placeholder-password")){if(f=f.hide().nextAll('input[type="password"]:first').show().attr("id",f.removeAttr("id").data("placeholder-id")),b===!0)return f[0].value=c;f.focus()}else d.value="",f.removeClass(m.customClass),d==e()&&d.select()}function d(){var d,e=this,f=a(e),g=this.id;if(""===e.value){if("password"===e.type){if(!f.data("placeholder-textinput")){try{d=f.clone().attr({type:"text"})}catch(h){d=a("<input>").attr(a.extend(b(this),{type:"text"}))}d.removeAttr("name").data({"placeholder-password":f,"placeholder-id":g}).bind("focus.placeholder",c),f.data({"placeholder-textinput":d,"placeholder-id":g}).before(d)}f=f.removeAttr("id").hide().prevAll('input[type="text"]:first').attr("id",g).show()}f.addClass(m.customClass),f[0].value=f.attr("placeholder")}else f.removeClass(m.customClass)}function e(){try{return document.activeElement}catch(a){}}var f,g,h="[object OperaMini]"==Object.prototype.toString.call(window.operamini),i="placeholder"in document.createElement("input")&&!h,j="placeholder"in document.createElement("textarea")&&!h,k=a.valHooks,l=a.propHooks;if(i&&j)g=a.fn.placeholder=function(){return this},g.input=g.textarea=!0;else{var m={};g=a.fn.placeholder=function(b){var e={customClass:"placeholder"};m=a.extend({},e,b);var f=this;return f.filter((i?"textarea":":input")+"[placeholder]").not("."+m.customClass).bind({"focus.placeholder":c,"blur.placeholder":d}).data("placeholder-enabled",!0).trigger("blur.placeholder"),f},g.input=i,g.textarea=j,f={get:function(b){var c=a(b),d=c.data("placeholder-password");return d?d[0].value:c.data("placeholder-enabled")&&c.hasClass(m.customClass)?"":b.value},set:function(b,f){var g=a(b),h=g.data("placeholder-password");return h?h[0].value=f:g.data("placeholder-enabled")?(""===f?(b.value=f,b!=e()&&d.call(b)):g.hasClass(m.customClass)?c.call(b,!0,f)||(b.value=f):b.value=f,g):b.value=f}},i||(k.input=f,l.value=f),j||(k.textarea=f,l.value=f),a(function(){a(document).delegate("form","submit.placeholder",function(){var b=a("."+m.customClass,this).each(c);setTimeout(function(){b.each(d)},10)})}),a(window).bind("beforeunload.placeholder",function(){a("."+m.customClass).each(function(){this.value=""})})}});
362		//# sourceMappingURL=jquery.placeholder.min.js.map
363		jQuery('input, textarea').placeholder();
364	}
365});

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.