1- <div class="pagination ">
2-
3- <div class="pagination-cursor">
4- <?php if ($ isFirst ):?>
5- <span <?= $ linkAttributes?> ><?= $ this ->prevPageLabel ?> </span>
6- <?php else : ?>
7- <a <?= $ linkAttributes?> href="<?= $ this ->pagination ->createUrl ($ page -1 );?> "><?= $ this ->prevPageLabel ?> </a>
8- <?php endif ?>
1+ <div data-pagination-scope>
2+ <div class="pagination ">
93
10- <?php foreach ($ this ->_buttonStack as $ key => $ btnPage ): ?>
11- <a <?= $ linkAttributes?> class="<?php if (($ page )==$ btnPage ):?> active<?php endif ?> " href="<?= $ this ->pagination ->createUrl ($ btnPage );?> "><?= $ btnPage?> </a>
12- <?php endforeach ?>
4+ <div class="pagination-cursor">
5+ <?php if ($ isFirst ):?>
6+ <span <?= $ linkAttributes?> ><?= $ this ->prevPageLabel ?> </span>
7+ <?php else : ?>
8+ <a <?= $ linkAttributes?> data-target="[data-pagination-content]" href="<?= $ this ->pagination ->createUrl ($ page -1 );?> "><?= $ this ->prevPageLabel ?> </a>
9+ <?php endif ?>
1310
14- <?php if ($ isLast ):?>
15- <span <?= $ linkAttributes?> ><?= $ this ->nextPageLabel ?> </span>
16- <?php else : ?>
17- <a <?= $ linkAttributes?> href="<?= $ this ->pagination ->createUrl ($ page +1 );?> "><?= $ this ->nextPageLabel ?> </a>
18- <?php endif ?>
11+ <?php foreach ($ this ->_buttonStack as $ key => $ btnPage ): ?>
12+ <a <?= $ linkAttributes?> data-target="[data-pagination-content]" class="<?php if (($ page )==$ btnPage ):?> active<?php endif ?> " href="<?= $ this ->pagination ->createUrl ($ btnPage );?> "><?= $ btnPage?> </a>
13+ <?php endforeach ?>
14+
15+ <?php if ($ isLast ):?>
16+ <span <?= $ linkAttributes?> ><?= $ this ->nextPageLabel ?> </span>
17+ <?php else : ?>
18+ <a <?= $ linkAttributes?> data-target="[data-pagination-content]" href="<?= $ this ->pagination ->createUrl ($ page +1 );?> "><?= $ this ->nextPageLabel ?> </a>
19+ <?php endif ?>
20+ </div>
21+
1922 </div>
23+ </div>
24+ <script>
25+ // Lightweight progressive AJAX for pagination (cursor view)
26+ (function(){
27+ if(window.__TAME_PAGINATION_INITED__) return;
28+ window.__TAME_PAGINATION_INITED__ = true;
29+
30+ function closestAnchor(el){
31+ while(el && el !== document){ if(el.tagName === 'A') return el; el = el.parentNode; }
32+ return null;
33+ }
34+
35+ document.addEventListener('click', function(e){
36+ var a = closestAnchor(e.target);
37+ if(!a) return;
38+ if(a.getAttribute('data-pagination') !== 'ajax') return;
39+ var href = a.getAttribute('href');
40+ if(!href) return;
41+ e.preventDefault();
42+
43+ var targetSelector = a.getAttribute('data-target') || '[data-pagination-content]';
44+ var scope = a.closest('[data-pagination-scope]');
45+ var container = document.querySelector(targetSelector);
46+ if(!container || !scope){ window.location.href = href; return; }
2047
21- </div>
48+ a.setAttribute('aria-busy', 'true');
49+ fetch(href, { headers: { 'X-Requested-With': 'XMLHttpRequest' }})
50+ .then(function(res){ return res.text(); })
51+ .then(function(html){
52+ var parser = new DOMParser();
53+ var doc = parser.parseFromString(html, 'text/html');
54+ var newContainer = doc.querySelector(targetSelector);
55+ var newScope = doc.querySelector('[data-pagination-scope]');
56+ if(!newContainer || !newScope){ window.location.href = href; return; }
57+ container.innerHTML = newContainer.innerHTML;
58+ scope.replaceWith(newScope);
59+ try { window.history.pushState({}, '', href); } catch(_e) {}
60+ })
61+ .catch(function(){ window.location.href = href; })
62+ .finally(function(){ a.removeAttribute('aria-busy'); });
63+ });
64+ })();
65+ </script>
0 commit comments