Skip to content

Commit

Permalink
Merge pull request #441 from lightspeedwp/368-read-more-fixes
Browse files Browse the repository at this point in the history
Fixing the Travel info read more.
  • Loading branch information
krugazul authored Nov 8, 2024
2 parents 030ae71 + 96b6ba7 commit 8298dc4
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 28 deletions.
16 changes: 8 additions & 8 deletions assets/js/blocks/destination.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ wp.domReady(() => {
metadata: {
name: 'Electricity',
},
className: 'lsx-additional-info-wrapper',
className: 'lsx-electricity-wrapper',
style: {
border: {
radius: '8px'
Expand Down Expand Up @@ -465,7 +465,7 @@ wp.domReady(() => {
metadata: {
name: 'Cuisine',
},
className: 'lsx-additional-info-wrapper',
className: 'lsx-cuisine-wrapper',
style: {
border: {
radius: '8px'
Expand Down Expand Up @@ -611,7 +611,7 @@ wp.domReady(() => {
metadata: {
name: 'Climate',
},
className: 'lsx-additional-info-wrapper',
className: 'lsx-climate-wrapper',
style: {
border: {
radius: '8px'
Expand Down Expand Up @@ -757,7 +757,7 @@ wp.domReady(() => {
metadata: {
name: 'Transport',
},
className: 'lsx-additional-info-wrapper',
className: 'lsx-transport-wrapper',
style: {
border: {
radius: '8px'
Expand Down Expand Up @@ -903,7 +903,7 @@ wp.domReady(() => {
metadata: {
name: 'Dress',
},
className: 'lsx-additional-info-wrapper',
className: 'lsx-dress-wrapper',
style: {
border: {
radius: '8px'
Expand Down Expand Up @@ -1049,7 +1049,7 @@ wp.domReady(() => {
metadata: {
name: 'Health',
},
className: 'lsx-additional-info-wrapper',
className: 'lsx-health-wrapper',
style: {
border: {
radius: '8px'
Expand Down Expand Up @@ -1196,7 +1196,7 @@ wp.domReady(() => {
metadata: {
name: 'Safety',
},
className: 'lsx-additional-info-wrapper',
className: 'lsx-safety-wrapper',
style: {
border: {
radius: '8px',
Expand Down Expand Up @@ -1352,7 +1352,7 @@ wp.domReady(() => {
metadata: {
name: 'Visa',
},
className: 'lsx-additional-info-wrapper',
className: 'lsx-visa-wrapper',
style: {
border: {
radius: '8px',
Expand Down
69 changes: 59 additions & 10 deletions assets/js/src/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,70 @@ if ( window.location.hash ) {
* @package tour-operator
* @subpackage scripts
*/
lsx_to.readMoreTIText = '';

lsx_to.set_read_more_travel_info = function() {
$( '.moretag-travel-info' ).click( function( event ) {
event.preventDefault();

var $modal = $( '#lsx-modal-placeholder' ),
$entry = $( this ).closest( '.lsx-travel-info' ),
title = $entry.find( '.lsx-to-widget-title' ).html(),
content = $entry.find( '.travel-info-entry-content' ).html();
$( '.single-tour-operator .additional-info .lsx-to-more-link' ).each( function() {
lsx_to.readMoreTIText = $(this).find('a').text();
lsx_to.readMoreSetTI( $(this) );
} );

$modal.find( '.modal-title' ).html( title );
$modal.find( '.modal-body' ).html( content );
$( '.single-tour-operator .additional-info .lsx-to-more-link' ).on( 'click', function( event ) {
event.preventDefault();
$( this ).hide();

$modal.modal();
if ( $( this ).hasClass( 'less-link' ) ) {
lsx_to.readMoreSetTI($( this ));
} else {
lsx_to.readMoreOpenTI($( this ));
}

$( this ).show();
} );

};
lsx_to.readMoreSetTI = function( button ) {
let contentWrapper = button.closest( '.additional-info' ).find('.content');
if ( 0 < contentWrapper.length ) {
if ( 1 < contentWrapper.find('p').length ) {

//first remove empty p tags.
contentWrapper.find('p').each( function() {
if ( '' === $(this).html() ) {
$(this).remove();
}
});

var limit = 1;
let counter = 0;

contentWrapper.find('p').each( function() {
if ( limit <= counter ) {
$(this).hide();
}
counter++;
});
} else {
button.hide();
}
button.removeClass('less-link');
button.find('a').text( lsx_to.readMoreTIText );
}
}

lsx_to.readMoreOpenTI = function( button ) {
let contentWrapper = button.closest( '.additional-info' ).find('.content p');
if ( 0 < contentWrapper.length ) {
contentWrapper.each( function() {
$(this).show();
});
button.addClass( 'less-link' );
button.find('a').text( 'View Less' );
button.show();

}
}

/**
* Read more (itinerary) effect.
Expand Down Expand Up @@ -312,7 +361,7 @@ if ( window.location.hash ) {
*/
$document.ready( function() {
lsx_to.set_read_more();
//lsx_to.set_read_more_travel_info();
lsx_to.set_read_more_travel_info();
//lsx_to.set_read_more_itinerary();
lsx_to.build_slider( window_width );
} );
Expand Down
10 changes: 0 additions & 10 deletions includes/classes/blocks/class-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,5 @@ public function register_block_patterns() {
// Require the file and add it to the patterns array

Check warning on line 70 in includes/classes/blocks/class-patterns.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/blocks/class-patterns.php#L70

Inline comments must end in full-stops, exclamation marks, or question marks. (Squiz.Commenting.InlineComment)
register_block_pattern( $key, require $file );
}

/*$patterns = array(
'lsx-tour-operator/itinerary-list' => require( LSX_TO_PATH . '/includes/patterns/itinerary-list.php' ),
'lsx-tour-operator/destination-card' => require( LSX_TO_PATH . '/includes/patterns/destination-card.php' ),
'lsx-tour-operator/room-card' => require( LSX_TO_PATH . '/includes/patterns/room-card.php' ),
);
foreach ( $patterns as $key => $function ) {
register_block_pattern( $key, $function );
}*/
}

Check warning on line 73 in includes/classes/blocks/class-patterns.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/blocks/class-patterns.php#L73

Expected 1 blank line before closing function brace; 0 found. (Squiz.WhiteSpace.FunctionClosingBraceSpace-[fixable])

Check warning on line 73 in includes/classes/blocks/class-patterns.php

View check run for this annotation

codefactor.io / CodeFactor

includes/classes/blocks/class-patterns.php#L73

Expected 2 blank lines after function; 0 found. (Squiz.WhiteSpace.FunctionSpacing-[fixable])
}

0 comments on commit 8298dc4

Please sign in to comment.