diff --git a/admin/themes/default/template/controllers/products/informations.tpl b/admin/themes/default/template/controllers/products/informations.tpl index 68a6d2d18..201cbc41d 100644 --- a/admin/themes/default/template/controllers/products/informations.tpl +++ b/admin/themes/default/template/controllers/products/informations.tpl @@ -356,9 +356,8 @@ file="controllers/products/textarea_lang.tpl" languages=$languages input_name='description_short' - class="autoload_rte" input_value=$product->description_short - max=$PS_PRODUCT_SHORT_DESC_LIMIT} + maxlength=$PS_PRODUCT_SHORT_DESC_LIMIT}
diff --git a/classes/Product.php b/classes/Product.php index 862dd457d..3dcade6be 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -357,7 +357,7 @@ class ProductCore extends ObjectModel ), 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128), 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), - 'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), + 'description_short' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml'), 'available_now' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'available_later' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'IsGenericName', 'size' => 255), ), diff --git a/modules/wkhotelroom/views/css/WkHotelRoomBlockFront.css b/modules/wkhotelroom/views/css/WkHotelRoomBlockFront.css index 2dede0a9e..794085365 100644 --- a/modules/wkhotelroom/views/css/WkHotelRoomBlockFront.css +++ b/modules/wkhotelroom/views/css/WkHotelRoomBlockFront.css @@ -17,18 +17,53 @@ * @license https://store.webkul.com/license.html */ -.hotelRoomDescContainer{ - position: absolute; - bottom: 0; - left: 0; - right: 0; - background-color: rgba(255, 255, 255, 0.85); - margin-left: 15px; - margin-right: 15px; - padding: 20px; - z-index: 10; +.htlRoomTypeDescTextContainer { + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; } +.htlRoomTypeDescReadmore, .htlRoomTypeDescReadless{ + cursor: pointer; + font-weight: 400; + display: none; +} +.htlRoomTypeDescExtras { + display: none; +} +@media (min-width: 530px) { + .hotelRoomDescContainer{ + position: absolute; + bottom: 0; + left: 0; + right: 0; + background-color: rgba(255, 255, 255, 0.8); + margin-left: 10px; + margin-right: 10px; + padding: 20px; + z-index: 10; + } + .htlRoomTypePriceText{ + float :right; + } +} +@media (max-width: 530px) { + .hotelRoomDescContainer{ + padding: 10px; + } + .wk_roomType_price_type{ + font-size: 16px; + font-weight: 400; + } + .htlRoomTypeNameText { + width: 100%; + } + .room_type_old_price { + width: 100%; + display: block; + } +} .htlRoomTypeNameText, .htlRoomTypePriceText { font-size: 18px; color: #222222; @@ -37,17 +72,19 @@ } .htlRoomTypeDescText{ font-size: 16px; + word-break: break-word; color: #555555; font-weight: 300; line-height: 21px; + margin-bottom: 10px; } -.htlRoomTypeBookNow { - font-size: 15px!important; - color: #333333!important; - font-weight: 400!important; - background: transparent!important; - border: 1px solid #333333!important; - padding: 10px 30px!important; +a.htlRoomTypeBookNow { + font-size: 15px; + color: #333333; + font-weight: 400; + background: transparent; + border: 1px solid #333333; + padding: 10px 30px; text-transform: capitalize; } @@ -55,10 +92,6 @@ border: 1px solid #333333; } -.htlRoomTypeDescText { - padding-bottom: 9px; -} - .room_type_old_price { text-decoration: line-through; color:#555555; diff --git a/modules/wkhotelroom/views/js/WkHotelRoomBlockFront.js b/modules/wkhotelroom/views/js/WkHotelRoomBlockFront.js new file mode 100644 index 000000000..f3b905a69 --- /dev/null +++ b/modules/wkhotelroom/views/js/WkHotelRoomBlockFront.js @@ -0,0 +1,78 @@ +/** +* Since 2010 Webkul. +* +* NOTICE OF LICENSE +* +* All right is reserved, +* Please go through this link for complete license : https://store.webkul.com/license.html +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to newer +* versions in the future. If you wish to customize this module for your +* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul IN +* @license https://store.webkul.com/license.html +*/ + +$(document).ready(function() { + applyChangesToDescription(); + $(window).on('resize', function() { + resetDescriptionChanges(); + applyChangesToDescription(); + }); + + $(document).on('click', '.htlRoomTypeDescReadmore', function(e) { + e.preventDefault(); + var target = (e.target).closest(".htlRoomTypeDescText"); + $(target).removeClass('htlRoomTypeDescTextContainer'); + $(target).html($(e.target).closest(".hotelRoomDescContainer").find('.htlRoomTypeDescOriginal').html()); + $(target).append($('.htlRoomTypeDescExtras').html()); + $(target).find('.htlRoomTypeDescReadless').show().css('display', 'inline-block'); + }); + + $(document).on('click', '.htlRoomTypeDescReadless', function(e) { + e.preventDefault(); + var target = (e.target).closest(".htlRoomTypeDescText"); + $(target).addClass('htlRoomTypeDescTextContainer'); + initToggleOptions($(target)); + }); +}); + +function resetDescriptionChanges() { + $(document).find('.htlRoomTypeDescText').each(function() { + $(this).addClass('htlRoomTypeDescTextContainer'); + $(this).html($(this).parent().find('.htlRoomTypeDescOriginal').html()); + }); +} + +function applyChangesToDescription() { + $(document).find('.htlRoomTypeDescText').each(function() { + // checking if the display:overFlow has been applied to the description. using 14px since font size is 14px. + if ($(this).prop('scrollHeight') - $(this).prop('clientHeight') > 14) { + initToggleOptions($(this)[0]); + } + }); +} + +function initToggleOptions(target) { + truncatedText = truncateText(target); + $(target).text(truncatedText); + $(target).append($('.htlRoomTypeDescExtras').html()); + $(target).find('.htlRoomTypeDescReadmore').first().show().css('display', 'inline-block'); +} + +function truncateText(target) { + var lineHeight = parseInt($(target).css('line-height'), 10); + var containerHeight = lineHeight * 3; + + text = $(target).text(); + while ($(target).prop('scrollHeight') > containerHeight) { + text = text.slice(0, -10); + $(target).text(text + ' ... ' + $('.htlRoomTypeDescReadmore').first().text()); + } + + return text; +} diff --git a/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl b/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl index d65fb9763..872d0030b 100644 --- a/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl +++ b/modules/wkhotelroom/views/templates/hook/hotelRoomDisplayBlock.tpl @@ -45,22 +45,24 @@

{$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}
-
- {$roomDisplay.description} -
+
{$roomDisplay.description|escape:'html':'UTF-8'}
+ +
...{l s='Read More.' mod='wkhotelroom'}...{l s='Read Less.' mod='wkhotelroom'}
diff --git a/modules/wkhotelroom/wkhotelroom.php b/modules/wkhotelroom/wkhotelroom.php index de73facb0..9318a0c08 100644 --- a/modules/wkhotelroom/wkhotelroom.php +++ b/modules/wkhotelroom/wkhotelroom.php @@ -115,6 +115,7 @@ class WkHotelRoom extends Module ) ); + $this->context->controller->addJs($this->_path.'/views/js/WkHotelRoomBlockFront.js'); $this->context->controller->addCSS($this->_path.'/views/css/WkHotelRoomBlockFront.css'); return $this->display(__FILE__, 'hotelRoomDisplayBlock.tpl');