// Modal Responsiveness var relatedItemsModal = $("#relatedItemsModal"); /** * Vertically center Bootstrap 3 modals so they aren't always stuck at the top * http://www.abeautifulsite.net/vertically-centering-bootstrap-modals/ */ $(function() { function reposition() { var modal = $(this), dialog = modal.find('.modal-dialog'); modal.css('display', 'block'); // Dividing by two centers the modal exactly, but dividing by three // or four works better for larger screens. dialog.css("margin-top", Math.max(0, (($(window).height() - dialog.height()) / 2)-15)); } // Reposition when a modal is shown $('.modal').on('show.bs.modal', reposition); // Reposition when the window is resized $(window).on('resize', function() { $('.modal:visible').each(reposition); }); }); relatedItemsModal.on('show.bs.modal', function () { $('.modal-dialog').css('height',$( window ).height()*0.9); $('.modal-dialog').css('width',$( window ).width()*0.95); setTimeout(function(){ $('#relatedItemsModal .modal-body').css('height',(($( window ).height()*0.9)-($('#relatedItemsModal .modal-header').outerHeight(true))-($('#relatedItemsModal .modal-footer').outerHeight(true)))); }, 500); setTimeout(function(){ // title and description var $nMaxHeight = 0; $(".related-modal-title_and_desc").each(function(){ // If this box is bigger than the current max if($(this).height() > $nMaxHeight) { // Set the max height to this boxes height $nMaxHeight = $(this).height(); } }); // For each box, set it's height to the max $(".related-modal-title_and_desc").each(function(){ $(this).height(Math.ceil($nMaxHeight)); }); }, 500); setTimeout(function(){ // price box var $nMaxHeight = 0; $(".ShopProd_Listing_Price").each(function(){ // If this box is bigger than the current max if($(this).height() > $nMaxHeight) { // Set the max height to this boxes height $nMaxHeight = $(this).height(); } }); // For each box, set it's height to the max $(".ShopProd_Listing_Price").each(function(){ $(this).height(Math.ceil($nMaxHeight)); }); }, 700); }); relatedItemsModal.on('hide.bs.modal', function () { $('.ruleExplanation').html(''); $('.productColumnsWrapper').html(''); });