var toolbarAnimating = false; var touchScroll = false; //Global variable to store whether or not a touch event is a touch scroll event or not. Used to distinguish between scrolls and clicks for touchend events. var modalInit = false; var facAccLoadInit = true; // Boolean to control if requests for more data can be made. var mobile = false; 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) || /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.substr(0,4))) { mobile = true; } function initMobileMenu(){ $('#mobile-menu-button').click(function(){ $(this).find('span').toggleClass('on').toggleClass(''+$(this).find('span').attr('data-icon')+' '+$(this).find('span').attr('data-icon-close')+''); $('#logo').toggleClass('bumpUp'); $(document.body).toggleClass('open'); if($(document.body).hasClass('open')){ //Wrap everything $(document.body).wrapInner('
'); } else { //Unwrap everything $('#alert').unwrap(); } setTimeout(function(){ $('#content').toggleClass('bumpLeft'); }, 100); }); $('#mobile-search-button').click(function(){ $(this).find('span').toggleClass('on').toggleClass(''+$(this).find('span').attr('data-icon')+' '+$(this).find('span').attr('data-icon-close')+'');; $('#logo').toggleClass('bumpUp'); $(document.body).toggleClass('open'); if($(document.body).hasClass('open')){ //Wrap everything $(document.body).wrapInner('
'); var attr = $('#content').attr('data-old-height'); if (typeof attr !== typeof undefined && attr !== false) { $('#content').height(attr); } } else { //Unwrap everything $('#alert').unwrap(); $('#content').height('auto'); //This is done to counteract searches that hard set #content's height so that results aren't clipped on mobile } setTimeout(function(){ $('#content, #toolbar').toggleClass('bumpRight'); if($('#content').hasClass('bumpRight')){ $('#urlinks, .flyout, #mobile-tools-button').hide(0); $('.flyout.search, #top-search, #top-search-results').show(0); } else{ $('#mobile-tools-button').show(0); } }, 100); }); $('#mobile-tools-button').click(function(){ $(this).find('span').toggleClass('on').toggleClass(''+$(this).find('span').attr('data-icon')+' '+$(this).find('span').attr('data-icon-close')+'');; if($('#logo').hasClass('bumpUp')){ //$('#logo').css('height', $('#logo').height()); //Tally the height of visible children and set it to the parent of height } $('#logo').toggleClass('bumpUp'); $(document.body).toggleClass('open'); if($(document.body).hasClass('open')){ //Wrap everything $(document.body).wrapInner('
'); } else { //Unwrap everything $('#alert').unwrap(); $('#content').height('auto'); //This is done to counteract searches that hard set #content's height so that results aren't clipped on mobile } setTimeout(function(){ $('#content, #toolbar').toggleClass('bumpRight'); if($('#content').hasClass('bumpRight')){ $('#top-search, #top-search-results, #mobile-search-button, .flyout').hide(0); $('#urlinks').show(0); } else{ $('#mobile-search-button').show(0); } }, 100); }); } function initToolbar(){ $('#toolbar .expandable').click(function(){ if(toolbarAnimating == false){ toolbarAnimating = true; $('#urlinks .buttonWrap').removeClass('on'); $(this).parents('.buttonWrap').toggleClass('on'); $(this).toggleClass(''+$(this).attr('data-icon')+' '+$(this).attr('data-icon-close')+''); if($('.flyout:visible').length==0){ //Open Flyout Sequence if($(this).data('flyout') == 'directory'){ var attr = $('#content').attr('data-old-height'); if (typeof attr !== typeof undefined && attr !== false) { $('#content').height(attr); } } if($('#logo .shield').length > 0){ if($('#logo .shield').hasClass('on')){ $('#logo .shield').removeClass('on').addClass('off transition'); $('#logo .urwordmark').removeClass('off').addClass('on transition'); setTimeout(function(){ $('#logo a').removeClass('transition'); },250); } } $('.flyout').hide(); $('.flyout.'+$(this).data('flyout')).show(); var height = $('#toolbar .viewer').height(); $('#toolbar .viewer').height(0).show().animate({ height: height }, 300, function(){ $(this).css('height', 'auto'); toolbarAnimating = false; }); } else if(! $('.flyout:visible').hasClass($(this).data('flyout'))){ //Open Different Flyout if($(this).data('flyout') == 'directory'){ var attr = $('#content').attr('data-old-height'); if (typeof attr !== typeof undefined && attr !== false) { $('#content').height(attr); } } var oldheight = $('#toolbar .viewer').height(); $('.flyout').hide(); $('.flyout.'+$(this).data('flyout')).show(); var height = $('#toolbar .viewer').height(); $('#toolbar .viewer').height(oldheight).animate({ height: height }, 300, function(){ $(this).css('height', 'auto'); $('#content').height('auto'); toolbarAnimating = false; }); } else if($('.flyout:visible').hasClass($(this).data('flyout'))){ //Close Flyout Sequence $(this).parents('.buttonWrap').removeClass('on'); if($('#stage').is(':hidden') || $('#stage').length==0){ //if the stage is hidden or the stage does not exist. #stage is an element of www only if($('#logo .shield').length > 0){ $('#logo .shield').removeClass('off').addClass('on transition'); $('#logo .urwordmark').removeClass('on').addClass('off transition'); setTimeout(function(){ $('#logo a').removeClass('transition'); },250); } } var height = $('#toolbar .viewer').height(); $('#toolbar .viewer').height(height).animate({ height: 0 }, 300, function(){ $(this).hide().css('height', 'auto'); $('.flyout').hide(); $('#content').height('auto'); toolbarAnimating = false; }); } return false; //Prevents anchor tag click } }); } function heroAutoScroller(){ var scroller = $('#heroScroller'); var scrollControls; var zIndex = scroller.children('.scrollWrap').length; var activeIndex = 0; var pauseScroller = false; var panelSwapping = false; //Pie chart timer variables var loader; var alpha = 0; var pi = Math.PI; var time = 23; //Time in milliseconds before draw is called again. 23*360 = 8280, or 8.280 seconds //Testing //var start; function fadeIn(activeIndex){ panelSwapping = true; var activePanel = scroller.find('.scrollWrap:eq(' + activeIndex + ')'); var img = $('#heroScroller .scrollWrap:eq(' + activeIndex + ') .responsiveImg'); resizeImg(img); activePanel.css({ 'z-index' : zIndex + 1 }); activePanel.fadeIn(500, function(){ $(this).css({ position: 'relative', 'z-index' : zIndex }); scroller.find('.scrollWrap:not(:eq(' + activeIndex + '))').hide().css({ 'z-index' : 'auto', position: 'absolute' }); panelSwapping = false; }); scrollControls.find('.controlElement').removeClass('on'); scrollControls.find('.controlElement:eq(' + activeIndex + ')').addClass('on'); } function advancePanel(){ activeIndex++; if(activeIndex > scroller.find('.scrollWrap').length - 1){ activeIndex = 0; } fadeIn(activeIndex); } function draw(){ if(pauseScroller == false) { alpha++; alpha %= 360; var r = ( alpha * pi / 180 ) , x = Math.sin(r) * 125 , y = Math.cos(r) * -125 , mid = ( alpha > 180 ) ? 1 : 0 , anim = 'M 0 0 v -125 A 125 125 1 ' + mid + ' 1 ' + x + ' ' + y + ' z'; loader.attr('d', anim); if (alpha == 0) { advancePanel(); } setTimeout(draw, time); // Redraw } } scroller.after('
'); scrollControls = $('#scrollControls .controlsWrap'); scroller.find('.scrollWrap').each(function(){ if($(this).index() != 0){ //Hides all but the first slide on initialization. First slide provides the initial pressure to #heroScroller $(this).hide(); resizeImg($(this).find('.responsiveImg')); } else { $(this).css({ 'z-index' : zIndex }); } var title = $(this).find('.content h2').text(); var printableIndex = $(this).index() + 1; var isOn = ''; if(title == '' || title == 'undefined'){ title = 'Panel ' + printableIndex; } if($(this).index() == 0){ isOn = ' on'; } scrollControls.append('
'); }); $(document).on('click', '#scrollControls .controlElement', function(){ if(panelSwapping == false) { activeIndex = $(this).index(); alpha = 0; //resets the pie chart timer if( (typeof(isMobile) != 'undefined') && (isMobile == true) ){ pauseScroller = true; } scrollControls.find('.loader').attr('d', 'M 0 0 v -125 A 125 125 1 0 1 0 -125 z'); fadeIn(activeIndex); } }); //if(!isMobile == true){ if( (typeof(isMobile) != 'undefined') && (isMobile == false) ){ $("#heroWrap .content, #scrollControls .controlsWrap").hover( function() { pauseScroller = true; }, function() { pauseScroller = false; draw(); } ); } loader = scrollControls.find('.loader'); //start = new Date().getTime(); draw(); } function heroSlider() { var slider = $('#heroSlider'); var numChildren = slider.children().length; slider.children().hide(); slider.width(99999); slider.children().each(function(){ $(this).width($(window).width()); $(this).show(); }); if(numChildren > 1){ slider.find('.parallaxWrap:first-child').addClass('on'); slider.parent().prepend(''); } $('#hero-next').click(function(){ var hero = slider.find('.on'); if(hero.index() + 1 == numChildren - 1){ $('#hero-next').hide(); } if(!$('#hero-prev').is(":visible")){ $('#hero-prev').show(); } hero.next().addClass('on'); hero.removeClass('on'); var offset = (hero.index()+1) * 100 * -1; slider.css({ marginLeft: offset+'%' }); }); $('#hero-prev').click(function(){ var hero = slider.find('.on'); if(hero.index() == 1){ $('#hero-prev').hide(); } if(!$('#hero-next').is(":visible")){ $('#hero-next').show(); } hero.prev().addClass('on'); hero.removeClass('on'); var offset = (hero.index()-1) * 100 * -1; slider.css({ marginLeft: offset+'%' }); }); } function heroParallax(img){ var windowWidth = $(window).width(); var responsiveImg = img.closest('.responsiveImg'); var parallaxWrap = responsiveImg.parent(); parallaxWrap.width(windowWidth); var wrapHeight = Math.floor((windowWidth/2)*.7); //Always uses 2:1 images, so half the windowWidth should equal height if(wrapHeight > 500){ wrapHeight = 500; //This is set in the css too as an initial value for parallaxWrap } parallaxWrap.height(wrapHeight); var scrollTop = $(window).scrollTop(); if(scrollTop < 0){ scrollTop = 0; } var elementOffset = parallaxWrap.offset().top; var distance = elementOffset + parallaxWrap.height(); var offset = ((windowWidth/2) - parallaxWrap.height()) * -1; /* if (scrollTop >= 0 && scrollTop <= distance) { //Top of image to bottom var percentageDown = scrollTop/distance; var newTop = offset * percentageDown; responsiveImg.css('margin-top',newTop+'px'); } */ if (scrollTop >= 0 && scrollTop <= distance) { //Center of image to bottom var percentageDown = scrollTop/distance; var newTop = (offset/2) - (percentageDown * (offset/2)); responsiveImg.css('margin-top',newTop+'px'); } else { responsiveImg.css('margin-top','0px'); } } function spotlightAutoScroller(){ var scroller = $('#spotlightScroller'); var padder = $('#spotlightScroller #spotlightPadder'); var scrollControls = $('#spotlights #scrollControls'); var activeIndex = 0; var pauseScroller = false; //Pie chart timer variables var loader; var alpha = 0; var pi = Math.PI; var time = 30; //Time in milliseconds before draw is called again. 30*360 = 10800, or 10.8 seconds function advanceIndex(advanceBy){ padder.find('.scrollWrap').each(function(){ var newIndex; newIndex = parseInt($(this).attr('data-index')) - advanceBy; // On an sample length of -3 if(newIndex <= (padder.find('.scrollWrap').length -1) * -1){ // Less than newIndex = newIndex + padder.find('.scrollWrap').length; // 1 = -3 + 4 } // On an sample length of 3 if(newIndex >= padder.find('.scrollWrap').length -1){ // Greater than newIndex = newIndex - padder.find('.scrollWrap').length; // -1 = 3 - 4; } if(newIndex == 0){ $(this).addClass('active'); } else { $(this).removeClass('active'); } $(this).attr('data-index',newIndex); }); // Keep scroll controls locked in step with active element in the scroller if(typeof scrollControls != 'undefined') { if(padder.find('.active').index() != scrollControls.find('.on').index()) { scrollControls.find('.on').removeClass('on'); scrollControls.find('.controlElement:eq(' + padder.find('.active').index() + ')').addClass('on'); } } if(advanceBy > 0) { padder.addClass('slideLeft' + Math.abs(advanceBy)); setTimeout(function () { padder.removeClass('slideLeft' + Math.abs(advanceBy)); if(modalInit == true){ modalInit = false; } }, 400); } if(advanceBy < 0) { padder.addClass('slideRight' + Math.abs(advanceBy)); setTimeout(function () { padder.removeClass('slideRight' + Math.abs(advanceBy)); if(modalInit == true){ modalInit = false; } }, 400); } } function draw(){ if(pauseScroller == false) { alpha++; alpha %= 360; var r = ( alpha * pi / 180 ) , x = Math.sin(r) * 125 , y = Math.cos(r) * -125 , mid = ( alpha > 180 ) ? 1 : 0 , anim = 'M 0 0 v -125 A 125 125 1 ' + mid + ' 1 ' + x + ' ' + y + ' z'; loader.attr('d', anim); if (alpha == 0) { advanceIndex(1); } setTimeout(draw, time); // Redraw } } function resetTimer(){ alpha = 0; //resets the pie chart timer if( (typeof(isMobile) != 'undefined') && (isMobile == true) ){ pauseScroller = true; } scrollControls.find('.loader').attr('d', 'M 0 0 v -125 A 125 125 1 0 1 0 -125 z'); } $(document).on('click', '#spotlights #scrollControls .controlElement', function(){ activeIndex = $(this).index(); resetTimer(); if($(this).index() != padder.find('.active').index()){ var virtualIndex = parseInt(padder.find('.scrollWrap:eq(' + $(this).index() + ')').attr('data-index')); advanceIndex(virtualIndex); } }); if(jQuery().hammer){ // if hammer.js is loaded $('#spotlightScroller .scrollWrap a').on('click',function(event){ event.preventDefault(); // Prevents default anchor functionality }); $('#spotlightScroller .scrollWrap').hammer().on('swiperight',function(event){ modalInit = true; // prevents modal events from firing on swipes event.stopPropagation(); event.preventDefault(); resetTimer(); advanceIndex(-1); }).on('swipeleft',function(event){ modalInit = true; // prevents modal events from firing on swipes event.stopPropagation(); event.preventDefault(); resetTimer(); advanceIndex(1); }).on('tap',function(event){ if($(this).find('a').length > 0) { window.location.href = $(this).find('a').attr('href'); } }); } else { console.log('Hammer.js not loaded.'); } if( (typeof(isMobile) != 'undefined') && (isMobile == false) ){ scroller.parent().hover( function() { pauseScroller = true; }, function() { pauseScroller = false; draw(); } ); } loader = scrollControls.find('.loader'); draw(); } function fullscreenSlideshow(){ var slideSwapping = false; $('.fullscreenSlideshow').each(function(){ loadImg(1, $(this)); if($(this).find('.slider > div').length > 1){ bindSlideshowEvents($(this)); $(this).find('.next').show(); } }); function loadImg(i, parent){ var imageSrc = parent.find('.linkset a:eq('+i+')').attr('href'); parent.find('.slider').append('
'); parent.find('.slider div:last-child img').load(function(){ if(i < parent.find('.linkset a').length - 1){ loadImg(i + 1, parent); } }); } function fadeIn(parent, activeIndex){ slideSwapping = true; var activePanel = parent.find('.slider > div:eq(' + activeIndex + ')'); var zIndex = 1; parent.height(activePanel.height()); //Allows smooth animation between photos of different height if (activeIndex == parent.find('.slider > div').length - 1) { parent.find('.controls .next').hide(); } else { parent.find('.controls .next').show(); } if (activeIndex == 0) { parent.find('.controls .previous').hide(); } else { parent.find('.controls .previous').show(); } activePanel.css({ 'z-index' : zIndex + 1, 'opacity' : 0 }); activePanel.show().animate({ 'z-index' : zIndex, 'opacity' : 1 }, 400, function(){ parent.find('.slider > div:not(:eq(' + activeIndex + '))').hide().css({ 'z-index' : 'auto', position: 'absolute', 'opacity' : 0 }).addClass('off').removeClass('on'); activePanel.css('position','relative').addClass('on').removeClass('off'); slideSwapping = false; }); } function bindSlideshowEvents(parent){ parent.find('.next').on('click', function(){ if(slideSwapping == false) { var activeIndex = parent.find('.slider .on').next().index(); fadeIn(parent, activeIndex); } }); parent.find('.previous').on('click', function(){ if(slideSwapping == false) { var activeIndex = parent.find('.slider .on').prev().index(); fadeIn(parent, activeIndex); } }); $(window).on('resize', parent, function(){ if(slideSwapping == false){ parent.height('auto'); //Allows parent to resize on with window } }); } } function calculateDimensions(element){ var elementWidth; var elementHeight; var availableWidth = $(window).width() * .65; //Controls take up 20% of width, additional 15% for padding var availableHeight = $('.modalShade .slideshowWrap .player').height(); if(element.find('img').length > 0){ element = element.find('img').first(); } if(element[0].nodeName == 'IMG'){ var wait = setInterval(function () { if (element[0].naturalWidth === undefined) { var i = new Image(); i.src = element[0].src; elementWidth = i.width; elementHeight = i.height; } else { elementWidth = element[0].naturalWidth; elementHeight = element[0].naturalHeight; } if (elementWidth && elementHeight) { clearInterval(wait); resizeThisImage(); } }, 30); } if(element[0].nodeName == 'SPAN'){ element.width(availableWidth).height('auto'); } function resizeThisImage() { element.height(availableHeight).width('auto'); //Update width after first resize elementWidth = element.width(); if (elementWidth > availableWidth) { element.width(availableWidth).height('auto'); } //Update width after first resize elementWidth = element.width(); if (element.prev().is('button')) { var left = elementWidth / 2; element.prev().css('left', left + 'px'); } } } function bindSlideshowEvents(){ $('.modalShade .slideshowWrap .next').on('click', function(){ var active = $('.modalShade .slideshowWrap .slider .active').index(); var queued = active + 2; var previous = active - 1; var next = active + 1; $('.modalShade .slideshowWrap .slider > *').addClass('animating'); setTimeout(function(){ $('.modalShade .slideshowWrap .slider > *').removeClass('animating'); }, 400); //Animating class enables css transitions for margin-left. Removed with setTimeout that matches the css transition length if(($('.modalShade .slideshowWrap .captions .caption').length - 1) > active) { $('.modalShade .slideshowWrap .captions .active').removeClass('active'); $('.modalShade .slideshowWrap .captions .caption:eq(' + next + ')').addClass('active').removeClass('off'); } $('.modalShade .slideshowWrap .slider > *:eq('+queued+')').removeClass('off'); $('.modalShade .slideshowWrap .slider > *:eq('+previous+')').addClass('off'); $('.modalShade .slideshowWrap .slider > *:eq('+active+')').addClass('prevQueue').removeClass('active'); calculateDimensions($('.modalShade .slideshowWrap .slider > *:eq('+active+')')); $('.modalShade .slideshowWrap .slider > *:eq('+next+')').addClass('active').removeClass('nextQueue off'); calculateDimensions($('.modalShade .slideshowWrap .slider > *:eq('+next+')')); if($('.modalShade .slideshowWrap .slider .nextQueue').length == 0){ $('.modalShade .slideshowWrap .controls .next').hide(); if($(this).parents('.modalShade').hasClass('instagram')){ var id = $(this).parents('.modalShade').data('id'); if($('.instagramRow[data-id='+id+']').find('.panel').last().attr('data-maxid') != 'false'){ $('.instagramRow[data-id='+id+']').addClass('isLoading'); getInstagramData(id, function(){ $('.instagramRow[data-id='+id+']').find('.panel').last().removeClass('on'); }); } } } else { $('.modalShade .slideshowWrap .controls .next').show(); } if($('.modalShade .slideshowWrap .slider .prevQueue').length == 0){ $('.modalShade .slideshowWrap .controls .previous').hide(); } else { $('.modalShade .slideshowWrap .controls .previous').show(); } }); $('.modalShade .slideshowWrap .previous').on('click', function(){ var active = $('.modalShade .slideshowWrap .slider .active').index(); var queued = active - 2; var previous = active - 1; var next = active + 1; $('.modalShade .slideshowWrap .slider > *').addClass('animating'); setTimeout(function(){ $('.modalShade .slideshowWrap .slider > *').removeClass('animating'); }, 400); //Animating class enables css transitions for margin-left. Removed with setTimeout that matches the css transition length if(active > 0) { $('.modalShade .slideshowWrap .captions .active').removeClass('active'); $('.modalShade .slideshowWrap .captions .caption:eq(' + previous + ')').addClass('active'); } if(queued >= 0){ $('.modalShade .slideshowWrap .slider > *:eq('+queued+')').addClass('prevQueue').removeClass('off'); } $('.modalShade .slideshowWrap .slider > *:eq('+previous+')').addClass('active').removeClass('prevQueue'); calculateDimensions($('.modalShade .slideshowWrap .slider > *:eq('+previous+')')); $('.modalShade .slideshowWrap .slider > *:eq('+active+')').addClass('nextQueue').removeClass('active'); calculateDimensions($('.modalShade .slideshowWrap .slider > *:eq('+active+')')); $('.modalShade .slideshowWrap .slider img:eq('+next+')').addClass('off'); if($('.modalShade .slideshowWrap .slider .nextQueue').length == 0){ $('.modalShade .slideshowWrap .controls .next').hide(); } else { $('.modalShade .slideshowWrap .controls .next').show(); } if($('.modalShade .slideshowWrap .slider .prevQueue').length == 0){ $('.modalShade .slideshowWrap .controls .previous').hide(); } else { $('.modalShade .slideshowWrap .controls .previous').show(); } }); } function modalSlideshow(type, id, title, showcaptions, index){ if(typeof index == 'undefined'){ index = 0; } var slideshow = { title: title, id: id, type: type, showcaptions: showcaptions, index: index }; function loadImg(i){ var imageSrc = $('.modalShade .slideshowWrap .linkset a').eq(i).attr('href'); var caption = $('.modalShade .slideshowWrap .linkset a').eq(i).attr('data-caption'); var needleIndex; var resizeDelay = 100; if(typeof $('.modalShade .slideshowWrap').attr('data-needle') === 'undefined'){ $('.modalShade .slideshowWrap').attr('data-needle',i); needleIndex = i; } else { needleIndex = parseInt($('.modalShade .slideshowWrap').attr('data-needle')); } if($('.modalShade .slideshowWrap .slider img').length == 0){ //If this is the first image to be loaded in the modal set $('.modalShade .slideshowWrap .slider').append(''); $('.modalShade .slideshowWrap .captions').append('
'+caption+'
'); $('.modalShade .slideshowWrap .slider img:last-child').load(function(){ $(this).removeClass('off'); if(i < $('.modalShade .slideshowWrap .linkset a').length - 1){ loadImg(i + 1); if(i != 0){ loadImg(i - 1); } } else if(i == $('.modalShade .slideshowWrap .linkset a').length - 1) { loadImg(i - 1); } else { $('.modalShade .slideshowWrap .slider img.active').fadeIn(400, function(){ $('.modalShade .slideshowWrap .slider img').each(function(){ calculateDimensions($(this)); }) }); calculateDimensions($('.modalShade .slideshowWrap .slider img.active')); } setTimeout(function(){ calculateDimensions($(this)); }, resizeDelay); }); } if(i < needleIndex){ $('.modalShade .slideshowWrap .slider').prepend(''); $('.modalShade .slideshowWrap .captions').prepend('
'+caption+'
'); $('.modalShade .slideshowWrap .slider img:first-child').load(function(){ $(this).removeClass('off'); $(this).closest('.player').find('.controls .previous').show(); if(i > 0){ loadImg(i - 1); } else { $('.modalShade .slideshowWrap .slider img.active').fadeIn(400, function(){ $('.modalShade .slideshowWrap .slider img').each(function(){ calculateDimensions($(this)); }) }); calculateDimensions($('.modalShade .slideshowWrap .slider img.active')); } setTimeout(function(){ calculateDimensions($(this)); }, resizeDelay); }); } if(i > needleIndex){ $('.modalShade .slideshowWrap .slider').append(''); $('.modalShade .slideshowWrap .captions').append('
'+caption+'
'); $('.modalShade .slideshowWrap .slider img:last-child').load(function(){ $(this).removeClass('off'); $(this).closest('.player').find('.controls .next').show(); if(i < $('.modalShade .slideshowWrap .linkset a').length - 1){ loadImg(i + 1); } else { $('.modalShade .slideshowWrap .slider img.active').fadeIn(400, function(){ $('.modalShade .slideshowWrap .slider img').each(function(){ calculateDimensions($(this)); }) }); calculateDimensions($('.modalShade .slideshowWrap .slider img.active')); } setTimeout(function(){ calculateDimensions($(this)); }, resizeDelay); }); } } $.ajax({ url: assetsUrl+'/actions/get/slideshow.php', type: "GET", data: slideshow, dataType: "jsonp", success: function(data){ $('body').prepend('
'); $('.modalShade').html(data); bindSlideshowEvents(); loadImg(slideshow.index); $('.modalShade').animate({opacity: 1}, 200, function(){ //animation complete modalInit = false; }); }, error: function(){ alert('Failed to load slideshow. Please try again later.'); modalInit = false; } }); } function modalVideo(id){ var video = { id: id }; $.ajax({ url: assetsUrl+'/actions/get/singleVideo.php', type: "GET", data: video, dataType: "jsonp", success: function(data){ $('body').prepend('
'); $('.modalShade .modalStage').append(data); $('.modalShade').animate({opacity: 1}, 200, function () { $('.modalShade').on('click', 'button.close', function () { $('.modalShade').fadeOut(200, function () { $('.modalShade').remove(); }); }); modalInit = false; }); }, error: function(){ alert('Failed to load video. Please try again later.'); modalInit = false; } }); } function modalVimeo(id){ var video = { id: id }; $.ajax({ url: assetsUrl+'/actions/get/singleVimeoVideo.php', type: "GET", data: video, dataType: "jsonp", success: function(data){ $('body').prepend('
'); $('.modalShade .modalStage').append(data); $('.modalShade').animate({opacity: 1}, 200, function () { $('.modalShade').on('click', 'button.close', function () { $('.modalShade').fadeOut(200, function () { $('.modalShade').remove(); }); }); modalInit = false; }); }, error: function(){ alert('Failed to load video. Please try again later.'); modalInit = false; } }); } function modalYoutubeVideo(id){ var video = { id: id }; $.ajax({ url: assetsUrl+'/actions/get/singleYoutubeVideo.php', type: "GET", data: video, dataType: "jsonp", success: function(data){ $('body').prepend('
'); $('.modalShade .modalStage').append(data); $('.modalShade').animate({opacity: 1}, 200, function () { $('.modalShade').on('click', 'button.close', function () { $('.modalShade').fadeOut(200, function () { $('.modalShade').remove(); }); }); modalInit = false; }); }, error: function(){ alert('Failed to load video. Please try again later.'); modalInit = false; } }); } function getInstagramData(id, callback){ callback = false || callback; if(!$.isFunction(callback)){ callback = false; } var instagramElement = $('.instagramRow[data-id='+id+']'); var maxId = ''; var countFrom = 0; if(instagramElement.find('.panel').length > 0){ maxId = instagramElement.find('.panel').last().data('maxid'); countFrom = parseInt(instagramElement.find('.modalInstagram').last().attr('rel')) + 1; } var batch = { maxId: maxId, id: id, countFrom: countFrom, isRow: true }; $.ajax({ url: assetsUrl+'/actions/get/instagram.php', type: "GET", data: batch, dataType: "jsonp", tryCount : 0, retryLimit : 3, success: function(data){ if(instagramElement.find('.slider .panel').length == 0){ //For AJAX initialization, removes the script element that makes the initial data request that also messes up proper index counts instagramElement.find('.slider').html(''); } instagramElement.find('.slider').append(data); instagramElement.removeClass('isLoading'); if($('.modalShade').length > 0){ var totalImageCount = instagramElement.find('.modalInstagram').length -1; var currentCount = $('.modalShade .slider').children().length; for(var i = currentCount; i <= totalImageCount; i++){ var newItemHtml = ''; var newElement = instagramElement.find('.modalInstagram[rel="'+i+'"]'); var newCaptionHtml = ''; var queueClass = 'nextQueue'; if(newElement.hasClass('video')){ newItemHtml = ''; } else { newItemHtml = ''; } newCaptionHtml = '
'+newElement.data('caption')+'
'; $('.modalShade .slider').append(newItemHtml); $('.modalShade .captions').append(newCaptionHtml); } calculateDimensions($('.modalShade .slider > *')); $('.modalShade .slideshowWrap .controls .next').show(); } if(callback != false){ callback(); } }, error: function(xhr, textStatus, errorThrown) { if (textStatus == 'timeout') { this.tryCount++; if (this.tryCount <= this.retryLimit) { //try again $.ajax(this); return; } return; } if (xhr.status == 500) { //handle error alert('Failed to load Instagram. Handle Error. Please try again later.'); instagramElement.removeClass('isLoading'); } else { alert('Failed to load Instagram. Please try again later.'); instagramElement.removeClass('isLoading'); } } }); } function modalInstagram (parent, index, title, id){ var itemHtml = ''; var captionHtml = ''; var element = parent.find('.modalInstagram[rel="'+index+'"]'); if(element.hasClass('video')){ itemHtml = ''; } else { itemHtml = ''; } captionHtml = '
'+element.data('caption')+'
'; $('body').prepend('
' + '
' + '
' + ''+title+'' + '' + '
' + '
' + '
' + '' + '' + '
' + '
' + itemHtml + '
' + '
' + captionHtml + '
' + '
' + '
' + '
'); calculateDimensions($('.modalShade .slider .active')); var totalImageCount = parent.find('.modalInstagram').length -1; for(var i = 0; i <= totalImageCount; i++){ var newItemHtml = ''; var newElement = parent.find('.modalInstagram[rel="'+i+'"]'); var newCaptionHtml = ''; var queueClass; if(i < index){ queueClass = 'prevQueue'; } if(i > index){ queueClass = 'nextQueue'; } if(newElement.hasClass('video')){ newItemHtml = ''; } else { newItemHtml = ''; } newCaptionHtml = '
'+newElement.data('caption')+'
'; if(i < index){ $('.modalShade .slider .active').before(newItemHtml); $('.modalShade .captions .active').before(newCaptionHtml); $('.modalShade .slider').children().first().load(function(){ calculateDimensions($(this)); }); } if(i > index){ $('.modalShade .slider').append(newItemHtml); $('.modalShade .captions').append(newCaptionHtml); $('.modalShade .slider').children().last().load(function(){ calculateDimensions($(this)); }); } } bindSlideshowEvents(); if(index < parent.find('.modalInstagram').length - 1){ $('.modalShade .next').show().animate({ opacity: 1 }, 200); } if(index > 0) { $('.modalShade .previous').show().animate({ opacity: 1 }, 200); } $('.modalShade').animate({opacity: 1}, 200, function() { modalInit = false; }); } function rowInstagram(){ $('.instagramRow').each(function(){ var instagramElement = $(this); var slider = instagramElement.find('.slider'); var id = $(this).data('id'); instagramElement.find('.next').on('click', function() { var currentPanel = instagramElement.find('.panel.on'); var previousButton = $(this).prev(); if(instagramElement.find('.panel.on').index() == instagramElement.find('.panel').length -1) { if (!instagramElement.hasClass('isLoading')) { instagramElement.addClass('isLoading'); //Prevents multiple loading calls from being passed getInstagramData(id, function () { var multiplier = instagramElement.find('.panel.on').index() + 1; var offset = multiplier * -105 + '%'; if ($(window).width() <= 1000) { var newWidth = $(window).width() * 1.05; instagramElement.find('.panel').css('maxWidth', newWidth + 'px'); } currentPanel.removeClass('on').next().addClass('on').removeClass('zeroOpacity'); slider.css('marginLeft', offset); if (instagramElement.find('.panel.on').index() == instagramElement.find('.panel').length - 1 && instagramElement.find('.panel.on').attr('data-maxid') == 'false') { instagramElement.find('.next').hide(); } }); } } else { //Just slide var multiplier = instagramElement.find('.panel.on').index() + 1; var offset = multiplier * -105 + '%'; currentPanel.removeClass('on').next().addClass('on').removeClass('zeroOpacity'); slider.css('marginLeft', offset); if(instagramElement.find('.panel.on').index() == instagramElement.find('.panel').length -1 && instagramElement.find('.panel.on').attr('data-maxid') == 'false'){ $(this).hide(); } } if(previousButton.is(':hidden')){ previousButton.show(); } }); instagramElement.find('.previous').on('click', function() { var currentPanel = instagramElement.find('.panel.on'); var nextButton = $(this).next(); if(!instagramElement.hasClass('isLoading') && currentPanel.index() != 0) { var multiplier = instagramElement.find('.panel.on').index() - 1; var offset = multiplier * -105 + '%'; if(nextButton.is(':hidden')){ nextButton.show(); } currentPanel.removeClass('on').prev().addClass('on'); slider.css('marginLeft', offset); if(instagramElement.find('.panel.on').index() == 0){ $(this).hide(); } } }); }); } function modalImage(imagePath, caption){ caption = caption || false; if(caption != false){ caption = ''+caption+''; } else { caption = ''; } $('body').prepend('
'+caption+'
'); $('.slideshowWrap .slider img, .slideshowWrap .slider span').each(function(){ calculateDimensions($(this)); }); $('.modalShade').animate({opacity: 1}, 200, function(){ modalInit = false; }); } function rowSlideshow(){ $('.slideshowRow').each(function(){ var slideshowElement = $(this); var initImageCount = slideshowElement.find('.player img').length; var spacerWidth = 100/initImageCount; var isAnimating = false; function sequentialLoad(i){ var img = slideshowElement.find('.linkset .slide:eq('+i+')').attr('href'); var caption = slideshowElement.find('.linkset .slide:eq('+i+')').attr('data-caption'); var smallCaption = slideshowElement.find('.linkset .slide:eq('+i+')').attr('data-smallcaption'); var linksetLength = slideshowElement.find('.linkset .slide').length; slideshowElement.find('.player .slider').append('
'+smallCaption+'
'); slideshowElement.find('.player img:eq('+i+')').one('load', function(){ if(i < linksetLength - 1){ sequentialLoad(i + 1); } else { slideshowElement.find('.next').show().animate({ opacity: 1 }, 200); } }); } if(slideshowElement.find('.linkset .slide').length > 3) { sequentialLoad(initImageCount); } slideshowElement.find('.next').on('click', function(){ if(isAnimating == false){ isAnimating = true; slideshowElement.find('.slider').animate({ marginLeft : (spacerWidth * -1)+'%' }, 200, function(){ slideshowElement.find('.slider .imgSpacer.on').first().removeClass('on').animate({ opacity: 0 }, 200); slideshowElement.find('.slider .imgSpacer.on').last().next().addClass('on').animate({ opacity: 1 }, 200); slideshowElement.find('.slider').css('margin-left', '0%'); if(slideshowElement.find('.slider .imgSpacer:last-child').hasClass('on')){ //hides next button when the last image is on slideshowElement.find('.next').hide(); } if(!slideshowElement.find('.slider .imgSpacer:first-child').hasClass('on')){ //shows previous button when first slideshow image is not on slideshowElement.find('.previous').show().animate({ opacity: 1 }, 200); } isAnimating = false; }); } }); slideshowElement.find('.previous').on('click', function(){ if(isAnimating == false){ isAnimating = true; slideshowElement.find('.slider').animate({ marginLeft : spacerWidth+'%' }, 200, function(){ slideshowElement.find('.slider .imgSpacer.on').first().prev().addClass('on').animate({ opacity: 1 }, 200); slideshowElement.find('.slider .imgSpacer.on').last().removeClass('on').animate({ opacity: 0 }, 200); slideshowElement.find('.slider').css('margin-left', '0%'); if(slideshowElement.find('.slider .imgSpacer:first-child').hasClass('on')){ //hides previous button when the last image is on slideshowElement.find('.previous').hide(); } if(!slideshowElement.find('.slider .imgSpacer:last-child').hasClass('on')){ //shows next button when last slideshow image is not on slideshowElement.find('.next').show().animate({ opacity: 1 }, 200); } isAnimating = false; }); } }); }); $('.slideshowRow').on('click', 'img', function(){ if(modalInit == false) { modalInit = true; var slideshow = $(this).closest('.slideshowRow'); var index = $(this).parent().index(); modalSlideshow(slideshow.data('type'), slideshow.data('id'), slideshow.data('title'), slideshow.data('showcaptions'), index); } }); } function infographicsSlider(){ $('.infographicsCarousel').each(function() { var carousel = $(this); var initImageCount = carousel.find('.imgSpacer.on').length; var spacerWidth = 100 / initImageCount; var isAnimating = false; carousel.find('.off').css('opacity', 0); carousel.find('.previous').hide(); carousel.find('.next').on('click', function () { if (isAnimating == false) { isAnimating = true; carousel.find('.slider').animate({ marginLeft: (spacerWidth * -1) + '%' }, 200, function () { carousel.find('.slider .imgSpacer.on').first().removeClass('on').addClass('off').css('opacity', 0); carousel.find('.slider .imgSpacer.on').last().next().removeClass('off').addClass('on').animate({ opacity: 1 }, 200); carousel.find('.responsiveImg:not(:hidden)').each(function () { resizeImg($(this)); }); carousel.find('.slider').css('margin-left', '0%'); if (carousel.find('.slider .imgSpacer:last-child').hasClass('on')) { //hides next button when the last image is on carousel.find('.next').hide(); } if (!carousel.find('.slider .imgSpacer:first-child').hasClass('on')) { //shows previous button when first infographic image is not on carousel.find('.previous').show().animate({ opacity: 1 }, 200); } isAnimating = false; }); } }); carousel.find('.previous').on('click', function () { if (isAnimating == false) { isAnimating = true; carousel.find('.slider').animate({ marginLeft: spacerWidth + '%' }, 200, function () { carousel.find('.slider .imgSpacer.on').last().removeClass('on').addClass('off').css('opacity', 0); carousel.find('.slider .imgSpacer.on').first().prev().removeClass('off').addClass('on').animate({ opacity: 1 }, 200); carousel.find('.responsiveImg:not(:hidden)').each(function () { resizeImg($(this)); }); carousel.find('.slider').css('margin-left', '0%'); if (carousel.find('.slider .imgSpacer:first-child').hasClass('on')) { //hides previous button when the last image is on carousel.find('.previous').hide(); } if (!carousel.find('.slider .imgSpacer:last-child').hasClass('on')) { //shows next button when last infographic image is not on carousel.find('.next').show().animate({ opacity: 1 }, 200); } isAnimating = false; }); } }); }); } function genericSlider(){ var isAnimating = false; var spacerWidth = 100/3; $('.genericSlider').each(function(){ if($(this).find('.slider').length == 0){ //build slider and player around objects $(this).find('.rowWrap .copy').wrapInner('
'); } if($(this).find('.slider').children().length > 3){ //build controls $(this).prepend(''); } $(this).find('.slider').children().each(function(){ if($(this).index() > 2){ $(this).addClass('element col3-1 off'); } else { $(this).addClass('element col3-1 on'); } }); $(this).find('.genericNext').on('click', function(){ if(isAnimating == false){ isAnimating = true; var slider = $(this).parent().find('.slider'); var row = $(this).parents('.genericSlider'); slider.animate({ marginLeft : (spacerWidth * -1)+'%' }, 200, function(){ slider.find('.element.on').first().removeClass('on').addClass('off').css('opacity',0); slider.find('.element.on').last().next().removeClass('off').addClass('on').animate({ opacity: 1 }, 200); slider.find('.responsiveImg:not(:hidden)').each(function(){ resizeImg($(this)); }); slider.css('margin-left', '0%'); if(slider.find('.element:last-child').hasClass('on')){ //hides next button when the last element is on row.find('.genericNext').hide(); } if(!slider.find('.element:first-child').hasClass('on')){ //shows previous button when first element image is not on row.find('.genericPrevious').show().animate({ opacity: 1 }, 200); } isAnimating = false; }); } }); $(this).find('.genericPrevious').on('click', function(){ if(isAnimating == false){ isAnimating = true; var slider = $(this).parent().find('.slider'); var row = $(this).parents('.genericSlider'); slider.animate({ marginLeft : spacerWidth+'%' }, 200, function(){ slider.find('.element.on').last().removeClass('on').addClass('off').css('opacity',0); slider.find('.element.on').first().prev().removeClass('off').addClass('on').animate({ opacity: 1 }, 200); slider.find('.responsiveImg:not(:hidden)').each(function(){ resizeImg($(this)); }); slider.css('margin-left', '0%'); if(slider.find('.element:first-child').hasClass('on')){ //hides previous button when the last element is on row.find('.genericPrevious').hide(); } if(!slider.find('.element:last-child').hasClass('on')){ //shows next button when last element image is not on row.find('.genericNext').show().animate({ opacity: 1 }, 200); } isAnimating = false; }); } }); }); } function setTables(){ $('table').each(function(){ if($(this).hasClass('dataTable')){ if($(this).find('tr:first-child th').length > 0){ var values = new Array(); $(this).find('tr:first-child th').each(function(){ var value = $.trim($(this).text()); values.push(value+': '); }); $(this).find('td').each(function(){ $(this).attr('data-category', values[$(this).index()]); }); } } else { $(this).wrap('
'); } }); } function textmarkResize(){ //This function is for department index and department secondary templates to get the shield and text correctly positioned if($('#logoRow img').length > 0 && $('#logoRow .sitemark').length == 0){ var imgWidth = $('#logoRow img').width(); $('#logoRow .textmark > span').css('padding-left', imgWidth+'px'); } } function setPaginationIndicator(row){ //For feedrows and mashuprows var index = row.attr('data-active') - 1; var indicator = row.find('.activeIndicator'); var position = row.find('.indicator:eq('+index+')').position(); row.find('.restrainer').removeClass('on'); row.find('.restrainer:eq('+index+')').addClass('on'); if(position) { indicator.css('marginLeft', position.left + 'px'); } } /* ###################################### */ /* ########## Event Assignment ########## */ /* ###################################### */ $(document).on('touchmove', function(e){ touchScroll = true; }); $(document).on('touchstart', function(e){ touchScroll = false; }); $(document).on('click', '.modalVideo', function(){ if(modalInit == false) { modalInit = true; modalVideo($(this).data('video')); } }); $(document).on('click', '.modalVimeo', function(){ if(modalInit == false) { modalInit = true; modalVimeo($(this).data('video')); } }); $(document).on('click', '.modalYoutubeVideo', function(){ if(modalInit == false) { modalInit = true; modalYoutubeVideo($(this).data('video')); } }); $(document).on('click', '.modalImage', function(){ if(modalInit == false) { modalInit = true; var caption = $(this).data('caption'); // For some browsers, `attr` is undefined; for others, // `attr` is false. Check for both. if (typeof caption !== typeof undefined && caption !== false) { modalImage($(this).data('image'), $(this).data('caption')); } else { modalImage($(this).data('image')); } } }); $(document).on('click', '.modalInstagram', function(){ if(modalInit == false) { modalInit = true; var parent = $(this).parents('.slider'); var index = $(this).attr('rel'); var title = $(this).parents('.instagram').find('h2').text(); var id = $(this).parents('.instagram').data('id'); modalInstagram(parent, index, title, id); if($(this).parent().attr('data-maxid') != 'false' && parseInt($(this).attr('rel')) == parent.find('.modalInstagram').length -1){ $('.instagramRow[data-id='+id+']').addClass('isLoading'); getInstagramData(id, function(){ $('.instagramRow[data-id='+id+']').find('.panel').last().removeClass('on'); }); } } }); $(document).on('click', '.modalSlideshow', function(){ if(modalInit == false) { modalInit = true; modalSlideshow($(this).data('type'), $(this).data('id'), $(this).data('title'), $(this).data('showcaptions'), 0); } }); $(document).on('click', '.modalShade button.close', function(){ $('.modalShade').fadeOut(200, function(){ $('.modalShade').remove(); modalInit = false; }); }); $(document).on('click', '#feedRow-next, #mashupRow-next, #exhibitionsRow-next', function(){ var row = $(this).parent(); var prevButton = $(this).prev(); var slider = row.find('.slider'); var restrainerElement = row.find('.restrainer'); var multiplier = row.attr('data-active') * -1; var offset = restrainerElement.width() + parseFloat(restrainerElement.css('margin-right')); row.attr('data-active', parseInt(row.attr('data-active')) + 1); slider.css('margin-left', offset * multiplier+'px'); row.find('.activeIndicator').removeClass('noTransition'); setPaginationIndicator(row); if(row.attr('data-active') == restrainerElement.length){ $(this).hide(); //Hides the next button } if(row.attr('data-active') > 1){ prevButton.show(); } }); $(document).on('click', '#feedRow-prev, #mashupRow-prev, #exhibitionsRow-prev', function(){ var row = $(this).parent(); var nextButton = $(this).next(); var slider = row.find('.slider'); var restrainerElement = row.find('.restrainer'); var multiplier = (row.attr('data-active') - 2) * -1; var offset = restrainerElement.width() + parseFloat(restrainerElement.css('margin-right')); row.attr('data-active', parseInt(row.attr('data-active')) - 1); slider.css('margin-left', offset * multiplier+'px'); row.find('.activeIndicator').removeClass('noTransition'); setPaginationIndicator(row); if(row.attr('data-active') == 1){ $(this).hide(); } if(row.attr('data-active') < restrainerElement.length){ nextButton.show(); //Show previous button } }); $(document).on('click', '.pageIndicator .indicator', function(){ var targetIndex = $(this).index(); var row = $(this).parents('.row'); if(parseInt(row.attr('data-active')) != targetIndex + 1){ var slider = row.find('.slider'); var restrainerElement = row.find('.restrainer'); var multiplier = targetIndex * -1; var offset = restrainerElement.width() + parseFloat(restrainerElement.css('margin-right')); var nextButton = row.find('#mashupRow-next, #feedRow-next'); var prevButton = row.find('#mashupRow-prev, #feedRow-prev'); row.attr('data-active', targetIndex + 1); slider.css('margin-left', offset * multiplier + 'px'); row.find('.activeIndicator').removeClass('noTransition'); setPaginationIndicator(row); if (row.attr('data-active') > 1) { prevButton.show(); } if (row.attr('data-active') == 1) { prevButton.hide(); } if (row.attr('data-active') < restrainerElement.length) { nextButton.show(); } if (row.attr('data-active') == restrainerElement.length) { nextButton.hide(); } } }); $(document).ready(function(){ initMobileMenu(); initToolbar(); setTables(); if($('#spotlightScroller').length > 0){ spotlightAutoScroller(); } if($('#heroScroller').length > 0){ heroAutoScroller(); } if($('#heroSlider').length > 0){ heroSlider(); } if($('.slideshowRow').length > 0){ rowSlideshow(); } if($('.instagramRow').length > 0) { rowInstagram(); if ($(window).width() <= 1000) { var newWidth = $(window).width() * 1.05; $('.instagramRow .panel').css('maxWidth', newWidth + 'px'); } } if($('.fullscreenSlideshow').length > 0){ fullscreenSlideshow(); } if($('.infographicsCarousel').length > 0){ infographicsSlider(); } if($('.genericSlider').length > 0){ genericSlider(); } if($('#submenu').length == 0 && $('#relatedContent').children().length == 0){ $('#primaryContent').addClass('col1'); //Makes secondary templates full width if they have no related content or subnav } $('.responsiveImg:not(:hidden)').each(function(){ resizeImg($(this)); }); if($('#iframeAlert').length > 0){ //iframed alert box for cached pages like WWW var iframeState = 'iframe=false'; $.ajax({ url: assetsUrl + '/actions/get/iframeAlert.php', type: "GET", data: iframeState, dataType: "jsonp", success: function (data) { eval(data); $('#alert, #iframeAlert').remove(); if(typeof console != 'undefined'){ console.log('Ajax Alert Enabled.'); } if(data.alert != null && data.alert != false){ if(typeof console != 'undefined'){ console.log('Javascript Alert Enabled.'); } $('body').prepend('
' + data.alert + '
'); } return true; }, error: function (data, status, errorThrown) { return false; } }); } $('.input[type="Text"], input[type="text"]').not('.hasDatepicker, [name="dstart"], [name="dend"]').focus(function(){ if($(this).attr('data-originalValue') == undefined){ $(this).attr('data-originalValue', $(this).val()); } if($(this).attr('data-originalValue') == $(this).val()){ $(this).val(''); } }); $('.input[type="Text"], input[type="text"]').not('.hasDatepicker, [name="dstart"], [name="dend"]').blur(function(){ if($(this).val() == ''){ $(this).removeClass('populated'); $(this).val($(this).attr('data-originalValue')); } else { $(this).addClass('populated'); } }); $('#heroWrap #heroSlider .responsiveImg > img').each(function(){ heroParallax($(this)); }); $('#logoRow .textmark img').load(function(){ textmarkResize(); }); $('.mashupRow').each(function(){ //Note - .restrainer divs are added in the PHP var mashupRow = $(this); if(mashupRow.find('.mashupItem').length > 3){ mashupRow.attr('data-active', 1); mashupRow.find('.restrainer').css({ marginRight : mashupRow.find('.rowWrap').width()*.02, width: mashupRow.find('.rowWrap').width() }); mashupRow.prepend(''); mashupRow.append('
'); var colStructure = mashupRow.find('.restrainer').length; var containerWidth = colStructure * 12; mashupRow.find('.pageIndicator').css('max-width',containerWidth+'%'); for(var i = 1; i <= colStructure; i++){ mashupRow.find('.pageIndicator').append('
'); } mashupRow.find('.indicator:eq(0)').addClass('on'); var position = mashupRow.find('.indicator:eq(0)').position(); mashupRow.find('.pageIndicator').append('
'); } $('.mashupRow .responsiveImg').each(function(){ resizeImg($(this)); }); $(this).find('#mashupRow-prev, #mashupRow-next').each(function(){ if($(window).width() >= 1250){ var newWidth = ($(window).width() - 1000)/2; $(this).width(newWidth+'px' ); } }) }); $('.feedRow').each(function(){ var feedRow = $(this); if(feedRow.find('.rowWrap .feedElement').length > 3) { feedRow.attr('data-active', 1); feedRow.find('.rowWrap .feedElement').wrapAll('
'); var elements = feedRow.find('.slider .feedElement'); var restrainerCount = 0; for (var i = 0; i < elements.length; i += 3) { elements.slice(i, i + 3).wrapAll('
'); restrainerCount++; } feedRow.find('.restrainer').css({ marginRight: feedRow.find('.rowWrap').width() * .02, width: feedRow.find('.rowWrap').width() }); feedRow.prepend(''); feedRow.append('
'); var colStructure = feedRow.find('.restrainer').length; var containerWidth = colStructure * 12; feedRow.find('.pageIndicator').css('max-width',containerWidth+'%'); for(var i = 1; i <= colStructure; i++){ feedRow.find('.pageIndicator').append('
'); } feedRow.find('.indicator:eq(0)').addClass('on'); var position = feedRow.find('.indicator:eq(0)').position(); feedRow.find('.pageIndicator').append('
'); } }); $('.exhibitionsRow').each(function(){ //Note - .restrainer divs are added in the PHP var exhibitionsRow = $(this); if(exhibitionsRow.find('a.card').length > 3){ exhibitionsRow.attr('data-active', 1); exhibitionsRow.find('.restrainer').css({ marginRight : exhibitionsRow.find('.rowWrap').width()*.02, width: exhibitionsRow.find('.rowWrap').width() }); exhibitionsRow.prepend(''); exhibitionsRow.append('
'); var colStructure = exhibitionsRow.find('.restrainer').length; var containerWidth = colStructure * 12; exhibitionsRow.find('.pageIndicator').css('max-width',containerWidth+'%'); for(var i = 1; i <= colStructure; i++){ exhibitionsRow.find('.pageIndicator').append('
'); } exhibitionsRow.find('.indicator:eq(0)').addClass('on'); var position = exhibitionsRow.find('.indicator:eq(0)').position(); exhibitionsRow.find('.pageIndicator').append('
'); } $('.exhibitionsRow .responsiveImg').each(function(){ resizeImg($(this)); }); $(this).find('#exhibitionsRow-prev, #exhibitionsRow-next').each(function(){ if($(window).width() >= 1250){ var newWidth = ($(window).width() - 1000)/2; $(this).width(newWidth+'px' ); } }) }); $('.shareButton').each(function(){ if(shareWidgetCompatible == true){ //This is a global namespace variable set in globals/components/scripts.php //This relies on /scripts/libraries/share.mon.js var shareImg = ''; var buttonText = ''; var descriptionText = ''; shareImg = $('#mainContent .responsiveImg').first().find('img').attr('src'); if (shareImg == undefined) { shareImg = ''; } if (shareImg.indexOf("/_KP4_content") >= 0) { shareImg = shareImg.replace('/_KP4_content', 'http://kp4content.richmond.edu'); } if ($('.articleDate').length > 0) { buttonText = 'Share this story' } else { buttonText = 'Share this page' } if(window.location.hostname == 'news.richmond.edu' || window.location.hostname == 'qanews.richmond.edu'){ descriptionText = ' via @URNews2Use'; if(window.location.pathname.indexOf('features') !== -1){ descriptionText = ' via @urichmond'; } } var config = { image: shareImg, ui: { flyout: 'bottom center', button_text: buttonText, enable_css: false, icon_font: false }, networks: { pinterest: { enabled: false }, email: { description: window.location.href }, twitter: { description: descriptionText } } }; var share = new Share('.shareButton', config); } }); $('.accomplishmentsLoadMore').on('click',function(){ if(facAccLoadInit) { facAccLoadInit = false; var page = $(this).attr('data-page'); var tags = $(this).attr('data-tags'); var hitsPerPage = 10; var contentTarget = $(this).parents('.accomplishmentsLoad').prev(); var button = $(this); if ($(this)[0].hasAttribute('data-hitsperpage')) { hitsPerPage = parseInt($(this).attr('data-hitsperpage')); } var slideshow = { page: page, tags: tags, hitsPerPage: hitsPerPage }; $.ajax({ url: assetsUrl + '/actions/get/facAccomplishmentsFlow.php', type: "GET", data: slideshow, dataType: "jsonp", success: function (data) { contentTarget.append(data.results); if(data.page) { button.attr('data-page', data.page); } else { button.remove(); } facAccLoadInit = true; }, error: function () { alert('Failed to load faculty accomplishments. Please try again later.'); facAccLoadInit = true; } }); } }); }); // resize the player on viewport size change $(window).on('resize', function () { textmarkResize(); $('#heroWrap #heroSlider .responsiveImg > img').each(function(){ heroParallax($(this)); }); $('.feedRow, .mashupRow, .exhibitionsRow').each(function(){ var row = $(this); var restrainerItem = row.find('.restrainer').first(); row.find('.slider').addClass('noTransition'); row.find('.restrainer').css({ //Resize each restrainer marginRight : row.find('> .rowWrap').width()*.02, width: row.find('> .rowWrap').width() }); var newMargin = ((row.attr('data-active') - 1) * -1) * (restrainerItem.width() + parseFloat(restrainerItem.css('margin-right'))); row.find('.slider').css('margin-left', newMargin+'px'); row.find('.slider').removeClass('noTransition'); row.find('.activeIndicator').addClass('noTransition'); setPaginationIndicator(row); }); $('.modalShade .slider span, .modalShade .slider img, .modalShade .slider .video').each(function(){ calculateDimensions($(this)); }); $('#exhibitionsRow-prev, #exhibitionsRow-next, #mashupRow-prev, #mashupRow-next').each(function(){ if($(window).width() >= 1250){ var newWidth = ($(window).width() - 1000)/2; $(this).width(newWidth+'px' ); } }); $('.instagramRow').each(function(){ if($(window).width() <= 1000){ var newWidth = $(window).width() * 1.05; $(this).find('.panel').css('maxWidth', newWidth + 'px'); } else { $(this).find('.panel').css('maxWidth', '1050px'); } }); }); $(window).on('load', function() { textmarkResize(); }); $(window).scroll(function() { $('#heroWrap #heroSlider .responsiveImg > img').each(function(){ heroParallax($(this)); }); });