PageSourceSearch

https://northumbriasport.com/sportcentral/assets/js/main.js

js northumbriasport.com collected 2026-10-02 05:45:32 UTC 14,310 bytes, 638 lines download raw bytes

1$(document).ready( function(){
2
3	_membershipSelection();
4
5	$(".date-selector").each(function(i, ele){
6
7		$(ele).css({
8			'height': '70px',
9			'overflow': 'hidden',
10			'margin-top': '24px'
11		});
12
13		$(ele).parent(".date-selector-wrapper:first").css({
14			'overflow': 'hidden',
15			'margin-top': '-22px'
16		});
17
18		if( $().bxSlider ){
19			var slider = $(ele).bxSlider({
20				touchEnabled: false,
21				slideWidth: 600,
22				minSlides: 7,
23				maxSlides: 14,
24				slideMargin: 5,
25				infiniteLoop: false,
26				pager: false,
27				controls: true,
28				slideWidth: '100px'
29            });
30
31			$(".bx-viewport").css({
32				'width': '86%',
33				'margin-left': '7%'
34			});
35		}
36
37		$(ele).parent(".date-selector-wrapper:first").children(".bx-next:first").css({
38			'width':'5%'
39		});
40
41	});
42
43	$('a').on('click', function(event) {
44		var a = new RegExp('/' + window.location.host + '/');
45		if (!a.test(this.href)) {
46			event.preventDefault();
47			event.stopPropagation();
48			window.open(this.href, '_blank');
49			return;
50		}
51	});
52
53	_facilityCharges();
54	_megaMenu();
55
56	if( typeof imagesLoaded === 'function' ){
57		$(document).imagesLoaded( function() {
58			_();
59		});
60	} else {
61		_();
62	}
63
64
65});
66
67function _membershipModify(){
68
69	if( $('form#membership').length === 0 )
70		return;
71
72	var otherContainer = $('form#membership :input[name="reasons[other]"]').parent();
73
74	$(':input[data-other]').on( 'change', function(){
75		if( $(this).is(':checked') ){
76			otherContainer.show()
77		} else {
78			otherContainer.hide()
79		}
80	});
81
82	otherContainer.hide();
83
84	if( $(':input[data-other]').is(':checked' ) )
85		otherContainer.show()
86
87}
88
89function _positionCostBox(){
90	var top = $('#m_cost_box').offset().top - parseFloat($('#m_cost_box').css('marginTop').replace(/auto/, 0));
91
92	var y = $(window).scrollTop();
93
94	// whether that's below the form
95	if (y >= top - 250) {
96		// if so, ad the fixed class
97		$('#m_cost_box').css("top", y-120);
98	} else {
99		// otherwise remove it
100		$('#m_cost_box').css("top", 0);
101	}
102}
103
104function _membershipSelection(){
105
106	var _isNorthMember = false;
107	var _selectedSports = [];
108	var _clubUpgrade = false;
109	var _adventureUpgrade = false;
110	var _payMethod = null;
111	var _isStaff, _isAssociate, _isStudent, _userType = false;
112
113	var container = $("#membership-options-container");
114	var about_option = $(".membership-opt-header.opt1");
115	var mem_option = $(".membership-opt-header.opt2");
116	var pay_option = $(".membership-opt-header.opt3");
117	var pay_proceed = $(".membership-opt-header.opt4");
118
119	if(container.length == 0)
120		return;
121
122	_positionCostBox();
123	$(window).scroll(function (event) {
124		_positionCostBox();
125	});
126
127
128	$(".membership-opt-form-reset").click(function(evt){
129		location.reload();
130		return false;
131	})
132
133	if($(container).length > 0){
134		$(".membertship-type-options .checkbox").click(function(){
135			$(".membertship-type-options .checkbox").removeClass("active");
136			$(this).addClass("active");
137
138			$(".membership-choice-box[data-opt=1]").html($(this).data("value")).addClass("selected");
139
140			if($(this).data("id") == "staff") {
141				_isStaff = true;
142				_userType = 'staff';
143			}else {
144				_isStaff = false;
145			}
146
147			if($(this).data("id") == "associate") {
148				_isAssociate = true;
149				_userType = 'associate';
150			}else {
151				_isAssociate = false;
152			}
153
154			if($(this).data("id") == "student") {
155				_isStudent = true;
156				_userType = 'student';
157			}else {
158				_isStudent = false;
159			}
160
161			$(mem_option).addClass("active");
162			$(about_option).removeClass("active");
163			$(".membership-choice-box[data-opt=2]").removeClass("hidden");
164		});
165
166		$(".membership-type-selection-box .checkbox.opt-check").click(function(){
167			var target = $(this).data("target");
168
169			if(target == "north")
170				_isNorthMember = true;
171			else
172				_isNorthMember = false;
173
174
175
176			$(".membership-details-box-upgrade").addClass("hidden");
177
178			if($(this).hasClass("active")) {
179				$(".membership-type-selection-box .checkbox").removeClass("active");
180				_isNorthMember = false;
181			}else {
182				$(".membership-type-selection-box .checkbox").removeClass("active");
183				$(this).addClass("active");
184				$(".membership-details-box-upgrade[data-type='"+target+"']").removeClass("hidden");
185			}
186
187			_selectedSports = [];
188			var _clubUpgrade = false;
189			var _adventureUpgrade = false;
190
191			_calcMembershipCost(_payMethod, _selectedSports, _isNorthMember, $(".mem_cost_total"), _userType, true);
192
193			$(".mem-confirm-btn-north").click(); // FORCE MEM CONFIRM
194			return;
195
196		});
197
198		$(".mem-sport-container .checkbox").click(function(){
199			var target = this;
200
201			if($(this).hasClass("active")) {
202				$(this).removeClass("active");
203
204				$(_selectedSports).each(function(id, ele){
205					if(ele.val == $(target).data("value")) {
206						_selectedSports.splice(id, 1);
207					}
208				})
209
210			}else {
211				$(this).addClass("active");
212
213				if($(this).data("type") == "club" && _isNorthMember) _clubUpgrade = true;
214				if($(this).data("type") == "adventure" && _isNorthMember) _adventureUpgrade = true;
215
216				_selectedSports.push(
217				{
218					ele: $(this),
219					val: $(this).data("value"),
220					type: $(this).data("type"),
221					costNorth: $(this).data("cost-north"),
222					cost: $(this).data("cost")
223				}
224				)
225			}
226
227			_calcMembershipCost(_payMethod, _selectedSports, _isNorthMember, $(".mem_cost_total"), _userType,  true);
228
229			return false;
230		});
231
232		$(".mem-confirm-btn").click(function(){
233
234			if(!_isNorthMember && _selectedSports.length == 0) {
235				alert("You must select at least one sport with your membership");
236				return;
237			}
238			var selected = $(".membership-type-selection-item .checkbox.active");
239			var data = $(selected).data("value");
240
241			var str = "";
242			if(_clubUpgrade) {
243				str += "<br /> + North Clubs Membership upgrade: ("
244
245				var count = 0;
246				$(_selectedSports).each(function (id, ele) {
247					if(ele.type == "club") {
248						str += ele.val;
249						if (count < _selectedSports.length -1)
250							str += ", ";
251					}
252					count ++;
253				});
254				str += ")";
255			}
256
257			if(_adventureUpgrade) {
258				str += "<br /> + North Adventure Membership upgrade: ("
259
260				var count = 0;
261				$(_selectedSports).each(function (id, ele) {
262					if(ele.type == "adventure") {
263						str += ele.val;
264						if (count < _selectedSports.length -1)
265							str += ", ";
266					}
267					count ++;
268				});
269				str += ")";
270			}
271
272			if(!_adventureUpgrade && !_clubUpgrade && _selectedSports.length > 0){
273				str += "<br />(";
274				var count = 0;
275				$(_selectedSports).each(function (id, ele) {
276					str += ele.val;
277					if (count < _selectedSports.length -1)
278						str += ", ";
279					count ++;
280				});
281				str += ")";
282			}
283
284			data += str;
285
286			// if(!_isStaff){
287				$("#ss-container").hide();
288			// }else{
289			// 	$("#ss-container").show();
290			// }
291
292			$(".membership-choice-box[data-opt=2]").html(data).addClass("selected");
293			$(".membership-choice-box[data-opt=3]").removeClass("hidden");
294			$(mem_option).removeClass("active");
295			$(pay_option).addClass("active");
296
297		});
298
299		$(".membership-option-box").click(function(){
300			_payMethod = $(this).data("id");
301
302			$(pay_proceed).addClass("active");
303			$(pay_option).removeClass("active");
304			$(this).addClass("active");
305
306			_calcMembershipCost(_payMethod, _selectedSports, _isNorthMember, $(".mem_cost_total"), _userType);
307
308			$(".membership-choice-box[data-opt=3]").html($(this).data("value")).addClass("selected");
309			$(".membership-choice-box[data-opt=4]").removeClass("hidden");
310
311			if(_payMethod == "ss"){
312				$(".ss_payment").removeClass("hidden");
313			}else{
314				$(".standard_payment").removeClass("hidden");
315			}
316		})
317	}
318}
319
320function _calcMembershipCost(method, sports, northMember, container, userType, bothPaymentOptions) {
321	cost = 0;
322	dd_cost = 0;
323
324	switch(userType){
325		case "staff":
326		cost = 270;
327		//dd_cost = 32.50;
328		dd_cost = 26;
329		break;
330		case "student":
331		cost = 210;
332		//dd_cost = 27.50;
333		dd_cost = 24;
334		break;
335		case "associate":
336		cost = 330;
337		//dd_cost = 36.50;
338		dd_cost = 28;
339		break;
340		default:
341		cost = 390;
342		//dd_cost = 41.50;
343		dd_cost = 32;
344		break;
345	}
346
347	var str;
348
349	if (method == null)
350		str = "£" + dd_cost.toFixed(2) + " per month / " + " £" + (cost.toFixed(2)) + " per year";
351	else if(method == 'annually')
352		str = " £" + (cost.toFixed(2)) + " per year";
353	else
354		str = "£" + dd_cost.toFixed(2) + " per month";
355
356	if(container)
357		$(container).html(str);
358	else
359		return str;
360}
361
362
363function _megaMenu() {
364
365	$('#site-navigation a').on( 'mouseover', function(){
366
367		var href     = $(this).attr( 'href' );
368		var selector = '[data-mm="' + href + '"]';
369
370		if( $(selector).length ){
371
372			if( typeof $(selector).attr( 'data-mm-ajax' ) != 'undefined' ){
373
374				$(selector).find( '[data-content]' ).load( $(selector).data('mm-ajax'), function(){
375					_toggleDisplayedMegaMenu( selector, href );
376					$(selector).removeAttr( 'data-mm-ajax' );
377				});
378
379			} else {
380				_toggleDisplayedMegaMenu( selector, href );
381			}
382		}
383	});
384
385}
386
387function _toggleDisplayedMegaMenu( selector, href ){
388
389	$(selector).slideDown( 100, function(){
390
391		$(selector).find('.mega-menu-close').on( 'click', function(){
392			$(selector).slideUp( 50 );
393		});
394
395		$('.site-main, #site-navigation a[href!="'+href+'"]').on( 'mouseover', function(){
396			$(selector).slideUp( 50 );
397		});
398
399	});
400
401}
402
403function _equiHeight(){
404
405	$('.equiheight').each( function(){
406
407		var heights   = new Array,
408		tolerances    = new Array,
409		heightContent = 0;
410
411		$(this).children().each( function(){
412
413			$(this).css( 'height', 'auto' );
414
415			var width  = $(this).outerWidth(),
416			width_low  = width-1,
417			width_high = width+1;
418
419			var f;
420			for( var t = 0; t < tolerances.length; t++ ){
421
422				if( width >= tolerances[t].width_low && width <= tolerances[t].width_high ){
423
424					f = t;
425					$(this).data( 'equiheight', t );
426					if( $(this).outerHeight() > heights[t] || typeof heights[t] == 'undefined' ){
427						heights[t] = $(this).outerHeight();
428					}
429					continue;
430
431				}
432
433			};
434
435			if( typeof f == 'undefined' ){
436				tolerances.push({ width_low: width_low, width_high: width_high, width: width });
437				heights.push( $(this).outerHeight() );
438				$(this).data( 'equiheight', tolerances.length - 1 );
439			}
440
441		});
442
443		$(this).children().each( function(){
444			$(this).css('height', heights[$(this).data( 'equiheight' )] );
445		});
446
447	});
448
449};
450
451function _bxSlider(){
452
453    function bannerTypeit(banner){
454
455        var mode = banner.attr('data-banner-typeit');
456        if( typeof mode === 'undefined' || mode.length === 0 ){
457            return;
458        }
459
460        var container = banner.find( '.banner-content');
461        container.css({
462            height: container.outerHeight()
463
464        })
465
466        if( mode === 'all' ){
467            mode = 'title,content';
468        }
469        mode = ',' + mode + ',';
470
471        if( mode.indexOf( ',title', ) > -1 ){
472
473            var tags = [
474            'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
475            ];
476
477            for( var t in tags ){
478                container.children(tags[t]).each(function (index, node){
479                    archTypeit($(node), 150); 
480                }); 
481            }
482        }
483
484
485        if( mode.indexOf( ',content', ) > -1 ){
486            container.children('p').each(function (index, node){
487                archTypeit($(node), 20); 
488            }); 
489        }
490    }
491
492    $('.banners').bxSlider({
493      touchEnabled: false,
494      'selector': '.banner',
495      'useCSS': false,
496      'auto': true,
497      'pause': 8000,
498      onSliderLoad: function(){
499        $('.banners > .banner .banner-image').show();
500        bannerTypeit($('.banner[aria-hidden="false"]'));
501    },  
502    onSliderAfter: function(){
503        bannerTypeit($('.banner[aria-hidden="false"]'));
504    },
505});
506
507}
508
509/**
510 *
511 *
512 * @return {[type]} [description]
513 */
514 function _facilityCharges(){
515
516 	if( $('#facility-charges').length == 0 )
517 		return;
518
519	// var speed = 500;
520
521	$('#facility-charges [data-facility-additional]').hide();
522	$('#facility-charges [data-facility]').css('cursor','pointer');
523
524	$('body').on( 'click', '#facility-charges [data-facility]', function(){
525
526		var facilityId = $(this).data( 'facility' );
527
528		if( $(this).hasClass( 'active' ) ) {
529			$('#facility-charges [data-facility-additional=' + facilityId + ']').hide();
530			$(this).removeClass( 'active' );
531		} else {
532			$('#facility-charges [data-facility-additional!=' + facilityId + '].active').trigger( 'click' )
533			$(this).addClass( 'active' );
534			$('#facility-charges [data-facility-additional=' + facilityId + ']').show();
535		}
536
537	});
538
539}
540
541
542function _headerPosition( header_height ){
543
544	$('body').addClass( 'header-fixed' );
545	$('.site-header').css('position','fixed' );
546	$('body').css( 'paddingTop', $('.site-header').outerHeight() );
547
548	var height = $(window.top).height() - ( $('.header-top').outerHeight(true) + $('.header-middle').outerHeight(true) );
549
550	if( height > $(window.top).height() ){
551		$('#site-navigation').removeClass( 'scroll' ).css({
552			'max-height': 'none',
553		});
554	} else {
555		$('#site-navigation').addClass( 'scroll' ).css({
556			'max-height': height,
557		});
558	}
559
560};
561
562
563/**
564 *
565 *
566 */
567 function _navigation(){
568
569 	_headerPosition( $('.site-header').outerHeight(true)  );
570 	$(window).on( 'resize scroll hidden.bs.collapse', function(){
571 		_headerPosition( $('.site-header').outerHeight(true) )
572 	});
573
574 	$(window).on( 'hidden.bs.collapse', function(){
575 		$('#site-navigation li ul').removeClass( 'show' );
576 		$('#site-navigation li .dd-toggle').text( 'Show' );
577 	});
578
579 	$('#site-navigation li ul').each( function(){
580 		var dropdown = $(this);
581 		var toggle = $('<span class="dd-toggle">Show</span>');
582
583 		toggle.insertBefore( dropdown );
584 		toggle.click( function(){
585 			dropdown.toggleClass('show').promise().done(function(){
586 				if( dropdown.hasClass( 'show' ) ){
587 					toggle.text( 'Hide' );
588 				} else {
589 					toggle.text( 'Show' );
590 				}
591 			});
592
593 		});
594
595 	});
596
597 };
598/**
599 *
600 *
601 */
602 function _activities(){
603
604 	if( $('.activities-listing').length === 0 )
605 		return;
606
607 	$( '.activity-header' ).on( 'click', function(){
608
609 		var header = $(this);
610 		var target = $(this).closest( '.activity' ).find('.activity-detail');
611
612 		target.stop().slideToggle().promise().done(function(){
613 			if( target.is(':visible' ) ){
614 				header.addClass( 'active' );
615 			} else {
616 				header.removeClass( 'active' );
617 			}
618
619 		});
620 	});
621
622 };
623
624
625 function _(){
626
627 	_navigation();
628 	_bxSlider();
629 	_activities();
630 	_membershipModify();
631
632 	if( $('.equiheight').length > 0 ) {
633 		_equiHeight();
634 		$(window).resize(function() {
635 			_equiHeight();
636 		});
637 	}
638 }

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.