11<div data-pagination-scope>
2+ <?php
3+ // Prepare variables in one scope
4+ $ page = $ this ->pagination ->page ;
5+ $ totalPages = $ this ->pagination ->pageCount ;
6+ $ isFirst = $ page <= 1 ;
7+ $ isLast = $ page >= $ totalPages ;
8+ $ prevPage = max (1 , $ page - 1 );
9+ $ nextPage = min ($ totalPages , $ page + 1 );
10+ $ firstUrl = $ this ->pagination ->createUrl (1 );
11+ $ prevUrl = $ this ->pagination ->createUrl ($ prevPage );
12+ $ nextUrl = $ this ->pagination ->createUrl ($ nextPage );
13+ $ lastUrl = $ this ->pagination ->createUrl ($ totalPages );
14+ ?>
215 <div class="pagination ">
316
417 <div class="pagination-cursor">
518 <?php if ($ isFirst ):?>
619 <span <?= $ linkAttributes?> ><?= $ this ->prevPageLabel ?> </span>
720 <?php else : ?>
8- <a <?= $ linkAttributes?> data-target="[data-pagination-content]" href="<?= $ this -> pagination -> createUrl ( $ page - 1 ); ?> "><?= $ this ->prevPageLabel ?> </a>
21+ <a <?= $ linkAttributes?> data-target="[data-pagination-content]" href="<?= $ prevUrl ?> "><?= $ this ->prevPageLabel ?> </a>
922 <?php endif ?>
1023
1124 <?php foreach ($ this ->_buttonStack as $ key => $ btnPage ): ?>
1528 <?php if ($ isLast ):?>
1629 <span <?= $ linkAttributes?> ><?= $ this ->nextPageLabel ?> </span>
1730 <?php else : ?>
18- <a <?= $ linkAttributes?> data-target="[data-pagination-content]" href="<?= $ this -> pagination -> createUrl ( $ page + 1 ); ?> "><?= $ this ->nextPageLabel ?> </a>
31+ <a <?= $ linkAttributes?> data-target="[data-pagination-content]" href="<?= $ nextUrl ?> "><?= $ this ->nextPageLabel ?> </a>
1932 <?php endif ?>
2033 </div>
2134
2437<script>
2538// Lightweight progressive AJAX for pagination (cursor view)
2639(function(){
27- if(window.__TAME_PAGINATION_INITED__ ) return;
28- window.__TAME_PAGINATION_INITED__ = true;
40+ if(window.__TAME_PAGINATION_CURSOR_INITED__ ) return; // Guard for cursor view only
41+ window.__TAME_PAGINATION_CURSOR_INITED__ = true;
2942
3043 function closestAnchor(el){
3144 while(el && el !== document){ if(el.tagName === 'A') return el; el = el.parentNode; }
@@ -36,8 +49,11 @@ function closestAnchor(el){
3649 var a = closestAnchor(e.target);
3750 if(!a) return;
3851 if(a.getAttribute('data-pagination') !== 'ajax') return;
52+
3953 var href = a.getAttribute('href');
4054 if(!href) return;
55+
56+ // Prevent default only for our ajax link
4157 e.preventDefault();
4258
4359 var targetSelector = a.getAttribute('data-target') || '[data-pagination-content]';
0 commit comments