(function($){function fixGalleryCaptionHeights(){$('.gallery').each(function(index,gallery){var $gallery=$(gallery);if($gallery.data('compact-view'))return;var galleryCaptionContainers=$gallery.find('.gallery-caption').toArray(),galleryCaptionsHeights=galleryCaptionContainers.map(function(captionContainer){return $(captionContainer).height()}),maxGalleryCaptionsHeight=Math.max.apply(null,galleryCaptionsHeights.concat(0)),setCaptionMinHeight=function(captionContainer){$(captionContainer).css('min-height',maxGalleryCaptionsHeight);$(captionContainer).css('height',maxGalleryCaptionsHeight)};if(maxGalleryCaptionsHeight!==0){galleryCaptionContainers.forEach(setCaptionMinHeight)}});setTimeout($().adjustSharedBgImgViewHeight,500)}function adjustGalleryOnResize(){$('.gallery[data-image-ratio="ACTUAL_RATIO"]').each(function(index,gallery){var currentGalleryWidth=$(gallery).outerWidth(false),originalGalleryWidth=$(gallery).data('original-width'),ratio=currentGalleryWidth/originalGalleryWidth,maxHeight=Math.ceil($(gallery).find('img:first').data('original-height'));var borderTop=parseInt($(gallery).find('.img-wrapper:first').css('borderTopWidth'),10)||0;var borderBottom=parseInt($(gallery).find('.img-wrapper:first').css('borderBottomWidth'),10)||0;var allowableROundOffError=2;$(gallery).find('img').css({maxHeight:(maxHeight-(borderBottom+borderTop+allowableROundOffError))*ratio})})}$(function(){setTimeout(function(){fixGalleryCaptionHeights()},100);$(window).on('view-chosen',function(e,isDesktop){if(isDesktop){var hasStretchGallery=$('.gallery[data-image-ratio="ACTUAL_RATIO"]').length;if(hasStretchGallery){adjustGalleryOnResize();$(window).resize(adjustGalleryOnResize)}}})})}(oneJQuery));