diff --git a/assets/js/blocks/destination.js b/assets/js/blocks/destination.js index c1f34a29..6bab1652 100644 --- a/assets/js/blocks/destination.js +++ b/assets/js/blocks/destination.js @@ -155,7 +155,7 @@ wp.domReady(() => { metadata: { name: 'Electricity', }, - className: 'lsx-additional-info-wrapper', + className: 'lsx-electricity-wrapper', style: { border: { radius: '8px' @@ -465,7 +465,7 @@ wp.domReady(() => { metadata: { name: 'Cuisine', }, - className: 'lsx-additional-info-wrapper', + className: 'lsx-cuisine-wrapper', style: { border: { radius: '8px' @@ -611,7 +611,7 @@ wp.domReady(() => { metadata: { name: 'Climate', }, - className: 'lsx-additional-info-wrapper', + className: 'lsx-climate-wrapper', style: { border: { radius: '8px' @@ -757,7 +757,7 @@ wp.domReady(() => { metadata: { name: 'Transport', }, - className: 'lsx-additional-info-wrapper', + className: 'lsx-transport-wrapper', style: { border: { radius: '8px' @@ -903,7 +903,7 @@ wp.domReady(() => { metadata: { name: 'Dress', }, - className: 'lsx-additional-info-wrapper', + className: 'lsx-dress-wrapper', style: { border: { radius: '8px' @@ -1049,7 +1049,7 @@ wp.domReady(() => { metadata: { name: 'Health', }, - className: 'lsx-additional-info-wrapper', + className: 'lsx-health-wrapper', style: { border: { radius: '8px' @@ -1196,7 +1196,7 @@ wp.domReady(() => { metadata: { name: 'Safety', }, - className: 'lsx-additional-info-wrapper', + className: 'lsx-safety-wrapper', style: { border: { radius: '8px', @@ -1352,7 +1352,7 @@ wp.domReady(() => { metadata: { name: 'Visa', }, - className: 'lsx-additional-info-wrapper', + className: 'lsx-visa-wrapper', style: { border: { radius: '8px', diff --git a/assets/js/src/custom.js b/assets/js/src/custom.js index 7cdbc5fa..abb89509 100755 --- a/assets/js/src/custom.js +++ b/assets/js/src/custom.js @@ -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. @@ -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 ); } ); diff --git a/includes/classes/blocks/class-patterns.php b/includes/classes/blocks/class-patterns.php index 64806695..10c63f06 100644 --- a/includes/classes/blocks/class-patterns.php +++ b/includes/classes/blocks/class-patterns.php @@ -70,15 +70,5 @@ public function register_block_patterns() { // Require the file and add it to the patterns array 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 ); - }*/ } }