Skip to content

Commit

Permalink
Adding in the itinerary read more.
Browse files Browse the repository at this point in the history
  • Loading branch information
krugazul committed Dec 3, 2024
1 parent d1fb978 commit 9293035
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 57 deletions.
82 changes: 25 additions & 57 deletions assets/js/src/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,24 @@ if ( window.location.hash ) {
lsx_to.readMoreText = $(this).contents().filter(function() {
return this.nodeType === Node.TEXT_NODE;
}).text();
lsx_to.readMoreSet( $(this) );
lsx_to.readMoreSet( $(this), $(this).closest( '.wp-block-group' ).find('.wp-block-post-content') );
} );

$( '.single-tour-operator .wp-block-read-more' ).on( 'click', function( event ) {
event.preventDefault();
$( this ).hide();

if ( $( this ).hasClass( 'less-link' ) ) {
lsx_to.readMoreSet($( this ));
lsx_to.readMoreSet( $(this), $(this).closest( '.wp-block-group' ).find('.wp-block-post-content') );
} else {
lsx_to.readMoreOpen($( this ));
lsx_to.readMoreOpen( $(this), $(this).closest( '.wp-block-group' ).find('.wp-block-post-content') );
}

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

lsx_to.readMoreSet = function( button ) {
let contentWrapper = button.closest( '.wp-block-group' ).find('.wp-block-post-content');
lsx_to.readMoreSet = function( button, contentWrapper ) {
if ( 0 < contentWrapper.length ) {
if ( 1 < contentWrapper.children().length ) {

Expand All @@ -90,8 +89,7 @@ if ( window.location.hash ) {
}
}

lsx_to.readMoreOpen = function( button ) {
let contentWrapper = button.closest( '.wp-block-group' ).find('.wp-block-post-content');
lsx_to.readMoreOpen = function( button, contentWrapper ) {
if ( 0 < contentWrapper.children().length ) {
contentWrapper.children().each( function() {
if ( ! $(this).hasClass('wp-block-read-more') ) {
Expand All @@ -116,79 +114,49 @@ if ( window.location.hash ) {

$( '.single-tour-operator .additional-info .lsx-to-more-link' ).each( function() {
lsx_to.readMoreTIText = $(this).find('a').text();
lsx_to.readMoreSetTI( $(this) );
lsx_to.readMoreSet( $(this), $(this).closest( '.additional-info' ).find('.content') );
} );

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

if ( $( this ).hasClass( 'less-link' ) ) {
lsx_to.readMoreSetTI($( this ));
lsx_to.readMoreSet( $(this), $(this).closest( '.additional-info' ).find('.content') );
} else {
lsx_to.readMoreOpenTI($( this ));
lsx_to.readMoreOpenTI( $(this), $(this).closest( '.additional-info' ).find('.content') );
}

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

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

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

var limit = 1;
let counter = 0;

contentWrapper.children().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');
if ( 0 < contentWrapper.children().length ) {
contentWrapper.each( function() {
$(this).show();
});
button.addClass( 'less-link' );
button.find('a').text( 'View Less' );
button.show();

}
}

/**
* Read more (itinerary) effect.
*
* @package tour-operator
* @subpackage scripts
*/

lsx_to.readMoreItinText = '';

lsx_to.set_read_more_itinerary = function() {
$( '#itinerary .view-more a' ).click( function( event ) {
$( '.single-tour-operator .lsx-itinerary-wrapper .wp-block-read-more' ).each( function() {
lsx_to.readMoreItinText = $(this).find('a').text();
lsx_to.readMoreSet( $(this), $(this).closest( 'div' ).find('.itinerary-description') );
} );

$( '.single-tour-operator .lsx-itinerary-wrapper .wp-block-read-more' ).on( 'click', function( event ) {
event.preventDefault();
$( this ).hide();

$( this ).parents( '#itinerary' ).find( '.itinerary-item.hidden' ).each( function() {
$( this ).removeClass( 'hidden' );
} );
if ( $( this ).hasClass( 'less-link' ) ) {
lsx_to.readMoreSet( $(this), $(this).closest( 'div' ).find('.itinerary-description') );
} else {
lsx_to.readMoreOpen( $(this), $(this).closest( 'div' ).find('.itinerary-description') );
}

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

Expand Down Expand Up @@ -380,7 +348,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_itinerary();
lsx_to.set_read_more_itinerary();
lsx_to.build_slider( window_width );
} );

Expand Down
2 changes: 2 additions & 0 deletions includes/classes/legacy/class-accommodation.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public function price_filter( $html = '', $meta_key = false, $value = false, $be
'single_supplement'
];

do_action( 'qm/debug', [ get_post_type(), $meta_key ] );

if ( get_post_type() === 'accommodation' && in_array( $meta_key, $currency_fields ) ) {
$price_type = get_post_meta( get_the_ID(), 'price_type', true );
$value = preg_replace( '/[^0-9,.]/', '', $value );
Expand Down

0 comments on commit 9293035

Please sign in to comment.