Update pages.html
Browse files- pages.html +132 -105
pages.html
CHANGED
@@ -789,117 +789,78 @@ editor.Blocks.add('video-player-settings-block', {
|
|
789 |
|
790 |
|
791 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
792 |
|
|
|
|
|
|
|
|
|
|
|
793 |
|
|
|
|
|
|
|
794 |
|
795 |
-
|
796 |
-
|
797 |
-
content: `
|
798 |
-
<style>
|
799 |
-
.countdown {
|
800 |
-
text-align: center;
|
801 |
-
}
|
802 |
-
.countdown-block {
|
803 |
-
display: inline-block;
|
804 |
-
margin: 0 10px;
|
805 |
-
padding: 10px;
|
806 |
-
}
|
807 |
-
.countdown-digit {
|
808 |
-
font-size: 5rem;
|
809 |
-
}
|
810 |
-
.countdown-endtext {
|
811 |
-
font-size: 5rem;
|
812 |
-
}
|
813 |
-
.countdown-cont {
|
814 |
-
display: inline-block;
|
815 |
-
}
|
816 |
-
</style>
|
817 |
-
|
818 |
-
<div id="ivtk" class="countdown">
|
819 |
-
<span data-js="countdown" class="countdown-cont">
|
820 |
-
<div class="countdown-block">
|
821 |
-
<div data-js="countdown-day" class="countdown-digit">00</div>
|
822 |
-
<div class="countdown-label">days</div>
|
823 |
-
</div>
|
824 |
-
<div class="countdown-block">
|
825 |
-
<div data-js="countdown-hour" class="countdown-digit">00</div>
|
826 |
-
<div class="countdown-label">hours</div>
|
827 |
-
</div>
|
828 |
-
<div class="countdown-block">
|
829 |
-
<div data-js="countdown-minute" class="countdown-digit">00</div>
|
830 |
-
<div class="countdown-label">minutes</div>
|
831 |
-
</div>
|
832 |
-
<div class="countdown-block">
|
833 |
-
<div data-js="countdown-second" class="countdown-digit">00</div>
|
834 |
-
<div class="countdown-label">seconds</div>
|
835 |
-
</div>
|
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 |
-
|
845 |
-
// Добавляем компонент custom-countdown
|
846 |
-
editor.Components.addType('custom-countdown', {
|
847 |
-
model: {
|
848 |
-
defaults: {
|
849 |
-
traits: [
|
850 |
-
{
|
851 |
-
type: 'text', // Заменен тип 'date' на 'text'
|
852 |
-
name: 'startfrom',
|
853 |
-
label: 'End Date (YYYY-MM-DD)',
|
854 |
-
placeholder: 'YYYY-MM-DD', // Добавлено пояснение
|
855 |
-
changeProp: true
|
856 |
-
},
|
857 |
-
{
|
858 |
-
type: 'text',
|
859 |
-
name: 'blockId',
|
860 |
-
label: 'Block ID to Hide',
|
861 |
-
changeProp: true
|
862 |
}
|
863 |
-
],
|
864 |
-
script: function() {
|
865 |
-
const startfrom = this.get('startfrom');
|
866 |
-
const blockId = this.get('blockId');
|
867 |
-
const o = this.view.el;
|
868 |
-
const a = new Date(startfrom).getTime();
|
869 |
-
const c = o.querySelector('[data-js=countdown]');
|
870 |
-
const d = o.querySelector('[data-js=countdown-endtext]');
|
871 |
-
const s = o.querySelector('[data-js=countdown-day]');
|
872 |
-
const l = o.querySelector('[data-js=countdown-hour]');
|
873 |
-
const i = o.querySelector('[data-js=countdown-minute]');
|
874 |
-
const r = o.querySelector('[data-js=countdown-second]');
|
875 |
-
const u = o.__gjsCountdownInterval;
|
876 |
-
u && clearInterval(u);
|
877 |
-
const p = window.__gjsCountdownIntervals || [], v = [];
|
878 |
-
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);
|
879 |
-
const y = (n, t, e, o) => {
|
880 |
-
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}`;
|
881 |
-
};
|
882 |
-
const f = () => {
|
883 |
-
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);
|
884 |
-
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'));
|
885 |
-
};
|
886 |
-
a ? (o.__gjsCountdownInterval = setInterval(f, 1e3), d.style.display = 'none', c.style.display = '', f()) : y(0, 0, 0, 0);
|
887 |
-
}
|
888 |
-
}
|
889 |
-
}
|
890 |
-
});
|
891 |
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
blockId: ''
|
899 |
},
|
900 |
-
attributes: {
|
901 |
-
class: 'fa fa-clock-o'
|
902 |
-
}
|
903 |
});
|
904 |
|
905 |
|
@@ -931,7 +892,73 @@ editor.CssComposer.addRules(`
|
|
931 |
}
|
932 |
`);
|
933 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
934 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
935 |
|
936 |
|
937 |
</script>
|
|
|
789 |
|
790 |
|
791 |
|
792 |
+
editor.Components.addType(id, {
|
793 |
+
model: {
|
794 |
+
defaults: {
|
795 |
+
startfrom: options.startTime,
|
796 |
+
classes: [pfx],
|
797 |
+
endText: options.endText,
|
798 |
+
blockId: '', // Добавьте поле для ID блока
|
799 |
+
droppable: false,
|
800 |
+
script: coundownScript,
|
801 |
+
'script-props': ['startfrom', 'endText', 'blockId'], // Добавьте blockId в скрипт-пропсы
|
802 |
+
traits: [{
|
803 |
+
label: 'Start',
|
804 |
+
name: 'startfrom',
|
805 |
+
changeProp: true,
|
806 |
+
type: options.dateInputType,
|
807 |
+
},{
|
808 |
+
label: 'End text',
|
809 |
+
name: 'endText',
|
810 |
+
changeProp: true,
|
811 |
+
},{
|
812 |
+
label: 'Block ID to Hide',
|
813 |
+
name: 'blockId',
|
814 |
+
changeProp: true,
|
815 |
+
}],
|
816 |
+
// @ts-ignore
|
817 |
+
components: `
|
818 |
+
<span data-js="countdown" class="${pfx}-cont">
|
819 |
+
<div class="${pfx}-block">
|
820 |
+
<div data-js="countdown-day" class="${pfx}-digit"></div>
|
821 |
+
<div class="${pfx}-label">${options.labelDays}</div>
|
822 |
+
</div>
|
823 |
+
<div class="${pfx}-block">
|
824 |
+
<div data-js="countdown-hour" class="${pfx}-digit"></div>
|
825 |
+
<div class="${pfx}-label">${options.labelHours}</div>
|
826 |
+
</div>
|
827 |
+
<div class="${pfx}-block">
|
828 |
+
<div data-js="countdown-minute" class="${pfx}-digit"></div>
|
829 |
+
<div class="${pfx}-label">${options.labelMinutes}</div>
|
830 |
+
</div>
|
831 |
+
<div class="${pfx}-block">
|
832 |
+
<div data-js="countdown-second" class="${pfx}-digit"></div>
|
833 |
+
<div class="${pfx}-label">${options.labelSeconds}</div>
|
834 |
+
</div>
|
835 |
+
</span>
|
836 |
+
<span data-js="countdown-endtext" class="${pfx}-endtext"></span>
|
837 |
+
`,
|
838 |
+
styles: (style || `
|
839 |
+
.${pfx} {
|
840 |
+
text-align: center;
|
841 |
+
}
|
842 |
|
843 |
+
.${pfx}-block {
|
844 |
+
display: inline-block;
|
845 |
+
margin: 0 10px;
|
846 |
+
padding: 10px;
|
847 |
+
}
|
848 |
|
849 |
+
.${pfx}-digit {
|
850 |
+
font-size: 5rem;
|
851 |
+
}
|
852 |
|
853 |
+
.${pfx}-endtext {
|
854 |
+
font-size: 5rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
855 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
856 |
|
857 |
+
.${pfx}-cont {
|
858 |
+
display: inline-block;
|
859 |
+
}
|
860 |
+
`) + (options.styleAdditional),
|
861 |
+
...props,
|
862 |
+
},
|
|
|
863 |
},
|
|
|
|
|
|
|
864 |
});
|
865 |
|
866 |
|
|
|
892 |
}
|
893 |
`);
|
894 |
|
895 |
+
const coundownScript = function(props: Record<string, any>) {
|
896 |
+
const startfrom: string = props.startfrom;
|
897 |
+
const endTxt: string = props.endText;
|
898 |
+
const blockId: string = props.blockId; // Получите ID блока для скрытия
|
899 |
+
// @ts-ignore
|
900 |
+
const el: TElement = this;
|
901 |
+
const countDownDate = new Date(startfrom).getTime();
|
902 |
+
const countdownEl = el.querySelector('[data-js=countdown]') as HTMLElement;
|
903 |
+
const endTextEl = el.querySelector('[data-js=countdown-endtext]') as HTMLElement;
|
904 |
+
const dayEl = el.querySelector('[data-js=countdown-day]')!;
|
905 |
+
const hourEl = el.querySelector('[data-js=countdown-hour]')!;
|
906 |
+
const minuteEl = el.querySelector('[data-js=countdown-minute]')!;
|
907 |
+
const secondEl = el.querySelector('[data-js=countdown-second]')!;
|
908 |
+
const oldInterval = el.__gjsCountdownInterval;
|
909 |
+
oldInterval && clearInterval(oldInterval);
|
910 |
+
|
911 |
+
const connected: TElement[] = window.__gjsCountdownIntervals || [];
|
912 |
+
const toClean: TElement[] = [];
|
913 |
+
connected.forEach((item: TElement) => {
|
914 |
+
if (!item.isConnected) {
|
915 |
+
clearInterval(item.__gjsCountdownInterval);
|
916 |
+
toClean.push(item);
|
917 |
+
}
|
918 |
+
});
|
919 |
+
connected.indexOf(el) < 0 && connected.push(el);
|
920 |
+
window.__gjsCountdownIntervals = connected.filter(item => toClean.indexOf(item) < 0);
|
921 |
+
|
922 |
+
const setTimer = function (days: number, hours: number, minutes: number, seconds: number) {
|
923 |
+
dayEl.innerHTML = `${days < 10 ? '0' + days : days}`;
|
924 |
+
hourEl.innerHTML = `${hours < 10 ? '0' + hours : hours}`;
|
925 |
+
minuteEl.innerHTML = `${minutes < 10 ? '0' + minutes : minutes}`;
|
926 |
+
secondEl.innerHTML = `${seconds < 10 ? '0' + seconds : seconds}`;
|
927 |
+
}
|
928 |
|
929 |
+
const moveTimer = function() {
|
930 |
+
const now = new Date().getTime();
|
931 |
+
const distance = countDownDate - now;
|
932 |
+
const days = Math.floor(distance / 86400000);
|
933 |
+
const hours = Math.floor((distance % 86400000) / 3600000);
|
934 |
+
const minutes = Math.floor((distance % 3600000) / 60000);
|
935 |
+
const seconds = Math.floor((distance % 60000) / 1000);
|
936 |
+
|
937 |
+
setTimer(days, hours, minutes, seconds);
|
938 |
+
|
939 |
+
if (distance < 0) {
|
940 |
+
clearInterval(el.__gjsCountdownInterval);
|
941 |
+
endTextEl.innerHTML = endTxt;
|
942 |
+
countdownEl.style.display = 'none';
|
943 |
+
endTextEl.style.display = '';
|
944 |
+
if (blockId) {
|
945 |
+
const blockToHide = document.getElementById(blockId);
|
946 |
+
if (blockToHide) {
|
947 |
+
blockToHide.style.display = 'none';
|
948 |
+
}
|
949 |
+
}
|
950 |
+
}
|
951 |
+
};
|
952 |
+
|
953 |
+
if (countDownDate) {
|
954 |
+
el.__gjsCountdownInterval = setInterval(moveTimer, 1000);
|
955 |
+
endTextEl.style.display = 'none';
|
956 |
+
countdownEl.style.display = '';
|
957 |
+
moveTimer();
|
958 |
+
} else {
|
959 |
+
setTimer(0, 0, 0, 0);
|
960 |
+
}
|
961 |
+
};
|
962 |
|
963 |
|
964 |
</script>
|