Created
November 8, 2017 14:57
-
-
Save AntMooreWebDev/c5508f10e7bc5a9021ca6eadfeeaabe9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .countdown-container { | |
| background-image: url(''); | |
| background-size: cover; | |
| background-repeat: no-repeat; | |
| margin: 20px 0px; | |
| background-position: center; | |
| } | |
| .countdown-container > #clockdiv .days, | |
| .countdown-container > #clockdiv .hours, | |
| .countdown-container > #clockdiv .minutes, | |
| .countdown-container > #clockdiv .seconds { | |
| display: inline-block; | |
| line-height: 1; | |
| padding-top: 8px; | |
| background-color: #1e0576; | |
| font-size: 95px; | |
| text-align: center; | |
| width: 150px; | |
| color: #ffffff; | |
| font-weight: 600; | |
| padding-bottom: 8px; | |
| margin-bottom: 2px; | |
| } | |
| .countdown-header { | |
| text-align: center; | |
| padding-top: 25px; | |
| color: #fff; | |
| font-size: 45px; | |
| text-transform: uppercase; | |
| font-weight: 600; | |
| line-height: 1; | |
| text-shadow: 1px 3px 15px rgba(0,0,0,0.5); | |
| } | |
| #clockdiv { | |
| display: table; | |
| margin: 10px auto; | |
| min-height: 140px; | |
| opacity: 0; | |
| transition: opacity .5s; | |
| } | |
| #clockdiv > div { | |
| display: inline-block; | |
| margin-right: 5px; | |
| } | |
| .smalltext { | |
| color: #fff; | |
| text-transform: uppercase; | |
| font-size: 18px; | |
| font-weight: 600; | |
| text-shadow: 1px 1px 15px rgba(0,0,0,0.5); | |
| } | |
| .countdown-link { | |
| text-align: center; | |
| padding-bottom: 20px; | |
| } | |
| .countdown-link a { | |
| color: #fff !important; | |
| font-size: 18px; | |
| font-weight: 600; | |
| text-shadow: 1px 1px 15px rgba(0,0,0,0.5); | |
| } | |
| @media(max-width:767px){ | |
| #clockdiv{ | |
| min-height: unset; | |
| } | |
| .countdown-container > #clockdiv .days, .countdown-container > #clockdiv .hours, .countdown-container > #clockdiv .minutes, .countdown-container > #clockdiv .seconds{ | |
| font-size: 50px; | |
| width: 100px; | |
| } | |
| } | |
| @media(max-width:470px){ | |
| .countdown-container > #clockdiv .days, .countdown-container > #clockdiv .hours, .countdown-container > #clockdiv .minutes, .countdown-container > #clockdiv .seconds{ | |
| font-size: 40px; | |
| width: 65px; | |
| } | |
| .countdown-link{ | |
| padding: 0 20px 20px; | |
| } | |
| .smalltext{ | |
| font-size:16px; | |
| } | |
| } | |
| @media(max-width:335px){ | |
| .countdown-container > #clockdiv .days, .countdown-container > #clockdiv .hours, .countdown-container > #clockdiv .minutes, .countdown-container > #clockdiv .seconds{ | |
| font-size: 30px; | |
| width: 50px; | |
| } | |
| .smalltext{ | |
| font-size:12px; | |
| } | |
| .countdown-header { | |
| font-size: 40px; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="row"> | |
| <div class="col-md-12"> | |
| <div class="countdown-container"> | |
| <div class="countdown-header"> | |
| {{CmsWidgetOption:Header}} | |
| </div> | |
| <div id="clockdiv"> | |
| <div> | |
| <span class="days"></span> | |
| <div class="smalltext">Days</div> | |
| </div> | |
| <div> | |
| <span class="hours"></span> | |
| <div class="smalltext">Hours</div> | |
| </div> | |
| <div> | |
| <span class="minutes"></span> | |
| <div class="smalltext">Minutes</div> | |
| </div> | |
| <div> | |
| <span class="seconds"></span> | |
| <div class="smalltext">Seconds</div> | |
| </div> | |
| </div> | |
| <div class="countdown-link"> | |
| <a href="{{CmsWidgetOption:linkUrl}}"> | |
| {{CmsWidgetOption:linkText}} | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require(['modules/config.min'], function () { | |
| require(['lib/jquery-1.12.0.min', 'lib/moment.min'], function (jQuery, moment) { | |
| $(document).ready(function () { | |
| function getMomentTimeRemaining(endtime) { | |
| var parsedEndTime = moment(endtime); | |
| var currentTime = moment(); | |
| var duration = moment.duration(parsedEndTime.diff(currentTime)); | |
| var seconds = duration.seconds(); | |
| var minutes = duration.minutes(); | |
| var hours = duration.hours(); | |
| var days = duration.days(); | |
| return { | |
| 'total': duration, | |
| 'days': days, | |
| 'hours': hours, | |
| 'minutes': minutes, | |
| 'seconds': seconds | |
| }; | |
| } | |
| function getTimeRemaining(endtime) { | |
| var t = Date.parse(endtime) - Date.parse(new Date()); | |
| var seconds = Math.floor((t / 1000) % 60); | |
| var minutes = Math.floor((t / 1000 / 60) % 60); | |
| var hours = Math.floor((t / (1000 * 60 * 60)) % 24); | |
| var days = Math.floor(t / (1000 * 60 * 60 * 24)); | |
| return { | |
| 'total': t, | |
| 'days': days, | |
| 'hours': hours, | |
| 'minutes': minutes, | |
| 'seconds': seconds | |
| }; | |
| } | |
| function initializeClock(id, endtime, callback) { | |
| var clock = document.getElementById(id); | |
| var daysSpan = clock.querySelector('.days'); | |
| var hoursSpan = clock.querySelector('.hours'); | |
| var minutesSpan = clock.querySelector('.minutes'); | |
| var secondsSpan = clock.querySelector('.seconds'); | |
| function updateClock() { | |
| //var t = getTimeRemaining(endtime); | |
| var t = getMomentTimeRemaining(endtime); | |
| daysSpan.innerHTML = t.days; | |
| hoursSpan.innerHTML = ('0' + t.hours).slice(-2); | |
| minutesSpan.innerHTML = ('0' + t.minutes).slice(-2); | |
| secondsSpan.innerHTML = ('0' + t.seconds).slice(-2); | |
| if (t.total <= 0) { | |
| clearInterval(timeinterval); | |
| clock.style.display = 'none'; | |
| } | |
| callback(); | |
| } | |
| updateClock(); | |
| var timeinterval = setInterval(updateClock, 1000); | |
| } | |
| var deadline = '2017-11-01 08:00:00'; | |
| //var timeInMinutes = 1; | |
| //var currentTime = Date.parse(new Date()); | |
| //var deadline = new Date(currentTime + timeInMinutes * 60 * 1000); | |
| initializeClock('clockdiv', deadline, function () { | |
| document.getElementById("clockdiv").style.opacity = "1"; | |
| }); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment