DmitrMakeev commited on
Commit
e196ce8
·
verified ·
1 Parent(s): fd7d580

Update pages.html

Browse files
Files changed (1) hide show
  1. pages.html +0 -148
pages.html CHANGED
@@ -785,90 +785,8 @@ editor.Blocks.add('video-player-settings-block', {
785
 
786
  </script>
787
 
788
- <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
 
867
 
868
-
869
-
870
- </script>
871
-
872
  <script>
873
 
874
 
@@ -892,73 +810,7 @@ editor.CssComposer.addRules(`
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>
 
785
 
786
  </script>
787
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
788
 
789
 
 
 
 
 
790
  <script>
791
 
792
 
 
810
  }
811
  `);
812
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
814
 
815
 
816
  </script>