From 1674d9eb1afa775feb0a479540b5e3dc83b69207 Mon Sep 17 00:00:00 2001
From: "vishalsingh.qlo325" ' , ''); // getting the text that we want to show to the user, removed the first tag.
+ if (content.trim().substr(content.trim().length - 4, content.trim().length) == '
' + html+ '
'); + } +} +function toggleRoomDescriptionExtras() +{ + $(document).find('.htlRoomTypeDescText').each(function() { + // checking if the display:overFlow has been applied to the description. + if ($(this).prop('scrollHeight') - $(this).prop('clientHeight') > 15) { + // Only show read more and read less text if the text is wrapped. + addExtraTextToDescription($(this)[0]); + } + }); +} +// Getting the number of characters displayed to the user. +function getChars(target) { + var style = window.getComputedStyle(target, null); + // Getting the size of the container displayed to the user, this will ignore the overflow: hidden text. + var line_height = parseInt(style.getPropertyValue("line-height")); + var font_size = parseInt(style.getPropertyValue("font-size")); + var height = parseInt(style.getPropertyValue("height")); + var width = parseInt(style.getPropertyValue("width")); + + if(isNaN(line_height)) line_height = font_size * 1.2; + // Counting the number of the lines displayed to the user by the display:overFlow property, since this can vary depending the screen size. + var lines = Math.ceil(height / line_height) + 1; + // Counting the number of the characters in the lines + var displayedCharacters = $(target).text().split('').slice(0, lines * (width / parseInt(font_size))).join('').length; + + return displayedCharacters + 20; +} diff --git a/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl b/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl index d65fb9763..2ad22920a 100644 --- a/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl +++ b/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl @@ -45,22 +45,27 @@{$roomDisplay.name|escape:'htmlall':'UTF-8'}
{if $roomDisplay.show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE} -+
{if $roomDisplay.feature_price_diff >= 0} {convertPrice price = $roomDisplay.price_without_reduction} {/if} {if $roomDisplay.feature_price_diff} {convertPrice price = $roomDisplay.feature_price} {/if} - / {l s='Per Night' mod='wkhotelroom'} + + / {l s='Per Night' mod='wkhotelroom'} +
{/if}' , ''); // getting the text that we want to show to the user, removed the first
tag. - if (content.trim().substr(content.trim().length - 4, content.trim().length) == '
') { - content = content.trim().substr(0, content.trim().length - 4);// removed the last closing tag. - } - var b = content.trim().substr(show_char - content.trim().length) // getting the text that will be toggled + // Dividing the text into two parts so that we are able to diffrentiate the displayed text from hidden text. + var a = content.trim().substr(0, show_char); + var b = content.trim().substr(show_char - content.trim().length); // Adding the read more and read less text with the ellipses to the original text. var html = a + "" + ellipses + ""+ readMoreText +""; - $(target).html('' + html+ '
'); + $(target).html(html); } } -function toggleRoomDescriptionExtras() -{ - $(document).find('.htlRoomTypeDescText').each(function() { - // checking if the display:overFlow has been applied to the description. - if ($(this).prop('scrollHeight') - $(this).prop('clientHeight') > 15) { - // Only show read more and read less text if the text is wrapped. - addExtraTextToDescription($(this)[0]); - } - }); -} + // Getting the number of characters displayed to the user. function getChars(target) { var style = window.getComputedStyle(target, null); @@ -90,4 +70,4 @@ function getChars(target) { var displayedCharacters = $(target).text().split('').slice(0, lines * (width / parseInt(font_size))).join('').length; return displayedCharacters + 20; -} +} \ No newline at end of file diff --git a/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl b/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl index 2ad22920a..38cdd5f63 100644 --- a/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl +++ b/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl @@ -59,13 +59,10 @@ {/if}