1$('input, textarea').placeholder(); // initilize /vendor/jquery.placeholder.js for IE placeholder fallback 2var origHeight = $('header.site').css("height"); // get the original height of the layout header (used for main nav & locations) 3 4/* ========================================================================== 5 Emergency Message Fader 6 ========================================================================== */ 7var $notificationMessages = $("#notification-rotator .message"); 8var notificationCount = $("#notification-rotator .message").length; 9var $firstMessage = $("#notification-rotator .message:first"); 10 11if (notificationCount > 1) { 12 13 $notificationMessages.hide(); 14 15 var $currentMessageDiv = $firstMessage.show(); 16 window.setInterval(function() 17 { 18 $currentMessageDiv.fadeOut(1500); 19 $currentMessageDiv = $currentMessageDiv.next($notificationMessages); 20 if ($currentMessageDiv.length === 0) 21 { 22 $currentMessageDiv = $firstMessage; 23 } 24 $currentMessageDiv.fadeIn(1500); 25 }, 26 7000); 27 28} else if (notificationCount === 1) { 29 $notificationMessages.show(); 30} 31 32var $expanderMessages = $("#messages .message-top"); 33var messageCount = $("#messages .message-top").length; 34var $firstExpanderMessage = $("#messages .message-top:first"); 35 36if (messageCount > 1) { 37 console.log('messageCount is greater than 1 ');
38 $expanderMessages.hide(); 39 40 var $currentExpanderDiv = $firstExpanderMessage.show(); 41 window.setInterval(function() 42 { 43 $currentExpanderDiv.fadeOut(1500); 44 $currentExpanderDiv = $currentExpanderDiv.next($expanderMessages); 45 if ($currentExpanderDiv.length === 0) 46 { 47 $currentExpanderDiv = $firstExpanderMessage; 48 } 49 $currentExpanderDiv.fadeIn(1500); 50 }, 51 7000); 52 53} else if (messageCount === 1) { 54 $expanderMessages.show(); 55} 56 57/* ========================================================================== 58 Mobile Navigation 59 ========================================================================== */ 60 61$('#expand-nav').on('click',function(){ 62 $('body').addClass('site-nav-transition site-nav-drawer-open'); 63}); 64 65$('.site-nav-overlay').on('click',function(){ 66 $('body').removeClass('site-nav-drawer-open'); 67 setTimeout(function(){ 68 $('body').removeClass('site-nav-transition'); 69 }, 300); 70}); 71 72$('#mobile-nav li.resources,#mobile-nav li.recommendations,#mobile-nav li.research').on('click',function(){ 73 $(this).find('.drop').slideToggle(); 74 $(this).toggleClass('active'); 75}); 76 77$('#mobile-navigation li.resources,#mobile-navigation li.recommendations,#mobile-navigation li.research').on('click',function(){ 78 if (!$(this).hasClass('active')) { 79 $('#mobile-navigation ul.main-menu li.active').find('.mob-drop').slideUp(); 80 $('#mobile-navigation ul.main-menu li.active').find('span.fa').toggleClass('hide'); 81 $('#mobile-navigation ul.main-menu li.active').removeClass('active'); 82 } 83 $(this).find('.mob-drop').slideToggle(); 84 $(this).find('span.fa').toggleClass('hide'); 85 $(this).toggleClass('active'); 86}); 87 88/* ========================================================================== 89 Active States 90 ========================================================================== */ 91 92$('ul.alphabet li a').on('click', function() { 93 $('ul.alphabet li a').removeClass('active'); 94 $(this).addClass('active'); 95 }); 96 97$('ul.booklists li a').on('click', function() { 98 $('ul.booklists li a').removeClass('active'); 99 $(this).addClass('active'); 100 }); 101 102 103 104 var refID = $('ul.ready-ref-icons li.active').attr('id'); 105 var refContent = $('#'+refID+'-expand').html(); 106 $('.expand-contain').hide(); 107 $('.expand-contain').html(refContent).fadeIn(); 108 109 $('ul.ready-ref-icons li').on('click', function() { 110 refID = $(this).attr('id'); 111 refContent = $('#'+refID+'-expand').html(); 112 113 if (!$(this).hasClass('active')) { 114 $('ul.ready-ref-icons li').removeClass('active'); 115 $('.expand-contain').hide(); 116 $('.expand-contain').html(refContent).fadeIn(); 117 $(this).addClass('active'); 118 } else { 119 $(this).removeClass('active'); 120 $('.expand-contain').fadeOut(); 121 } 122 }); 123 124/* ========================================================================== 125 Datepicker 126 ========================================================================== */ 127 128$(function() { 129 $( "#startdate" ).datepicker({ dateFormat: 'yy-mm-dd' }); 130 $( "#enddate" ).datepicker({ dateFormat: 'yy-mm-dd' }); 131 }); 132 133function getISODateTime(d){ 134 // padding function 135 var s = function(a,b){return(1e15+a+"").slice(-b)}; 136 137 // default date parameter 138 if (typeof d === 'undefined'){ 139 d = new Date(); 140 }; 141 142 // return ISO datetime 143 return d.getFullYear() + '-' + 144 s(d.getMonth()+1,2) + '-' + 145 s(d.getDate(),2); 146} 147 148/* ========================================================================== 149 Page Image Helpers 150 ========================================================================== */ 151$('.page-image img').load(function() { 152 var imageWidth = $('.page-image').outerWidth(); 153 var imageHeight = $('.page-image').outerHeight(); 154 $('.image-buffer').animate({ 155 "width":(imageWidth+25), 156 "height":(imageHeight-100) 157 }); 158 $('aside#buckets').animate({ 159 "margin-top":imageHeight-25 160 }); 161}); 162 163/* ========================================================================== 164 Left Nav Expand/Collapse 165 ========================================================================== */ 166 167$('.menu-collapse').on('click', function() { 168 //console.log($(this).parent('li').parent('ul')); 169 var $theMenu = $(this).parent('li').parent('ul'); 170 var menuFontAwesome = $theMenu.find('.fa'); 171 console.log(menuFontAwesome); 172 if ($theMenu.hasClass('open')) { 173 $theMenu.find('.menu').slideUp( function() { 174 $theMenu.removeClass('open'); 175 menuFontAwesome.removeClass('fa-caret-up'); 176 menuFontAwesome.addClass('fa-caret-down'); 177 }); 178 } else { 179 180 $theMenu.find('.menu').slideDown(function() { 181 $theMenu.addClass('open'); 182 menuFontAwesome.removeClass('fa-caret-down'); 183 menuFontAwesome.addClass('fa-caret-up'); 184 }); 185 } 186}); 187 188/* ========================================================================== 189 Main Nav Drop-Downs 190 ========================================================================== */ 191 footerHeight = 0; 192 mapHeight = 0; 193 194 $('#site-map .nav .clearfix').each(function() { 195 196 mapHeight = $(this).outerHeight(); 197 //console.log("Map Height: " + mapHeight); 198 199 if (mapHeight > footerHeight) { 200 footerHeight = mapHeight; 201 } 202 203 $('footer').css({ "height": footerHeight + 210}); 204 $('.container').css({ "padding-bottom": footerHeight + 200}); 205 206 }); 207 208if ($('body').hasClass('index')) { // if the page is the index page 209 210 var indexNavHeight = $('#main-nav').css("height"); // get the original height of #main-nav 211 212 $('html').click(function() { // clicking outside of #main-nav closes the dropdown 213 $('#main-nav').animate({ 214 height:indexNavHeight 215 }, 250, "linear"); 216 $('#main-nav').removeClass('open'); 217 }); 218 219 $('#main-nav').click(function(event){ // stop bubbling 220 event.stopPropagation(); 221 }); 222 223 $('#main-nav a').click(function() { // when clicking on a link in #main-nav 224 225 if ($('#main-nav').hasClass('open')) { // if #main-nav is open, close it 226 227 $('#main-nav').animate({ 228 height:indexNavHeight 229 }); 230 $('#main-nav').removeClass('open'); 231 232 } else { // otherwise, open it 233 234 var contentHeight = 0; 235 var mainHeight = 0; 236 237 $('#main-nav li .content').each(function() { 238 239 contentHeight = $(this).outerHeight(); 240 //console.log("Content Height: " + contentHeight); 241 242 if (contentHeight > mainHeight) { 243 mainHeight = contentHeight; 244 } 245 246 }); 247 248 249 //console.log("Final Height: " + mainHeight); 250 251 $('#main-nav').animate({ 252 height:mainHeight 253 }); 254 $('#main-nav').addClass('open'); 255 256 } 257 258 if ($('#locations').hasClass('open')) { // if the locations dropdown is open, close it when the main-nav opens 259 260 $('header.site').animate({ 261 height:origHeight 262 }, 250, "linear", function() { 263 $('#locations').hide(); 264 $('#locations').removeClass('open').addClass('closed'); 265 }); 266 267 } 268 269 }); // end main-nav click 270 271} else { // if the page isn't the index 272 273 $('html').click(function(e, v) { // clicking outside of #main-nav closes the dropdowns 274 if ($(e.target).attr("id") != 'gallery-nav-right') { // so gallery doesn't auto-close menus
275 $('.drop').slideUp(); // close and deactivate any open drop downs 276 $('#main-nav li').removeClass('active'); 277 } 278 }); 279 280 $('#main-nav').click(function(event){ // stop bubbling 281 event.stopPropagation(); 282 }); 283 284 $('#main-nav a').click(function() { // when clicking on a link in #main-nav 285 286 if ($(this).parent().hasClass('active')) { // if the parent li is active 287 288 $(this).parent().find('.drop').slideUp(); // close the dropdown & deactivate 289 $(this).parent().removeClass('active'); 290 291 } else { // if the parent li isn't active 292 293 $('.drop').slideUp(); // close and deactivate any open drop downs 294 $('#main-nav li').removeClass('active'); 295 296 $(this).parent().find('.drop').slideDown(); // and open/activate the one clicked on 297 $(this).parent().addClass('active'); 298 299 } 300 301 }); // end main-nav click 302 303} // end is/is not index logic 304 305/* ========================================================================== 306 Font Sizes & Calendar View 307 ========================================================================== */ 308 309 $('#regfont').click(function() { // choose regular font size & set cookie 310 $('body').removeClass('bigfont'); 311 $(this).addClass('selected'); 312 $('#bigfont').removeClass('selected'); 313 314 var userFontSize = 'fontsize='+$(this).attr('id'); 315 316 $.ajax({ 317 type: 'GET', 318 url: '/assets/cookies.php', 319 data: userFontSize 320 }); 321 }); 322 323 $('#bigfont').click(function() { // choose big font size & set cookie 324 $('body').addClass('bigfont'); 325 $(this).addClass('selected'); 326 $('#regfont').removeClass('selected'); 327 328 var userFontSize = 'fontsize='+$(this).attr('id'); 329 330 $.ajax({ 331 type: 'GET', 332 url: '/assets/cookies.php', 333 data: userFontSize 334 }); 335 }); 336 337/* ========================================================================== 338 Homepage Campaign 339 ========================================================================== */ 340if ($('#campaign').length !== 0) { 341 totalWidth = 0; // determine the total width of box elements in the campaign 342 $('#campaign div').each(function() { 343 totalWidth += $(this).outerWidth(); 344 }); 345 $('#campaign-slider').css('width', totalWidth); // and make sure the container is big enough to hold them all horizontally 346 347 var slideTimer; // the setTimeout 348 var focusTime = 6000; // how long to stay stationary 349 var fadeTime = 1500; // amount of time between movements 350 var hovering = false; // is the user hovering 351 352 $(document).ready(function() { // initilize slide timing 353 slideTimer = setTimeout(changeCampaign, focusTime); 354 }); 355 356 357 358 359 360// Stop slides on hover 361$('#campaign,.left-arrow,.right-arrow').hover(function(){ 362 hovering = true; 363 $('.left-arrow,.right-arrow').show(); 364 clearTimeout(slideTimer); 365},function(){ 366 hovering = false; 367 $('.left-arrow,.right-arrow').hide(); 368 slideTimer = setTimeout(changeCampaign, focusTime); 369}) 370 371 372// clone the items in #campaign-slider to give illusion of endless loop 373$allItemsAppend = $('#campaign-slider').children().clone(); 374$allItemsPrepend = $('#campaign-slider').children().clone(); 375 376// used to check when out of bounds 377$('div','#campaign-slider').addClass('original'); 378 379 380$allItemsAppend.appendTo('#campaign-slider'); 381$allItemsPrepend.prependTo('#campaign-slider'); 382 383 384 385 386$('.left-arrow a').click(function(e) { // manual left navigation for slides 387 slideCampaignItems(e); 388}); 389 390$('.right-arrow a').click(function(e) { // manual right navigation for slides 391 slideCampaignItems(e); 392}); 393 394 395 396;(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==null)return;var d=this,$elem=$(d),targ=e,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}$.each(g.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=h.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(g.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=g.offset[pos]||0;if(g.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*g.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(g.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&g.queue){if(old!=attr[key])animate(g.onAfterFirst);delete attr[key]}});animate(g.onAfter);function animate(a){$elem.animate(attr,f,g.easing,a&&function(){a.call(this,e,g)})}}).end()};h.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery); 397 398 399 400var $active_slide = $('.original:first','#campaign'); 401$('#campaign').scrollTo($active_slide, 0, {margin:true}); 402 403 404function slideCampaignItems(button, duration, callback){ 405 duration = duration || 300; 406 if (callback && hovering) return false;
407 var side_left = $(button.currentTarget).parents('.left-arrow').length; 408 if (side_left){ 409 $active_slide = $active_slide.prevAll('div:first'); 410 $('#campaign').scrollTo($active_slide, duration, {margin:true, onAfter: function(){ 411 if (!$active_slide.hasClass('original')){ 412 $active_slide = $('.original[data-id="'+$active_slide.data('id')+'"]'); 413 $('#campaign').scrollTo($active_slide, 0, {margin:true}); 414 } 415 }}); 416 } else { 417 $active_slide = $active_slide.nextAll('div:first'); 418 $('#campaign').scrollTo($active_slide, duration, {margin:true, onAfter: function(){ 419 if (!$active_slide.hasClass('original')){ 420 $active_slide = $('.original[data-id="'+$active_slide.data('id')+'"]'); 421 $('#campaign').scrollTo($active_slide, 0, {margin:true}); 422 } 423 if (callback) callback(); 424 }}); 425 } 426} 427 428 429 430 431 432function changeCampaign(){ // the function to show a new box from the left, joel's code 433 434 if (hovering) return clearTimeout(slideTimer); 435 436 slideTimer = setTimeout(function(){ 437 slideCampaignItems($('.right-arrow a')[0], 1000, changeCampaign); 438 }, focusTime); 439 440/* 441 var last = $('#campaign-slider').children(':last'), 442 width = last.outerWidth(), 443 last_clone = last.clone(true); 444 last_clone.css({marginLeft:-width+'px'}); 445 $('#campaign-slider').prepend(last_clone); 446 last_clone.animate({marginLeft:'10px'}, {easing:'easeInOutQuad', duration:1500, complete:function() { 447 if (hovering) return; 448 slideTimer = setTimeout(changeCampaign, focusTime); 449 }}); 450 last.remove(); 451*/ 452} 453 454} 455 456 457function flash(title, message, opts) { 458 if (!message) { 459 message = title; 460 title = "notice" 461 } 462 opts = opts || {}; 463 var opts = $.extend(true, { 464 title: title, 465 message: message 466 }, opts); 467 PostIt.notify(opts) 468} 469 470var PostIt = function () { 471 var stick = function (opts) { 472 PostIt.notify({title: opts.icon, message: opts.message}) 473 }; 474 var init = function(){ 475 $(document).bind("webkitAnimationEnd oAnimationEnd msAnimationEnd animationend", function(e){ 476 if (e.originalEvent.animationName === "slideUp"){ 477 $(e.target).remove() 478 } 479 }); 480 $(document).delegate(".notification", "mousedown", function (e) { 481 if (e.which === 2){ 482 var opts = $(this).data("notify"); 483 if (opts.url) {window.open(opts.url)} 484 } 485 }) 486 }; 487 var notify = function(opts) { 488 489 var defaults = { 490 delay: 5000, 491 sticky: false, 492 class_name: "message", 493 title: "", 494 message: "", 495 url: null, 496 click: null 497 }; 498 499 opts = opts || {}; 500 opts = $.extend({}, defaults, opts); 501 502 switch(opts.title){ 503 case "ok": 504 opts.title = "success"; 505 break; 506 case "fail": 507 case "danger": 508 opts.title = "error"; 509 break; 510 } 511 512 513 var icon = opts.icon || opts.title; 514 515 switch (icon.toLowerCase()) { 516 case "ok": 517 icon = "success"; 518 break; 519 case "fail": 520 case "danger": 521 icon = "error"; 522 break; 523 case "warning": 524 icon = "warn"; 525 break; 526 case "notice": 527 case "success":
528 case "info": 529 case "warn": 530 case "error": 531 case "help": 532 break 533 } 534 var style = ""; 535 if (icon.match(/\//)) { 536 style = 'style="background-image:url(' + icon + '); background-size:cover;"'; 537 icon = "custom" 538 } 539 var $notification = $('<div class="notification ' + opts.class_name + '"><i class="notify-icon icon-' + icon + '" ' + style + '></i><span class="notify-text"><span class="notify-title">' + opts.title + '</span><span class="notify-message">' + opts.message + "</span></span></div>"); 540 541 if (!$("#notification-wrapper").length) {$('<div id="notification-wrapper" />').appendTo(document.body);} 542 543 if (!opts.sticky) { 544 setTimeout(function(){ 545 $notification.addClass("animate-out"); 546 }, opts.delay) 547 } else { 548 $("#notification-wrapper").addClass("clickable") 549 } if (opts.click) { 550 $notification.on("click", opts.click).addClass("clickable"); 551 $("#notification-wrapper").addClass("clickable") 552 } else { 553 if (opts.url) { 554 $notification.on("click", function () { 555 window.location = opts.url; 556 $(this).addClass("animate-out") 557 }).addClass("clickable"); 558 $("#notification-wrapper").addClass("clickable") 559 } else { 560 $notification.on("click", function () { 561 $(this).addClass("animate-out") 562 }); 563 $("#notification-wrapper").addClass("clickable") 564 } 565 } 566 $notification.data("notify", opts); 567 $("#notification-wrapper").append($notification); 568 $notification.addClass("animate-in") 569 }; 570 init(); 571 return { 572 stick: stick, 573 notify: notify 574 } 575}(); 576 577 578/* ========================================================================== 579 Messages Slide Open 580 ========================================================================== 581*/ 582 583$('html, #messages a.close').click(function() { // clicking outside of the location dropdown will close it 584 if ($('#messages').hasClass('open')) { 585 $('#messages').slideUp(function() { 586 $('#messages').removeClass('open').addClass('closed'); 587 $('#message-center').removeClass('open'); 588 }); 589 } 590}); 591 592 593$('#messages').click(function(event){ // stop bubbling 594 event.stopPropagation(); 595}); 596 597 598$('#message-center').on('click', function() { // clicking on the choose your location link 599 600 if ($('#messages').hasClass('closed')) { // if the locations dropdown is closed 601 $('#message-center').addClass('open'); 602 if ($('body').hasClass('index')) { } else { $('.drop').hide(); } // if we're on secondaries, close the main-nav dropdowns 603 604 $('#messages').slideDown(); 605 606 $('#messages').fadeIn( function() { // and display the locations div 607 $('#messages').removeClass('closed').addClass('open'); 608 $('#message-center').removeClass('active'); 609 }); 610 611 } // end if locations are closed 612 613}); 614 615/* ========================================================================== 616 Quick Links Slide Open 617 ========================================================================== 618*/ 619 620$('html, #quicklinks-menu a.close').click(function() { // clicking outside of the location dropdown will close it 621 if ($('#quicklinks-menu').hasClass('open')) { 622 $('#quicklinks-menu').slideUp(function() { 623 $('#quicklinks-menu').removeClass('open').addClass('closed'); 624 $('#top-menu li.quicklinks').removeClass('open'); 625 }); 626 } 627}); 628 629 630$('#quicklinks-menu').click(function(event){ // stop bubbling 631 event.stopPropagation(); 632}); 633 634 635$('#top-menu li.quicklinks').on('click', function() { // clicking on the choose your location link 636 637 if ($('#quicklinks-menu').hasClass('closed')) { // if the locations dropdown is closed 638 $('#top-menu li.quicklinks').addClass('open'); 639 if ($('body').hasClass('index')) { } else { $('.drop').hide(); } // if we're on secondaries, close the main-nav dropdowns 640 641 $('#quicklinks-menu').slideDown(); 642 643 $('#quicklinks-menu').fadeIn( function() { // and display the locations div 644 $('#quicklinks-menu').removeClass('closed').addClass('open'); 645 $('#main-nav li').removeClass('open'); 646 $('#message-center').removeClass('open'); 647 }); 648 649 } // end if locations are closed 650 651}); 652 653 654/* ========================================================================== 655 Choose A Location Slide Open 656 ========================================================================== */ 657 658$('html, #locations a.close').click(function() { // clicking outside of the location dropdown will close it 659 660 if ($('#locations').hasClass('open')) { 661 662 663
664 $('#locations').slideUp(function() { 665 $('#locations').removeClass('open').addClass('closed'); 666 $('#top-menu li.hours').removeClass('open'); 667 }); 668 669 670 671 } 672 673}); 674 675 676$('#locations').click(function(event){ // stop bubbling 677 event.stopPropagation(); 678}); 679 680 681$('#top-menu li.hours').on('click', function() { // clicking on the choose your location link 682 683 if ($('#locations').hasClass('closed')) { // if the locations dropdown is closed 684 $('#top-menu li.hours').addClass('open'); 685 if ($('body').hasClass('index')) { } else { $('.drop').hide(); } // if we're on secondaries, close the main-nav dropdowns 686 687 $('#locations').slideDown(); 688 689 $('#locations').fadeIn( function() { // and display the locations div 690 $('#locations').removeClass('closed').addClass('open'); 691 $('#main-nav li').removeClass('active'); 692 $('#message-center').removeClass('open'); 693 }); 694 695 } // end if locations are closed 696 697}); 698// Show all hours at once 699function open_all_hours(which) { 700 $(which).toggleClass('open'); 701 $(which).text("Close All Hours"); 702 if($(which).hasClass('open')) { 703 $(which).text("Close All Hours"); 704 $('ul.show-all-hours').slideDown(); 705 $('a.all-hours-toggle').addClass('down').text('Today Only'); 706 $('.todays-hours, .todays-hours-title').hide(); 707 } else { 708 $(which).text("View All Hours"); 709 $('ul.show-all-hours').slideUp(); 710 $('a.all-hours-toggle').removeClass('down').text('View All'); 711 $('.todays-hours, .todays-hours-title').show(); 712 } 713 714} 715// Toggle view all hours on hours and location page 716function open_branch_hours(which) { 717 var branch = which; 718 if($('[data-branch="hours-'+branch+'"]').hasClass('down')) { 719 $('ul#branch-list'+branch).slideUp(); 720 $('#today-branch-'+branch+", #today-title-"+branch).show(); 721 $('[data-branch="hours-'+branch+'"]').text('View All').removeClass('down'); 722 } else { 723 $('#today-branch-'+branch +", #today-title-"+branch).hide(); 724 $('ul#branch-list'+branch).slideDown(); 725 $('[data-branch="hours-'+branch+'"]').text('Today Only').addClass('down'); 726 } 727 728 729 730} 731 732 733 734 735// jQuery(function($) { 736 // // Asynchronously Load the map API 737 // var script = document.createElement('script'); 738 // script.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyA5f65LyVJVKUq4pRaR93yqFaD30zWFhYg&callback=initialize"; 739 // document.body.appendChild(script); 740// }); 741 742 743var topMarkers = Array(); 744var bottomMarkers = Array(); 745var branchMarkers = Array(); 746var infoWindows = Array(); 747var infoWindows2 = Array(); 748var originalContent = Array(); 749var chosenContent = Array(); 750 751$('li.hours').click(function() { 752 // Asynchronously Load the map API 753 var script = document.createElement('script'); 754 script.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyA5f65LyVJVKUq4pRaR93yqFaD30zWFhYg&callback=initialize"; 755 document.body.appendChild(script); 756 setTimeout(() => { 757 758 var address = $('span#address').html(); 759 //console.log(address); 760 var map; 761 var bounds = new google.maps.LatLngBounds(); 762 var mapOptions = { 763 mapTypeId: 'roadmap', 764 mapTypeControl: false, 765 streetViewControl: false, 766 }; 767 768 // Display a map on the page 769 // console.log('Hours pane click to init map'); 770 map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); 771 772 773 map.setTilt(45); 774 775 // Display multiple markers on a map 776 /* var infoWindow = new google.maps.InfoWindow(), marker, i; */ 777 778 var image = '/assets/images/mapmarker.png'; 779 var openWindow = ''; 780 781 // Loop through our array of markers & place each one on the map 782 for( i = 0; i < markers.length; i++ ) { 783 var position = new google.maps.LatLng(markers[i][2], markers[i][3]); 784 bounds.extend(position); 785 topMarkers[markers[i][0]] = new google.maps.Marker({ 786 position: position, 787 map: map, 788 title: markers[i][1], 789 icon: image, 790 zIndex: parseInt(markers[i][0]) 791 }); 792 793 //console.log(topMarkers); 794 795 originalContent[markers[i][0]] = '<div class="infowindow"><h5>'+markers[i][1]+'</h5>'+markers[i][4]+'<br><b>Hours Today:</b> '+markers[i][5]+'<br><a href="'+markers[i][6]+'" class="readmore">More Information</a><br><span class="choose"><i class="fa fa-home"></i> Make This My MPL</span></div>'; 796 chosenContent[markers[i][0]] = '<div class="infowindow"><h5>'+markers[i][1]+'</h5>'+markers[i][4]+'<br><b>Hours Today:</b> '+markers[i][5]+'<br><a href="'+markers[i][6]+'" class="readmore">More Information</a><br><span class="chosen"><i class="fa fa-home"></i> This Is My MPL</span></div>' 797 798 infoWindows[markers[i][0]] = new google.maps.InfoWindow({ 799 content: originalContent[markers[i][0]], 800 zIndex: parseInt(markers[i][0]) 801 }); 802 803 804 google.maps.event.addListener(topMarkers[markers[i][0]], 'mouseover', function() { 805 this.setIcon("/assets/images/mapmarker.hover.png"); 806 $(".top-location.id-"+this.zIndex).addClass("hover"); 807 }); 808 google.maps.event.addListener(topMarkers[markers[i][0]], 'mouseout', function() { 809 if(!$(".top-location.id-"+this.zIndex).hasClass('selected')) { 810 this.setIcon("/assets/images/mapmarker.png"); 811 } 812 $(".top-location.id-"+this.zIndex).removeClass("hover"); 813 }); 814 google.maps.event.addListener(topMarkers[markers[i][0]], 'click', function() { 815 if (openWindow.length != 0) { openWindow.close(); } 816 infoWindows[this.zIndex].open(map,topMarkers[this.zIndex]); 817 openWindow = infoWindows[this.zIndex]; 818 }); 819 google.maps.event.addDomListener(infoWindows[markers[i][0]], 'domready', function() { 820 var windowIndex = this.zIndex; 821 822 $('.choose').click(function() { 823 if ($('.top-location.selected').length != 0) { 824 oldMarker = $('.top-location.selected').data('id'); 825 topMarkers[oldMarker].setIcon("/assets/images/mapmarker.png"); 826 infoWindows[oldMarker].setContent(originalContent[oldMarker]); 827 } 828 829 infoWindows[windowIndex].setContent(chosenContent[windowIndex]); 830 topMarkers[windowIndex].setIcon("/assets/images/mapmarker.hover.png"); 831 832 $('#location-list li').removeClass('selected'); // remove the selected state from any that are 833 $(".top-location.id-"+windowIndex).addClass("selected"); 834 $(".bottom-location.id-"+windowIndex).addClass("selected"); 835 836 var selectedLocation = 'location='+$(".top-location.id-"+windowIndex).find('h6').text(); // fake the $_GET with the location name 837 838 // console.log(selectedLocation); 839 840 $.ajax({ // send it to the cookie baker 841 type: 'GET',
842 url: '/assets/cookies.php', 843 data: selectedLocation 844 }); 845 846 $('#location-name').hide().html($(".top-location.id-"+windowIndex).find('h6').text()).fadeIn('slow'); 847 }); 848 }); 849 850 // Automatically center the map fitting all markers on the screen 851 map.fitBounds(bounds); 852 } 853 854 // Override our map zoom level once our fitBounds function runs (Make sure it only runs once) 855 var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function(event) { 856 this.setZoom(11); 857 google.maps.event.removeListener(boundsListener); 858 }); 859 860 if ($(".top-location[data-map-marker='true']").hasClass('selected')) { 861 markerID = $(".top-location[data-map-marker='true'].selected").data("id"); 862 topMarkers[markerID].setIcon("/assets/images/mapmarker.hover.png"); 863 infoWindows[markerID].setContent(chosenContent[markerID]); 864 } 865 866 $(".top-location[data-map-marker='true']").hover(function(event){ 867 topMarkers[$(this).data("id")].setIcon("/assets/images/mapmarker.hover.png"); 868 }, function(event){ 869 markerID = $(this).data("id"); 870 if(!$(".top-location.id-"+markerID).hasClass('selected')) { 871 topMarkers[$(this).data("id")].setIcon("/assets/images/mapmarker.png"); 872 } 873 }); 874 875 }, 250); 876 877}); 878 879function initialize() { 880 881 var map_branch; 882 var bounds2 = new google.maps.LatLngBounds(); 883 var mapOptions2 = { 884 mapTypeId: 'roadmap', 885 disableDefaultUI: true, 886 streetViewControl: false, 887 }; 888 889 // if no canvas, don't do the map added by MD 20180916 890 if (!document.getElementById("branch-canvas")) return; 891 892 // Display a map on the page 893 map_branch = new google.maps.Map(document.getElementById("branch-canvas"), mapOptions2); 894 895 //map2.setTilt(45); 896 897 // Display multiple markers on a map 898 var infoWindow = new google.maps.InfoWindow(), marker, i; 899 900 var image2 = '/assets/images/mapmarker2.png'; 901 902 // Loop through our array of markers & place each one on the map 903 for( i = 0; i < markers.length; i++ ) { 904 var position2 = new google.maps.LatLng(markers[i][2], markers[i][3]); 905 bounds2.extend(position2); 906 branchMarkers[markers[i][0]] = new google.maps.Marker({ 907 position: position2, 908 map: map_branch, 909 title: markers[i][1], 910 icon: image2, 911 zIndex: parseInt(markers[i][0]) 912 }); 913 originalContent[markers[i][0]] = '<div class="infowindow"><h5>'+markers[i][1]+'</h5>'+markers[i][4]+'<br><b>Hours Today:</b> '+markers[i][5]+'<br><a href="'+markers[i][6]+'" class="readmore">More Information</a><br><span class="choose"><i class="fa fa-home"></i> Make This My MPL</span></div>'; 914 chosenContent[markers[i][0]] = '<div class="infowindow"><h5>'+markers[i][1]+'</h5>'+markers[i][4]+'<br><b>Hours Today:</b> '+markers[i][5]+'<br><a href="'+markers[i][6]+'" class="readmore">More Information</a><br><span class="chosen"><i class="fa fa-home"></i> This Is My MPL</span></div>' 915 916 infoWindows2[markers[i][0]] = new google.maps.InfoWindow({ 917 content: originalContent[markers[i][0]], 918 zIndex: parseInt(markers[i][0]) 919 }); 920 google.maps.event.addListener(branchMarkers[markers[i][0]], 'mouseover', function() { 921 this.setIcon("/assets/images/mapmarker2.hover.png"); 922 $(".bottom-location.id-"+this.zIndex).addClass("hover"); 923 //console.log(this.zIndex); 924 }); 925 google.maps.event.addListener(branchMarkers[markers[i][0]], 'mouseout', function() { 926 if (!$(".bottom-location.id-"+this.zIndex).hasClass('selected')) { 927 this.setIcon("/assets/images/mapmarker2.png"); 928 } 929 $(".bottom-location.id-"+this.zIndex).removeClass("hover"); 930 }); 931 google.maps.event.addListener(branchMarkers[markers[i][0]], 'click', function() { 932 if (openWindow.length != 0) { openWindow.close(); } 933 infoWindows2[this.zIndex].open(map_branch,branchMarkers[this.zIndex]); 934 openWindow = infoWindows2[this.zIndex]; 935 }); 936 google.maps.event.addDomListener(infoWindows2[markers[i][0]], 'domready', function() { 937 var windowIndex = this.zIndex; 938 939 $('.choose').click(function() { 940 if ($('.top-location.selected').length != 0) { 941 oldMarker = $('.top-location.selected').data('id'); 942 branchMarkers[oldMarker].setIcon("/assets/images/mapmarker2.png"); 943 //infoWindows[oldMarker].setContent(originalContent[oldMarker]); 944 infoWindows2[oldMarker].setContent(originalContent[oldMarker]); 945 } 946 947 //infoWindows[windowIndex].setContent(chosenContent[windowIndex]); 948 infoWindows2[windowIndex].setContent(chosenContent[windowIndex]); 949 branchMarkers[windowIndex].setIcon("/assets/images/mapmarker2.hover.png"); 950 //topMarkers[windowIndex].setIcon("/assets/images/mapmarker.hover.png"); 951 952 $('#location-list li').removeClass('selected'); // remove the selected state from any that are 953 $(".top-location.id-"+windowIndex).addClass("selected"); 954 $(".bottom-location.id-"+windowIndex).addClass("selected"); 955 956 var selectedLocation = 'location='+$(".top-location.id-"+windowIndex).find('h6').text(); // fake the $_GET with the location name 957 958 // console.log(selectedLocation); 959 960 $.ajax({ // send it to the cookie baker 961 type: 'GET',
962 url: '/assets/cookies.php', 963 data: selectedLocation 964 }); 965 966 $('#location-name').hide().html($(".top-location.id-"+windowIndex).find('h6').text()).fadeIn('slow'); 967 }); 968 }); 969 970 971 // Automatically center the map fitting all markers on the screen 972 map_branch.fitBounds(bounds2); 973 } 974 975 // Override our map zoom level once our fitBounds function runs (Make sure it only runs once) 976 var boundsListener2 = google.maps.event.addListener((map_branch), 'bounds_changed', function(event) { 977 this.setZoom(11); 978 google.maps.event.removeListener(boundsListener2); 979 }); 980 981 /*In these listeners, we retrieve the index of the marker, and use that 982 to retrieve the unique id of its location ("#location_<index>"), and set 983 an active state on it. The second listener removes it*/ 984 $(".bottom-location[data-map-marker='true']").hover(function(event){ 985 branchMarkers[$(this).data("id")].setIcon("/assets/images/mapmarker2.hover.png"); 986 }, function(event){ 987 markerID = $(this).data("id"); 988 if(!$(".bottom-location.id-"+markerID).hasClass('selected')) { 989 branchMarkers[$(this).data("id")].setIcon("/assets/images/mapmarker2.png"); 990 } 991 }); 992 993 if ($(".bottom-location[data-map-marker='true']").hasClass('selected')) { 994 markerID = $(".bottom-location[data-map-marker='true'].selected").data("id"); 995 branchMarkers[markerID].setIcon("/assets/images/mapmarker2.hover.png"); 996 } 997 998} // end initilize map 999 1000function initializemap() { 1001 console.log('initializemap()'); 1002 var map2; 1003 var bounds2 = new google.maps.LatLngBounds(); 1004 var mapOptions2 = { 1005 mapTypeId: 'roadmap', 1006 }; 1007 1008 // Display a map on the page 1009 map2 = new google.maps.Map(document.getElementById("map-canvas"), mapOptions2); 1010 1011 map2.setTilt(45); 1012 1013 // Display multiple markers on a map 1014/* var infoWindow = new google.maps.InfoWindow(), marker, i; */ 1015 1016 var image2 = '/assets/images/mapmarker2.png'; 1017 1018 // Loop through our array of markers & place each one on the map 1019 for( i = 0; i < markers.length; i++ ) { 1020 var position2 = new google.maps.LatLng(markers[i][2], markers[i][3]); 1021 bounds2.extend(position2); 1022 bottomMarkers[markers[i][0]] = new google.maps.Marker({ 1023 position: position2, 1024 map: map2, 1025 title: markers[i][1], 1026 icon: image2, 1027 zIndex: parseInt(markers[i][0]) 1028 }); 1029 originalContent[markers[i][0]] = '<div class="infowindow"><h5>'+markers[i][1]+'</h5>'+markers[i][4]+'<br><b>Hours Today:</b> '+markers[i][5]+'<br><a href="'+markers[i][6]+'" class="readmore">More Information</a><br><span class="choose"><i class="fa fa-home"></i> Make This My MPL</span></div>'; 1030 chosenContent[markers[i][0]] = '<div class="infowindow"><h5>'+markers[i][1]+'</h5>'+markers[i][4]+'<br><b>Hours Today:</b> '+markers[i][5]+'<br><a href="'+markers[i][6]+'" class="readmore">More Information</a><br><span class="chosen"><i class="fa fa-home"></i> This Is My MPL</span></div>' 1031 1032 infoWindows2[markers[i][0]] = new google.maps.InfoWindow({ 1033 content: originalContent[markers[i][0]], 1034 zIndex: parseInt(markers[i][0]) 1035 }); 1036 google.maps.event.addListener(bottomMarkers[markers[i][0]], 'mouseover', function() { 1037 this.setIcon("/assets/images/mapmarker2.hover.png"); 1038 $(".bottom-location.id-"+this.zIndex).addClass("hover"); 1039 //console.log(this.zIndex); 1040 }); 1041 google.maps.event.addListener(bottomMarkers[markers[i][0]], 'mouseout', function() { 1042 if (!$(".bottom-location.id-"+this.zIndex).hasClass('selected')) { 1043 this.setIcon("/assets/images/mapmarker2.png"); 1044 } 1045 $(".bottom-location.id-"+this.zIndex).removeClass("hover"); 1046 }); 1047 google.maps.event.addListener(bottomMarkers[markers[i][0]], 'click', function() { 1048 if (openWindow.length != 0) { openWindow.close(); } 1049 infoWindows2[this.zIndex].open(map2,bottomMarkers[this.zIndex]); 1050 openWindow = infoWindows2[this.zIndex]; 1051 }); 1052 google.maps.event.addDomListener(infoWindows2[markers[i][0]], 'domready', function() { 1053 var windowIndex = this.zIndex; 1054 1055 $('.choose').click(function() { 1056 if ($('.top-location.selected').length != 0) { 1057 oldMarker = $('.top-location.selected').data('id'); 1058 bottomMarkers[oldMarker].setIcon("/assets/images/mapmarker2.png"); 1059 //infoWindows[oldMarker].setContent(originalContent[oldMarker]); 1060 infoWindows2[oldMarker].setContent(originalContent[oldMarker]); 1061 } 1062 1063 //infoWindows[windowIndex].setContent(chosenContent[windowIndex]); 1064 infoWindows2[windowIndex].setContent(chosenContent[windowIndex]); 1065 bottomMarkers[windowIndex].setIcon("/assets/images/mapmarker2.hover.png"); 1066 //topMarkers[windowIndex].setIcon("/assets/images/mapmarker.hover.png"); 1067 1068 $('#location-list li').removeClass('selected'); // remove the selected state from any that are 1069 $(".top-location.id-"+windowIndex).addClass("selected"); 1070 $(".bottom-location.id-"+windowIndex).addClass("selected"); 1071 1072 var selectedLocation = 'location='+$(".top-location.id-"+windowIndex).find('h6').text(); // fake the $_GET with the location name 1073 1074 // console.log(selectedLocation); 1075 1076 $.ajax({ // send it to the cookie baker 1077 type: 'GET',
1078 url: '/assets/cookies.php', 1079 data: selectedLocation 1080 }); 1081 1082 $('#location-name').hide().html($(".top-location.id-"+windowIndex).find('h6').text()).fadeIn('slow'); 1083 }); 1084 }); 1085 1086 1087 // Automatically center the map fitting all markers on the screen 1088 map2.fitBounds(bounds2); 1089 } 1090 1091 // Override our map zoom level once our fitBounds function runs (Make sure it only runs once) 1092 var boundsListener2 = google.maps.event.addListener((map2), 'bounds_changed', function(event) { 1093 this.setZoom(11); 1094 google.maps.event.removeListener(boundsListener2); 1095 }); 1096 1097 /*In these listeners, we retrieve the index of the marker, and use that 1098 to retrieve the unique id of its location ("#location_<index>"), and set 1099 an active state on it. The second listener removes it*/ 1100 $(".bottom-location").hover(function(event){ 1101 bottomMarkers[$(this).data("id")].setIcon("/assets/images/mapmarker2.hover.png"); 1102 }, function(event){ 1103 markerID = $(this).data("id"); 1104 if(!$(".bottom-location.id-"+markerID).hasClass('selected')) { 1105 bottomMarkers[$(this).data("id")].setIcon("/assets/images/mapmarker2.png"); 1106 } 1107 }); 1108 1109 if ($(".bottom-location").hasClass('selected')) { 1110 markerID = $(".bottom-location.selected").data("id"); 1111 bottomMarkers[markerID].setIcon("/assets/images/mapmarker2.hover.png"); 1112 } 1113 1114} // end initilize map 1115 1116 1117 $('#location-list li').click(function(event) { // when clicking on a location in the locations dropdown 1118 var target = $(event.target); 1119 if (target.is("a")) { 1120 return; 1121 } 1122 var locationID = $(this).data("id"); 1123 //console.log("New: "+locationID); 1124 if ($('#location-list li.selected').length != 0 && !$("#location-list li[data-map-marker='false'].selected")) { 1125 var oldLocation = $('#location-list li.selected').data('id'); 1126 //console.log("Old: "+oldLocation); 1127 if($('.bottom-location').length != 0) { 1128 bottomMarkers[oldLocation].setIcon("/assets/images/mapmarker2.png"); 1129 infoWindows2[oldLocation].setContent(originalContent[oldLocation]); 1130 infoWindows2[locationID].setContent(chosenContent[locationID]); 1131 } 1132 //topMarkers[oldLocation].setIcon("/assets/images/mapmarker.png"); 1133 //infoWindows[oldLocation].setContent(originalContent[oldLocation]); 1134 } 1135 1136 //infoWindows[locationID].setContent(chosenContent[locationID]); 1137 1138 $('#location-list li').removeClass('selected'); // remove the selected state from any that are 1139 1140 $('.top-location.id-'+locationID).addClass('selected'); // and select this one instead 1141 if($('.bottom-location').length != 0 && !$(".bottom-location[data-map-marker='false']")) { 1142 $('.bottom-location.id-'+locationID).addClass('selected'); 1143 bottomMarkers[locationID].setIcon("/assets/images/mapmarker2.hover.png"); 1144 } // and select this one instead 1145 1146 //topMarkers[locationID].setIcon("/assets/images/mapmarker.hover.png"); 1147 var selectedLocation = 'location='+$(this).find('h6').text(); // fake the $_GET with the location name 1148 1149 // console.log(selectedLocation); 1150 1151 $.ajax({ // send it to the cookie baker 1152 type: 'GET', 1153 url: '/assets/cookies.php', 1154 data: selectedLocation 1155 }); 1156 1157 $('#location-name').hide().html($(this).find('h6').text()).fadeIn('slow'); 1158 1159 }); // end clicking on a location 1160 1161/* 1162 $('#location-list li').hover( function() { // when hovering on a location list item 1163 markID = $(this).data('id'); // grab it's data-id, should correspond to position in markers[] 1164 markers[markID].setIcon('/assets/mapmarker2.png'); // reset the icon of the marker 1165 }); 1166*/ 1167 1168 1169/*==================================================================================================== 1170 Booklists 1171====================================================================================================*/ 1172function getBooks(books) { 1173 $.ajax({ 1174 url: "/assets/inc/booklists_2020.php", 1175 dataType: "json", 1176 type: "GET", 1177 contentType: "application/json", 1178 data: {id:books}, 1179 success: function(data) { 1180 console.log(data); 1181 1182 var output = ''; 1183 1184 for (var i = 0; i < data.books.length; i++) { 1185 // set/determine dataBookCover's value 1186 if (data.books[i].image_override) var dataBookCover = data.books[i].image_override; 1187 else var dataBookCover = "https://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=MCFL97008&Password=CC29541&Return=1&Type=L&Value=\'"+data.books[i].isbn+"\'&erroroverride="; 1188 // set/determine buttonText's value 1189 if(data.books[i].button_override) var buttonText = data.books[i].button_override; 1190 else var buttonText = 'View on CountyCat'; 1191 1192 output += "<div class='book-item' data-id='"+data.books[i].id+"'>" 1193 output += "<div class='book-cover'>"; 1194 output += "<div class='cover-front'>"; 1195 if (data.books[i].image_override) { 1196 // output += '<img src="'+data.books[i].image_override+'" alt="'+data.books[i].title+'" />'; 1197 output += "<div class='pane' style='background-image:url("+data.books[i].image_override+")'></div>"; 1198 } else { 1199 output += '<img src="https://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=MCFL97008&Password=CC29541&Return=1&Type=L&Value='+data.books[i].isbn+'&erroroverride=" alt="'+data.books[i].title+'" />'; 1200 } 1201 output += "</div>"; 1202 output += "<div class='cover-back'></div>"; 1203 output += "</div>"; 1204 1205 output += "<div class='book-content'>"; 1206 output += "<div class='heading'>"+data.books[i].title+"<br /> <span>by "+data.books[i].author+"</span></div>"; 1207 output += "<p class='desc'>"+data.books[i].description+"</p>"; 1208 if (data.books[i].links.length > 1) { 1209 output += "<div class='links-container' data-id='"+data.books[i].id+"'>"; 1210 output += "<a href='#' class='links-top' onclick='toggleBookDropdown("+data.books[i].id+"); return false;'>Available as..</a>"; 1211 output += "<div class='links-dropdown'>"; 1212 for (var j=0; j<data.books[i].links.length; j++) { 1213 output += "<a href='"+data.books[i].links[j].link+"' target='_blank' class='link "+data.books[i].links[j].type_slug+"'>"+data.books[i].links[j].type+"</a>"; 1214 } 1215 output += "</div>"; // closes .links-dropdown 1216 output += "</div>"; // closes .links-container 1217 } else { 1218 output += "<a href='"+data.books[i].countycat_link+"' target='_blank' class='view-all'>"+buttonText+"</a>"; 1219 } 1220 output += "</div>"; 1221 output += "</div>"; 1222 1223 /* 1224 output += '<div class="bookcover" onclick="location.href=\''+data.books[i].countycat_link+'\'" id="'+data.books[i].id+'">'; 1225 if(data.books[i].image_override) output += '<div class="flipcover"><div class="frontface"><img src="'+data.books[i].image_override+'" alt="'+data.books[i].title+'" /></div>'; 1226 else output += '<div class="flipcover"><div class="frontface"><img src="https://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=MCFL97008&Password=CC29541&Return=1&Type=L&Value='+data.books[i].isbn+'&erroroverride=" alt="'+data.books[i].title+'" /></div>'; 1227 if(data.books[i].button_override) var buttonText = data.books[i].button_override; 1228 else var buttonText = 'View on CountyCat'; 1229 output += '<div class="backface">'; 1230 output += '<h3>'+data.books[i].title+'<br /> <span>
1230by '+data.books[i].author+'</span></h3>'; 1231 output += '<p class="desc">'+data.books[i].description+'</p>' 1232 output += '<a href="'+data.books[i].countycat_link+'" class="view-all external">'+buttonText+'</a></div></div></div>'; 1233 */ 1234 } 1235 1236 1237 var old = $('#content').html(); 1238 $('#booklist-container').hide().html(output).fadeIn(); 1239 $('h4#title').html(data.booklist[0].title); 1240 $('#booklist_description').html(data.booklist[0].description); 1241 if (data.booklist[0].pdf) { 1242 console.log ('--->', data.booklist[0].pdf); 1243 $('#booklist-pdf').html('<a id="booklist-pdf-2" href="'+data.booklist[0].pdf+'">Download PDF <i class="fa fa-file-pdf-o"></i></a>'); 1244 } 1245 1246 //This is where we update the address bar with the 'url' parameter 1247 var url = '?booklist='+data.booklist[0].slug; 1248 1249 history.pushState({html:old},'',url); 1250 } 1251 }); 1252} 1253 1254window.onpopstate = function(e) { 1255 if (e.state && e.state.html) { 1256 $('#content').html(e.state.html); 1257 } 1258} 1259/*==================================================================================================== 1260 Booklists: Toggle Dropdown 1261====================================================================================================*/ 1262function toggleBookDropdown(index) { 1263 // set bookItems - then loop though them to find selected one 1264 var bookItems = document.getElementsByClassName('book-item'); 1265 for (var i=0; i<bookItems.length; i++) { 1266 if (bookItems[i].getAttribute('data-id') == index && !bookItems[i].classList.contains('dropdown-active')) { 1267 bookItems[i].classList.add('dropdown-active'); 1268 } else bookItems[i].classList.remove('dropdown-active'); 1269 } 1270} 1271 1272 1273/* ========================================================================== 1274 Locations Area click on Closing Link 1275 ========================================================================== */ 1276 1277function show_closing_panel(which){ 1278 //$(this).toggleClass('collapsed'); 1279 $(which).children('span').slideToggle(); 1280 //$(this)('.expanded').slideToggle(); 1281} 1282 1283/* ========================================================================== 1284 Calendar 1285 ========================================================================== */ 1286$('html').click(function() { 1287 $('div.contain').removeClass('open').addClass('closed'); 1288 $('.contain.closed').animate({ opacity:1,scrollTop:0 }); 1289}); 1290 1291$('.event_links').on('click', '.total-events', function(event) { 1292 event.stopPropagation(); 1293 if ($(this).parent().parent('div.contain').hasClass('open')) { 1294 $(this).parent().parent('div.contain').removeClass('open').addClass('closed'); 1295 $('.contain.open').animate({ opacity:1 }); 1296 $('.contain.closed').animate({ opacity:1,scrollTop:0 }); 1297 } else { 1298 $('div.contain').removeClass('open').addClass('closed'); 1299 $(this).parent().parent('div.contain').addClass('open').removeClass('closed'); 1300 $('.contain.open').animate({ opacity:1 }); 1301 $('.contain.closed').animate({ opacity:.5 }); 1302 1303 } 1304}); 1305 1306 1307/* ========================================================================== 1308 Scrolling 1309 ========================================================================== */ 1310 1311var leftNavHeight = $('nav#left-nav').outerHeight(); 1312 1313//console.log(leftNavHeight); 1314 1315$('[href^="#"]').on('click',function() { 1316 1317 var anchor = $(this).attr('href'); 1318 1319 //check if anchor exists 1320 if ($(anchor).length > 1) { 1321 $('body,html').animate({ 1322 scrollTop: $(anchor).offset().top - 130 1323 }); 1324 } 1325 1326}); 1327 1328if (!$('body').hasClass("no-left")) { 1329 $(window).scroll(function() { 1330 //console.log("Scroll: "+ $('body').scrollTop()); 1331 1332 if ($('body').scrollTop() > leftNavHeight/4) { 1333 $('#to-top-container').fadeIn(); 1334 } else if ($('body').scrollTop() < leftNavHeight/4) { 1335 $('#to-top-container').fadeOut(); 1336 } 1337 }); 1338} 1339 1340$(window).load(function() { 1341 // console.log(location.hash.substring(1, 7)); 1342 if (location.hash && location.hash.substring(1, 7) != 'covid-') { 1343 var loadAnchor = location.hash; 1344 if($(loadAnchor).offset()){ 1345 $('body,html').animate({ 1346 scrollTop: $(loadAnchor).offset().top - 130 1347 }); 1348 } 1349 } 1350}); 1351 1352/* ========================================================================== 1353 External Links and PDFs 1354 ========================================================================== */ 1355 1356$('a').filter(function() { 1357 return this.hostname && this.hostname !== location.hostname; 1358}).addClass("external"); 1359$('a.external img').parent('a').removeClass('external'); 1360$('.box a').removeClass('external'); 1361 1362$('a[href$=".pdf"]').addClass("pdf"); 1363 1364/* ========================================================================== 1365 Newletter Sign-up 1366 ========================================================================== */ 1367/* 1368function newsletterSignup() { 1369 1370 $('#news-contain .errors').html(''); 1371 1372 var errors = false;
1373 1374 if (!errors) { 1375 1376 var email = $('#news-contain input#email').val(); 1377 var firstname = $('#news-contain input#firstname').val(); 1378 var lastname = $('#news-contain input#lastname').val(); 1379 1380 $.ajax({ 1381 type: 'POST', 1382 url: '/assets/inc/subscribe.php', 1383 data: 'ajax=1&email='+email+'&firstname='+firstname+'&lastname='+lastname, 1384 dataType: 'json', 1385 success: function(msg){ 1386 //console.log(msg); 1387 //console.log(msg.status); 1388 if (msg.status != 'success') { 1389 //console.log('m_not_success'); 1390 1391 $('#news-contain .errors').html(msg.responseText); 1392 $('#news-contain .errors').show('fast'); 1393 1394 } else { 1395 1396 //console.log('msuccess'); 1397 $('#news-contain').html('<p><b>Thank you for signing up to receive our newsletter!</b></p><p>You will receive an email to confirm your subscription.</p>'); 1398 $('#news-contain').show('fast'); 1399 1400 } 1401 }, 1402 1403 error: function(msg){ 1404 $('#news-contain .errors').html(msg.responseText); 1405 $('#news-contain .errors').show('fast'); 1406 } 1407 }); 1408 1409 } else {} 1410} 1411*/ 1412 1413/* ========================================================================== 1414 Mobile Location Chooser 1415 ========================================================================== */ 1416 1417 $('#expand-chooser').on('click', function() { 1418 $('#location-chooser').toggleClass('open'); 1419 }); 1420 $('#choose-branch,#choose-branch2').on('click', function() { 1421 $('#show-branches').toggleClass('open'); 1422 }); 1423 1424 $('#branch-expanded .location').on('click',function() { 1425 var selectedLocation = 'location='+$(this).find('h6 b').text(); // fake the $_GET with the location name 1426 1427 $.ajax({ // send it to the cookie baker 1428 type: 'GET', 1429 url: '/assets/cookies.php', 1430 data: selectedLocation, 1431 complete: function() { 1432 window.location.reload(); 1433 } 1434 }); 1435 }); 1436 1437 1438 1439/* ========================================================================== 1440 Events 1441 ========================================================================== */ 1442 1443function getEvents(clear) { 1444 console.log('getEvents:'+clear); 1445 var today = getISODateTime(new Date()); 1446 1447 if (clear) { 1448 var searchQuery = '?location=&category&user=&startdate=&enddate='; 1449 } else { 1450 var searchQuery = $('#eventfilter').serialize(); 1451 } 1452 1453 if ($('.ie9').length === 0) { 1454 history.pushState({}, '', '?'+searchQuery); 1455 } 1456 1457 // Update Links for Sticky Filtering 1458 var $nextMonthLink = $('#next-month'); 1459 var $prevMonthLink = $('#prev-month'); 1460 var $nextMonthBase = $nextMonthLink.attr('href'); 1461 var $prevMonthBase = $prevMonthLink.attr('href'); 1462 1463 $nextMonthLink.prop('href', $nextMonthBase + '&' + searchQuery); 1464 $prevMonthLink.prop('href', $prevMonthBase + '&' + searchQuery); 1465 1466 $.ajax({ 1467 url: "/assets/inc/eventfilter.php", 1468 dataType: "json", 1469 type: "GET", 1470 contentType: "application/json", 1471 data: searchQuery, 1472 1473 success: function(data) { 1474 1475 // start list view output 1476 var output = ''; 1477 var overallCounter = 0; 1478 var theDate = ''; 1479 var findDate = ''; 1480 var theTime = ''; 1481 var findTime = ''; 1482 var classes = ''; 1483 var color = ''; 1484 1485 //console.log(data.length); 1486 1487 for (var i = 0; i < data.length; i++) { 1488 overallCounter++; 1489 1490 theDate = data[i].date; 1491 if (theDate != findDate) { 1492 if (output != '') { output += '</div>'; } 1493 output += '<h4>'+data[i].date+'</h4>'; 1494 output += '<div class="event-list">'; 1495 findTime = ''; 1496 classes = ''; 1497 color = ''; 1498 } 1499 1500 theTime = data[i].time; 1501 if (theTime != findTime) { 1502 classes = ''; 1503 classes += 'first '; 1504 1505 if (color == '') { 1506 color = 'dark '; 1507 } else { 1508 color = ''; 1509 } 1510 classes += color; 1511 1512 } else { 1513 classes = ''; 1514 classes += color; 1515 } 1516 1517 output += '<div class="'+classes+'">'; 1518 output += '<span class="time">'+data[i].time+'</span>'; 1519 output += '<h5><a href="/services/events/?eid='+data[i].id+'">'+data[i].title+'</a> <span>at</span> '+data[i].location+'</h5>'; 1520 output += '<p>'+data[i].description+'</p>'; 1521 output += '</div>'; 1522 1523 findTime = data[i].time; 1524 findDate = data[i].date; 1525 } 1526 1527 $('#event-results').hide().html(output).fadeIn(); 1528 1529 1530 1531 $('#calendar td .event_links').each(function(object) { 1532 $(this).html(''); 1533 }); 1534 1535 $('#calendar td .event_links').each(function(object) { 1536 var eventItem = ''; 1537 var oldTitle; 1538 1539 var total_events = 0;
1540 var this_event_count = 1; 1541 var printed_events = 0; 1542 var bg_class; 1543 var event_title = ''; 1544 var oldTime; 1545 1546 var boxDay = parseInt($(this).data('day')); 1547 for (var x = 0; x < data.length; x++) { 1548 1549 if (data[x].day == boxDay) { 1550 total_events++; 1551 1552 if (data[x].title == "Teacher in the Library <b>(Bilingual Spanish teacher available)</b>") { 1553 event_title = "Teacher in the Library"; 1554 } else { 1555 event_title = data[x].title; 1556 } 1557 1558 if (event_title != oldTitle) { 1559 if (printed_events % 2 == 0) { 1560 bg_class = ''; 1561 } else { 1562 bg_class = ' odd '; 1563 } 1564 eventItem += '<a href="index.php?eid='+data[x].id+'" class="event_item '+bg_class+'"><span class="time">'+data[x].time+' <span class="hide location">'+data[x].location+'</span></span><br>'+data[x].title; 1565 printed_events++; 1566 } else if (event_title == oldTitle && data[x].time != oldTime) { 1567 if (printed_events % 2 == 0) { 1568 bg_class = ''; 1569 } else { 1570 bg_class = ' odd '; 1571 } 1572 eventItem += '<a href="index.php?eid='+data[x].id+'" class="event_item '+bg_class+'"><span class="time">'+data[x].time+' <span class="hide location">'+data[x].location+'</span></span><br>'+data[x].title; 1573 printed_events++; 1574 } else { 1575 if (printed_events >= 1 && this_event_count == 1) { 1576 eventItem += ' <i class="fa fa-plus open-hide" title="Multiple Locations"></i></a>'; 1577 } 1578 eventItem += '<a href="index.php?eid='+data[x].id+'" class="event_item hide '+bg_class+'"><span class="time">'+data[x].time+' <span class="hide location">'+data[x].location+'</span></span><br>'+data[x].title+'</a>'; 1579 this_event_count++; 1580 } 1581 oldTitle = event_title; 1582 oldTime = data[x].time; 1583 } 1584 } 1585 $(this).append(eventItem); 1586 if (printed_events > 3 || total_events > 3) { 1587 $(this).append('</a><div class="total-events" title="Show/Hide All Events"><span>'+total_events+'</span> events <i class="fa fa-lg fa-expand"></i></div>'); 1588 } 1589 1590 }); 1591 } 1592 }); 1593 1594 } 1595 1596 1597/*==================================================================================================== 1598 Alert Block Cookie 1599====================================================================================================*/ 1600/*======================================== 1601 Check for Option Block Cookie 1602========================================*/ 1603function optionsBlockScroll(which) { 1604 if (which != null) { 1605 setCookie("alert_seen", true, 1); 1606 1607 // hide alert block 1608 $('#alert-block').addClass('hidden'); 1609 } 1610} 1611/*======================================== 1612 Get Alert Cookie 1613========================================*/ 1614function getCookie(which) { 1615 var v = document.cookie.match('(^|;) ?' + which + '=([^;]*)(;|$)'); 1616 return v ? v[2] : null; 1617} 1618/*======================================== 1619 Set Alert Cookie 1620========================================*/ 1621function setCookie(name, value, days) { 1622 var date = new Date; 1623 date.setTime(date.getTime() + 24*60*60*1000*days); 1624 document.cookie = name + "=" + value + ";path=/;expires=" + date.toGMTString(); 1625} 1626/*======================================== 1627 Delete Alert Cookie 1628========================================*/ 1629function deleteCookie(which) { 1630 setCookie(which, '', -1); 1631}
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.