Commit f60ff8dd authored by Gaus Surahman's avatar Gaus Surahman
Browse files

- Fixed for D9 broken views ajax pager.

parent 801fcf5f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line

Intersection Observer 8.x-1.0-dev, 2019-06-30
---------------------------------------------
- Fixed for D9 broken views ajax pager.

Intersection Observer 8.x-1.0-dev, 2019-06-24
---------------------------------------------
- Updated to D9.
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ base:
  dependencies:
    - blazy/bio
    - blazy/bio.ajax
    - blazy/loading

block:
  js:
+16 −6
Original line number Diff line number Diff line
@@ -87,25 +87,35 @@ function io_config_schema_info_alter(array &$definitions) {
 * Implements hook_preprocess_io_pager().
 */
function io_preprocess_io_pager(&$variables) {
  global $pager_page_array, $pager_total;
  /* @var $pager_manager \Drupal\Core\Pager\PagerManagerInterface */
  $pager_manager = \Drupal::service('pager.manager');

  $element = $variables['element'];
  $parameters = $variables['parameters'];

  // Nothing to do if there is only one page.
  if ($pager_total[$element] <= 1) {
  $pager = $pager_manager->getPager($element);
  if (!$pager) {
    return;
  }

  $current = $pager->getCurrentPage();
  $total = $pager->getTotalPages();

  // Calculate various markers within this pager piece:
  if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
  if ($current < ($total - 1)) {
    $options = [
      // See https://www.drupal.org/node/2779457.
      'query' => \Drupal::service('pager.manager')->getUpdatedParameters($parameters, $element, $pager_page_array[$element] + 1),
      'query' => $pager_manager->getUpdatedParameters($parameters, $element, $current + 1),
    ];
    $variables['items']['next']['href'] = Url::fromRoute('<current>', [], $options);
    $variables['items']['next']['href'] = Url::fromRoute('<current>', [], $options)->toString();
  }

  $variables['#cache']['contexts'][] = 'url.query_args';

  if (!\Drupal::service('module_handler')->moduleExists('ajaxin')) {
    // @todo remove media--loading for is-b-loading post blazy:2.3+.
    $variables['content_attributes']['class'][] = 'media--loading is-b-loading';
  }
}

/**
+1 −1
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ class IoManager implements IoManagerInterface {
      $classes[] = 'io__loading';
    }
    else {
      $classes[] = 'media--loading';
      $classes[] = 'media--loading is-b-loading';
      $variables['#attached']['library'][] = 'blazy/loading';
    }

+7 −1
Original line number Diff line number Diff line
@@ -18,11 +18,17 @@
    options.autoload ? 'pager--io--autoload',
  ]
%}
{%
  set content_classes = [
    'pager__items',
    'js-pager__items',
  ]
%}
{% if items.next or options.end_text %}
<nav role="navigation" aria-labelledby="pagination-heading"{{ attributes.addClass(classes)|without('role', 'aria-labelledby') }}>
  <h4 class="visually-hidden">{{ 'Pagination'|t }}</h4>
  {% if items.next %}
    <ul class="pager__items js-pager__items">
    <ul{{ content_attributes.addClass(content_classes) }}>
      <li class="pager__item">
        <a class="btn btn-primary" href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" data-io-pager-trigger>{{ options.button_text|t }}</a>
      </li>