diff --git a/composer.json b/composer.json index 3e25f6f7932fd1f4591d5765e69b69582e8f6c2c..bda85b2a8d9b333410566012d67917fcafc172ff 100644 --- a/composer.json +++ b/composer.json @@ -172,7 +172,7 @@ "drupal/views_bootstrap": "3.6", "drupal/views_bulk_operations": "4.2.3", "drupal/views_fieldsets": "^3.4", - "drupal/views_infinite_scroll": "1.9", + "drupal/views_infinite_scroll": "2.0.2", "drupal/webform": "^6.1", "drush-ops/behat-drush-endpoint": "0.0.5", "drush/drush": "^11", diff --git a/composer.lock b/composer.lock index 1324949865fdee2237d7536e1ec106c6968660cb..e9c6ae69d47cd7ede001e94daf69d9be9882c6b8 100644 --- a/composer.lock +++ b/composer.lock @@ -7864,26 +7864,26 @@ }, { "name": "drupal/views_infinite_scroll", - "version": "1.9.0", + "version": "2.0.2", "source": { "type": "git", "url": "https://git.drupalcode.org/project/views_infinite_scroll.git", - "reference": "8.x-1.9" + "reference": "2.0.2" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/views_infinite_scroll-8.x-1.9.zip", - "reference": "8.x-1.9", - "shasum": "875d58d317d48036ed1d9ef538bc8a76bc3dcb5b" + "url": "https://ftp.drupal.org/files/projects/views_infinite_scroll-2.0.2.zip", + "reference": "2.0.2", + "shasum": "8b2b935d1e5d94d7ad068d099512d3b915efb41f" }, "require": { - "drupal/core": "^8.8 || ^9" + "drupal/core": "^9.2 || ^10" }, "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.9", - "datestamp": "1632421809", + "version": "2.0.2", + "datestamp": "1689001933", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 9e426ae601b8dafcbadbb6a911d7bfe9615d10da..c9f06b7b001d5aaf97ee1c698d2eb62dc4ab5bcb 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -8154,27 +8154,27 @@ }, { "name": "drupal/views_infinite_scroll", - "version": "1.9.0", - "version_normalized": "1.9.0.0", + "version": "2.0.2", + "version_normalized": "2.0.2.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/views_infinite_scroll.git", - "reference": "8.x-1.9" + "reference": "2.0.2" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/views_infinite_scroll-8.x-1.9.zip", - "reference": "8.x-1.9", - "shasum": "875d58d317d48036ed1d9ef538bc8a76bc3dcb5b" + "url": "https://ftp.drupal.org/files/projects/views_infinite_scroll-2.0.2.zip", + "reference": "2.0.2", + "shasum": "8b2b935d1e5d94d7ad068d099512d3b915efb41f" }, "require": { - "drupal/core": "^8.8 || ^9" + "drupal/core": "^9.2 || ^10" }, "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.9", - "datestamp": "1632421809", + "version": "2.0.2", + "datestamp": "1689001933", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -8188,7 +8188,15 @@ ], "authors": [ { - "name": "Bobík", + "name": "Anybody", + "homepage": "https://www.drupal.org/user/291091" + }, + { + "name": "Grevil", + "homepage": "https://www.drupal.org/user/3668491" + }, + { + "name": "Honza Pobořil", "homepage": "https://www.drupal.org/user/123612" }, { @@ -8202,6 +8210,10 @@ { "name": "Sam152", "homepage": "https://www.drupal.org/user/1485048" + }, + { + "name": "thomas.frobieter", + "homepage": "https://www.drupal.org/user/409335" } ], "description": "A pager which allows an infinite scroll effect for views.", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 9610850237c120c1a049ff65c614d8dd021b9da8..da26b845dab5b2dfbd5ea5fc70ddba7e5dfe0f7b 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1292,9 +1292,9 @@ 'dev_requirement' => false, ), 'drupal/views_infinite_scroll' => array( - 'pretty_version' => '1.9.0', - 'version' => '1.9.0.0', - 'reference' => '8.x-1.9', + 'pretty_version' => '2.0.2', + 'version' => '2.0.2.0', + 'reference' => '2.0.2', 'type' => 'drupal-module', 'install_path' => __DIR__ . '/../../web/modules/views_infinite_scroll', 'aliases' => array(), diff --git a/web/modules/views_infinite_scroll/README.txt b/web/modules/views_infinite_scroll/README.txt index 32c58ea04b3a99686a7dda39a4f906d4deaf937c..ae0fee51bbd321ef3a2e2a30aafef2300685e8e1 100644 --- a/web/modules/views_infinite_scroll/README.txt +++ b/web/modules/views_infinite_scroll/README.txt @@ -14,9 +14,11 @@ INTRODUCTION The Views Infinite Scroll module provides a pager, which allows an infinite scroll effect for views. It can work on any view: block, page, etc. -* For a full description of the module visit https://www.drupal.org/project/views_infinite_scroll +* For a full description of the module visit + https://www.drupal.org/project/views_infinite_scroll -* To submit bug reports and feature suggestions, or to track changes visit https://www.drupal.org/project/issues/views_infinite_scroll +* To submit bug reports and feature suggestions, or to track changes visit + https://www.drupal.org/project/issues/views_infinite_scroll REQUIREMENTS @@ -28,7 +30,9 @@ This module requires no modules outside of Drupal core. INSTALLATION ------------ -* Install the Views Infinite Scroll module as you would normally install a contributed Drupal module. Visit https://www.drupal.org/node/1897420 for further information. +* Install the Views Infinite Scroll module as you would normally install + a contributed Drupal module. Visit https://www.drupal.org/node/1897420 + for further information. CONFIGURATION diff --git a/web/modules/views_infinite_scroll/js/infinite-scroll.js b/web/modules/views_infinite_scroll/js/infinite-scroll.js index 48abbcb92792d653c7b5216c27976fe2cf6d0c97..31af21198d5eedd6886609d8e02d6ca06aa8541f 100644 --- a/web/modules/views_infinite_scroll/js/infinite-scroll.js +++ b/web/modules/views_infinite_scroll/js/infinite-scroll.js @@ -44,11 +44,11 @@ var view = Drupal.views.instances[currentViewId]; // Remove once so that the exposed form and pager are processed on // behavior attach. - view.$view.removeOnce('ajax-pager'); - view.$exposed_form.removeOnce('exposed-form'); + once.remove('ajax-pager', view.$view); + once.remove('exposed-form', view.$exposed_form); // Make sure infinite scroll can be reinitialized. var $existingPager = view.$view.find(pagerSelector); - $existingPager.removeOnce('infinite-scroll'); + once.remove('infinite-scroll', $existingPager); var $newRows = $newView.find(contentWrapperSelector).children(); var $newPager = $newView.find(pagerSelector); @@ -79,8 +79,8 @@ */ Drupal.behaviors.views_infinite_scroll_automatic = { attach : function (context, settings) { - $(context).find(automaticPagerSelector).once('infinite-scroll').each(function () { - var $pager = $(this); + once('infinite-scroll', automaticPagerSelector, context).forEach(function (elem) { + var $pager = $(elem); $pager.addClass('visually-hidden'); var isLoadNeeded = function () { return window.innerHeight + window.pageYOffset > $pager.offset().top - scrollThreshold; @@ -102,7 +102,7 @@ // other than a scroll. AJAX filters are a good example of the event needing // to be destroyed earlier than above. if (trigger === 'unload') { - if ($(context).find(automaticPagerSelector).removeOnce('infinite-scroll').length) { + if (once.remove('infinite-scroll', automaticPagerSelector, context).length) { $window.off(scrollEvent); } } diff --git a/web/modules/views_infinite_scroll/src/EventSubscriber/AjaxResponseSubscriber.php b/web/modules/views_infinite_scroll/src/EventSubscriber/AjaxResponseSubscriber.php index 4cd796982522e376983cac223df65147afac5658..782422a54971f263be0807cd518c5b871ea2c2b6 100644 --- a/web/modules/views_infinite_scroll/src/EventSubscriber/AjaxResponseSubscriber.php +++ b/web/modules/views_infinite_scroll/src/EventSubscriber/AjaxResponseSubscriber.php @@ -4,7 +4,7 @@ use Drupal\views\Ajax\ViewAjaxResponse; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -26,7 +26,10 @@ protected function alterPaginationCommands(array &$commands) { $command['method'] = 'infiniteScrollInsertView'; } // Stop the view from scrolling to the top of the page. - if ($command['command'] === 'viewsScrollTop') { + // We need to check for both commands as "viewsScrollTop" is deprecated + // and not used in views_ajax.js for Drupal 10.1 anymore and replaced + // by "scrollTop". + if (in_array($command['command'], ['scrollTop', 'viewsScrollTop'])) { unset($commands[$delta]); } } @@ -35,10 +38,10 @@ protected function alterPaginationCommands(array &$commands) { /** * Renders the ajax commands right before preparing the result. * - * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event + * @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event * The response event, which contains the possible AjaxResponse object. */ - public function onResponse(FilterResponseEvent $event) { + public function onResponse(ResponseEvent $event) { $response = $event->getResponse(); // Only alter views ajax responses. diff --git a/web/modules/views_infinite_scroll/tests/src/Functional/IntegrationSmokeTest.php b/web/modules/views_infinite_scroll/tests/src/Functional/IntegrationSmokeTest.php index 9cee25ea34eb3b252f6a27c2944ecf340cb0c32e..1a6867b1077f36b85f37eaa6b285e727aa080f8f 100644 --- a/web/modules/views_infinite_scroll/tests/src/Functional/IntegrationSmokeTest.php +++ b/web/modules/views_infinite_scroll/tests/src/Functional/IntegrationSmokeTest.php @@ -26,7 +26,7 @@ class IntegrationSmokeTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->drupalLogin($this->createUser(['administer views'])); } diff --git a/web/modules/views_infinite_scroll/tests/src/FunctionalJavascript/InfiniteScrollTest.php b/web/modules/views_infinite_scroll/tests/src/FunctionalJavascript/InfiniteScrollTest.php index 30b6704c8224b637847885b6668dbadffcbe2077..bce58de054ca733d59a5502affdf751f0de59a2e 100644 --- a/web/modules/views_infinite_scroll/tests/src/FunctionalJavascript/InfiniteScrollTest.php +++ b/web/modules/views_infinite_scroll/tests/src/FunctionalJavascript/InfiniteScrollTest.php @@ -30,12 +30,12 @@ class InfiniteScrollTest extends WebDriverTestBase { /** * {@inheritdoc} */ - protected $defaultTheme = 'classy'; + protected $defaultTheme = 'starterkit_theme'; /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->createContentType([ 'type' => 'page', diff --git a/web/modules/views_infinite_scroll/views_infinite_scroll.info.yml b/web/modules/views_infinite_scroll/views_infinite_scroll.info.yml index 7ca3ca3bef1d6617cabac540c141aaf9ae6faa70..24734339290f54345be51a6ce8013971885c79d6 100644 --- a/web/modules/views_infinite_scroll/views_infinite_scroll.info.yml +++ b/web/modules/views_infinite_scroll/views_infinite_scroll.info.yml @@ -2,12 +2,12 @@ name: Views Infinite Scroll type: module description: A pager which allows an infinite scroll effect for views. package: Views -core_version_requirement: ^8.8 || ^9 +core_version_requirement: ^9.2 || ^10 dependencies: - drupal:views -# Information added by Drupal.org packaging script on 2021-09-23 -version: '8.x-1.9' +# Information added by Drupal.org packaging script on 2023-07-10 +version: '2.0.2' project: 'views_infinite_scroll' -datestamp: 1632421789 +datestamp: 1689001934 diff --git a/web/modules/views_infinite_scroll/views_infinite_scroll.libraries.yml b/web/modules/views_infinite_scroll/views_infinite_scroll.libraries.yml index 249790b406f2a115c977af5b39c1db1993e6b941..0dcb38adc27256f7467ff903c1b5bb41a618ed17 100644 --- a/web/modules/views_infinite_scroll/views_infinite_scroll.libraries.yml +++ b/web/modules/views_infinite_scroll/views_infinite_scroll.libraries.yml @@ -4,7 +4,7 @@ views-infinite-scroll: js/infinite-scroll.js : {} dependencies: - core/jquery - - core/jquery.once + - core/once - core/drupal - core/drupal.debounce - views/views.ajax diff --git a/web/modules/views_infinite_scroll/views_infinite_scroll.module b/web/modules/views_infinite_scroll/views_infinite_scroll.module index 1362c17e5f47ae402be5564748c7b05f1c5bfc73..b9782fedf0368bcbe952d05eb28e1ffd7faa7111 100644 --- a/web/modules/views_infinite_scroll/views_infinite_scroll.module +++ b/web/modules/views_infinite_scroll/views_infinite_scroll.module @@ -5,8 +5,9 @@ * Module file for views_infinite_scroll. */ -use Drupal\Core\Url; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Template\Attribute; +use Drupal\Core\Url; use Drupal\views_infinite_scroll\Plugin\views\pager\InfiniteScroll; /** @@ -54,10 +55,23 @@ function views_infinite_scroll_preprocess_views_view(&$vars) { } /** - * Implements hook_preprocess_eva_display_entity_view() + * Implements hook_preprocess_eva_display_entity_view(). */ function views_infinite_scroll_preprocess_eva_display_entity_view(&$vars) { // When the contributed EVA module is used to display the View, apply the // preprocessing logic of this module. views_infinite_scroll_preprocess_views_view($vars); } + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function views_infinite_scroll_form_view_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) { + $viewDisplay = $form_state->getFormObject()->getEntity()->getDisplay('default'); + if (isset($viewDisplay['display_options']['pager']['type']) && $viewDisplay['display_options']['pager']['type'] != 'infinite_scroll') { + return; + } + if (isset($viewDisplay['display_options']['use_ajax']) && $viewDisplay['display_options']['use_ajax'] === FALSE) { + \Drupal::messenger()->addWarning('AJAX is currently disabled, for this views default display. For the "Views Infinite Scroll" to work, this setting needs to be enabled!'); + } +}