1var showPageStats = true; 2var scrollingOffset = 130;//make header squish height data- ? 3var pushLast = false; 4var docReady; 5$( document ).ready(function() { 6 if( $('body').hasClass('manageable') ){ 7 docReady = (Date.now()-loadStart)/1000; 8 } 9}); 10 11$(function() { 12 if( $('#postcode_lookup').length ){ 13 IdealPostcodes.PostcodeLookup.setup({ 14 apiKey: "ak_mmaracx7lUDDIO3N0n95cBcuGfbts", 15 context: "#postcode_lookup", 16 outputFields: { 17 line_1: "#address-1", 18 line_2: "#address-2", 19 line_3: "#address-3", 20 post_town: "#town-city", 21 county: "#county-region", 22 postcode: "#postcode", 23 country: "#country", 24 }, 25 onAddressesRetrieved: function(data){ 26 $(".select.alu").remove(); 27 $(".idpc-select-container").wrap("<div class=\"select alu\"></div>"); 28 }, 29 onSearchError: function(){ 30 31 }, 32 onAddressSelected: function(elem,index){ 33 $('#country').val('UK'); 34 $('.hider').removeClass('hider'); 35 $('#man-add').hide(); 36 console.log(elem); 37 }, 38 }); 39 if($("#getaddress_button").length){ 40 $( "#getaddress_button").addClass( "button" ); 41 } 42 $('#man-add').on('click',function(e){ 43 e.preventDefault(); 44 $('.hider').removeClass('hider'); 45 $(this).hide(); 46 }) 47 48 $('#donation-form').on('submit',function(){ 49 $('.buttonload').addClass('buttonload--loading').html(''); 50 }); 51 $('#fundraise-form').on('submit',function(){ 52 $('.buttonload').addClass('buttonload--loading').html(''); 53 }); 54 } 55 //site specific 56 $('.is-datepicker').datepicker({ 57 changeMonth: true, 58 changeYear: true, 59 yearRange: "-75:+0", 60 dateFormat: "dd/mm/yy", 61 }); 62 63 //user gallery 64 if(document.getElementById("gal-send")){ 65 if( !window.URL ){ 66 document.getElementById('img-share').innerHTML = '<p class="h2-style">We are sorry :(</p><p class="page-lead">Unfortunately your browser does not support this feature, make sure you are using the latest version of your favourite browser to protect your online security!</p>'; 67 } 68 var blobArray = []; 69 //file uploader resizing 70 function handlePreUpload() { 71 var fileCountProc = 0; 72 const resizedFiles = []; 73 const uiOP = document.getElementById("gal-op"); 74 const uiSpin = document.getElementById("gal-frm-spin"); 75 const uiSpinOP = document.getElementById("gal-frm-spin-op"); 76 const maxSize = 1600;//get from data var 77 if (!this.files.length) { 78 uiOP.innerHTML = "<p>No files selected!</p>"; 79 } else { 80 uiOP.innerHTML = ""; 81 let nBytes = 0, 82 oFiles = this.files, 83 nFiles = oFiles.length; 84 for (let nFileId = 0; nFileId < nFiles; nFileId++) { 85 nBytes += oFiles[nFileId].size; 86 } 87 let sOutput = nBytes + " bytes"; 88 const aMultiples = ["Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"]; 89 for (nMultiple = 0, nApprox = nBytes / 1024; nApprox > 1; nApprox /= 1024, nMultiple++) { 90 sOutput = nApprox.toFixed(3) + " " + aMultiples[nMultiple];// + " (" + nBytes + " bytes)"; 91 } 92 uiOP.innerHTML = '<p class="ul-summary">' + nFiles + " files selected (" + sOutput + " total size)</p>"; 93 const list = document.createElement("ul"); 94 list.className = 'ul-thumbs'; 95 uiOP.appendChild(list); 96 //console.log('start proc'); 97 uiSpinOP.innerHTML = 'Processing Images'; 98 uiSpin.classList.add("run"); 99 const procTotal = this.files.length; 100 const procNo = 6;//limit to 101 var procSkipped = 0; 102 for (let i = 0; i < procNo; i++) { 103 if (this.files[i].type.match('image.*')) { 104 const imgName = this.files[i].name; 105 const imgSize = ((this.files[i].size/1024)/1024).toFixed(3); 106 const img = document.createElement("img"); 107 img.src = URL.createObjectURL(this.files[i]); 108 img.onload = function() { 109 var imgWidth = this.width; 110 var imgHeight = this.height; 111 //console.log(imgName+": "+imgWidth+"px/"+imgHeight+"px "+"("+imgSize+"Mb)"); 112 var canvas = document.createElement('canvas'); 113 if (imgWidth > imgHeight) { 114 if ( imgWidth > maxSize ) { 115 imgHeight *= maxSize/imgWidth; 116 imgHeight = Math.round(imgHeight); 117 imgWidth = maxSize; 118 } 119 }else{ 120 if ( imgHeight > maxSize ) { 121 imgWidth *= maxSize/imgHeight; 122 imgWidth = Math.round(imgWidth); 123 imgHeight = maxSize; 124 } 125 } 126 //console.log('Resize: '+imgWidth+'/'+imgHeight); 127 canvas.width = imgWidth; 128 canvas.height = imgHeight; 129 canvas.getContext("2d").drawImage(img, 0, 0, imgWidth, imgHeight); 130 canvas.toBlob(function(blob){ 131 var rImg = {name: imgName, image: blob} 132 resizedFiles.push(rImg); 133 const li = document.createElement("li"); 134 list.appendChild(li); 135 const imgTN = document.createElement('img'); 136 const imgTNUrl = URL.createObjectURL(blob); 137 imgTN.onload = function() { 138 URL.revokeObjectURL(imgTNUrl); 139 fileCountProc++; 140 if (fileCountProc == ( procTotal - procSkipped )) { 141 //console.log('end proc'); 142 blobArray = resizedFiles; 143 uiSpinOP.innerHTML = 'Completed'; 144 uiSpin.classList.remove("run"); 145 document.getElementById('GalUp').innerHTML = "Change Photos"; 146 } 147 }; 148 imgTN.src = imgTNUrl; 149 li.appendChild(img); 150 const info = document.createElement("span"); 151 info.innerHTML = imgName + ": (" + imgSize + "Mb)"; 152 li.appendChild(info); 153 },'image/jpeg',0.7); 154 URL.revokeObjectURL(this.src); 155 } 156 }else{ 157 procSkipped++; 158 } 159 } 160 } 161 } 162 document.getElementById("GalImg").addEventListener("change", handlePreUpload, false); 163 //form actions 164 $("#gal-send").validate(); 165 $('#GalUp').on('click',function(e){ 166 e.preventDefault(); 167 document.getElementById('GalImg').click(); 168 }); 169 $('#gal-send').submit(function(e){ 170 e.preventDefault(); 171 const uiSpin = document.getElementById("gal-frm-spin"); 172 const uiSpinOP = document.getElementById("gal-frm-spin-op"); 173 const errorOp = document.getElementById('error-op'); 174 errorOp.innerHTML = ''; 175 errorOp.classList.remove('show'); 176 //console.log('start upload'); 177 uiSpinOP.innerHTML = 'Uploading Images'; 178 uiSpin.classList.add("run"); 179 const fd = new FormData(); 180 fd.append( "Nonce", document.getElementById('Nonce').value ); 181 fd.append( "g-recaptcha-response", document.getElementById('g-recaptcha-response').value ); 182 fd.append( "UserName", document.getElementById('UserName').value ); 183 fd.append( "UserEmail", document.getElementById('UserEmail').value ); 184 fd.append( "GalleryName", document.getElementById('GalleryName').value ); 185 const imageNo = blobArray.length; 186 //console.log(imageNo+" resized images"); 187 for (let i = 0; i < imageNo; i++ ){ 188 fd.append("GalImg[]", blobArray[i].image, blobArray[i].name); 189 //console.log(blobArray[i].name + " appended"); 190 } 191 $.ajax({ 192 type: 'post', 193 url: '/includes/Functions/forms_ajax/handle-u-gal.php', 194 data: fd, 195 cache: false, 196 processData: false, 197 contentType: false, 198 dataType: "json", 199 success: function(r) { 200 //alert(r.success); 201 uiSpinOP.innerHTML = 'Completed'; 202 uiSpin.classList.remove("run"); 203 //console.log('end upload'); 204 if ( r.success == 1 ) { 205 document.getElementById('img-share').innerHTML = '<p class="h2-style">Thank You <i class="tvw-heart"></i></p><p class="page-lead">Your photos will appear in the Supporter's Gallery once they have been checked by a human being!</p>'; 206 } else { 207 var eop = '<p>Something went wrong'; 208 if ( r.error.length ) { 209 for (let i = 0; i < r.error.length; i++ ) { 210 eop += '<br>' + r.error[i]; 211 } 212 } 213 eop += '</p>'; 214 errorOp.innerHTML = eop; 215 errorOp.classList.add('show'); 216 } 217 } 218 }); 219 }); 220 } 221 222 //donation forms 223 $('#UserType_1').on('change',function(){ 224 if( $(this).is(':checked') ){ 225 $('#giftaid-c').removeClass('hide'); 226 } 227 }); 228 $('#UserType_2').on('change',function(){ 229 if( $(this).is(':checked') ){ 230 $('#giftaid-c').addClass('hide');
231 $('#GiftAid').prop('checked',false); 232 } 233 }); 234 $('#isFundraised').on('change',function(){ 235 if( $(this).is(':checked') ){ 236 $('#giftaid-c').addClass('hide'); 237 $('#GiftAid').prop('checked',false); 238 } else { 239 $('#giftaid-c').removeClass('hide'); 240 } 241 }); 242 243 if( $('.n-con').length ) { 244 function doMenuStick() { 245 var stickAt = 240; 246 if( $(window).scrollTop() > stickAt ) { 247 $('.n-con').addClass('stuck'); 248 $('#pop-logo').addClass('stuck'); 249 $('#search-box').addClass('stuck'); 250 } else { 251 $('.n-con').removeClass('stuck'); 252 $('#pop-logo').removeClass('stuck'); 253 $('#search-box').removeClass('stuck'); 254 } 255 } 256 $(window).on( 'scroll', function() { 257 //console.log( $(this).scrollTop() ); 258 doMenuStick() 259 }); 260 $(window).on( 'resize', function() { 261 //console.log( $(this).scrollTop() ); 262 doMenuStick() 263 }); 264 doMenuStick() 265 } 266 //portal style link sections 267 $('.manageable .quick-links .column .maf-content').click(function(){ 268 var theUrl = $(this).find('.button').attr('href'); 269 if( !theUrl.trim() ) { 270 return; 271 } else { 272 if( theUrl.match( /^http/ ) ) { 273 window.open( theUrl, "_blank" ); 274 } else { 275 window.location.href = theUrl; 276 } 277 } 278 }); 279 $('.manageable .three-buttons .column').click(function(){ 280 $(this).find('a').first().click(); 281 }); 282 283 //concertina 284 $('.manageable .concertina-section .maf-cs-trigger').on('click',function(){ 285 var $this = $(this); 286 $this.toggleClass('active'); 287 $this.next().slideToggle(); 288 }); 289 //make filters single 290 $('select.single-filter').on('change', function(){ 291 var $this = $(this); 292 var tid = $this.attr('id'); 293 var tform = $this.parents('form'); 294 tform.find('select').each(function(){ 295 if( $(this).attr('id') != tid ){ 296 $(this).val(0); 297 } 298 }); 299 tform.submit(); 300 }); 301 302 if( $('#maf-btn-dwn').length ){ 303 $('#maf-btn-dwn').on('click', function(e) { 304 var where = $(this).parents('section').next().offset().top; 305 TweenMax.to( window, 1, { scrollTo:{ y: where, ease: Power3.easeOut } } ).delay(0.2); 306 }); 307 } 308 if($('body').hasClass('manageable')){ 309 $('.maf-content i').html(function (i, html) { 310 return html.replace(/ /g, ''); 311 }); 312 } 313 //this could be quite useful to keep 314 if( $('.media-item.product .p-content').length ) { 315 $('.media-item.product .p-content input[type="image"]').attr('value', 'Buy Now').attr('type', 'submit'); 316 $('.media-item.product .p-content select').wrap('<div class="select"></div>'); 317 } 318 319 if( $('body.manageable .blog-body img[alt], body.manageable p.figure img[alt]').length ) { 320 $('body.manageable .blog-body img[alt], body.manageable p.figure img[alt]').each(function(){ 321 var $this = $(this); 322 if( !$this.parent('figure').length) { 323 var figc = $this.attr('alt'); 324 if(figc){ 325 $this.wrap('<figure></figure>'); 326 $this.after('<figcaption>'+figc+'</figcaption>'); 327 } 328 } 329 }); 330 } 331 if( $('body.manageable .blog-body blockquote').length ) { 332 $('body.manageable .blog-body blockquote p').each(function(){ 333 var $this = $(this); 334 $this.wrapInner( '<q></q>'); 335 }); 336 } 337 338 //animations 339 if( $('body.manageable').length ) { 340 var ctrlr = new ScrollMagic.Controller(); 341 var tl = new TimelineMax(); 342 TweenMax.set("#maf-h-bg", {width:"100%"}); 343 tl.to("#maf-h-bg", 1, {backgroundPosition: "50% 300px", autoAlpha: 0, width: "100%", ease: Linear.easeNone}); 344 new ScrollMagic.Scene({triggerElement: "#maf-nav-head",triggerHook: 0, duration: "70%",offset: 10}) 345 .setTween(tl) 346 .addTo(ctrlr); 347 } 348 349 //content 350 if(pushLast){ 351 $('section.two-column .column .maf-content').each(function(){ 352 $this = $(this); 353 if( $this.find('p:last-child').find('a.button').length !== 0){ 354 $this.addClass('push-last'); 355 } 356 }); 357 } 358 //header 359 if( $('.header-split').length ){ 360 function doSubNav() { 361 var snOffset = 100;//header height 362 var targ = $('#maf-s-nav'); 363 //console.log($(window).scrollTop() + ' - ' + parseInt( $('#maf-hh-dock').offset().top ) ); 364 if( ( $(window).scrollTop() + snOffset ) > parseInt( $('#maf-hh-dock').offset().top ) ) { 365 targ.addClass('stuck'); 366 } else { 367 targ.removeClass('stuck'); 368 } 369 } 370 $(window).on( 'scroll', function() { 371 //console.log( $(this).scrollTop() ); 372 doSubNav(); 373 }); 374 $(window).on( 'resize', function() { 375 //console.log( $(this).scrollTop() ); 376 doSubNav(); 377 }); 378 doSubNav(); 379 } 380 //header squish 381 if( $('.maf-squish').length ){ 382 var homeOnly = false;
383 var t = $('#maf-nav-head'); 384 var w = $('#maf-nav-head').data('maf-sq-at'); 385 var phero = $('.is-hero:first'); 386 var hl = $('#hero-logo'); 387 var bt = $('#page-con'); 388 function squishHead(){ 389 if( $(this).scrollTop() > w ) { 390 if( !t.hasClass('squish') ) { 391 t.addClass('squish'); 392 phero.addClass('squish'); 393 hl.addClass('squish'); 394 bt.addClass('squish'); 395 } 396 }else{ 397 if( t.hasClass('squish') ) { 398 t.removeClass('squish'); 399 phero.removeClass('squish'); 400 hl.removeClass('squish'); 401 bt.removeClass('squish'); 402 } 403 } 404 } 405 if( homeOnly ){ 406 if( $('body').hasClass('is-home') ) { 407 $(window).on( 'scroll', function() { 408 squishHead(); 409 }); 410 squishHead(); 411 }else{ 412 t.addClass('squish'); 413 hl.addClass('squish'); 414 bt.addClass('squish'); 415 } 416 }else{ 417 $(window).on( 'scroll', function() { 418 squishHead(); 419 }); 420 squishHead(); 421 } 422 } 423 424 //search box 425 $('#dosearch, #dosearch-h').on('click',function(){ 426 //console.log('clicked'); 427 var t = $(this); 428 var tp = t.parents('.search-box'); 429 console.log(tp); 430 if(tp.hasClass('on')){ 431 if(tp.find('input.search-term').val()){ 432 tp.find('form').submit(); 433 console.log('submit'); 434 return false; 435 }else{ 436 if(tp.hasClass('collapse')){ 437 tp.removeClass('on'); 438 } 439 } 440 }else{ 441 if(tp.hasClass('collapse')){ 442 tp.addClass('on'); 443 } 444 } 445 }); 446 $('.input#SearchTerm,.input#SearchTermH,input#search-blog').keypress(function(e) { 447 if(e.which == 13) { 448 $('form#searchform').submit(); 449 return false; 450 } 451 }); 452 453 //hero check 454 var hero = $('main section:first').hasClass('is-hero'); 455 if( !hero ){ 456 $('main').addClass('no-hero'); 457 } 458 459 //touch detection 460 $(window).on('touchstart', function touched() { 461 $('body').addClass('is-touch'); 462 $(window).off('touchstart', touched); 463 }); 464 465 //collapse empty headers 466 $('body.manageable .header').each(function(){ 467 var $this = $(this); 468 var targ = $this.children('.maf-content'); 469 if( !$.trim( targ.html() ) ) { 470 $this.parents('section').addClass('maf-h-c'); 471 }else{ 472 $this.parents('section').addClass('maf-h-h'); 473 } 474 }); 475 $('body.manageable .footer').each(function(){ 476 var $this = $(this); 477 var targ = $this.children('.maf-content'); 478 if( !$.trim( targ.html() ) ) { 479 $this.parents('section').addClass('maf-f-c'); 480 } 481 }); 482 483 //video 484 if( $('.maf-content iframe').length ) { 485 if( !$('body').hasClass('manageable-bo') ){ 486 $('.maf-content iframe').each(function(){ 487 $this = $(this); 488 if($this.attr('src').length > 0){ 489 var tsrc = $this.attr('src'); 490 if( tsrc.indexOf('youtube') != -1 || tsrc.indexOf('vimeo') != -1 ){ 491 $this.wrap('<div class="is-video"></div>'); 492 } 493 } 494 }); 495 } 496 } 497 if( $('.tvw-player').length ){ 498 $('.tvw-player').each(function(){ 499 var notPlayed = true; 500 var vidid = $(this).attr('id'); 501 var vid = document.getElementById(vidid); 502 var startClass = vid.className; 503 console.log(startClass); 504 vid.oncanplay = function() { 505 if( notPlayed ){ 506 vid.play(); 507 notPlayed = false; 508 vid.className = startClass + ' ready'; 509 } 510 }; 511 }); 512 } 513 514 //accessability hide images with no description 515 $('img').each(function(){ 516 if ( !$(this).attr('alt') ){ 517 $(this).attr('aria-hidden', 'true').attr('alt',''); 518 } 519 }); 520 521 //animation engine 522 if($('.animate').length){ 523 var smController = new ScrollMagic.Controller(); 524 var animations = new Array(); 525 $('.animate').each(function(){ 526 var thisIs = '#' + $(this).attr('id'); 527 animations[animations.length] = new ScrollMagic.Scene({triggerElement: thisIs, triggerHook: 0.7}) 528 .setClassToggle(thisIs, "anim-1") 529 .addTo(smController); 530 animations[animations.length] = new ScrollMagic.Scene({triggerElement: thisIs, triggerHook: 0.5}) 531 .setClassToggle(thisIs, "anim-2") 532 .addTo(smController); 533 animations[animations.length] = new ScrollMagic.Scene({triggerElement: thisIs, triggerHook: 0.3}) 534 .setClassToggle(thisIs, "anim-3") 535 .addTo(smController); 536 }); 537 } 538 //check if element is in view 539 function isInView(el, p) { 540 var hOffset = 0; 541 if( $('.is-main-header.is-fixed').length ){ 542 hOffset = $('.is-main-header.is-fixed').outerHeight(); 543 } 544 var pOffset = ( $(window).height() / 100 ) * p; 545 var docViewTop = $(window).scrollTop() + hOffset + pOffset; 546 var docViewBottom = docViewTop + $(window).height(); 547 var elemTop = el.offset().top ; 548 var elemBottom = elemTop + el.height(); 549 return( docViewTop >= elemTop ); 550 } 551 //smooth scrolling 552 var scrollOffset = scrollingOffset;; 553 554 //on page Load 555 if(window.location.hash){ 556 setTimeout( 557 function(){ 558 var hsh = window.location.hash; 559 //console.log('hash is: ' + hsh ); 560 if( hsh.substring(0,2) != '#&' ) {//because of photoswipe hash 561 if( $(hsh).length ) { 562 var plt = $(window.location.hash); 563 var where = plt.offset().top - scrollOffset; 564 TweenMax.to( window, 1, { scrollTo:{ y: where, ease: Power3.easeOut } } ); 565 } 566 } 567 }, 1500 568 ); 569 } 570 571 //debounce 572 function de( func, wait, immediate ) { 573 var timeout; 574 return function() { 575 var context = this, args = arguments; 576 var later = function() { 577 timeout = null; 578 if( !immediate ) {
579 func.apply(context, args); 580 return false; 581 } else { 582 return false; 583 } 584 }; 585 var callNow = immediate && !timeout; 586 clearTimeout(timeout); 587 timeout = setTimeout(later, wait ); 588 if( callNow ) { 589 func.apply(context, args); 590 return false; 591 } else { 592 return false; 593 } 594 }; 595 }; 596 597 //forms 598 $('.radio').on('click', function(e) { 599 //console.log('clicked span'); 600 var targ = $(this).find('input:radio'); 601 targ.prop("checked", !targ.prop("checked")); 602 }); 603 604 $('#RegPassword, #RegPassword_Confirm').on('keyup', function() { 605 //console.log($('#RegPassword').val()+' '+$('#RegPassword_Confirm')); 606 if($('#RegPassword').val() == $('#RegPassword_Confirm').val()) { 607 $('#maf-message').html('Passwords match').removeClass('error-msg').addClass('success-msg'); 608 }else{ 609 if($('#RegPassword_Confirm').val() != ''){ 610 $('#maf-message').html('Passwords must match').removeClass('success-msg').addClass('error-msg'); 611 } 612 } 613 }); 614 615 if( $('#contact-section').length ){ 616 $('#email-floater').addClass('no-show'); 617 }else{ 618 $('#contact-form-apf').on('submit', function(e){ 619 //console.log('called'); 620 e.preventDefault(); 621 var targ = $('#contact-form-apf'); 622 var targS = $('#contact-form-apf button[type="submit"]'); 623 targS.attr('disabled','disabled'); 624 $.ajax({ 625 type: 'post', 626 url: '/includes/Functions/forms_ajax/handle-contact.php', 627 data: targ.serialize(), 628 success: function(r) { 629 if (r == '1') { 630 //console.log('ajax contact recap fail'); 631 targ.find('.cap-con').prepend('<div class="error-msg">Please confirm that you are not a robot</div>'); 632 targS.attr('disabled',false); 633 }else if (r == '2') { 634 console.log('ajax contact form fail'); 635 targS.attr('disabled',false); 636 }else{ 637 //console.log('ajax contact success'); 638 targ.addClass('hide'); 639 var targP = targ.parent(); 640 if( targP.find('.a-f-resp').length ){ 641 targP.find('.a-f-resp').remove(); 642 } 643 targP.prepend(r); 644 var tr = targP.find('.a-f-resp'); 645 tr.addClass('show'); 646 targ.find(':input').each(function(){ 647 $(this).val(''); 648 }); 649 grecaptcha.reset(); 650 setTimeout(function(){ 651 tr.removeClass('show'); 652 setTimeout(function(){ 653 targ.removeClass('hide'); 654 }, 800); 655 }, 8000); 656 } 657 } 658 }); 659 }); 660 } 661 662 //contact floater 663 var trigp = window.innerHeight ? window.innerHeight : $(window).height(); 664 trigp = trigp * 0.2; 665 var trigt = $('#floater-menu'); 666 function floater(){ 667 if( $(window).scrollTop() > trigp){ 668 if( !trigt.hasClass('out') ){ 669 trigt.addClass('out'); 670 } 671 }else{ 672 if( trigt.hasClass('out') ){ 673 trigt.removeClass('out'); 674 } 675 } 676 } 677 $('#email-floater button').on('click', function() { 678 var t = $('#conco'); 679 if( !t.hasClass('open') ){ 680 t.addClass('open'); 681 $('#conco-f, #fader').addClass('open'); 682 $('body').addClass('conco-open'); 683 } 684 }); 685 $('#conco-f #close').on('click', function() { 686 $('#conco').removeClass('open'); 687 $('#conco-f, #fader').removeClass('open'); 688 $('body').removeClass('conco-open'); 689 }); 690 floater(); 691 $(window).on( 'scroll', floater ); 692 693 //shop 694 //session product-filters 695 $('.f-c-show').on('click', function(e) { 696 e.preventDefault(); 697 var $this = $(this); 698 $this.siblings('.hidden-controls').addClass('show'); 699 $this.siblings('.f-c-hide').removeClass('hide'); 700 $this.addClass('hide'); 701 }); 702 $('.f-c-hide').on('click', function(e) { 703 e.preventDefault(); 704 var $this = $(this); 705 $this.siblings('.hidden-controls').removeClass('show'); 706 $this.siblings('.f-c-show').removeClass('hide'); 707 $this.addClass('hide'); 708 }); 709 //image browser 710 $('.image-browser #image-nav img').on('click', function() { 711 var $this = $(this); 712 var theSrc = $this.attr('src'); 713 var theAlt = $this.attr('alt'); 714 $this.parents('.image-browser').find('.image-viewer img').attr('src', theSrc).attr('alt', theAlt); 715 $('.image-browser #image-nav img').removeClass('active'); 716 $this.addClass('active'); 717 }); 718 719 //links 720 //in page anchors 721 $('a[href*="#"]') 722 .not('[href="#"]') 723 .not('[href="#0"]') 724 .on('click', function(event) { 725 if (
726 location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') 727 && 728 location.hostname == this.hostname 729 ) { 730 var target = $(this.hash); 731 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 732 if(target.length) { 733 event.preventDefault(); 734 var where = target.offset().top - scrollOffset; 735 console.log(target.offset().top +' '+where); 736 TweenMax.to( window, 1, { scrollTo:{ y: where, ease: Power3.easeOut } } ); 737 } 738 } 739 }); 740 //js links 741 $('.is-link').on('click', function(e) { 742 e.preventDefault(); 743 var theUrl = $(this).data('link'); 744 //console.log(theUrl); 745 if( !theUrl.trim() ) { 746 return; 747 } else { 748 if( theUrl.match( /^http/ ) ) { 749 window.open( theUrl, "_blank" ); 750 } else { 751 window.location.href = theUrl; 752 } 753 } 754 }); 755 $('.is-home-link, #maf-brand').on('click', function(){ 756 window.location.href = "/"; 757 }); 758 //ad-block links 759 $('.ad-block').on('click', function(e) { 760 e.preventDefault(); 761 //fire event 762 var adId = $(this).data('adid'); 763 var adName = $(this).data('adname'); 764 gtag('event', 'ad-click '+adId+' '+adName, { 765 'event_category' : 'advert',
766 'event_label' : adId + adName 767 }); 768 //then open link 769 var theUrl = $(this).data('link'); 770 //console.log(theUrl); 771 if( !theUrl.trim() ) { 772 return; 773 } else { 774 if( theUrl.match( /^http/ ) ) { 775 window.open( theUrl, "_blank" ); 776 } else { 777 window.location.href = theUrl; 778 } 779 } 780 }); 781 782 //mega menu hover toggle groups - could be deprecated 783 $('.mega-tab').on('click', function(e){ 784 e.preventDefault(); 785 var $this = $(this); 786 var what = '.mega-tab-group.' + $this.data('group'); 787 if($this.hasClass('active')) { 788 var theUrl = $(this).attr('href'); 789 window.location.href = theUrl; 790 } else { 791 $this.siblings('.mega-tab-group').removeClass('is-on'); 792 $(what).addClass('is-on'); 793 $('.mega-tab').removeClass('active'); 794 $this.addClass('active'); 795 } 796 }); 797 798 // Accordian toggle groups 799 $('.toggle-click').on('click', function() { 800 var $this = $(this); 801 var what = '.toggle-group.' + $this.data('group'); 802 if($this.hasClass('active')) { 803 $this.siblings('.toggle-group').removeClass('is-on'); 804 $this.removeClass('active'); 805 } else { 806 $this.siblings('.toggle-group').removeClass('is-on'); 807 $(what).addClass('is-on'); 808 $this.siblings('.toggle-click').removeClass('active'); 809 $this.addClass('active'); 810 } 811 }); 812 813 // Tabs 814 $('.tab-click').on('click', function() { 815 var $this = $(this); 816 var what = '.tab-group.' + $this.data('group'); 817 if( !$this.hasClass('active') ) { 818 $('.tab-group').removeClass('is-on'); 819 $(what).addClass('is-on'); 820 $('.tab-click').removeClass('active'); 821 $this.addClass('active'); 822 } 823 }); 824 825 //share button 826 if( $('.maf-share-this').length ) {//to do - each loop for multiple items on page 827 var targ = $('.maf-share-this'); 828 var cont = '<div class="maf-share-btn"><i class="tvw-share-alt"></i></div><div class="maf-share-acts">'; 829 var thisUrl = encodeURI(window.location.href); 830 var thisTitle = encodeURI(document.getElementsByTagName("title")[0].innerHTML); 831 cont += '<a class="pop fbk" href="https://www.facebook.com/sharer/sharer.php?u=' + thisUrl + '&title=' + thisTitle + '"><i class="tvw-facebook"></i></a>'; 832 cont += '<a class="pop twtr" href="https://twitter.com/intent/tweet?text=' + thisTitle + '&url=' + thisUrl + '"><i class="tvw-twitter"></i></a>'; 833 if (/Mobi/.test(navigator.userAgent)) { 834 cont += '<a class="pop wapp" href=" https://wa.me/?text=' + thisUrl + '"><i class="tvw-whatsapp"></i></a>'; 835 } 836 cont += '<a class="pop lnkn" href="https://www.linkedin.com/shareArticle?mini=true&url=' + thisUrl + '"><i class="tvw-linkedin"></i></a>'; 837 cont += '<a class="email" href="mailto:?subject=I wanted you to see this page&body=Check out this page: ' + thisUrl + '"><i class="tvw-envelope-o"></i></a>'; 838 cont += '</div>'; 839 $('.maf-share-this').html( cont ); 840 targ.find('a.pop').on('click', function() { 841 newWindow=window.open($(this).attr('href'),'','height=424,width=555'); 842 return false; 843 }); 844 } 845 if($('#blog-bar,.sharer').length){ 846 $('#blog-bar,.sharer').find('a.pop').on('click', function() { 847 newWindow=window.open($(this).attr('href'),'','height=424,width=555'); 848 return false; 849 }); 850 } 851 //card sharer 852 $('.card-share .pop').on('click', function(e){ 853 e.preventDefault(); 854 var turl = $(this).data('link'); 855 newWindow=window.open(turl,'','height=424,width=555'); 856 }); 857 858 //modal 859 var scrollPos; 860 function closeThisPop(){ 861 $('.modal.show').removeClass('show'); 862 $('body').off('click.popclose'); 863 $(window).off('scroll.popup'); 864 } 865 function openThisPop(targ){ 866 scrollPos = $(window).scrollTop(); 867 $(window).on('scroll.popup',stopScroll); 868 $('.modal.show').removeClass('show'); 869 targ.addClass('show'); 870 $('body').on('click.popclose', closePop); 871 } 872 function closePop(event){//close modal on clicking outside 873 if( !$(event.target).closest('.mod-content').length ){ 874 closeThisPop(); 875 } 876 } 877 function stopScroll() { 878 $(window).scrollTop(scrollPos); 879 } 880 //modal pop up trigger 881 $('.modal-pop').on('click', function(e) { 882 e.preventDefault(); 883 e.stopPropagation(); 884 var $this = $(this); 885 var targ = '#mp-' + $this.data('modal'); 886 //console.log(targ); 887 openThisPop($(targ)); 888 }); 889 $('.modal .close').on('click', function(event) { 890 event.stopPropagation(); 891 closeThisPop(); 892 }); 893 894 //cookies 895 function bake_cookie(name, value) { 896 var cookie = [name, '=', JSON.stringify(value), '; domain=.', window.location.host.toString(), '; path=/;'].join(''); 897 document.cookie = cookie; 898 } 899 function read_cookie(name) { 900 var result = document.cookie.match(new RegExp(name + '=([^;]+)')); 901 result && (result = JSON.parse(result[1])); 902 return result; 903 } 904 function delete_cookie(name) { 905 document.cookie = [name, '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.', window.location.host.toString()].join(''); 906 } 907 908 //filtering 909 if( $('.filtered').length ) {
910 // combination filter groups 911 var filters = {}; 912 913 function doFiltering( filters ) { 914 //console.log(filters.length); 915 var noResults = $('#no-results'); 916 if(filters.length>0){ 917 $('.filtered .filter-target .filter-item').addClass('hide'); 918 $('.filtered .filter-target .filter-item').filter(filters).removeClass('hide'); 919 }else{ 920 $('.filtered .filter-target .filter-item').removeClass('hide'); 921 } 922 if( $('.filter-item').not('.hide').length > 0 ){ 923 noResults.removeClass('show'); 924 }else{ 925 noResults.addClass('show'); 926 } 927 hideUnusedButtons(); 928 } 929 function getComboFilter( filters ) { 930 var i = 0; 931 var comboFilters = []; 932 var message = []; 933 for ( var prop in filters ) { 934 message.push( filters[ prop ].join(' ') ); 935 var filterGroup = filters[ prop ]; 936 // skip to next filter group if it doesn't have any values 937 if ( !filterGroup.length ) { 938 continue; 939 } 940 if ( i === 0 ) { 941 // copy to new array 942 comboFilters = filterGroup.slice(0); 943 } else { 944 var filterSelectors = []; 945 // copy to fresh array 946 var groupCombo = comboFilters.slice(0); // [ A, B ] 947 // merge filter Groups 948 for (var k=0, len3 = filterGroup.length; k < len3; k++) { 949 for (var j=0, len2 = groupCombo.length; j < len2; j++) { 950 filterSelectors.push( groupCombo[j] + filterGroup[k] ); // [ 1, 2 ] 951 } 952 } 953 // apply filter selectors to combo filters for next group 954 comboFilters = filterSelectors; 955 } 956 i++; 957 } 958 var comboFilter = comboFilters.join(', '); 959 return comboFilter; 960 } 961 function manageButtons( $button ) { 962 var button = $button[0]; 963 var group = $button.parents('.filter-set').attr('data-filter-group'); 964 var filterGroup = filters[ group ]; 965 if ( !filterGroup ) { 966 filterGroup = filters[ group ] = []; 967 } 968 var isAll = $button.hasClass('all'); 969 if ( isAll ) { 970 delete filters[ group ]; 971 if ( !$button.hasClass('active') ) { 972 $button.addClass('active'); 973 } 974 } 975 var index = $.inArray( $button.attr('data-filter'), filterGroup ); 976 if ( $button.hasClass('active') ) { 977 var selector = isAll ? 'button' : 'button.all'; 978 $button.siblings( selector ).removeClass('active'); 979 if ( !isAll && index === -1 ) { 980 filters[ group ].push( $button.attr('data-filter') ); 981 } 982 } else if ( !isAll ) { 983 filters[ group ].splice( index, 1 ); 984 if( !$button.siblings('.active').length ) { 985 $button.siblings('button.all').addClass('active'); 986 } 987 //to do check if all buttons on if so select all instead? 988 } 989 } 990 function hideUnusedButtons(){ 991 $('#filters .filter-set.hide-unused').each(function(){ 992 $(this).children('button').each(function(){ 993 var $this = $(this); 994 if( !$this.hasClass('all') ){ 995 var ft = $this.data('filter'); 996 var tc = ft.substr(1, ft.length); 997 var hide = true; 998 $('.filter-item').not('.hide').each(function(){ 999 if( $(this).hasClass(tc) ) { 1000 hide = false;
1001 return false; 1002 } 1003 }); 1004 if(hide){ 1005 //console.log($(this).data('filter') + ' | ' + tc); 1006 $(this).addClass('hide'); 1007 }else{ 1008 $(this).removeClass('hide'); 1009 } 1010 } 1011 }); 1012 }); 1013 } 1014 // filter button action 1015 $('#filters').on( 'click', '.filter-action', function() { 1016 $(this).toggleClass('active'); 1017 manageButtons( $(this) ); 1018 var comboFilter = getComboFilter( filters ); 1019 doFiltering( comboFilter ); 1020 //isoGrid.isotope({ filter: comboFilter });//------------------------------------------------ 1021 var cname = 'filters' + $('#filters').data('filtername'); 1022 bake_cookie(cname, filters); 1023 }); 1024 1025 //init - load cookie and set or default to most recent year 1026 if( $('#filters').length ) { 1027 var cname = 'filters' + $('#filters').data('filtername'); 1028 var storedFilters = read_cookie(cname); 1029 if( storedFilters ) { 1030 filters = storedFilters; 1031 var comboFilter = getComboFilter( filters ); 1032 doFiltering( comboFilter ); 1033 //isoGrid.isotope({ filter: comboFilter }); 1034 for ( var prop in filters ) { 1035 var filterGroup = filters[ prop ]; 1036 if ( filterGroup.length ) { 1037 for (var d=0, l = filterGroup.length; d < l; d++) { 1038 var but = $('#filters').find('[data-filter="'+filterGroup[d]+'"]'); 1039 but.addClass('active'); 1040 but.siblings('button.all').removeClass('active'); 1041 } 1042 } 1043 } 1044 }else{ 1045 if( $('#filters .filter-set[data-filter-group="date"]').length ) { 1046 $('#filters .filter-set[data-filter-group="date"]').find('.filter-action[data-filter*=".year-"]').first().trigger('click'); 1047 } 1048 } 1049 } 1050 } 1051 //external filter links 1052 $('.nav-filter-link').on( 'click', function(e) { 1053 e.preventDefault(); 1054 var $this = $(this); 1055 var cname = 'filters' + $this.parents('.nav-filter').data('filtername'); 1056 var group = $this.parents('.nav-filter').data('filtergroup'); 1057 var filt = $this.data('filter'); 1058 var url = $this.data('link'); 1059 var filters = {}; 1060 filters[ group ] = [filt]; 1061 bake_cookie(cname, filters); 1062 window.location.href = url; 1063 }); 1064 1065 //age consent 1066 if( $('body.maf-age-consent').length && !$('.privacy-policy').length ){ 1067 var cname = 'consent'; 1068 var cval = read_cookie(cname); 1069 if( !cval || cval != '1' ) { 1070 function openAC(){ 1071 scrollPos = $(window).scrollTop(); 1072 $(window).on('scroll.popup',stopScroll); 1073 $('.modal.show').removeClass('show'); 1074 $('#mp-age-consent').addClass('show'); 1075 } 1076 //alert('age consent'); 1077 var mbox = '<div id="mp-age-consent" class="modal"><div><div class="mod-content">'; 1078 mbox += '<h1><img id="logo" src="/images/Layout/logo.png" alt="Kirkwood Distillery An Honest Shropshire Spirit"></h1>'; 1079 mbox += '<p>As part of our commitment to responsible drinking we require you to be <strong>OVER 18</strong> to enter this site</p>'; 1080 mbox += '<button id="agree">ENTER</button>'; 1081 mbox += '<p class="small">By entering this site you also agree to our <a href="/privacy-cookie-policy">Privacy and Cookie policies</a></p>'; 1082 mbox += '</div><!-- .mod-content --></div></div><!-- .modal -->'; 1083 $('body').append(mbox); 1084 openAC(); 1085 $('#mp-age-consent #agree').on('click', function(event) { 1086 $('.modal.show').removeClass('show'); 1087 $(window).off('scroll.popup'); 1088 bake_cookie('consent', 1); 1089 }); 1090 } 1091 } 1092 1093 //Vendor & APIs 1094 //gallery photoswipe (dep fancybox) 1095 if( $('.is-simple-gallery').length || $('.is-layered-gallery').length ){ 1096 /*$(".fancybox").fancybox({ 1097 beforeShow : function() { 1098 var alt = this.element.attr('title'); 1099 this.inner.find('img').attr('alt', alt); 1100 this.title = alt; 1101 } 1102 });*/ 1103 var assets = []; 1104 var photoswipeParseHash = function() { 1105 var hash = window.location.hash.substring(1), 1106 params = {}; 1107 if(hash.length < 5) { 1108 return params; 1109 } 1110 var vars = hash.split('&'); 1111 for (var i = 0; i < vars.length; i++) { 1112 if(!vars[i]) { 1113 continue; 1114 } 1115 var pair = vars[i].split('='); 1116 if(pair.length < 2) { 1117 continue; 1118 } 1119 params[pair[0]] = pair[1]; 1120 } 1121 if(params.gid) { 1122 params.gid = parseInt(params.gid, 10); 1123 } 1124 return params; 1125 }; 1126 var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) { 1127 var $pswp = $('.pswp')[0], 1128 options = { 1129 index: index, 1130 bgOpacity: 0.8, 1131 showHideOpacity: true, 1132 closeOnScroll: false, 1133 closeOnVerticalDrag: false 1134 }; 1135 var gallery = new PhotoSwipe($pswp, PhotoSwipeUI_Default, assets, options); 1136 gallery.listen('close', function() { 1137 setTimeout(function(){ 1138 history.pushState("", document.title, window.location.pathname + window.location.search); 1139 },500); 1140 }); 1141 gallery.init(); 1142 } 1143 $('.pswp__container').on('wheel mousewheel DOMMouseScroll', '.gal-prod', function(e) { 1144 // Stop the event propagation bubbling up to the existing photoswipe listener. 1145 e.stopPropagation(); 1146 }); 1147 $('figure.media-item').each(function(){ 1148 $this = $(this); 1149 var t = $this.children('a'); 1150 if( $this.hasClass('product') ){ 1151 var pHtml = '<div class="gal-prod"><div class="p-img">'; 1152 pHtml += '<div><img src="'+t.attr('href')+'" alt="'+t.attr('title')+'"></div>'; 1153 pHtml += '</div><div class="p-text">'+t.find('div.p-content').html()+'</div></div>'; 1154 item = { 1155 html: pHtml 1156 } 1157 }else if( $this.hasClass('video') ){ 1158 item = { 1159 html: $this.html() 1160 } 1161 /*if( /Mobi/.test(navigator.userAgent) == false ) { 1162 assets.push(item); 1163 }*/ 1164 }else{ 1165 item = { 1166 src: t.attr('href'), 1167 w: t.data('w'), 1168 h: t.data('h'),
1169 title: t.attr('title') 1170 }; 1171 } 1172 assets.push(item); 1173 }); 1174 var hashData = photoswipeParseHash(); 1175 if(hashData.pid && hashData.gid) { 1176 openPhotoSwipe( hashData.pid , assets[ hashData.gid - 1 ], false, true ); 1177 } 1178 $('figure.media-item a').on('click',function(e){ 1179 e.preventDefault(); 1180 openPhotoSwipe( $(this).closest('figure').index(0), assets, false, false); 1181 }); 1182 } 1183 1184 //twitter 1185 if( $(".tweet").length ){ 1186 var $this = $(".tweet"); 1187 var accountName = $(".tweet").data('tweet'); 1188 var tCount = $(".tweet").data('tno'); 1189 if ( accountName.length ) { 1190 $(".tweet").tweet({ 1191 modpath: '/includes/3rdparty/twitter/twitter.php', 1192 username: accountName, 1193 count: tCount, 1194 loading_text: "loading twitter feed...", 1195 refresh_interval: 300 1196 }); 1197 $('.tweet').on('click', 'a', function(e){ 1198 e.preventDefault(); 1199 var theUrl = $(this).attr('href'); 1200 window.open(theUrl, '_blank'); 1201 }); 1202 }else{ 1203 $this.html('<p>There is no twitter account set to this website</p>'); 1204 } 1205 } 1206 1207 //Google Maps 1208 if($('#google-map').length){ 1209 var map; 1210 var targ = $('#google-map'); 1211 var label1, lat, long; 1212 var pinRadius = false; 1213 var multiPin = false; 1214 var dropPin = true; 1215 var zoom = 16; 1216 if( targ.hasClass('no-pin') ) { 1217 dropPin = false; 1218 } 1219 if( !targ.hasClass('multi-pin') ) { 1220 if( targ.attr('data-lat') ){ 1221 lat = targ.data('lat'); 1222 }else{ 1223 console.log('no latitude set'); 1224 } 1225 if( targ.attr('data-long') ){ 1226 long = targ.data('long'); 1227 }else{ 1228 console.log('no longtitude set'); 1229 } 1230 if( targ.attr('data-radius') ){ 1231 zoom = targ.data('radius'); 1232 } 1233 if( targ.attr('data-zoom') ){ 1234 zoom = targ.data('zoom'); 1235 } 1236 if(dropPin){ 1237 label1 = targ.data('label'); 1238 } 1239 var Address1 = new google.maps.LatLng(lat, long); 1240 }else{ 1241 multiPin = true; 1242 //console.log('multi pin map'); 1243 } 1244 1245 /*var mapInfo = [ 1246 { 1247 "featureType": "water", 1248 "elementType": "geometry", 1249 "stylers": [ 1250 { 1251 "color": "#e9e9e9" 1252 }, 1253 { 1254 "lightness": 17 1255 } 1256 ] 1257 }, 1258 { 1259 "featureType": "landscape", 1260 "elementType": "geometry", 1261 "stylers": [ 1262 { 1263 "color": "#f5f5f5" 1264 }, 1265 { 1266 "lightness": 20 1267 } 1268 ] 1269 }, 1270 { 1271 "featureType": "road.highway", 1272 "elementType": "geometry.fill", 1273 "stylers": [ 1274 { 1275 "color": "#ffffff" 1276 }, 1277 { 1278 "lightness": 17 1279 } 1280 ] 1281 }, 1282 { 1283 "featureType": "road.highway", 1284 "elementType": "geometry.stroke", 1285 "stylers": [ 1286 { 1287 "color": "#ffffff" 1288 }, 1289 { 1290 "lightness": 29 1291 }, 1292 { 1293 "weight": 0.2 1294 } 1295 ] 1296 }, 1297 { 1298 "featureType": "road.arterial", 1299 "elementType": "geometry", 1300 "stylers": [ 1301 { 1302 "color": "#ffffff" 1303 }, 1304 { 1305 "lightness": 18 1306 } 1307 ] 1308 }, 1309 { 1310 "featureType": "road.local", 1311 "elementType": "geometry", 1312 "stylers": [ 1313 { 1314 "color": "#ffffff" 1315 }, 1316 { 1317 "lightness": 16 1318 } 1319 ] 1320 }, 1321 { 1322 "featureType": "poi", 1323 "elementType": "geometry", 1324 "stylers": [ 1325 { 1326 "color": "#f5f5f5" 1327 }, 1328 { 1329 "lightness": 21 1330 } 1331 ] 1332 }, 1333 { 1334 "featureType": "poi.park", 1335 "elementType": "geometry", 1336 "stylers": [ 1337 { 1338 "color": "#dedede" 1339 }, 1340 { 1341 "lightness": 21 1342 } 1343 ] 1344 }, 1345 { 1346 "elementType": "labels.text.stroke", 1347 "stylers": [ 1348 { 1349 "visibility": "on" 1350 }, 1351 { 1352 "color": "#ffffff" 1353 }, 1354 { 1355 "lightness": 16 1356 } 1357 ] 1358 }, 1359 { 1360 "elementType": "labels.text.fill", 1361 "stylers": [ 1362 { 1363 "saturation": 36 1364 }, 1365 { 1366 "color": "#333333" 1367 }, 1368 { 1369 "lightness": 40 1370 } 1371 ] 1372 }, 1373 { 1374 "elementType": "labels.icon", 1375 "stylers": [ 1376 { 1377 "visibility": "off" 1378 } 1379 ] 1380 }, 1381 { 1382 "featureType": "transit", 1383 "elementType": "geometry", 1384 "stylers": [ 1385 { 1386 "color": "#f2f2f2" 1387 }, 1388 { 1389 "lightness": 19 1390 } 1391 ] 1392 }, 1393 { 1394 "featureType": "administrative", 1395 "elementType": "geometry.fill", 1396 "stylers": [ 1397 { 1398 "color": "#fefefe" 1399 }, 1400 { 1401 "lightness": 20 1402 } 1403 ] 1404 }, 1405 { 1406 "featureType": "administrative", 1407 "elementType": "geometry.stroke", 1408 "stylers": [ 1409 { 1410 "color": "#fefefe" 1411 }, 1412 { 1413 "lightness": 17 1414 }, 1415 { 1416 "weight": 1.2 1417 } 1418 ] 1419 } 1420 ];*/ 1421 function goMap() { 1422 if(!multiPin){ 1423 var mapOptions = { 1424 zoom: zoom, 1425 //styles: mapInfo, 1426 center: Address1, 1427 disableDefaultUI: !dropPin, 1428 scrollwheel: false, 1429 mapTypeControl: false 1430 //scaleControl: false, 1431 //draggable: false, 1432 }; 1433 map = new google.maps.Map(document.getElementById('google-map'), mapOptions); 1434 if(dropPin){ 1435 var pinIcon = { 1436 url: '/images/Layout/ui/map-icon-red.png', 1437 size: new google.maps.Size(27, 44), 1438 origin: new google.maps.Point(0, 0), 1439 anchor: new google.maps.Point(14, 44), 1440 labelOrigin: new google.maps.Point(12, -8) 1441 }; 1442 var marker = new google.maps.Marker({ 1443 position: Address1, 1444 map: map, 1445 icon: pinIcon, 1446 label: { 1447 text: label1, 1448 color: '#333333' 1449 } 1450 }); 1451 } 1452 if( pinRadius > 0 ){ 1453 var metersMile = 1609.34; 1454 var cityCircle = new google.maps.Circle({ 1455 strokeColor: '#152952', 1456 strokeOpacity: 0.8, 1457 strokeWeight: 3, 1458 fillColor: '#6599d2', 1459 fillOpacity: 0.2, 1460 map: map, 1461 center: Address1, 1462 //radius miles*meters/mile 1463 radius: pinRadius*1609.34 1464 }); 1465 } 1466 }else{ 1467 var mapOptions = { 1468 zoom: zoom, 1469 styles: mapInfo, 1470 center: new google.maps.LatLng(52.405479, -2.743408), 1471 disableDefaultUI: false, 1472 scrollwheel: false, 1473 mapTypeControl: false 1474 //scaleControl: false, 1475 //draggable: false, 1476 }; 1477 map = new google.maps.Map(document.getElementById('google-map'), mapOptions); 1478 var pinIcon = { 1479 url: '/images/Layout/ui/map-icon-gray-blue.png', 1480 size: new google.maps.Size(27, 44), 1481 origin: new google.maps.Point(0, 0), 1482 anchor: new google.maps.Point(14, 44), 1483 labelOrigin: new google.maps.Point(12, 15) 1484 }; 1485 var bounds = new google.maps.LatLngBounds(); 1486 1487 for (var i = 0; i < locations.length; i++) { 1488 //console.log(locations[i][0]+' | '+locations[i][1]+' | '+locations[i][2]); 1489 1490 var marker = new google.maps.Marker({ 1491 position: new google.maps.LatLng(locations[i][1], locations[i][2]), 1492 map: map, 1493 icon: pinIcon, 1494 label: locations[i][0] 1495 }); 1496 bounds.extend(marker.position); 1497 1498 } 1499 map.fitBounds(bounds); 1500 /* 1501 var listener = google.maps.event.addListener(map, "idle", function () { 1502 map.setZoom(13); 1503 google.maps.event.removeListener(listener); 1504 }); 1505 */ 1506 } 1507 } 1508 //google.maps.event.addDomListener(window, 'load', goMap); <-- fyi this is sketchy in firefox 1509 goMap(); 1510 } 1511 if($('#google-map-interactive').length){ 1512 var map; 1513 var bounds = new google.maps.LatLngBounds(); 1514 var mapInfo = []; 1515 var filterId = '0'; 1516 function goIMap() { 1517 var mapOptions = { 1518 styles: mapInfo, 1519 scrollwheel: false, 1520 //center: Address, 1521 mapTypeControl: false, 1522 //disableDefaultUI: true, 1523 mapTypeId: google.maps.MapTypeId.TERRAIN 1524 }; 1525 map = new google.maps.Map(document.getElementById('google-map-interactive'), mapOptions); 1526 //plot markers 1527 var marker = []; 1528 var infoWindowContent = []; 1529 var infoWindow = new google.maps.InfoWindow(), marker, d; 1530 var pinIcon = { 1531 url: '/images/Layout/ui/map-icon-blue3.png', 1532 size: new google.maps.Size(27, 44), 1533 origin: new google.maps.Point(0, 0), 1534 anchor: new google.maps.Point(14, 44), 1535 labelOrigin: new google.maps.Point(12, -8) 1536 }; 1537 for (d = 0; d < iMapJson.pins.length; d++) { 1538 var filtered = false;
1539 if(filterId != '0'){ 1540 filtered = true; 1541 for (s = 0; s < iMapJson.pins[d].filter.length; s++) { 1542 if( filterId == iMapJson.pins[d].filter[s].filterid ){ 1543 filtered = false; 1544 } 1545 } 1546 } 1547 if( !filtered ){ 1548 //console.log( distributorJson.distributor[i].name + ' ' + distributorJson.distributor[i].lat ); 1549 infoWindowContent[d] = '<div class="map-info-content">'; 1550 infoWindowContent[d] += '<p class="name">' + iMapJson.pins[d].name + '</p>'; 1551 if( iMapJson.pins[d].address != '' ){ 1552 infoWindowContent[d] += '<p><strong>Address:</strong> ' + iMapJson.pins[d].address + '</p>'; 1553 } 1554 if( iMapJson.pins[d].description != '' ) { 1555 infoWindowContent[d] += '<p>' + iMapJson.pins[d].description + '</p>'; 1556 } 1557 if( iMapJson.pins[d].phone != '' ) { 1558 infoWindowContent[d] += '<p><strong>Phone:</strong> ' + iMapJson.pins[d].phone + '</p>'; 1559 } 1560 if( iMapJson.pins[d].email != '' ) { 1561 infoWindowContent[d] += '<p><strong>Email:</strong>' + iMapJson.pins[d].email + '</p>'; 1562 } 1563 if( iMapJson.pins[d].web != '' ) { 1564 infoWindowContent[d] += '<p><a class="button" href="' + iMapJson.pins[d].web + '" target="_blank">Website</a></p>'; 1565 } 1566 infoWindowContent[d] += '</div>'; 1567 var position = new google.maps.LatLng( iMapJson.pins[d].lat, iMapJson.pins[d].long ); 1568 bounds.extend(position); 1569 marker = new google.maps.Marker({ 1570 position: position, 1571 map: map, 1572 icon: pinIcon, 1573 }); 1574 google.maps.event.addListener(marker, 'click', (function(marker, d) { 1575 return function(){ 1576 map.panTo(marker.getPosition()); 1577 infoWindow.setContent(infoWindowContent[d]); 1578 infoWindow.open(map, marker); 1579 } 1580 })(marker, d)); 1581 map.fitBounds(bounds); 1582 } 1583 } 1584 } 1585 //google.maps.event.addDomListener(window, 'load', goIMap); 1586 goIMap(); 1587 $('#map-filters .imap-filter').on('click', function(){ 1588 var $this = $(this); 1589 filterId = $this.data('id'); 1590 $this.siblings().removeClass('active'); 1591 $this.addClass('active'); 1592 goIMap(); 1593 }); 1594 } 1595 $('pre.dispell').on('click', function(){ 1596 $(this).hide(); 1597 }); 1598 $('.init').removeClass('init'); 1599 $('body').addClass('maf-loaded'); 1600 1601 //made by 1602 if( $('body').hasClass('manageable') ){ 1603 console.log('%c---------------------------------------------------------------------','background-color:orange;color:white;'); 1604 console.log('%c[manageable] </> by The Visual Works [https://www.visualworks.co.uk]','color:orange;font-weight:bold'); 1605 console.log('%c---------------------------------------------------------------------','background-color:orange;color:white;'); 1606 if(showPageStats){ 1607 console.log('[manageable] page rendered in '+$('#maf-prt').data('rt')+' seconds'); 1608 console.log("[manageable] page ready "+ docReady + ' seconds'); 1609 console.log("[manageable] page loaded "+ (Date.now()-loadStart)/1000 + ' seconds'); 1610 } 1611 } 1612});
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.