Update pages.html
Browse files- pages.html +46 -32
pages.html
CHANGED
|
@@ -836,41 +836,9 @@ editor.BlockManager.add('custom-countdown', {
|
|
| 836 |
</span>
|
| 837 |
<span data-js="countdown-endtext" class="countdown-endtext"></span>
|
| 838 |
</div>
|
| 839 |
-
<input type="text" id="blockIdInput" placeholder="Enter block ID to hide">
|
| 840 |
`,
|
| 841 |
attributes: {
|
| 842 |
class: 'fa fa-clock-o'
|
| 843 |
-
},
|
| 844 |
-
script: function() {
|
| 845 |
-
const blockIdInput = document.getElementById('blockIdInput');
|
| 846 |
-
const props = {
|
| 847 |
-
"ivtk": {
|
| 848 |
-
"startfrom": "",
|
| 849 |
-
"endText": "EXPIRED",
|
| 850 |
-
"blockId": blockIdInput ? blockIdInput.value : "" // ID блока, который нужно закрыть
|
| 851 |
-
}
|
| 852 |
-
};
|
| 853 |
-
|
| 854 |
-
const ids = Object.keys(props).map(id => `#${id}`).join(',');
|
| 855 |
-
const els = document.querySelectorAll(ids);
|
| 856 |
-
|
| 857 |
-
for (let i = 0, len = els.length; i < len; i++) {
|
| 858 |
-
const el = els[i];
|
| 859 |
-
(function(n) {
|
| 860 |
-
const t = n.startfrom, e = n.endText, blockId = n.blockId, o = this, a = new Date(t).getTime(), c = o.querySelector('[data-js=countdown]'), d = o.querySelector('[data-js=countdown-endtext]'), s = o.querySelector('[data-js=countdown-day]'), l = o.querySelector('[data-js=countdown-hour]'), i = o.querySelector('[data-js=countdown-minute]'), r = o.querySelector('[data-js=countdown-second]'), u = o.__gjsCountdownInterval;
|
| 861 |
-
u && clearInterval(u);
|
| 862 |
-
const p = window.__gjsCountdownIntervals || [], v = [];
|
| 863 |
-
p.forEach(n => n.isConnected || (clearInterval(n.__gjsCountdownInterval), v.push(n))), p.indexOf(o) < 0 && p.push(o), window.__gjsCountdownIntervals = p.filter(n => v.indexOf(n) < 0);
|
| 864 |
-
const y = (n, t, e, o) => {
|
| 865 |
-
s.innerHTML = `${n < 10 ? '0' + n : n}`, l.innerHTML = `${t < 10 ? '0' + t : t}`, i.innerHTML = `${e < 10 ? '0' + e : e}`, r.innerHTML = `${o < 10 ? '0' + o : o}`;
|
| 866 |
-
};
|
| 867 |
-
const f = () => {
|
| 868 |
-
const n = (new Date).getTime(), t = a - n, s = Math.floor(t / 864e5), l = Math.floor(t % 864e5 / 36e5), i = Math.floor(t % 36e5 / 6e4), r = Math.floor(t % 6e4 / 1e3);
|
| 869 |
-
y(s, l, i, r), t < 0 && (clearInterval(o.__gjsCountdownInterval), d.innerHTML = e, c.style.display = 'none', d.style.display = '', blockId && (document.getElementById(blockId).style.display = 'none'));
|
| 870 |
-
};
|
| 871 |
-
a ? (o.__gjsCountdownInterval = setInterval(f, 1e3), d.style.display = 'none', c.style.display = '', f()) : y(0, 0, 0, 0);
|
| 872 |
-
}).bind(el)(props[el.id]);
|
| 873 |
-
}
|
| 874 |
}
|
| 875 |
});
|
| 876 |
|
|
@@ -900,6 +868,52 @@ editor.CssComposer.addRules(`
|
|
| 900 |
`);
|
| 901 |
|
| 902 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 903 |
</script>
|
| 904 |
|
| 905 |
<script>
|
|
|
|
| 836 |
</span>
|
| 837 |
<span data-js="countdown-endtext" class="countdown-endtext"></span>
|
| 838 |
</div>
|
|
|
|
| 839 |
`,
|
| 840 |
attributes: {
|
| 841 |
class: 'fa fa-clock-o'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 842 |
}
|
| 843 |
});
|
| 844 |
|
|
|
|
| 868 |
`);
|
| 869 |
|
| 870 |
|
| 871 |
+
editor.Components.addType('custom-countdown', {
|
| 872 |
+
model: {
|
| 873 |
+
defaults: {
|
| 874 |
+
traits: [
|
| 875 |
+
{
|
| 876 |
+
type: 'date',
|
| 877 |
+
name: 'startfrom',
|
| 878 |
+
label: 'End Date',
|
| 879 |
+
changeProp: true
|
| 880 |
+
},
|
| 881 |
+
{
|
| 882 |
+
type: 'text',
|
| 883 |
+
name: 'blockId',
|
| 884 |
+
label: 'Block ID to Hide',
|
| 885 |
+
changeProp: true
|
| 886 |
+
}
|
| 887 |
+
],
|
| 888 |
+
script: function() {
|
| 889 |
+
const startfrom = this.get('startfrom');
|
| 890 |
+
const blockId = this.get('blockId');
|
| 891 |
+
const o = this.view.el;
|
| 892 |
+
const a = new Date(startfrom).getTime();
|
| 893 |
+
const c = o.querySelector('[data-js=countdown]');
|
| 894 |
+
const d = o.querySelector('[data-js=countdown-endtext]');
|
| 895 |
+
const s = o.querySelector('[data-js=countdown-day]');
|
| 896 |
+
const l = o.querySelector('[data-js=countdown-hour]');
|
| 897 |
+
const i = o.querySelector('[data-js=countdown-minute]');
|
| 898 |
+
const r = o.querySelector('[data-js=countdown-second]');
|
| 899 |
+
const u = o.__gjsCountdownInterval;
|
| 900 |
+
|
| 901 |
+
u && clearInterval(u);
|
| 902 |
+
const p = window.__gjsCountdownIntervals || [], v = [];
|
| 903 |
+
p.forEach(n => n.isConnected || (clearInterval(n.__gjsCountdownInterval), v.push(n))), p.indexOf(o) < 0 && p.push(o), window.__gjsCountdownIntervals = p.filter(n => v.indexOf(n) < 0);
|
| 904 |
+
const y = (n, t, e, o) => {
|
| 905 |
+
s.innerHTML = `${n < 10 ? '0' + n : n}`, l.innerHTML = `${t < 10 ? '0' + t : t}`, i.innerHTML = `${e < 10 ? '0' + e : e}`, r.innerHTML = `${o < 10 ? '0' + o : o}`;
|
| 906 |
+
};
|
| 907 |
+
const f = () => {
|
| 908 |
+
const n = (new Date).getTime(), t = a - n, s = Math.floor(t / 864e5), l = Math.floor(t % 864e5 / 36e5), i = Math.floor(t % 36e5 / 6e4), r = Math.floor(t % 6e4 / 1e3);
|
| 909 |
+
y(s, l, i, r), t < 0 && (clearInterval(o.__gjsCountdownInterval), d.innerHTML = 'EXPIRED', c.style.display = 'none', d.style.display = '', blockId && (document.getElementById(blockId).style.display = 'none'));
|
| 910 |
+
};
|
| 911 |
+
a ? (o.__gjsCountdownInterval = setInterval(f, 1e3), d.style.display = 'none', c.style.display = '', f()) : y(0, 0, 0, 0);
|
| 912 |
+
}
|
| 913 |
+
}
|
| 914 |
+
}
|
| 915 |
+
});
|
| 916 |
+
|
| 917 |
</script>
|
| 918 |
|
| 919 |
<script>
|