$(function(){ // // Cover photos $('.cover-photo').each(function(){ $(this).css("background-image", "url("+$(this).data('src')+")"); }); // // Polls $('.poll-form .vote button').click(function(){ form = $(this).closest('.poll-form'); if( form.serialize() != '' ){ form.submit(); } }); // Nav $('.navigation .parent').mouseenter(function(){ $(this).find('.children').show(); }).mouseleave(function(){ $(this).find('.children').hide(); }); // Gallery widget $('.box-content-gallery .carousel').on('slide.bs.carousel', function(e){ var target = $(e.relatedTarget); var container = target.closest('.box-content-gallery'); container.find('.thumbnails li').removeClass('active'); container.find('.thumbnails li[data-slide-to='+target.data('item')+']').addClass('active'); }); $('.box-content-gallery .thumbnails li').click(function(){ var container = $(this).closest('.box-content-gallery'); container.find('.carousel').carousel('pause'); }); $('.box-content-gallery .carousel .canvas').mouseenter(function(){ $(this).find('.carousel-caption').fadeIn('fast'); }); $('.box-content-gallery .carousel .canvas').mouseleave(function(){ $(this).find('.carousel-caption').fadeOut('fast'); }); // Auto height window.setTimeout(function(){ $('.autoheight-group').each(function(){ $(this).find('.autoheight').height( parseInt($(this).height()) - 40 ); }) }, 2000 ); // Mobile subnav toggle $('.mobile-subnav-icon').click(function(){ if( $(this).data('toggled') ){ $('.mobile-subnav-item-'+$(this).data('navitem')).slideUp('fast'); $(this).removeClass('fa-minus').addClass('fa-plus').data('toggled',false); }else{ $('.mobile-subnav-item-'+$(this).data('navitem')).slideDown('fast'); $(this).removeClass('fa-plus').addClass('fa-minus').data('toggled',true); } }); // Link away // $(function(){ // $('a').each(function(){ // var href = $(this).attr('href'); // if( typeof href != 'string' ){ // return; // } // if( $(this).attr('href').indexOf('http') == 0 ){ // $(this).prop('target','new'); // } // }); // }); }); function fitSliderArrow(slide) { var carousel = slide.closest('.carousel'); var arrow = carousel.find('.right-arrow'); /* This just places the arrow on the right */ arrow.css('right','0'); /* This fits the arrow to the edge of the image var img = slide.find('img'); if( img.length > 0 ){ var imgRightEdge = img.offset().left + img.outerWidth(); var container = img.closest('.photo'); var containerRightEdge = container.offset().left + container.outerWidth(); var difference = containerRightEdge - imgRightEdge; if( difference > 0 ){ arrow.css('right', difference+'px'); }else{ arrow.css('right','0'); } }else{ arrow.css('right','0'); } */ carousel.find('.arrows').show(); }