1;(function( window, document ) { 2 window.HOPE = window.HOPE || {}; 3 4 HOPE.init = function() { 5 6 // Initialize Utility and Common functions 7 HOPE.util.init(); 8 HOPE.common.init(); 9 10 // Add "data-page" to body tag to trigger page-specific function 11 var page = document.body.getAttribute( "data-page" ); 12 13 if (HOPE[page] && typeof HOPE[page]["init"] === "function") { 14 HOPE[page]["init"](); 15 } 16 }; 17 18 /* 19 * Utility/Helper 20 */ 21 HOPE.util = { 22 init: function() { 23 var _this = this; 24 }, 25 pushState: function(url) { 26 if(!Modernizr.touch) { 27 History.pushState(null, document.title, url); 28 } 29 } 30 }; 31 32 /* 33 * Common/Site-Wide 34 */ 35 HOPE.common = { 36 init: function() { 37 var _this = this; 38 39 // Activate JS Styles 40 $('html').removeClass('no-js'); 41 42 // UA Attribute 43 $('html').attr('data-useragent', navigator.userAgent); 44 45 // Detect Old iOS 46 if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { 47 function iOSversion() { 48 if (/iP(hone|od|ad)/.test(navigator.platform)) { 49 // supports iOS 2.0 and later: <http://bit.ly/TJjs1V> 50 var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); 51 return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)]; 52 } 53 } 54 55 iOS = iOSversion(); 56 57 if (iOS[0] <= 5) { 58 $('html').addClass('oldios'); 59 } 60 } 61 62 // Detect IE11 63 if(!(window.ActiveXObject) && "ActiveXObject" in window) { 64 $('html').addClass('ie11'); 65 } 66 67 // Detect Cursor Move (because Firefox is dumb) 68 $(document).on('mousemove', function(){ 69 $('html').addClass('cursor-moved') 70 }); 71 72 // Test for Sticky Support 73 Modernizr.addTest('csssticky', function() { 74 var bool; 75 Modernizr.testStyles("#modernizr { position: -webkit-sticky;position: -moz-sticky;position: -o-sticky; position: -ms-sticky; position: sticky;}", function(elem, rule) { 76 bool = ((window.getComputedStyle ? getComputedStyle(elem, null) : elem.currentStyle)["position"]).indexOf("sticky") !== -1 77 }); 78 return bool; 79 }); 80 81 if(!Modernizr.csssticky) { 82 $('html').addClass('no-csssticky'); 83 } else { 84 $('html').addClass('csssticky'); 85 } 86 87 // Test for Datalist Support 88 // if (!Modernizr.input.list || (parseInt($.browser.version) > 400)) { 89 // $('html').addClass('no-datalist'); 90 // } 91 92 // Sticky Header 93 var headerHeight = $('#page-head').outerHeight(); 94 95 $(window).load(_this.alertHeight); 96 $(window).resize(_this.alertHeight); 97 98 if(!$('html[data-useragent*="Android 2"]').length) { 99 $('.no-touch #page-head').headroom({ 100 classes: { 101 pinned: 'slideDown', 102 unpinned: 'slideUp', 103 top: 'top', 104 notTop: 'not-top' 105 }, 106 offset: headerHeight, 107 onPin: function() { 108 $('.section-dropdown-content, .section-dropdown a').removeClass('scroll-hide'); 109 }, 110 onUnpin: function() { 111 $('.section-dropdown-content, .section-dropdown a').addClass('scroll-hide'); 112 }, 113 onNotTop: function() { 114 $('body').addClass('scroll'); 115 $('.section-dropdown-content, .section-dropdown a').addClass('scroll-hide'); 116 }, 117 onTop: function() { 118 $('body').removeClass('scroll'); 119 $('.section-dropdown-content, .section-dropdown a').removeClass('scroll-hide'); 120 }, 121 tolerance: 5 122 }); 123 } 124 125 // Place Nav Toggle Buttons 126 $('.js-nav-btn').remove().appendTo('#page-head > .wrapper, .site-nav'); 127 128 if($('.banner').size() == 1) { 129 $('.js-sub-nav-btn').remove().appendTo('.banner'); 130 } else { 131 $('.js-sub-nav-btn').remove().appendTo('.page-content').addClass('no-banner'); 132 } 133 134 if(!$('.js-sub-nav-btn').length && !$('.section-nav').length && $('.breadcrumbs').length) { 135 $('.breadcrumbs').addClass('no-sub-nav'); 136 137 if($('.banner').length) { 138 $('.banner').append('<h2 class="sub-nav-btn js-sub-nav-btn"><span class="meta">Breadcrumb Navigation</span></h2>'); 139 } else { 140 $('.page-content').append('<h2 class="sub-nav-btn js-sub-nav-btn no-banner"><span class="meta">Breadcrumb Navigation</span></h2>'); 141 } 142 } 143 144 // Show/Hide Nav 145 $('#page-head').on('click', '.js-nav-btn', _this.toggleNav); 146 147 if(!navigator.userAgent.match(/Android 2/i)){ 148 $(window).resize(_this.closeNav); 149 } 150 151 // Show/Hide Section Nav 152 $('.page-content').on('click', '.js-sub-nav-btn', _this.toggleSubNav); 153 154 // Expand Breadcrumbs 155 $('.breadcrumbs').on('click', _this.expandBreadcrumbs); 156 157 // Section Nav Active State 158 var absPageURL = window.location.href, 159 relPageURL = location.pathname; 160 161 if(absPageURL.indexOf('?') > -1) { 162 absPageURL = absPageURL.substr(0, absPageURL.indexOf('?')); 163 } 164 165 $('.section-nav-list a[href="'+absPageURL+'"], .section-nav-list a[href="'+relPageURL+'"]').addClass('active'); 166 167 // Back to Top 168 if(!navigator.userAgent.match(/Android 2/i)){ 169 $('.to-top').click(function(e){ 170 e.preventDefault(); 171 var target = $(this).attr('href'); 172 173 $('html, body').animate({ 174 scrollTop: $(target).position().top 175 }, 500); 176 }); 177 } 178 179 // Main Content Height 180 $(window).load(_this.contentHeight); 181 $(window).resize(_this.contentHeight); 182 183 // Master Search Form 184 var searchAction = $('.head-search').attr('action'); 185 $('.viewport').after('<form class="cover-search js-cover-search" action="' + searchAction +'"><fieldset><label for="cover-keywords">Search</label><input type="text" name="q" id="cover-keywords" placeholder="Searchâ¦" autocomplete="off" /><ul class="search-suggest"></ul></fieldset><button type="reset">Cancel</button></form>'); 186 187 /* Search suggest preview (goes inside fieldset) 188 <ul class="search-suggest"><li><a href="#"><span class="highlight">Su</span>mmer Classes</a></li><li><a href="#"><span class="highlight">Su</span>mmer Sports</a></li></ul>*/ 189 190 // Show/Hide Master Search Form
191 $('.js-head-search input, .js-foot-search input').keyup(function(e){ 192 if(e.keyCode > 46 && e.keyCode < 91) { 193 _this.showSearch(e); 194 $('.cover-search input').val($(this).val()); 195 } 196 }); 197 $('.js-head-search button, .js-foot-search button').click(function(e){ 198 if($(this).prev('input').val().length === 0) { 199 _this.showSearch(e); 200 } 201 }); 202 $('.cover-search button[type="reset"]').click(_this.hideSearch); 203 204 // Activate Master Search Form on Key Down and Hide on Escape 205 $(document).keydown(function(e){ 206 if(!$(e.target).is('input') && !$(e.target).is('textarea') && e.keyCode > 46 && e.keyCode < 91 && ($(window).width() / parseFloat($("body").css("font-size"))) > 62.4375 && !e.ctrlKey && !e.altKey && !e.metaKey && !$('html').hasClass('ou-justedit-active') && !$('html').hasClass('translated-ltr') && !$('html').hasClass('translated-rtl')) { 207 _this.showSearch(e); 208 209 if(e.shiftKey) { 210 var searchTerm = $('.cover-search input').val() + String.fromCharCode(e.keyCode); 211 } else { 212 var searchTerm = $('.cover-search input').val() + String.fromCharCode(e.keyCode).toLowerCase(); 213 } 214 $('.cover-search input').val(searchTerm); 215 } 216 if($('body').hasClass('show-search') && e.keyCode == 27) { 217 _this.hideSearch(); 218 } 219 }); 220 221 // Hide Notifications 222 $('.dismiss').on('click', _this.notificationDismiss); 223 224 // Banner Size 225 if (!$('.banner').hasClass('-is-video')) { 226 _bannerHeight = $('.banner').outerHeight(); 227 $(window).load(_this.bannerHeight); 228 $(window).resize(_this.bannerHeight); 229 } 230 231 // Banner Effects 232 if(!$('html').hasClass('touch')) { 233 _this.bannerEffects(); 234 } 235 236 // Numbers Blur 237 var privateBrowsing = false; 238 239 try { localStorage.test = 1; } catch (e) { 240 privateBrowsing = true; 241 } 242 243 var local = false;
244 245 if(window.location.hostname == 'hope.dev') { 246 local = true; 247 } 248 249 // Check if the site is local or old iOS (privateBrowsing) because blurring won't work in those cases 250 if(privateBrowsing == false && local == false) { 251 $('.numbers').prepend('<div class="banner-blur-proxy" style="'+$('.numbers').attr('style')+'"></div>'); 252 253 $('.numbers').blurjs({ 254 cache: true, 255 source: '.numbers', 256 radius: 20 257 }); 258 } 259 260 // Equalize Number Height 261 $(window).load(_this.equalizeNumbers).resize(_this.equalizeNumbers); 262 263 // Fit Text in Numbers 264 $('.number-list li strong').fitText(.5); 265 $('#home .number-list li:first-child strong, #home .number-list li:last-child strong').fitText(1); 266 267 // Mobile Banner Faux Slideshows 268 // if($('.section-banner .banner-body').length) { 269 // $('.section-banner').append('<ol class="banner-nav"><li><a class="active" href="#banner-headline">Headline</a></li><li><a href="#banner-body">Introduction</a></li></ol>'); 270 271 // $('.section-banner').on('click', '.banner-nav a', _this.bannerSlide); 272 273 // if(($(window).width() / parseFloat($("body").css("font-size"))) < 62.5) { 274 // $('.section-banner').on('drag', _this.bannerDrag); 275 // } 276 // } 277 278 // 279 // Check for mobile device 280 // 281 var isMobile = false; //initiate as false 282 // device detection 283 if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) 284 || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.
284substr(0,4))) { 285 isMobile = true; 286 } 287 288 // 289 // Accessible HTML5 video 290 // 291 // var playPauseBtn = $('.-pause'); 292 var playPauseBtn = document.getElementById('homePlayPause'); 293 // var player = $('.c-player__video'); 294 var player = document.getElementById('homeVideo'); 295 296 if (playPauseBtn != null) { 297 playPauseBtn.onclick = function() { 298 if (player.paused) { 299 player.play(); 300 playPauseBtn.textContent = 'Pause'; 301 } else { 302 player.pause(); 303 playPauseBtn.textContent = 'Play'; 304 } 305 }; 306 } 307 308 // 309 // Show/Hide CTA 310 // 311 var buttonsShowUp; 312 var buttonsGoAway; 313 $(window).scroll(function() { 314 var $height = $(window).scrollTop(); 315 var buttonsShowUp = 400; 316 if (isMobile) { 317 var buttonsGoAway = 5000; 318 } else { 319 var buttonsGoAway = 4250; 320 } 321 // console.log($height); 322 323 if($height > buttonsShowUp && $height < buttonsGoAway) { 324 $('.c-button-callout').addClass('-is-visible'); 325 } else { 326 $('.c-button-callout').removeClass('-is-visible'); 327 } 328 }); 329 330 // http://web.archive.org/web/20141228124112/http://www.idangero.us/sliders/swiper/api.php 331 // TODO: Update Swiper 2.6.1 to 5.3.x, most of the manual work is covered by options in later versions, 332 333 // Banner Slideshows 334 $('.js-banner-slideshow .swiper-wrapper').after('<ol class="banner-nav"></ol>'); 335 var bannerSlideshow = $('.js-banner-slideshow').swiper({ 336 loop: false, 337 mode: 'horizontal', 338 pagination: '.banner-nav', 339 paginationActiveClass: 'active', 340 paginationClickable: true, 341 paginationElement: 'li', 342 simulateTouch: false, 343 speed: 500 344 }); 345 346 // Photo Slideshows 347 $('.js-photo-slideshow .swiper-wrapper').each(function(){ 348 $(this).after('<div class="slide-nav-holder"><div class="slide-nav"><button class="slide-prev">Previous</button><button class="slide-next">Next</button></div></div>'); 349 }); 350 351 $('.js-photo-slideshow .swiper-wrapper').after('<span class="slide-count"><span>1</span>/'+$('.js-photo-slideshow .swiper-wrapper li:not(.swiper-slide-duplicate)').length+'</span>'); 352 353 var photoSlideshow = []; 354 355 $('.js-photo-slideshow').each(function(index){ 356 $(this).addClass('swiper-' + index); 357 358 photoSlideshow[index] = $('.swiper-' + index).swiper({ 359 calculateHeight: true, 360 loop: true, 361 mode: 'horizontal', 362 onSlideChangeStart: function() { 363 $('.swiper-' + index + ' .slide-count span').text(photoSlideshow[index].activeLoopIndex + 1); 364 }, 365 simulateTouch: false, 366 speed: 500 367 }); 368 369 $('.swiper-' + index).on('click', '.slide-prev', function(){ 370 photoSlideshow[index].swipePrev(); 371 }); 372 373 $('.swiper-' + index).on('click', '.slide-next', function(){ 374 photoSlideshow[index].swipeNext(); 375 }); 376 }); 377 378 // Tweet Slideshows 379 $('.js-tweet-slideshow .swiper-wrapper').each(function(){ 380 if($(this).parents('.js-tweet-slideshow').find('article').length > 1) { 381 $(this).after('<div class="slide-nav-holder"><div class="slide-nav"><button class="slide-prev">Previous</button><button class="slide-next">Next</button></div></div>'); 382 } 383 }); 384 385 $('.js-tweet-slideshow .slide-prev').hide(); 386 387 var tweetSlideshow = $('.js-tweet-slideshow').swiper({ 388 calculateHeight: true, 389 loop: false, 390 mode: 'horizontal', 391 onSlideChangeStart: function() { 392 if((tweetSlideshow.activeIndex + 1) == $('.js-tweet-slideshow').find('article').size()) { 393 $('.js-tweet-slideshow .slide-next').hide(); 394 } else { 395 $('.js-tweet-slideshow .slide-next').show(); 396 } 397 398 if(tweetSlideshow.activeIndex == 0) { 399 $('.js-tweet-slideshow .slide-prev').hide(); 400 } else { 401 $('.js-tweet-slideshow .slide-prev').show(); 402 } 403 }, 404 simulateTouch: false, 405 speed: 500 406 }); 407 408 $('.js-tweet-slideshow').on('click', '.slide-prev', function(){ 409 tweetSlideshow.swipePrev(); 410 }); 411 412 $('.js-tweet-slideshow').on('click', '.slide-next', function(){ 413 tweetSlideshow.swipeNext(); 414 }); 415 416 // Highlights swiper 417 // wrap it with nav bar on either side 418 $('#swiperHighlights .swiper-wrapper').each(function(){ 419 if($(this).parents('#swiperHighlights').find('.swiper-slide').length > 1) { 420 $(this).before('<div class="swiper-button-next"></div>'); 421 $(this).after('<div class="swiper-button-prev"></div>'); 422 } 423 }); 424 // hide previous arrow 425 $('#swiperHighlights .swiper-button-prev').hide(); 426 // init Swiper
427 var highlightsSwiper = $('#swiperHighlights').swiper({ 428 slidesPerView: 'auto', 429 slidesPerViewFit: false, 430 calculateHeight: true, 431 simulateTouch: false, 432 onSlideChangeStart: function() { 433 var currSlide = $('#swiperHighlights').find('.swiper-slide').size(); 434 if((highlightsSwiper.activeIndex + 2) == currSlide) { 435 $('#swiperHighlights .swiper-wrapper').css('right', '-10%'); 436 $('#swiperHighlights .swiper-button-next').fadeOut('fast'); 437 } else { 438 $('#swiperHighlights .swiper-wrapper').css('right', 'auto'); 439 $('#swiperHighlights .swiper-button-next').fadeIn('fast'); 440 } 441 if(highlightsSwiper.activeIndex == 0) { 442 $('#swiperHighlights .swiper-button-prev').fadeOut('fast'); 443 } else { 444 $('#swiperHighlights .swiper-button-prev').fadeIn('fast'); 445 } 446 }, 447 }); 448 // manually init swiper nav 449 $('#swiperHighlights').on('click', '.swiper-button-prev', function(){ 450 highlightsSwiper.swipePrev(); 451 }); 452 $('#swiperHighlights').on('click', '.swiper-button-next', function(){ 453 highlightsSwiper.swipeNext(); 454 }); 455 // force responsiveness 456 if (window.matchMedia('only screen and (max-width:62.5em)').matches) { 457 var highlightsSwiper = $('#swiperHighlights').swiper({ 458 slidesPerView: 1, 459 // spaceBetween: 30, 460 simulateTouch: false, 461 calculateHeight: true 462 }); 463 } 464 465 // Story swiper 466 // wrap it with nav bar on either side 467 $('#swiperStories .swiper-wrapper').each(function(){ 468 if($(this).parents('#swiperStories').find('.swiper-slide').length > 1) { 469 $(this).before('<div class="swiper-button-next"></div>'); 470 $(this).after('<div class="swiper-button-prev"></div>'); 471 } 472 }); 473 // hide previous arrow 474 $('#swiperStories .swiper-button-prev').hide(); 475 var storySwiper = $('#swiperStories').swiper({ 476 slidesPerView: 'auto', 477 slidesPerFit: false, 478 spaceBetween: 40, 479 centeredSlides: true, 480 calculateHeight: true, 481 onSlideChangeStart: function() { 482 $('#swiperStories .swiper-wrapper').removeClass('-flush-left') 483 if((storySwiper.activeIndex + 1) == $('#swiperStories').find('.swiper-slide').size()) { 484 $('#swiperStories .swiper-button-next').fadeOut('fast'); 485 } else { 486 $('#swiperStories .swiper-button-next').fadeIn('fast'); 487 } 488 if(storySwiper.activeIndex == 0) { 489 $('#swiperStories .swiper-button-prev').fadeOut('fast'); 490 } else { 491 $('#swiperStories .swiper-button-prev').fadeIn('fast'); 492 } 493 }, 494 }); 495 $('#swiperStories').on('click', '.swiper-button-prev', function(){ 496 storySwiper.swipePrev(); 497 }); 498 $('#swiperStories').on('click', '.swiper-button-next', function(){ 499 storySwiper.swipeNext(); 500 }); 501 if (window.matchMedia('only screen and (max-width:62.5em)').matches) { 502 var storySwiper = $('#swiperStories').swiper({ 503 slidesPerView: 1, 504 spaceBetween: 40, 505 centeredSlides: true, 506 calculateHeight: true, 507 }); 508 } 509 $(window).load(function() { 510 $('#swiperStories .swiper-wrapper').addClass('-flush-left'); 511 }) 512 513 // News swiper 514 var newsSwiper = $('#swiperNews').swiper({ 515 slidesPerView: 'auto', 516 spaceBetween: 15, 517 simulateTouch: false, 518 resizeReInit: true 519 }) 520 if (window.matchMedia('only screen and (max-width:62.5em)').matches) { 521 var newsSwiper = $('#swiperNews').swiper({ 522 slidesPerView: 'auto', 523 spaceBetween: 15, 524 simulateTouch: true, 525 }); 526 } 527 528 // Events swiper 529 var eventsSwiper = $('#swiperEvents').swiper({ 530 slidesPerView: 'auto', 531 spaceBetween: 15, 532 simulateTouch: false, 533 resizeReInit: true 534 }) 535 if (window.matchMedia('only screen and (max-width:62.5em)').matches) { 536 var eventsSwiper = $('#swiperEvents').swiper({ 537 slidesPerView: 'auto', 538 spaceBetween: 15, 539 simulateTouch: true, 540 }); 541 } 542 543 // Lightboxes 544 $('.js-photo-gallery a').magnificPopup({ 545 callbacks: { 546 buildControls: function() { 547 this.contentContainer.append(this.arrowLeft.add(this.arrowRight)); 548 } 549 }, 550 gallery: { 551 arrowMarkup: '<span class="gallery-nav gallery-nav-%dir%">%dir%</span>', 552 enabled: true, 553 tCounter: '' 554 }, 555 showCloseBtn: false, 556 type: 'image' 557 }); 558 559 $('.primary').magnificPopup({ 560 delegate: '.expand-table', 561 showCloseBtn: false, 562 type: 'inline' 563 }); 564 565 $('.video-card a').magnificPopup({ 566 showCloseBtn: false, 567 type: 'iframe' 568 }); 569 570 $('.-play').magnificPopup({ 571 type: 'iframe' 572 }) 573 574 // Definition Accordions 575 $('.definitions').on('click', 'dt', _this.expandDefinitions); 576 577 // Update Select Fields 578 $('.select-holder option:selected').each(function(){ 579 $(this).parent().siblings('.select-text').text($(this).text()); 580 }); 581 582 $('.select-holder select').on('change', function(){ 583 $(this).siblings('.select-text').text($(this).children('option:selected').text()); 584 }); 585 586 // Pseudo Select Fields 587 // $('.pseudo-select').on('click', function(){ 588 // $(this).toggleClass('open'); 589 // }); 590 591 // Mobile Table Rows 592 $('tbody td').each(function(){ 593 var col = $(this).index() + 1, 594 lbl = $(this).closest('table').find('thead th:nth-child('+col+')').text(); 595 596 $(this).attr('data-label', lbl); 597 }); 598 599 // Mobile Category Filters 600 $('.featured-list .media-headline').on('click', function(){ 601 if(!$(this).hasClass('open')) { 602 $(this).addClass('open'); 603 } else { 604 $(this).removeClass('open'); 605 } 606 }); 607 608 // Table Expand
609 $('.no-touch .expanding-table').wrap('<div class="table-holder"></div>'); 610 $('.no-touch .expanding-table').each(function(){ 611 $(this).clone().appendTo('.primary').attr('id', $(this).attr('id') + '-popup').attr('class', 'mfp-hide inline-popup'); 612 $(this).after('<a class="expand-table" href="#'+$(this).closest('table').attr('id')+'-popup">Expand Full Table</a>'); 613 }); 614// $('.no-touch .expanding-table th, .expanding-table td').mouseenter(_this.tableExpand) 615// $('.primary').on('mouseleave', '.table-expand', function(){ 616// $(this).remove(); 617// }); 618 619 // CTA Form Toggle 620 $('.cta-form').on('click', '.expand-form', _this.toggleCTAForm); 621 622 // AJAX Load More 623 $(window).resize(function(){ 624 $('.media-list').attr('style', false); 625 }); 626 627 $('.js-load-more, .js-filter, .js-month-nav').on('click', _this.ajaxMore); 628 $('.media-nav').on('click', '.js-media-nav:not(.disabled)', _this.ajaxMore); 629 $('.media').on('click', '.unfilter', _this.ajaxMore); 630 631 $('.media-nav').on('click', '.js-media-nav.disabled', function(e){ 632 e.preventDefault(); 633 }); 634 635 // Location Detection 636 $('.location-btn').on('click', _this.detectLocation); 637 638 // Reponsive Videos 639 $('.primary').fitVids(); 640 641 // Social Card Image Orientation 642 $('.tweet-card-photo, .instagram-card-photo').each(function(){ 643 var imgSrc = $(this).attr('src'); 644 $(this).parents('.tweet-card, .instagram-card').css('background-image', 'url('+imgSrc+')'); 645 }); 646 647 // A11y Hover vs. Focus updates // 648 649 // Child Element 650 $('.photo-blocks a, .photo-block article a').on('focus blur', function (e) { 651 if (e.type == 'focus') { 652 $(this).find('.photo-content').addClass('card-focus'); 653 } else { 654 $(this).find('.photo-content').removeClass('card-focus'); 655 } 656 }); 657 658 // One Level Up 659 // $('.news-card .cover-link, .blog-card .cover-link').on('focus blur', function (e) { 660 // if (e.type == 'focus') { 661 // $(this).parent().addClass('card-focus'); 662 // } else { 663 // $(this).parent().removeClass('card-focus'); 664 // } 665 // }); 666 667 // Two Levels Up 668 $('.blog-card .cover-link, .number-list li .number-detail .btn').on('focus blur', function (e) { 669 if (e.type == 'focus') { 670 $(this).parent().parent().addClass('card-focus'); 671 } else { 672 $(this).parent().parent().removeClass('card-focus'); 673 } 674 }); 675 676 // Three Levels Up 677 $('.news-card .cover-link, .featured-events .cover-link, .person-card .cover-link').on('focus blur', function (e) { 678 if (e.type == 'focus') { 679 $(this).parent().parent().parent().addClass('card-focus'); 680 } else { 681 $(this).parent().parent().parent().removeClass('card-focus'); 682 } 683 }); 684 685 // Four Levels Up 686 $('.event-card .cover-link').on('focus blur', function (e) { 687 if (e.type == 'focus') { 688 $(this).parent().parent().parent().parent().addClass('card-focus'); 689 } else { 690 $(this).parent().parent().parent().parent().removeClass('card-focus'); 691 } 692 }); 693 694 // Nav List Accommodations // 695 $('.nav-list .dropdown > a').on('focus', function(e){ 696 $(this).next().addClass('dropdown-has-focus'); 697 $(this).parent().addClass('active-nav'); 698 }); 699 700 $('.nav-list .dropdown').bind('focusin', function (e) { 701 $(this).find('.dropdown-content').addClass('dropdown-has-focus'); 702 $(this).addClass('active-nav'); 703 }); 704 705 $('.nav-list .dropdown').bind('focusout', function (e) { 706 $('.dropdown-has-focus').removeClass('dropdown-has-focus'); 707 $('.active-nav').removeClass('active-nav'); 708 }); 709 710 // $('.tweet-card, .instagram-card').each(function(){ 711 // if($(this).width() <= $(this).height()) { 712 // $(this).find('img').addClass('portrait'); 713 // } 714 // }); 715 716 // Event Image Orientation 717 $('.event-img, .staff-photo img').each(_this.imageUpdate); 718 719 // Remove Image Spacing from WYSIWYG Tags 720 $('p > span:only-child > img:only-child').each(function(){ 721 $(this).parent().parent().addClass('img-p'); 722 }); 723 724 // Image Captions 725 $('.primary > img[title], .primary p img[title]').each(function(){ 726 var caption = $(this).attr('title'), 727 className = $(this).attr('class'); 728 captionWidth = $(this).attr('width'); 729 $(this).wrap('<figure class="caption-image '+className+'" style="width:'+captionWidth+'px;">').after('<span class="photo-caption js-photo-caption">'+caption+'</span>').attr('title', '').attr('width', ''); 730 }); 731 // Translate 732 $('.site-tools .translate > span').text(''); 733 $('.event-short-date, .expand-table').addClass('notranslate'); 734 735 translateInt = window.setInterval(function(){ 736 if($('#google_translate_element option').length && !$('.translate-languages').length) { 737 $('.site-tools .translate').append('<ul class="translate-languages"></ul>'); 738 $('#google_translate_element option').each(function(){ 739 var langCode = $(this).val(), 740 lang = $(this).text(); 741 742 if(langCode) { 743 $('.translate-languages').append('<li><a href="#'+langCode+'" data-language="'+langCode+'">'+lang+'</a></li>'); 744 } 745 }); 746 $('.site-tools .translate > span').text('Translate'); 747 748 clearInterval(translateInt); 749 } 750 }, 100); 751 752 $('.translate').on('click', 'a', _this.translate); 753 _this.translateOnLoad(); 754 755 // Find a Rep 756 $.expr[":"].contains = $.expr.createPseudo(function(arg) { 757 return function( elem ) { 758 return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; 759 }; 760 }); 761 762 $('.repfinder').each(function(i){ 763 $(this).find('input').each(function(){ 764 $(this).attr('id', $(this).attr('id')+i); 765 }); 766 $(this).find('label').each(function(){ 767 $(this).attr('for', $(this).attr('for')+i); 768 }); 769 }); 770 771 $('.repfinder').each(_this.repFinder); 772 773 // Tooltips 774 // $('.tooltip').tooltip(); 775 }, 776 toggleNav: function() { 777 // $('.alert').remove(); 778 779 if(!$('body').hasClass('show-nav')) { 780 $('body').addClass('show-nav'); 781 $('body').removeClass('show-sub-nav'); 782 } else { 783 $('body').removeClass('show-nav'); 784 } 785 }, 786 toggleSubNav: function() { 787 // $('.alert').remove(); 788 789 if(!$('body').hasClass('show-sub-nav')) { 790 $('body').addClass('show-sub-nav'); 791 $('body').removeClass('show-nav'); 792 } else { 793 $('body').removeClass('show-sub-nav'); 794 } 795 }, 796 expandBreadcrumbs: function() { 797 if(($(window).width() / parseFloat($("body").css("font-size"))) < 62.5) { 798 if(!$(this).hasClass('expanded')) { 799 $(this).addClass('expanded'); 800 $('.section-nav').css({ 801 'margin-top': $('.breadcrumbs').height() - 30 802 }); 803 } else { 804 $(this).removeClass('expanded'); 805 $('.section-nav').css({ 806 'margin-top': '0' 807 }); 808 } 809 } 810 }, 811 closeNav: function() { 812 var w = $(window).width(); 813
814 if(typeof checkw == 'undefined') checkw = w; 815 816 if(w != checkw) { 817 $('body').removeClass('show-nav').removeClass('show-sub-nav'); 818 $('#head-keywords').blur(); 819 checkw = w; 820 } 821 }, 822 contentHeight: function() { 823 if(($(window).width() / parseFloat($("body").css("font-size"))) > 62.4375) { 824 var secondaryHeight = $('.secondary').outerHeight(), 825 tertiaryHeight = $('.tertiary').outerHeight(); 826 827 if(secondaryHeight > tertiaryHeight) { 828 $('.primary').css({'min-height': secondaryHeight}); 829 } else { 830 $('.primary').css({'min-height': tertiaryHeight}); 831 } 832 } else { 833 $('.primary').css({'min-height': '0'}); 834 } 835 836 }, 837 showSearch: function(e) { 838 if(($(window).width() / parseFloat($("body").css("font-size"))) > 62.4375) { 839 e.preventDefault(); 840 if(!$('body').hasClass('show-search')) { 841 $('body').addClass('show-search'); 842 $('.cover-search input').removeAttr('disabled'); 843 } 844 setTimeout(function(){ 845 $('.cover-search input').focus(); 846 var value = $('.cover-search input').val(); 847 $('.cover-search input').val(''); 848 $('.cover-search input').val(value); 849 }, 400); 850 } 851 }, 852 hideSearch: function() { 853 $('.cover-search input').attr('disabled', true).val('').blur(); 854 $('body').removeClass('show-search'); 855 }, 856 notificationDismiss: function(e) { 857 e.preventDefault(); 858 859 if($(this).parents('.alert').length) { 860 $('#page-head, .viewport').removeAttr('style'); 861 } 862 863 $(this).parents('.alert').fadeOut('250', function(){ 864 $('.alert').remove(); 865 }); 866 867 $(this).parents('.banner-alert').slideUp(250, function(){ 868 $(this).remove(); 869 }); 870 }, 871 bannerHeight: function() { 872 var headerHeight = parseInt($('#page-head').outerHeight()); 873 874 if(($(window).width() / parseFloat($("body").css("font-size"))) > 62.4375) { 875 if($(window).height() < (_bannerHeight + headerHeight) && ($(window).height() - headerHeight) > 550) { 876 $('.banner, .banner .swiper-slide').css({ 877 'height': $(window).height() - headerHeight 878 }); 879 } else if(($(window).height() - headerHeight) <= 550 && _bannerHeight > 550) { 880 $('.banner, .banner .swiper-slide').css({ 881 'height': 550 882 }); 883 } else { 884 $('.banner').css('height', ''); 885 } 886 } else { 887 $('.banner').css('height', ''); 888 } 889 890 // Hide Headline if text too long 891 // var textElement = $('.banner-body div p'); 892 // var headlineElement = $(".banner-headline h1"); 893 // if (($(window).width() / parseFloat($("body").css("font-size"))) < 29.9375) { 894 895 // // If text is too long chars and too tall height, truncate it 896 // if (textElement.text().length > 100 && textElement.height() > 100) { 897 // textElement.addClass("truncate"); 898 // } else { 899 // textElement.removeClass("truncate"); 900 // } 901 902 // // if text is not truncated but is too tall, hide headline 903 // if (textElement.text().length > 100 && textElement.not("truncate")) { 904 // headlineElement.addClass("hide"); 905 // } 906 907 // } else { 908 // headlineElement.removeClass("hide"); 909 // textElement.removeClass("truncate"); 910 // } 911 }, 912 bannerEffects: function() { 913 /* Artifact from banner blurring 914 $('.banner:not(.banner-slideshow)').prepend('<div class="banner-proxy" style="'+$('.banner').attr('style')+'"></div><div class="banner-blur-proxy" style="'+$('.banner').attr('style')+'"></div>');*/ 915 916 $('.banner:not(.banner-slideshow):not(.no-img):not(.-is-video)').prepend('<div class="banner-proxy"></div>'); 917 $('.banner:not(.banner-slideshow) .banner-proxy').attr('style', $('.banner').attr('style')); 918 919 $('.banner-slideshow .swiper-slide').each(function(){ 920 $(this).prepend('<div class="banner-proxy"></div>'); 921 $(this).find('.banner-proxy').attr('style', $(this).attr('style')); 922 }); 923 924 var fadeUntil = $('.banner').height() - 200; 925 var speed = -3; 926 var scrollStart = 0; 927 928 $(window).resize(function(){ 929 fadeUntil = $('.banner').height() - 200; 930 }); 931 932 // Set Banner Scale 933 934 if(!(window.matchMedia && (window.matchMedia('only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)').matches)) || (window.devicePixelRatio && window.devicePixelRatio > 1.3)) { 935 $('.banner-proxy').css({ 936 '-moz-transform': 'scale(' + (1.25 - (window.pageYOffset / 9000)) + ')', 937 '-ms-transform': 'scale(' + (1.25 - (window.pageYOffset / 9000)) + ')', 938 '-webkit-transform': 'scale(' + (1.25 - (window.pageYOffset / 9000)) + ')', 939 'transform': 'scale(' + (1.25 - (window.pageYOffset / 9000)) + ')' 940 }); 941 } 942 943 // Scroll Event 944 scrollInterval = setInterval(function(){ 945 var offset = Number($(document).scrollTop()), 946 headerHeight = parseInt($('.viewport').css('border-top-width')), 947 bannerHeight = $('.banner').height(), 948 bannerStatus = offset - bannerHeight - headerHeight; 949 950 if(bannerStatus < 0) { 951 window.requestAnimationFrame(animateElements); 952 } 953 }, 10); 954 955 function animateElements() { 956 var offset = Number($(document).scrollTop()); 957 958 if(window.pageYOffset <= 0) { 959 if(($(window).width() / parseFloat($("body").css("font-size"))) > 62.4375) { 960 // $('.banner-events').parent().find('.banner-content, .hud, .banner-alert').css({ 961 // 'opacity': '1' 962 // }); 963 $('.banner-proxy').css({ 964 'opacity': '1' 965 }); 966// $('.banner-copy').css({ 967// 'top': '0' 968// }); 969 } 970 } else { 971 if(($(window).width() / parseFloat($("body").css("font-size"))) > 62.4375) { 972 // if(offset > 100) { 973 // $('.banner-events').parent().find('.banner-content, .hud, .banner-alert').css({ 974 // 'opacity': 1 - ((offset - 100)/fadeUntil) * 2 975 // }); 976 // } 977 978 if((window.matchMedia && (window.matchMedia('only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)').matches)) || (window.devicePixelRatio && window.devicePixelRatio > 1.3)) { 979 $('.banner-proxy').css({ 980 'opacity': 1 - (offset/fadeUntil) * .5 981 }); 982 } else { 983 $('.banner-proxy').css({ 984 'opacity': 1 - (offset/fadeUntil) * .5, 985 '-moz-transform': 'scale(' + (1.25 - (window.pageYOffset / 9000)) + ')', 986 '-ms-transform': 'scale(' + (1.25 - (window.pageYOffset / 9000)) + ')', 987 '-webkit-transform': 'scale(' + (1.25 - (window.pageYOffset / 9000)) + ')', 988 'transform': 'scale(' + (1.25 - (window.pageYOffset / 9000)) + ')' 989 }); 990 } 991 992// $('.banner-copy').css({ 993// 'top': (-window.pageYOffset / speed) + 'px' 994// }); 995 } 996 } 997 998 // if(offset > 100) { 999 // $('.banner-events').css({ 1000 // '-moz-transform': 'translate3d(0, ' + -(offset - 100) + 'px, 0)', 1001 // '-ms-transform': 'translate3d(0, ' + -(offset - 100) + 'px, 0)', 1002 // '-webkit-transform': 'translate3d(0, ' + -(offset - 100) + 'px, 0)', 1003 // 'transform': 'translate3d(0, ' + -(offset - 100) + 'px, 0)' 1004 // }); 1005 // } else { 1006 // $('.banner-events').css({ 1007 // '-moz-transform': 'translate3d(0, 0, 0)', 1008 // '-ms-transform': 'translate3d(0, 0, 0)', 1009 // '-webkit-transform': 'translate3d(0, 0, 0)', 1010 // 'transform': 'translate3d(0, 0, 0)' 1011 // }); 1012 // } 1013 1014 scrollStart = offset; 1015 } 1016 }, 1017 equalizeNumbers: function(){ 1018 var boxHeight = 0; 1019 1020 if(($(window).width() / parseFloat($("body").css("font-size"))) > 29.9375) { 1021 $('.number-detail').each(function(){ 1022 $(this).height('auto'); 1023 thisHeight = $(this).outerHeight(); 1024 if(thisHeight > boxHeight) { 1025 boxHeight = thisHeight; 1026 } 1027 }); 1028 1029 $('.number-detail').css({ 1030 'height': boxHeight 1031 }).addClass('equalized'); 1032 } else { 1033 $('.number-detail').each(function(){ 1034 $(this).removeAttr('style'); 1035 }); 1036 } 1037 }, 1038 bannerSlide: function(e) { 1039 e.preventDefault(); 1040 $('.banner-nav .active').removeClass('active'); 1041 $(this).addClass('active'); 1042 var target = $(this).attr('href'); 1043 if(target == '#banner-body') { 1044 $('.section-banner').addClass('show-intro').removeClass('show-headline'); 1045 } else { 1046 $('.section-banner').removeClass('show-intro').addClass('show-headline'); 1047 } 1048 }, 1049 bannerDrag: function(e) { 1050 var bannerWidth = $(this).width(); 1051 1052 if(e.orientation == 'horizontal') { 1053 if(!$(this).hasClass('show-intro') && e.direction < 0) { 1054 $('.banner-headline, .banner-body').css({ 1055 'margin-left': e.dx 1056 }); 1057 1058 if(e.end && e.dx < -(bannerWidth / 5)) { 1059 $(this).addClass('show-intro').removeClass('show-headline'); 1060 $('a[href="#banner-headline"]').removeClass('active'); 1061 $('a[href="#banner-body"]').addClass('active'); 1062 $('.banner-headline, .banner-body').removeAttr('style'); 1063 } 1064 } else if($(this).hasClass('show-intro') && e.direction > 0) { 1065 $('.banner-headline, .banner-body').css({ 1066 'margin-left': e.dx 1067 }); 1068 1069 if(e.end && e.dx > (bannerWidth / 5)) { 1070 $(this).addClass('show-headline').removeClass('show-intro'); 1071 $('a[href="#banner-body"]').removeClass('active'); 1072 $('a[href="#banner-headline"]').addClass('active'); 1073 $('.banner-headline, .banner-body').removeAttr('style'); 1074 } 1075 } 1076 } 1077 }, 1078 expandDefinitions: function() { 1079 if(!$(this).hasClass('expanded')) { 1080 $(this).addClass('expanded'); 1081 $(this).next('dd').slideDown(250); 1082 } else { 1083 $(this).removeClass('expanded');
1084 $(this).next('dd').slideUp(250); 1085 } 1086 }, 1087 tableExpand: function() { 1088 if(($(window).width() / parseFloat($("body").css("font-size"))) > 62.4375) { 1089 var columnIndex = $(this).index(), 1090 leftOffset = ($(this).offset().left - $(this).closest('table').offset().left); 1091 $('.table-expand').remove(); 1092 $('.table-holder').append('<div class="table-expand"><a class="expand-table" href="#'+$(this).closest('table').attr('id')+'-popup">Expand Full Table</a><table><thead></thead><tbody></tbody></table></div>'); 1093 $('.table-expand').css({ 1094 'left': leftOffset 1095 }); 1096 $(this).closest('table').find('thead td:nth-child('+(columnIndex+1)+'), thead th:nth-child('+(columnIndex+1)+')').clone().appendTo('.table-expand thead'); 1097 $(this).closest('table').find('tbody td:nth-child('+(columnIndex+1)+'), tbody th:nth-child('+(columnIndex+1)+')').clone().appendTo('.table-expand tbody'); 1098 $('.table-expand tr, .table-expand td').wrap('<tr></tr>'); 1099 } 1100 }, 1101 toggleCTAForm: function(e) { 1102 e.preventDefault(); 1103 if(!$(this).parent().hasClass('expanded')) { 1104 $(this).parent().addClass('expanded'); 1105 $(this).parent().find('form').slideDown(250, function(){ 1106 HOPE.common.contentHeight(); 1107 }); 1108 } else { 1109 $(this).parent().removeClass('expanded'); 1110 $(this).parent().find('form').slideUp(250, function(){ 1111 HOPE.common.contentHeight(); 1112 }); 1113 } 1114 }, 1115 ajaxMore: function(e){ 1116 e.preventDefault(); 1117 var url = $(this).attr('href'), 1118 pushstate = $(this).attr('data-push'), 1119 parent = $(this).attr('data-parent'); 1120 1121 $(this).addClass('loading'); 1122 1123 if($(this).hasClass('js-filter') && !$(this).hasClass('active')) { 1124 var filter = true; 1125 $(this).parents('.category-filter').find('.active').removeClass('active'); 1126 $(this).parents('.category-filter').find('.inactive').removeClass('inactive'); 1127 $(this).addClass('active'); 1128 $(this).parents('.category-filter').find('a:not(.active)').addClass('inactive'); 1129 $(parent).addClass('filtering'); 1130 // $(parent).siblings('.media-nav:not(.js-static-media-nav)').fadeOut(250); 1131 $(parent).siblings('.media-headline').addClass('unfilter').attr('data-parent', parent); 1132 } else if ($(this).hasClass('js-filter') && $(this).hasClass('active') || $(this).hasClass('unfilter')) { 1133 $(parent).siblings('.category-filter').find('.active').removeClass('active'); 1134 $(parent).siblings('.category-filter').find('.inactive').removeClass('inactive'); 1135 $(parent).find('.append').remove(); 1136 $(parent).find('.original').addClass('appending').removeAttr('style'); 1137 $(parent).find('.original').each(function(i, el){ 1138 setTimeout(function(){ 1139 $(el).removeClass('appending'); 1140 }, 0 + (i * 100)); 1141 }); 1142 // $(parent).siblings('.media-nav').fadeIn(250); 1143 $(parent).siblings('.media-headline').removeClass('unfilter'); 1144 return false; 1145 } 1146 1147 if($(this).hasClass('js-media-nav')) { 1148 var mediaNav = true; 1149 } 1150 1151 if($(this).hasClass('js-month-nav')) { 1152 var monthNav = true; 1153 // $(parent).siblings('.media-nav').fadeIn(250); 1154 $(this).parent().parent().parent().siblings('.category-filter').find('.active').removeClass('active'); 1155 $(this).parents('.month-nav-list').find('.active').removeClass('active'); 1156 $(this).addClass('active'); 1157 } 1158 1159 $.ajax({ 1160 url: url, 1161 success: function(data) { 1162 var content = $($.trim(data)).find('.append'); 1163 var button = $($.trim(data)).find('.load-more').attr('href'); 1164 1165 // Append New Content 1166 if(filter || mediaNav || monthNav) { 1167 $(parent).removeAttr('style') 1168 var parentHeight = $(parent).outerHeight(); 1169 $(parent).css({'min-height': parentHeight}); 1170 $(parent).children(':not(.append)').addClass('original').hide(); 1171 $(parent).children('.append').remove(); 1172 $(parent).prepend(content).find('.append').addClass('appending'); 1173 $(parent).removeClass('filtering'); 1174 $(parent).find('.append').each(function(i, el){ 1175 setTimeout(function(){ 1176 $(el).removeClass('appending'); 1177 if(i >= $(parent).find('.append').length - 1) { 1178 $(parent).css({'min-height': 0}); 1179 } 1180 }, 0 + (i * 100)); 1181 }); 1182 1183 $('.event-img').each(HOPE.common.imageUpdate); 1184 } else { 1185 $(parent).append(content); 1186 $('.event-img').each(HOPE.common.imageUpdate); 1187 } 1188 1189 // Enable/Disable Pagination Buttons 1190 if(mediaNav) { 1191 var next = $($.trim(data)).find('.media-next:not(.disabled)').attr('href'); 1192 var prev = $($.trim(data)).find('.media-prev:not(.disabled)').attr('href'); 1193 1194 if(next) { 1195 $(parent).siblings('.media-nav').find('.media-next').removeClass('disabled').attr('href', next); 1196 } else { 1197 $(parent).siblings('.media-nav').find('.media-next').addClass('disabled').attr('href', '#'); 1198 } 1199 1200 if(prev) { 1201 $(parent).siblings('.media-nav').find('.media-prev').removeClass('disabled').attr('href', prev); 1202 } else { 1203 $(parent).siblings('.media-nav').find('.media-prev').addClass('disabled').attr('href', '#'); 1204 } 1205 } 1206 1207 // Enable/Disable Additional Load More Button 1208 if(button) { 1209 $('.js-load-more.loading').attr('href', button); 1210 $('.js-load-more.loading').removeClass('loading'); 1211 } else {
1212 // console.log("removing") 1213 $('.js-load-more.loading').remove(); 1214 } 1215 1216 // News Grid Layout 1217 if($('.append .news-grid').length) { 1218 $(window).on('scroll',HOPE.news.autoLoadMore); 1219 var grid = $('.append .news-grid')[0]; 1220 salvattore['register_grid'](grid); 1221 $('.news-month').removeClass('append'); 1222 } 1223 1224 $('.parent').focus(); 1225 } 1226 }); 1227 1228 if(pushstate === "y") { 1229 HOPE.util.pushState(url); 1230 } 1231 }, 1232 detectLocation: function(e) { 1233 e.preventDefault(); 1234 1235 var target = $(this).attr('for'); 1236 1237 if (navigator.geolocation) { 1238 $('#'+target).val('Locatingâ¦'); 1239 navigator.geolocation.getCurrentPosition(inputLocation); 1240 } 1241 1242 function inputLocation(position) { 1243 $('#'+target).val(position.coords.latitude + ', ' + position.coords.longitude); 1244 $('#'+target).parents('form').submit(); 1245 } 1246 }, 1247 imageUpdate: function() { 1248 var local = false; 1249 1250 if(window.location.hostname == 'hope.dev') { 1251 local = true; 1252 } 1253 1254 if(local == false) { 1255 var defaultSrc = $(this).attr('src'); 1256 if (typeof defaultSrc != "undefined") 1257 { 1258 var lrgSrc = defaultSrc.replace('medium', 'big').replace('huge', 'big').replace('small', 'big'); 1259 } 1260 1261 $(this).attr('src', lrgSrc); 1262 checkOrientation($(this)); 1263 1264 $(this).error(function(){ 1265 lrgSrc = lrgSrc.replace('big', 'original'); 1266 $(this).attr('src', lrgSrc); 1267 checkOrientation($(this)); 1268 }); 1269 1270 function checkOrientation(thisObj) { 1271 var img = new Image(); 1272 img.onload = function() { 1273 if(img.width < img.height) { 1274 thisObj.addClass('portrait'); 1275 } else { 1276 thisObj.addClass('landscape'); 1277 } 1278 } 1279 img.src = thisObj.attr('src'); 1280 } 1281 } 1282 }, 1283 alertHeight: function() { 1284 if($('.alert').length) { 1285 var headerHeight = $('#page-head').outerHeight(); 1286 1287 var headerHeight = headerHeight + $('.alert').outerHeight(); 1288 1289 if($('html[data-useragent*="Android"]').length){ 1290 $('.viewport').css({ 1291 'padding-top': $('.alert').outerHeight() 1292 }); 1293 } else { 1294 $('#page-head').css({ 1295 'top': $('.alert').outerHeight() 1296 }); 1297 1298 $('.viewport').css({ 1299 'padding-top': headerHeight 1300 }); 1301 }; 1302 } 1303 }, 1304 translateOnLoad: function() { 1305 window.setTimeout(function(){ 1306 var language = $('select.goog-te-combo').val(); 1307 var $currentOpt = $('.language-options a[data-language="'+ language +'"]'); 1308 if(language != "" && !$currentOpt.hasClass('active')) { 1309 $('.language-options a.active').removeClass('active') 1310 $currentOpt.addClass('active'); 1311 } 1312 },5000); 1313 }, 1314 translate: function(e) { 1315 e.preventDefault(); 1316 1317 var language = $(this).data('language'); 1318 var $select = $('.goog-te-combo'); 1319 var select = $select.get(0); 1320 var $parent = $(this).parent().parent(); 1321 1322 $select.val(language); 1323 1324 HOPE.common.triggerHtmlEvent(select, 'change'); 1325 1326 if(language == 'en') { 1327 window.location.reload(); 1328 } 1329 }, 1330 triggerHtmlEvent: function(element, eventName) { 1331 var event; 1332 if(document.createEvent) { 1333 event = document.createEvent('HTMLEvents'); 1334 event.initEvent(eventName, true, true); 1335 element.dispatchEvent(event); 1336 } else { 1337 event = document.createEventObject(); 1338 event.eventType = eventName; 1339 element.fireEvent('on' + event.eventType, event); 1340 } 1341 }, 1342 repFinder: function() { 1343 $('.repfinder-select select').change(function(){ 1344 var region = $(this).val(), 1345 $form = $(this).parents('form'); 1346 1347 if(region != '') { 1348 if($form.hasClass('state')) { 1349 if(region == 'Illinois' || region == 'Indiana' || region == 'Michigan') { 1350 $form.find('.repfinder-search, .repfinder-check').show(); 1351 $form.find('button').hide(); 1352 1353 $form.attr('action', '/_resources/php/finder/admissions/hs-'+region+".php"); 1354 1355 // $form.find('.input-suggest').load('/assets/data/michigan.txt', function(){ 1356 // $form.find('.input-suggest-list').remove(); 1357 // $form.find('.repfinder-search').append('<ul class="input-suggest-list"></ul>'); 1358 // $form.find('.input-suggest option').each(function(){ 1359 // $form.find('.input-suggest-list').append('<li data-text="'+$(this).text().toLowerCase()+'">'+$(this).text()+'</li>'); 1360 // }); 1361 // }); 1362 1363 $form.find('.input-suggest').load('/_resources/php/finder/admissions/textdata/' + region + '.txt', function(){ 1364 $form.find('.input-suggest-list').remove(); 1365 $form.find('.repfinder-search').append('<ul class="input-suggest-list"></ul>'); 1366 $form.find('.input-suggest option').each(function(){ 1367 $form.find('.input-suggest-list').append('<li data-text="'+$(this).text().toLowerCase()+'">'+$(this).text()+'</li>'); 1368 }); 1369 }); 1370 } else { 1371 $form.find('.repfinder-search').hide(); 1372 $form.find('.repfinder-check, button').css('display', 'block'); 1373 } 1374 } else { 1375 $form.find('.repfinder-check, button').show(); 1376 } 1377 } else { 1378 $form.find('.repfinder-search, .repfinder-check, button').hide(); 1379 } 1380 }); 1381 1382 $('.repfinder-search').on('click', '.input-suggest-list li', function(){ 1383 var searchText = $(this).text(), 1384 $form = $(this).parents('form'); 1385 1386 $form.find('.repfinder-search input').val(searchText); 1387 $form.find('.repfinder-check').hide(); 1388 $form.find('button').show(); 1389 $form.trigger('click'); 1390 }); 1391 1392 $('.repfinder-search input').focus(function(){ 1393 $(this).parent().addClass('focus'); 1394 }); 1395 1396 $('.repfinder-search input').on('keydown', function(e){ 1397 if(e.keyCode == 13) { 1398 e.preventDefault(); 1399 } 1400 }); 1401 1402 $('.repfinder-search input').on('keyup', function(){ 1403 var keyword, keywordLength, $matchItems; 1404 keyword = $(this).val(); 1405 keywordLength = keyword.length, 1406 $form = $(this).parents('form'); 1407 1408 if(keywordLength > 0) { 1409 $(this).siblings('.input-suggest-list').find('li').hide(); 1410 1411 $matchItems = $(this).siblings('.input-suggest-list').find('li[data-text^="'+keyword.toLowerCase()+'"]'); 1412 1413 $matchItems.each(function() { 1414 $(this).show(); 1415 }); 1416 1417 var matchLen = $('.input-suggest-list li:visible').filter(function(){ 1418 return $(this).text().toLowerCase() === $form.find('.repfinder-search input').val().toLowerCase(); 1419 }).length; 1420 1421 if(keywordLength > 3 && matchLen > 0) { 1422 $form.find('.repfinder-check').hide(); 1423 $form.find('button').show(); 1424 } else { 1425 $form.find('.repfinder-check').show(); 1426 $form.find('button').hide(); 1427 } 1428 } else { 1429 $(this).siblings('.input-suggest-list').find('li').show(); 1430 $form.find('.repfinder-check, button').hide(); 1431 } 1432 }); 1433 1434 $(document).click(function(e){ 1435 if(!$('.repfinder-search').is(e.target) && $('.repfinder-search').has(e.target).length === 0) { 1436 $('.repfinder-search').removeClass('focus'); 1437 } 1438 }); 1439 1440 $('.repfinder-check input[type="checkbox"]').change(function(){ 1441 $form = $(this).parents('form'), 1442 region = $form.find('select').val(); 1443 1444 if(region == 'Illinois' || region == 'Indiana' || region == 'Michigan') { 1445 if($(this).is(':checked')) { 1446 $form.find('button').css('display', 'block'); 1447 } else { 1448 $form.find('button').hide(); 1449 } 1450 } 1451 }); 1452 1453 // Override Form Actions 1454 $('input[id*="state-homeschool"]').change(function() { 1455 if ($(this).is(':checked')) { 1456 $('.repfinder.state').attr('action', '/_resources/php/finder/admissions/homeschool.php'); 1457 } 1458 }); 1459 1460 $('input[id*="country-homeschool"]').change(function() { 1461 if ($(this).is(':checked')) { 1462 $('.repfinder.country').attr('action', '/_resources/php/finder/admissions/homeschool-intl.php'); 1463 } 1464 }); 1465 } 1466 }; 1467 1468 /* 1469 * Page-Specific 1470 */ 1471 HOPE.home = { 1472 init: function() { 1473 var _this = this; 1474 1475 // HUD Date/Time 1476 1477 updateTime = function() { 1478 var hudTime = new Date(), 1479 day = hudTime.getDate(), 1480 hours = hudTime.getHours(), 1481 minutes = hudTime.getMinutes(), 1482 tod = 'Morning'; 1483 1484 var monthNames = new Array(); 1485 monthNames[0] = "January"; 1486 monthNames[1] = "February"; 1487 monthNames[2] = "March"; 1488 monthNames[3] = "April"; 1489 monthNames[4] = "May"; 1490 monthNames[5] = "June"; 1491 monthNames[6] = "July"; 1492 monthNames[7] = "August"; 1493 monthNames[8] = "September"; 1494 monthNames[9] = "October"; 1495 monthNames[10] = "November"; 1496 monthNames[11] = "December"; 1497
1498 var month = monthNames[hudTime.getMonth()]; 1499 1500 if(hours >= 12 && hours < 17) { 1501 tod = 'Afternoon'; 1502 } else if(hours >= 17 && hours < 20) { 1503 tod = 'Evening'; 1504 } else if(hours >= 20) { 1505 tod = 'Night'; 1506 } 1507 1508 if(hours > 12) { 1509 hours = hours - 12; 1510 } 1511 if(minutes < 10) { 1512 minutes = '0'+minutes; 1513 } 1514 1515 $('.hud .time, .hud .date').remove(); 1516 1517 if($('.banner-alert').length) { 1518 $('.banner-alert').after('<li class="date"><div class="info"><strong>'+day+'</strong><span class="notranslate">'+month+'</span></div></li>'); 1519 } else { 1520 $('.hud').prepend('<li class="date"><div class="info"><strong>'+day+'</strong><span class="notranslate">'+month+'</span></div></li>'); 1521 } 1522 1523 $('.hud .date').after('<li class="time"><div class="info"><strong>'+hours+':'+minutes+'</strong><span class="notranslate">'+tod+'</span></div></li>'); 1524 } 1525 1526 updateTime(); 1527 setInterval(updateTime, 1000); 1528 1529 // Home Numbers Section 1530 $(window).load(_this.equalizeNumbers).resize(_this.equalizeNumbers); 1531 } 1532 }; 1533 1534 HOPE.giving = { 1535 init: function() { 1536 var _this = this; 1537 1538 $('.donate-form').on('click', '.radio label', _this.donateAmount); 1539 $('.donate-form').on('keydown', '#donate-amount', _this.donateRadio); 1540 }, 1541 donateAmount: function() { 1542 var target = $(this).attr('for'); 1543 $('#donate-amount').val($('input#'+target).val()); 1544 }, 1545 donateRadio: function(e) { 1546 if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || (e.keyCode >= 35 && e.keyCode <= 39)) { 1547 return; 1548 } 1549 if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { 1550 e.preventDefault(); 1551 } else { 1552 $('.donate-form .radio input').attr('checked', false); 1553 } 1554 } 1555 }; 1556 1557 HOPE.directory = { 1558 init: function() { 1559 var _this = this; 1560 1561 $('#staff-group-select option:first-child').each(function(){ 1562 $(this).attr('selected', true).parent().siblings('.select-text').text($(this).text()); 1563 }); 1564 $('.directory-section li').on('click', 'strong:first-child', _this.toggleInfo); 1565 $('#staff-group-select').on('change', _this.filterStaff); 1566 // $('.js-staff-select a').on('click', _this.filterStaff); 1567 1568 $.expr[":"].contains = $.expr.createPseudo(function(arg) { 1569 return function( elem ) { 1570 return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; 1571 }; 1572 }); 1573 1574 // Directory Search 1575 var names = new Array(); 1576 1577 $('.directory-section li .fn').each(function(){ 1578 var name = $(this).text(), 1579 altName = name.split(' ').reverse().join(' '); 1580 1581 names.push({ 1582 'name': name + altName, 1583 // 'altName': altName, 1584 'el': $(this) 1585 }); 1586 }); 1587 1588 var searchOptions = { 1589 pre: '<span class="highlight">', 1590 post: '</span>', 1591 extract: function(entry) { 1592 return entry.name; 1593 } 1594 } 1595 1596 $('.directory-search input').on('keyup', directorySearch); 1597 1598 function directorySearch() { 1599 var keyword, keywordLength, $matchItems; 1600 keyword = $(this).val(); 1601 keywordLength = keyword.length; 1602 1603 $('.directory-section li.expanded').removeClass('expanded'); 1604 $('.js-directory-category .active').removeClass('active'); 1605 1606 if(keywordLength > 2) { 1607 $('.directory-section li, .directory-section, .directory-sub-section, .staff-group .directory-sub-headline').hide(); 1608 $('.directory-section li').removeClass('match'); 1609 $('.directory-section li strong').each(function(){ 1610 $(this).html($(this).text()); 1611 }); 1612 1613 $('#staff-group-select').parent().hide(); 1614 $('.staff-group').show(); 1615 1616 keyword = keyword.replace(/\(|\)/g, ''); 1617 var keywords = keyword.split(' '); 1618 1619 // var result = fuzzy.filter(keyword, names, searchOptions); 1620 1621 // Set data attribute on directory items to help count keyword matches 1622 $('.directory-section li').attr('data-match', '0'); 1623 1624 var q = keywords.length; 1625 1626 while(q--) { 1627 var thisKeyword = keywords[q]; 1628 1629 $matchItems = $('.directory-section').find('li .fn:contains("'+thisKeyword+'")'); 1630 1631 $matchItems.each(function(){ 1632 var resultMatch = parseInt($(this).parents('li').attr('data-match')); 1633 1634 $(this).parents('li').attr('data-match', resultMatch + 1); 1635 1636 resultMatch = parseInt($(this).parents('li').attr('data-match')); 1637 1638 if(resultMatch == keywords.length) { 1639 $(this).parent('li:not([data-repeat="yes"])').show().addClass('match'); 1640 1641 var matchCount = $('.directory-holder li:visible').length; 1642 1643 if(matchCount <= 10) { 1644 $(this).parent().addClass('expanded'); 1645 } 1646 1647 $('.directory-section li.match').parents('.directory-sub-section, .directory-section').show(); 1648 $('.directory-section li.match').parents('.directory-sub-section').find('.directory-sub-headline').show(); 1649 } 1650 }); 1651 } 1652 1653 $('.directory-section li .fn').highlight(keywords); 1654 } else { 1655 $('.directory-section, .directory-sub-section').show(); 1656 $('.directory-section li').show(); 1657 $('.directory-section li strong').each(function(){ 1658 $(this).html($(this).text()); 1659 }); 1660 1661 $('#staff-group-select').parent().show(); 1662 $('#staff-group-select').prop('selectedIndex', 0); 1663 $('#staff-group-select').prev().text($('#staff-group-select option:selected').text()); 1664 $('.staff-group').hide(); 1665 } 1666 } 1667 1668 $('.directory-search input').on('focus', function() { 1669 if($(window).height() < 500) { 1670 $('html, body').animate({ 1671 scrollTop: $('.directory-search input').offset().top - 30 1672 }, 500); 1673 } 1674 }); 1675 // $('.directory-search').on('keyup', 'input', _this.directorySearch); 1676 $('.js-directory-category').on('click', 'a', _this.directoryFilter); 1677 $('.directory-search').on('submit', function(e) { 1678 e.preventDefault(); 1679 $(this).find('input').blur(); 1680 }); 1681 }, 1682 toggleInfo: function() { 1683 if(!$(this).parent().hasClass('expanded')) { 1684 $(this).parent().addClass('expanded'); 1685 } else { 1686 $(this).parent().removeClass('expanded'); 1687 } 1688 }, 1689 filterStaff: function() { 1690 var groupId = $(this).val(); 1691 1692 if(groupId == '') {
1693 $('.staff-group').slideUp(250); 1694 } else { 1695 $('.staff-group:not(#'+groupId+')').slideUp(250, function(){ 1696 $('.staff-group#'+groupId).slideDown(250); 1697 }); 1698 } 1699 }, 1700 directoryFilter: function(e) { 1701 e.preventDefault(); 1702 1703 $('.directory-section li, .directory-section, .directory-sub-section').hide(); 1704 $('.directory-search input').val(''); 1705 1706 if(!$(this).hasClass('active')) { 1707 $('.js-directory-category .active').removeClass('active'); 1708 $(this).parents('.category-filter').find('.inactive').removeClass('inactive'); 1709 $(this).addClass('active'); 1710 $(this).parents('.category-filter').find('a:not(.active)').addClass('inactive'); 1711 $('.directory-section li.'+$(this).attr('data-category')+'-vcard').show(); 1712 $('.directory-section li.'+$(this).attr('data-category')+'-vcard').parents('.directory-sub-section, .directory-section').show(); 1713 $('.directory-section li.expanded').removeClass('expanded'); 1714 $('#staff-group-select').parent().hide(); 1715 $('.staff-group').show(); 1716 } else { 1717 $(this).removeClass('active'); 1718 $(this).parents('.category-filter').find('.inactive').removeClass('inactive'); 1719 $('.directory-section li, .directory-section, .directory-sub-section').show(); 1720 $('#staff-group-select').parent().show(); 1721 $('.staff-group + .staff-group').hide(); 1722 } 1723 } 1724 }; 1725 1726 HOPE.academics = { 1727 init: function() { 1728 var _this = this; 1729 1730 $('.course-holder').on('click', '.course-expand, .course-bar', _this.expandCourses); 1731 1732 $('.course-holder').append('<span class="course-bar">Expand</span>'); 1733 $('.course-bar').height($('.course-holder').outerHeight()); 1734 1735 // Course Search 1736 $.expr[":"].contains = $.expr.createPseudo(function(arg) { 1737 return function( elem ) { 1738 return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; 1739 }; 1740 }); 1741 1742 $('.course-search').on('keyup', 'input', _this.courseSearch); 1743 $('.course-search').on('submit', function(e) { 1744 e.preventDefault(); 1745 $(this).find('input').blur(); 1746 }); 1747 1748 // Expands the course catalog if #expanded is the URL hash 1749 if (window.location.hash === "#expanded") { 1750 $('.course-holder').addClass('expanded'); 1751 $('.course-expand').text('Collapse'); 1752 } 1753 1754 }, 1755 expandCourses: function(e) { 1756 e.preventDefault(); 1757 1758 if($('.course-holder').hasClass('expanded')) { 1759 $('.course-holder').removeClass('expanded'); 1760 $('.course-expand').text('Expand'); 1761 1762 // Removes #expanded from URL >> with older browser fallback 1763 if(history.pushState) { 1764 history.replaceState("", document.title, window.location.pathname); 1765 } else { 1766 window.location.hash = ""; 1767 } 1768 1769 1770 } else { 1771 $('.course-holder').addClass('expanded'); 1772 $('.course-expand').text('Collapse'); 1773 1774 // Adds '#expanded' to URL >> with older browser fallback 1775 if(history.pushState) { 1776 history.replaceState("", document.title, "#expanded"); 1777 } else { 1778 window.location.hash = "#expanded"; 1779 } 1780 1781 $('.course-majors:hidden + .course-minors').addClass('first'); 1782 $('.course-majors:visible + .course-minors').removeClass('first'); 1783 } 1784 }, 1785 courseSearch: function() { 1786 var keyword, keywordLength, $matchItems; 1787 keyword = $(this).val(); 1788 keywordLength = keyword.length; 1789 1790 if(keywordLength > 0) { 1791// $('.course-holder').addClass('expanded'); 1792 1793 //$('.course-department, .course-majors, .course-minors, .course-list li').hide(); 1794 $('.course-list li').removeClass('match'); 1795 $('.course-list strong').each(function(){ 1796 $(this).html($(this).text()); 1797 }); 1798 1799 // Update Banner 1800 $('.academic-banner').addClass('searching'); 1801 1802 $('.academic-banner .course-results').remove(); 1803 1804 if(!$('.academic-banner .course-results').length > 0) { 1805 $('.academic-banner .banner-copy').append('<div class="course-results"><div class="course-majors"><h4 class="course-type-title"><small>Related</small> Majors</h4><ul class="course-list"></ul></div><div class="course-minors"><h4 class="course-type-title"><small>Related</small> Minors</h4><ul class="course-list"></ul></div><div class="course-depts"><h4 class="course-type-title"><small>Related</small> Departments</h4><div class="dept-list"></div></div></div>'); 1806 } 1807 1808 $matchItems = $('.course-list').find('li a:contains("'+keyword+'") strong'); 1809 keyword = keyword.replace(/\(|\)/g, ''); 1810 var keywordTLC = new RegExp('('+keyword+')', 'gi'); 1811 1812 $matchItems.each(function() { 1813 var highlightText = $(this).html().replace(keywordTLC, '<span class="highlight">$&</span>'); 1814 highlightText = highlightText.replace('amp;', ''); 1815 $(this).html(highlightText); 1816 $(this).parents('li').show().addClass('match'); 1817 1818 $('.course-list li.match').parents('.course-department, .course-majors, .course-minors').show(); 1819 1820 // Add Search Results to Banner 1821 if($(this).parents('.course-type').hasClass('course-majors')) { 1822 $(this).parents('li').clone().appendTo('.course-results .course-majors .course-list'); 1823 } else { 1824 $(this).parents('li').clone().appendTo('.course-results .course-minors .course-list'); 1825 } 1826 }); 1827 1828// MATCH DEPTS START 1829 $matchDepts = $('#full-dept-list').find('li:contains("'+keyword+'")'); 1830 keyword = keyword.replace(/\(|\)/g, ''); 1831 var keywordTLC = new RegExp('('+keyword+')', 'gi'); 1832 1833 $matchDepts.each(function() { 1834 console.log("matchdept each"); 1835 $('#full-dept-list li.match').show(); 1836 1837 // Add Search Results to Banner 1838 if($(this)) { 1839 console.log("yes match"); 1840 $(this).children().clone().addClass('btn').appendTo('.course-results .course-depts .dept-list'); 1841 } else { 1842 console.log('NO Matches!'); 1843 } 1844 }); 1845// MATCH DEPTS END 1846 1847 if($('.course-results .course-majors .course-list li').length > 0) { 1848 $('.course-results .course-majors .no-results').remove(); 1849 } else { 1850 $('.course-results .course-majors').append('<span class="no-results">No majors match your search.</span>'); 1851 } 1852 1853 if($('.course-results .course-minors .course-list li').length > 0) { 1854 $('.course-results .course-minors .no-results').remove(); 1855 } else { 1856 $('.course-results .course-minors').append('<span class="no-results">No minors match your search.</span>'); 1857 } 1858 if($('.course-results .course-depts .dept-list a').length > 0) { 1859 $('.course-results .course-depts .no-results').remove(); 1860 } else { 1861 $('.course-results .course-depts').append('<span class="no-results">No departments match your search.</span>'); 1862 } 1863 1864 } else { 1865// $('.course-holder').removeClass('expanded'); 1866 $('.course-majors, .course-minors, .course-list li').show(); 1867 $('.course-department').removeAttr('style'); 1868 $('.course-list strong').each(function(){ 1869 $(this).html($(this).text()); 1870 }); 1871 1872 $('.academic-banner').removeClass('searching'); 1873 $('.academic-banner').find('.course-results').remove(); 1874 } 1875 } 1876 }; 1877 1878 1879 HOPE.news = { 1880 init: function() { 1881 var _this = this; 1882 _scrollStart = 0; 1883 1884 // News Navigation
1885 $('.news-links').on('click', _this.showLinks); 1886 $('.news-filter select, #blog-select, #media-select').change(_this.selectNews); 1887 $('.news-filter select').change(_this.filterNews); 1888 $('.news-filter input').keyup(_this.filterNews); 1889 1890 // Active Months 1891 $(window).scroll(_this.activeMonth); 1892 1893 // Auto Load More 1894 //$(window).scroll(_this.autoLoadMore); 1895 1896 // Open Appended Videos 1897 $('.news-holder').magnificPopup({ 1898 delegate: '.video-card a', 1899 showCloseBtn: false, 1900 type: 'iframe' 1901 }); 1902 1903 // Instagram Card Truncation 1904 _this.instagramText(); 1905 $(window).resize(function(){ 1906 _this.instagramText(); 1907 }); 1908 1909 // Style Drupal Caption 1910 $('.field-label-hidden').each(_this.styleDrupal); 1911 }, 1912 showLinks: function() { 1913 if (($(window).width() / parseFloat($("body").css("font-size"))) < 45) { 1914 if(!$(this).hasClass('show')) { 1915 $(this).addClass('show'); 1916 } else { 1917 $(this).removeClass('show'); 1918 } 1919 } 1920 }, 1921 selectNews: function() { 1922 window.location.href = $(this).val(); 1923 }, 1924 filterNews: function() { 1925 var filled = 0; 1926 1927 $('.news-filter input, .news-filter select').each(function(){ 1928 if($(this).val() != '') { 1929 filled += 1; 1930 } 1931 }); 1932 1933 if(filled > 0) { 1934 if(!$('.news-filter').hasClass('filtered')) { 1935 $('.news-filter').addClass('filtered').append('<a class="reset news-reset" href="/news/">Reset Filters</a>'); 1936 } 1937 } else { 1938 $('.news-filter').removeClass('filtered') 1939 $('.news-reset').remove(); 1940 } 1941 }, 1942 activeMonth: function() { 1943 $('.news-month').each(function(){ 1944 var distance = $(this).offset().top - $(window).scrollTop(); 1945 1946 if(distance <= 200){ 1947 $('.news-month .active').removeClass('active'); 1948 $(this).find('.month-marker').addClass('active'); 1949 } else { 1950 $(this).find('.month-marker').removeClass('active'); 1951 } 1952 }); 1953 }, 1954 instagramText: function() { 1955 $('.instagram-text').each(function(){ 1956 // var textHeight = $(this).find('.instagram-text').outerHeight(), 1957 // lineHeight = parseInt($(this).find('.instagram-text').css('line-height')), 1958 // lineCount = textHeight / lineHeight; 1959 // 1960 // alert(lineCount); 1961 1962 var current = $(this), 1963 text = current.text(), 1964 words = text.split(' '), 1965 lineBreak = 0, 1966 lineLimit; 1967 1968 current.text(words[0]); 1969 1970 var height = current.height(), 1971 width = current.parents('.instagram-card').width() / 16; 1972 1973 if(width > 15.625) { 1974 lineLimit = 6; 1975 } else if(width < 13.125) { 1976 lineLimit = 1; 1977 } else { 1978 lineLimit = 4; 1979 } 1980 1981 for(var i = 1; i < words.length; i++) { 1982 if(lineBreak >= lineLimit) { 1983 current.find('span:last-of-type').html(current.find('span:last-of-type').html() + ' ' + words[i]); 1984 } else { 1985 current.html(current.html() + ' <span>' + words[i] + '</span>'); 1986 } 1987 1988 if(current.height() > height) { 1989 lineBreak += 1; 1990 height = current.height(); 1991 1992 if(lineBreak === lineLimit) { 1993 current.append('<span>'); 1994 } 1995 } 1996 } 1997 }); 1998 }, 1999 styleDrupal: function(){ 2000 var caption = $(this).find('.field-item:first-child').text(); 2001 2002 if($(this).next('p').length > 0) { 2003 $(this).next('p').remove(); 2004 } 2005 2006 $(this).next('img').wrap('<figure class="caption-image">').after('<span class="photo-caption js-photo-caption">'+caption+'</span>').attr('title', ''); 2007 2008 $(this).remove(); 2009 } 2010 // autoLoadMore: function() { 2011 2012 // console.log('in autoLoadMore'); 2013 2014 // var distance = $('#page-foot').offset().top - ($(window).scrollTop() + $(window).height()) 2015 // newScroll = $(document).scrollTop(); 2016 2017 // if(distance <= 100 && newScroll - _scrollStart > 100){ 2018 // _scrollStart = newScroll; 2019 // console.log('load'); 2020 // $(window).off('scroll',HOPE.news.autoLoadMore); 2021 // $('.js-auto-more').trigger('click'); 2022 // } 2023 2024 2025 // // $(window).off('scroll',HOPE.news.autoLoadMore); 2026 // } 2027 }; 2028 2029 HOPE.init(); 2030})( window, document ); 2031 2032//$(window).load(function(){ 2033// var img = new Image(); 2034// img.onload = function() { 2035// Pixastic.process(img, 'blurfast', {amount: 0.5}); 2036// } 2037// 2038// document.body.appendChild(img); 2039// img.src = "/assets/img/uploads/section-banner-01.jpg" 2040//});
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.