function getDeviceType(){ deviceType = (scrWidth < 600)?'mobile':'desktop'; if(scrWidth >= 600 && scrWidth <=900) deviceType = 'tablet'; } function getViewType(){ viewWidth = $(window).width(); viewType = (viewWidth < 600) ?'mobile':'desktop'; if(viewWidth >= 600 && viewWidth <=900) viewType = 'tablet'; } function imgReplace(){ $('.build-image').each(function(){ var imgSrc = $(this).data('src'); var imgWidth = $(this).data('width'); var imgTitle = $(this).data('title'); var imgHeight = $(this).data('height'); if(imgHeight == '') imgHeight = 'auto'; var thisImg = $(''); $(this).replaceWith(thisImg); }); } function setupSlideshow(){ currentPosition = 0; slideWidth = $('.slideshow').width(); slideHeight = $('.slideshow').height(); slides = $('.slide'); numberOfSlides = slides.length; // Remove scrollbar in JS $('.slideshow').css('overflow', 'hidden'); // Wrap all .slides with .slideInner div slides.wrapAll('
') // Float left to display horizontally, readjust .slides width .css({ 'float' : 'left', 'width' : slideWidth, 'height' : slideHeight }); // Set .slide-box width equal to total width of all slides $('.slide-box').css('width', slideWidth * numberOfSlides); // Insert left and right arrow controls in the DOM $('.slideshow-box') .prepend('Move left') .append('Move right'); // Hide left arrow control on first load manageControls(currentPosition); // Create event listeners for .controls clicks $('.control') .bind('click', function(){ // Determine new position currentPosition = ($(this).attr('id')=='control-right') ? currentPosition+1 : currentPosition-1; // Hide / show controls manageControls(currentPosition); // Move slide-box using margin-left $('.slide-box').animate({ 'marginLeft' : slideWidth*(-currentPosition) }); }); // manageControls: Hides and shows controls depending on currentPosition function manageControls(position){ // Hide left arrow if position is first slide if(position==0){ $('#control-left').hide() } else{ $('#control-left').show() } // Hide right arrow if position is last slide if(position==numberOfSlides-1){ $('#control-right').hide() } else{ $('#control-right').show() } } } function resetSlideshow() { slideWidth = $('.slideshow').width(); slideHeight = $('.slideshow').height(); $('.slide-box').css('width', slideWidth * numberOfSlides); $('.slide').css({'width':slideWidth,'height':slideHeight}); $('.slide-box').animate({ 'marginLeft' : slideWidth*(-currentPosition) }); } function hideNavTitle(){ windowTop = $(window).scrollTop()+$('#nav-wrapper').height(); if(hideTitle == 0 && windowTop < titleBottom){ $('#nav-title').addClass('hidden'); $('#nav .social-links').addClass('no-title'); hideTitle = 1; } else if(hideTitle == 1 && windowTop > titleBottom){ $('#nav-title').removeClass('hidden'); $('#nav .social-links').removeClass('no-title'); hideTitle = 0; }; } function renderSocialButtons() { $('.fb-like-build').addClass('fb-like').removeClass('fb-like-build'); twitterPopup(); fbLike(); } function twitterPopup() { var offsetX = screen.width; offsetX = offsetX-600; offsetX = offsetX/2; $('.popup').not('.popup-loaded').click(function(event){ window.open($(this).attr('href'), 'popup', 'status=0,resizeable=1,width=600,height=600,top=60,left='+offsetX); $(this).addClass('popup-loaded'); event.preventDefault(); return false; }); } function fbLike() { if(deviceType == 'desktop') { $('.unrendered, .unrendered-lightbox').mouseover(function(){ if(!$(this).hasClass('rendered')) { var thisId = $(this).attr('id'); FB.XFBML.parse(document.getElementById(thisId)); gapi.plusone.go(thisId); $(this).addClass('rendered'); }; }); } else { FB.XFBML.parse(document); gapi.plusone.go(document); }; } function loadFeaturedVideo(){ var videoHeight = $('.welcome-video').height(); $('.welcome-video').css('height',videoHeight); $('a.featured-post').click(function(event){ var videoUrl = $(this).attr('href'); var videoTitle = $(this).attr('title'); $('.welcome-video').empty().load(videoUrl+' .entry-media'); $('.welcome-feature .entry-title').html(videoTitle); event.preventDefault(); return false; }); } function triggerLoadMonthClick(){ var nextMonth = $('.timeline-month:first').filter(':first'); var thisHeight = nextMonth.offset(); var windowHeight = $(window).height(); var loadPoint = thisHeight.top - windowHeight-20; if($(window).scrollTop() > loadPoint) nextMonth.trigger('click'); } function loadMonthClick(){ $('.timeline-month').each(function(i){ $(this).click({month: $(this).data('month'),year:$(this).data('year'),thisId:$(this).attr('id'),content:'',monthHtml:$(this).html(),ff: $(this).data('ff'), medium: $(this).data('medium')}, function(event){ $.get('/timeline/?t_month='+event.data.month+'&t_year='+event.data.year+'&ff='+event.data.ff+'&medium='+event.data.medium,function(data){ if(data != ''){ $(data).insertAfter($('#'+event.data.thisId)); renderSocialButtons(); if(viewType != 'mobile') { contentColumns(); imgReplace(); }; $(document.body).ajaxLightbox(); }; }); $(this).replaceWith('