removed the tinymce from the room type short description, and updated the read more and read less toggle buttons

This commit is contained in:
vishalsingh.qlo325
2024-07-25 15:43:56 +05:30
parent ef5e37aa29
commit dc3fee3ece
6 changed files with 19 additions and 46 deletions

View File

@@ -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}
</div>
</div>
<div class="form-group">

View File

@@ -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),
),

View File

@@ -25,9 +25,6 @@
cursor: pointer;
font-weight: 400;
}
.htlRoomTypeDescTextContainer p{
margin: 0px;
}
@media (min-width: 530px) {
.hotelRoomDescContainer{
position: absolute;
@@ -72,7 +69,7 @@
color: #555555;
font-weight: 300;
line-height: 21px;
margin-bottom: 9px;
margin-bottom: 10px;
}
a.htlRoomTypeBookNow {
font-size: 15px;

View File

@@ -18,10 +18,12 @@
*/
$(document).ready(function() {
toggleRoomDescriptionExtras();
$(window).on('resize', function() {
removePreviousChanges();
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.
initToogleOtions($(this)[0]);
}
});
$(document).on('click', '.read-extra-text', function(e) {
@@ -36,44 +38,22 @@ $(document).ready(function() {
});
});
// Function is called to revert the changes made to the description on the window size change.
function removePreviousChanges()
{
$(document).find('.htlRoomTypeDescText').each(function() {
//Reverting the changes so we can reapply them according the new screen size.
$(this).html($(this).parent().find('.htlRoomTypeDescTextOriginal').html());
if (!$(this).hasClass('htlRoomTypeDescTextContainer')){
$(this).addClass('htlRoomTypeDescTextContainer');
}
});
}
function addExtraTextToDescription(target)
function initToogleOtions(target)
{
// Getting the number of displayed characters
var show_char = getChars(target);
var ellipses = "... ";
var content = $(target).html();
if (content.trim().length > show_char) {
var a = content.trim().substr(0, show_char).replace('<p>' , ''); // getting the text that we want to show to the user, removed the first <p> tag.
if (content.trim().substr(content.trim().length - 4, content.trim().length) == '</p>') {
content = content.trim().substr(0, content.trim().length - 4);// removed the last closing </p> 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 + "<span class='truncated'>" + ellipses + "</span><span class='read-extra-text'>"+ readMoreText +"</span><span class='truncated' style='display:none'>" + b + "</span><span class='read-extra-text' style='display:none'> "+ readLessText +"</span></span>";
$(target).html('<p>' + html+ '</p>');
$(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;
}
}

View File

@@ -59,13 +59,10 @@
{/if}
</div>
<div class="row margin-lr-0 htlRoomTypeDescText htlRoomTypeDescTextContainer">
{$roomDisplay.description}
</div>
<div class="htlRoomTypeDescTextOriginal" style="display: none;">
{$roomDisplay.description}
{$roomDisplay.description|escape:'html':'UTF-8'}
</div>
<div class="row margin-lr-0">
<a class="btn btn-default htlRoomTypeBookNow" href="{$link->getProductLink($roomDisplay.id_product)|escape:'html':'UTF-8'}"><span>{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{l s='book now' mod='wkhotelroom'}{else}{l s='View' mod='wkhotelroom'}{/if}</span></a>
<a class="btn htlRoomTypeBookNow" href="{$link->getProductLink($roomDisplay.id_product)|escape:'html':'UTF-8'}"><span>{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{l s='book now' mod='wkhotelroom'}{else}{l s='View' mod='wkhotelroom'}{/if}</span></a>
</div>
</div>
</div>

View File

@@ -104,8 +104,8 @@ class WkHotelRoom extends Module
)
);
$this->context->controller->addCSS($this->_path.'/views/css/WkHotelRoomBlockFront.css');
$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');
}