Hi!

I'm migrating from another forum to hosted nodeBB but need som help with one important feature.

We have some users that make long posts, and when someone quotes, the quote become equally long, this makes it cumbersome to scroll throught the topic.

Other forums solve this by fading out, and a clickable "read more..." text that expands the big quotes.

I was hoping to do this as well, but am failing. Mainly I hope due to my lacking knowledge in javascript.

So I tried uploading readmore.min.js to /assets/uploads/... and added the following to custon javascript:

function onLoad() {
    require(['/assets/uploads/readmore.min.js']);
    console.log('yeah it works');
    console.log($('blockquote'));
    $('blockquote').readmore();
}

$(document).ready(onLoad);
$(window).on('action:ajaxify.end', onLoad);

This gives me the following output in the console:

86a146b2-755d-45ef-8924-e2b63c5849df-image.png

Any help is much appreciated!

all 10 comments

sorted by: hot top controversial new old
[–] 2 points 3 months ago (1 child)

The latest file is here https://github.com/jedfoster/Readmore.js/blob/master/readmore.min.js, I tried using it with the latest version of nodebb and found some issues. Create a pull request with my fixes at https://github.com/jedfoster/Readmore.js/pull/265/changes.

So with that updated file in public/uploads folder and the below custom javascript in the ACP it works.

$(window).on('action:topic.loaded action:posts.loaded', function() {
   function enableReadMore() {
       $('blockquote').readmore({});
   } 
   if (!$.readmore) {
       $.getScript('/foren/assets/uploads/readmore.min.js').then(enableReadMore);
   } else {
       enableReadMore();
   }
});

readmore.gif

readmore.gif

  • source
  • hideshow 2 child comments
  • [–] 2 points 3 months ago

    @baris I would appreciate a more detailed explanation! I guess I didn't understand the whole thread. Is there a way to add a read more button to very long quotes? If so, what is the whole process you had to do?

  • source
  • [–] 2 points 3 months ago

    @julian yeah we do, there is a button to collapse them in core.

  • source
  • [–] 2 points 2 months ago

    Actually, we collapse nested blockquotes. I don't think there is anything in code to collapse very long blockquotes.

  • source
  • [–] 1 point 3 months ago

    Is there a solution to this issue today? Does this come as part of the options nodebb?

  • source
  • [–] 1 point 3 months ago*

    @downpw Where do I download the updated readmore.min.js file?

  • source
  • [–] 1 point 3 months ago

    @baris It looks like this was fixed as part of NODEBB, but was removed in recent versions.

  • source
  • [–] 1 point 3 months ago

    Core no longer uses requirejs so that syntax will no longer work. If you put the readmore.min.js file in public/uploads then you can load it and use it with $.getScript().

    $.getScript('/assets/uploads/readmore.min.js', function () {
      $('<div>').readmore();
    })
    ```</div>
    
  • source
  • [–] 1 point 3 months ago

    @moshe

    Why don't use custom javascript in ACP ?

  • source