| 1 |
import { render, useEffect } from '@wordpress/element'; |
| 2 |
import { withState } from '@wordpress/compose'; |
| 3 |
import domReady from '@wordpress/dom-ready'; |
| 4 |
|
| 5 |
import GutenifyCountDownBlock from './Block'; |
| 6 |
import attributesDefaults from './attributesDefaults' |
| 7 |
|
| 8 |
const Frontend = withState({ |
| 9 |
isCalenderVisible: false, |
| 10 |
isTimerStart: false, |
| 11 |
timerInterval: false, |
| 12 |
dateTime: new Date(), |
| 13 |
timerDays: '00', |
| 14 |
timerHour: '00', |
| 15 |
timerMinute: '00', |
| 16 |
timerSecond: '00', |
| 17 |
isExpired: false, |
| 18 |
hideTimer: false |
| 19 |
})((props) => { |
| 20 |
let attributes = { ...attributesDefaults, ...props.options }; |
| 21 |
|
| 22 |
useEffect(() => { |
| 23 |
// load Fonts |
| 24 |
if (attributes.digitAttrs.typography.fontFamily) { |
| 25 |
WebFont.load({ |
| 26 |
google: { |
| 27 |
families: [attributes.digitAttrs.typography.fontFamily] |
| 28 |
} |
| 29 |
}); |
| 30 |
} |
| 31 |
|
| 32 |
if (attributes.titleAttrs.typography.fontFamily) { |
| 33 |
WebFont.load({ |
| 34 |
google: { |
| 35 |
families: [attributes.titleAttrs.typography.fontFamily] |
| 36 |
} |
| 37 |
}); |
| 38 |
} |
| 39 |
}, []); |
| 40 |
|
| 41 |
return <> |
| 42 |
<GutenifyCountDownBlock {...props} attributes={attributes} screen="frontend" /> |
| 43 |
</>; |
| 44 |
}) |
| 45 |
domReady(function () { |
| 46 |
//do something after DOM loads. |
| 47 |
const allCountDown = document.getElementsByClassName('gutenify-google-maps-wrapper'); |
| 48 |
for (let i = 0; i < allCountDown.length; i++) { |
| 49 |
const id = allCountDown[i].getAttribute('id'); |
| 50 |
const options = window[id]; |
| 51 |
render(<Frontend options={options} id={id} />, document.getElementById(id)); |
| 52 |
} |
| 53 |
}); |
| 54 |
|