Commit b3ec016d authored by Kristof De Jaeger's avatar Kristof De Jaeger
Browse files

Issue #3241512: run behaviors on infinite scroll

parent 0937aa1e
Loading
Loading
Loading
Loading
+1 −1
Changes for src/Controller/ReaderController.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ class ReaderController extends ControllerBase {

        // Date.
        $date = '';
        $datetime = isset($item->published) ? $item->published : '';
        $datetime = $item->published ?? '';
        if (!empty($datetime)) {
          $date = $this->dateFormatter->format(strtotime($item->published), 'custom', 'd/m/Y H:i');
        }
+9 −2
Changes for themes/reader_theme/js/reader.infinite.scroll.js: 9 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -4,9 +4,10 @@

  Drupal.behaviors.readerInfiniteScroll = {
    attach: function () {
      let $timelineColumn = $('.column-1 .scrollable .column-timeline');
      if ($('.pager__item--next a').length > 0) {
        $('.pager__items li a').addClass('use-ajax');
      $('.column-1 .scrollable .column-timeline').infiniteScroll({
        // options
        $timelineColumn.infiniteScroll({
          path: '.pager__item--next a',
          append: '.content-article',
          prefill: true,
@@ -17,6 +18,12 @@
          debug: false,
        });
      }

      $timelineColumn.on( 'load.infiniteScroll', function( event, response, path ) {
        //console.log('Loaded: ' + path);
        Drupal.attachBehaviors();
      });
    }
  }

})(jQuery);
+8 −8
Changes for themes/reader_theme/js/reader.js: 8 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
      searchWrapper = $('.column-header__collapsible.search-container');

      // Get button links to set active classes and hide/show columns.
      $('.button-link').on('click', function(e) {
      $('.button-link').once().on('click', function(e) {
        let type = $(this).data('button');

        // Do not reload page on home.
@@ -65,7 +65,7 @@
        }
      });

      $(document).click(function() {
      $(document).once().click(function() {
        if (actionLinks !== null) {
          actionLinks.hide();
        }
@@ -73,7 +73,7 @@

      // Action links.
      let actionLinks = null;
      $('.status__action-bar-dropdown').on('click', function (e) {
      $('.status__action-bar-dropdown').once().on('click', function (e) {
        e.stopPropagation();
        actionLinks = $(this).parent().children('.status__action-bar-links');
        if (actionLinks.is(':visible')) {
@@ -92,7 +92,7 @@
      }

      // Catch logout link.
      $('.reader-logout').on('click', function(e) {
      $('.reader-logout').once().on('click', function(e) {
        let l = confirm(Drupal.t("Are you sure you want to logout?"));
        if (l !== true) {
          e.preventDefault();
@@ -102,7 +102,7 @@

      // Catch clicks on links inside the article, apart from gallery and action
      // links, to open in a new tab or window (depending on browser).
      $('.content-article a:not(.image-gallery-item,.status__action-bar-links a)').on('click', function(e) {
      $('.content-article a:not(.image-gallery-item,.status__action-bar-links a)').once().on('click', function(e) {
        e.preventDefault();
        let url = $(this).attr('href');
        window.open(url, '_blank');
@@ -113,7 +113,7 @@
      let actions = $('.column-header__button.actions');
      let actionsWrapper = $('.column-header__collapsible.actions-container');
      if (actions.length > 0 && actionsWrapper.length > 0) {
        actions.on('click', function() {
        actions.once().on('click', function() {
          if (actionsVisible) {
            actionsVisible = false;
            actionsWrapper.addClass('collapsed');
@@ -126,7 +126,7 @@
      }

      if (search.length > 0 && searchWrapper.length > 0) {
        search.on('click', function() {
        search.once().on('click', function() {
          if (searchVisible) {
            searchVisible = false;
            searchWrapper.addClass('collapsed');
@@ -159,7 +159,7 @@
    let duration	= '1000';
    let easing = 'linear';

    $('.main-content').each(function() {
    $('.main-content').once().each(function() {
      if ($(this).height() > height) {
        $(this).data('fullHeight', $(this).height()).css('height', height);
        $(this).after('<a href="javascript:void(0);" class="reader-more-link closed">' + moreText + '</a>');