nodebb-plugin-ezoic-infinite 1.6.25 → 1.6.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/client.js +40 -42
- package/public/style.css +8 -9
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
function
|
|
4
|
+
function ezoicInsertAfterTopicHost(target, wrap, kindClass) {
|
|
5
5
|
try {
|
|
6
|
-
if (!
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
6
|
+
if (!target || !wrap) return false;
|
|
7
|
+
if (kindClass !== 'ezoic-ad-between') return false;
|
|
8
|
+
|
|
9
|
+
// Ensure we insert a LI host that looks like a topic item so NodeBB list virtualization keeps ordering.
|
|
10
|
+
var anchorLi = target.closest ? (target.closest('li[component="category/topic"]') || target.closest('li')) : null;
|
|
11
|
+
if (!anchorLi && target.tagName === 'LI') anchorLi = target;
|
|
12
|
+
if (!anchorLi) return false;
|
|
13
|
+
|
|
14
|
+
var ul = anchorLi.parentElement;
|
|
15
|
+
if (!ul || !(ul.tagName === 'UL' || ul.tagName === 'OL')) return false;
|
|
16
|
+
|
|
17
|
+
// If wrap already hosted, do nothing
|
|
18
|
+
var existingHost = wrap.closest ? wrap.closest('li.nodebb-ezoic-host') : null;
|
|
19
|
+
if (existingHost) return true;
|
|
20
|
+
|
|
21
|
+
var host = document.createElement('li');
|
|
22
|
+
host.className = 'nodebb-ezoic-host';
|
|
23
|
+
// mimic topic list item so NodeBB doesn't relocate it
|
|
24
|
+
host.setAttribute('component', 'category/topic');
|
|
25
|
+
host.setAttribute('data-ezoic-host', 'between');
|
|
26
|
+
host.style.listStyle = 'none';
|
|
27
|
+
host.style.width = '100%';
|
|
28
|
+
|
|
29
|
+
// Insert host after anchorLi
|
|
30
|
+
if (anchorLi.insertAdjacentElement) anchorLi.insertAdjacentElement('afterend', host);
|
|
31
|
+
else ul.insertBefore(host, anchorLi.nextSibling);
|
|
32
|
+
|
|
33
|
+
host.appendChild(wrap);
|
|
34
|
+
try { wrap.style.width = '100%'; } catch (e) {}
|
|
34
35
|
return true;
|
|
35
36
|
} catch (e) {}
|
|
36
37
|
return false;
|
|
@@ -704,9 +705,7 @@ function globalGapFixInit() {
|
|
|
704
705
|
insertingIds.add(id);
|
|
705
706
|
try {
|
|
706
707
|
const wrap = buildWrap(id, kindClass, afterPos, !existingPh);
|
|
707
|
-
if (
|
|
708
|
-
if (ezoicPlaceBetweenInLi(target, wrap)) return;
|
|
709
|
-
}
|
|
708
|
+
if (ezoicInsertAfterTopicHost(target, wrap, kindClass)) return;
|
|
710
709
|
target.insertAdjacentElement('afterend', wrap);
|
|
711
710
|
|
|
712
711
|
// If placeholder exists elsewhere (including pool), move it into the wrapper.
|
|
@@ -1199,9 +1198,7 @@ function buildOrdinalMap(items) {
|
|
|
1199
1198
|
if (!anchorEl || !wrap || !wrap.isConnected) return null;
|
|
1200
1199
|
|
|
1201
1200
|
wrap.setAttribute('data-ezoic-after', String(afterPos));
|
|
1202
|
-
if (
|
|
1203
|
-
if (ezoicPlaceBetweenInLi(anchorEl, wrap)) return;
|
|
1204
|
-
}
|
|
1201
|
+
if (ezoicInsertAfterTopicHost(anchorEl, wrap, kindClass)) return;
|
|
1205
1202
|
anchorEl.insertAdjacentElement('afterend', wrap);
|
|
1206
1203
|
|
|
1207
1204
|
// Ensure minimal layout impact.
|
|
@@ -1553,26 +1550,27 @@ function buildOrdinalMap(items) {
|
|
|
1553
1550
|
|
|
1554
1551
|
|
|
1555
1552
|
|
|
1556
|
-
// =====
|
|
1557
|
-
function
|
|
1553
|
+
// ===== V16 repair invalid UL children (between) =====
|
|
1554
|
+
function ezoicRepairBetweenHosts() {
|
|
1558
1555
|
try {
|
|
1559
1556
|
var bad = document.querySelectorAll('ul > div.nodebb-ezoic-wrap.ezoic-ad-between, ol > div.nodebb-ezoic-wrap.ezoic-ad-between');
|
|
1560
1557
|
bad.forEach(function(wrap){
|
|
1561
1558
|
try {
|
|
1562
1559
|
var prev = wrap.previousElementSibling;
|
|
1563
|
-
if (prev)
|
|
1560
|
+
if (!prev) return;
|
|
1561
|
+
ezoicInsertAfterTopicHost(prev, wrap, 'ezoic-ad-between');
|
|
1564
1562
|
} catch (e) {}
|
|
1565
1563
|
});
|
|
1566
1564
|
} catch (e) {}
|
|
1567
1565
|
}
|
|
1568
|
-
try {
|
|
1566
|
+
try { ezoicRepairBetweenHosts(); } catch (e) {}
|
|
1569
1567
|
if (window.jQuery) {
|
|
1570
1568
|
try {
|
|
1571
1569
|
window.jQuery(window).on('action:ajaxify.end action:infiniteScroll.loaded', function(){
|
|
1572
|
-
setTimeout(function(){ try {
|
|
1573
|
-
setTimeout(function(){ try {
|
|
1570
|
+
setTimeout(function(){ try { ezoicRepairBetweenHosts(); } catch(e) {} }, 0);
|
|
1571
|
+
setTimeout(function(){ try { ezoicRepairBetweenHosts(); } catch(e) {} }, 250);
|
|
1574
1572
|
});
|
|
1575
1573
|
} catch (e) {}
|
|
1576
1574
|
}
|
|
1577
|
-
// ===== /
|
|
1575
|
+
// ===== /V16 =====
|
|
1578
1576
|
|
package/public/style.css
CHANGED
|
@@ -81,15 +81,14 @@
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
/* =====
|
|
85
|
-
li
|
|
86
|
-
|
|
87
|
-
width:
|
|
88
|
-
margin-top: 12px;
|
|
89
|
-
margin-bottom: 12px;
|
|
84
|
+
/* ===== V16 host topic li ===== */
|
|
85
|
+
li.nodebb-ezoic-host[component="category/topic"]{
|
|
86
|
+
list-style:none;
|
|
87
|
+
width:100%;
|
|
90
88
|
}
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
/* ensure host doesn't inherit topic card layout */
|
|
90
|
+
li.nodebb-ezoic-host[component="category/topic"] > .nodebb-ezoic-wrap.ezoic-ad-between{
|
|
91
|
+
width:100%;
|
|
93
92
|
}
|
|
94
|
-
/* ===== /
|
|
93
|
+
/* ===== /V16 ===== */
|
|
95
94
|
|