diff --git a/modules/wkhotelfeaturesblock/views/js/wkHotelFeaturesBlockFront.js b/modules/wkhotelfeaturesblock/views/js/wkHotelFeaturesBlockFront.js index fdabdc017..3bfcc9f08 100644 --- a/modules/wkhotelfeaturesblock/views/js/wkHotelFeaturesBlockFront.js +++ b/modules/wkhotelfeaturesblock/views/js/wkHotelFeaturesBlockFront.js @@ -17,48 +17,47 @@ * @license https://store.webkul.com/license.html */ -$(document).ready(function(){ - // For Block separator line in home page - if ($(".home_amenities_wrapper").length) { - // For width - var window_width = $(window).width(); - var home_block_width = $(".home_amenities_wrapper").width() + 30; - var width_in_neg = ((window_width - home_block_width)/2); - //For Height()top - amenities_block_top = $(".home_amenities_wrapper .home_block_desc_wrapper").height() + 50; - $(".homeAmenitiesBlock").css({"left": -width_in_neg, "right": -width_in_neg, "top": amenities_block_top}); - // home_amenities_wrapper height - var homeAmenitiesBlockHeight = $(".homeAmenitiesBlock").height(); - $(".home_amenities_wrapper").css("height", (homeAmenitiesBlockHeight + amenities_block_top)); +function setAmenitiesWrapperHeight() { + // for width + var window_width = $(window).width(); + var home_block_width = $('.home_amenities_wrapper').width() + 30; + var width_in_neg = ((window_width - home_block_width)/2); - $(window).resize(function() { - // For width - var window_width = $(window).width(); - var home_block_width = $(".home_amenities_wrapper").width() + 30; - var width_in_neg = ((window_width - home_block_width)/2); + // for height + amenities_block_top = $('.home_amenities_wrapper .home_block_desc_wrapper').height() + 50; + $('.homeAmenitiesBlock').css({'left': -width_in_neg, 'right': -width_in_neg, 'top': amenities_block_top}); - //For Height(top) - amenities_block_top = $(".home_amenities_wrapper .home_block_desc_wrapper").height() + 50; - $(".homeAmenitiesBlock").css({"left": -width_in_neg, "right": -width_in_neg, "top": amenities_block_top}); + // home_amenities_wrapper height + var homeAmenitiesBlockHeight = $('.homeAmenitiesBlock').height(); + $('.home_amenities_wrapper').css('height', (homeAmenitiesBlockHeight + amenities_block_top)); +} - // home_amenities_wrapper height - var homeAmenitiesBlockHeight = $(".homeAmenitiesBlock").height(); - $(".home_amenities_wrapper").css("height", (homeAmenitiesBlockHeight + amenities_block_top)); - }); +function setAmenitiesDescContHeight() { + $('.amenity_desc_cont').each(function () { + var amenityDescParentHeight = $(this).parent('div.amenity_content').height(); + $(this).css('height', amenityDescParentHeight); + }); +} + +$(document).ready(function() { + if ($('.homeAmenitiesBlock').length) { + setAmenitiesDescContHeight(); + } +}); + +$(window).load(function() { + if ($('.home_amenities_wrapper').length) { + setAmenitiesWrapperHeight(); + } +}); + +$(window).resize(function() { + if ($('.home_amenities_wrapper').length) { + setAmenitiesWrapperHeight(); } - if ($(".homeAmenitiesBlock").length) { - $(".amenity_desc_cont").each(function(index) { - var amenityDescParentHeight = $(this).parent("div.amenity_content").height(); - $(this).css("height", amenityDescParentHeight); - }); - - $(window).resize(function(){ - $(".amenity_desc_cont").css("height", 0); - $(".amenity_desc_cont").each(function(index) { - var amenityDescParentHeight = $(this).parent("div.amenity_content").height(); - $(this).css("height", amenityDescParentHeight); - }); - }); + if ($('.homeAmenitiesBlock').length) { + $('.amenity_desc_cont').css('height', 0); + setAmenitiesDescContHeight(); } -}); \ No newline at end of file +});