TweenMax.js
1 year ago
anime.js
1 year ago
flipster.js
1 year ago
headroom.js
1 year ago
iscroll.js
1 year ago
isotope.js
1 year ago
jquery-countdown.js
1 year ago
jquery-mousewheel.js
1 year ago
jquery-slimscroll.js
1 year ago
lottie.js
1 year ago
luxon.js
1 year ago
markerclusterer.js
1 year ago
modal.js
1 year ago
motionpath.js
1 year ago
pa-gsap.js
1 year ago
pa-scrolldir.js
1 year ago
premium-addons.js
1 year ago
premium-banner.js
1 year ago
premium-blog.js
1 year ago
premium-button.js
1 year ago
premium-carousel-widget.js
1 year ago
premium-contact-form.js
1 year ago
premium-countdown-timer.js
1 year ago
premium-counter.js
1 year ago
premium-dis-conditions.js
1 year ago
premium-dual-header.js
1 year ago
premium-eq-height.js
1 year ago
premium-fancy-text.js
1 year ago
premium-floating-effects.js
1 year ago
premium-global-tooltips.js
1 year ago
premium-icon-list.js
1 year ago
premium-image-button.js
1 year ago
premium-image-scroll.js
1 year ago
premium-img-gallery.js
1 year ago
premium-maps.js
1 year ago
premium-media-wheel.js
1 year ago
premium-mini-cart.js
1 year ago
premium-mobile-menu.js
1 year ago
premium-modal-box.js
1 year ago
premium-nav-menu.js
1 year ago
premium-notifications.js
1 year ago
premium-person.js
1 year ago
premium-pinterest-feed.js
1 year ago
premium-post-ticker.js
1 year ago
premium-progressbar.js
1 year ago
premium-search-form.js
1 year ago
premium-shape-divider.js
1 year ago
premium-svg-drawer.js
1 year ago
premium-tcloud.js
1 year ago
premium-testimonials.js
1 year ago
premium-textual-showcase.js
1 year ago
premium-tiktok-feed.js
1 year ago
premium-title.js
1 year ago
premium-video-box.js
1 year ago
premium-vscroll.js
1 year ago
premium-weather.js
1 year ago
premium-woo-categories.js
1 year ago
premium-woo-cta.js
1 year ago
premium-woo-products.js
1 year ago
premium-world-clock.js
1 year ago
premium-wrapper-link.js
1 year ago
prettyPhoto.js
1 year ago
scrollTrigger.js
1 year ago
slick.js
1 year ago
tooltipster.js
1 year ago
typed.js
1 year ago
universal-tilt.js
1 year ago
vticker.js
1 year ago
premium-countdown-timer.js
166 lines
| 1 | (function ($) { |
| 2 | |
| 3 | var PremiumCountDownHandler = function ($scope, $) { |
| 4 | |
| 5 | var $countDownElement = $scope.find(".premium-countdown"), |
| 6 | $countDown = $countDownElement.find('.countdown'), |
| 7 | settings = $countDownElement.data("settings"), |
| 8 | timerType = settings.timerType, |
| 9 | until = 'evergreen' === timerType ? settings.until.date.replace(/ /g, "T") : settings.until, |
| 10 | layout = '', |
| 11 | computedStyle = getComputedStyle($scope[0]); |
| 12 | |
| 13 | function escapeHTML(str) { |
| 14 | var map = { |
| 15 | '&': '&', |
| 16 | '<': '<', |
| 17 | '>': '>', |
| 18 | '"': '"', |
| 19 | "'": ''', |
| 20 | }; |
| 21 | |
| 22 | return str.replace(/[&<>"']/g, function (m) { return map[m]; }); |
| 23 | } |
| 24 | |
| 25 | if (settings.separator) { |
| 26 | settings.separator = escapeHTML(settings.separator); |
| 27 | } |
| 28 | |
| 29 | var currentDate = new Date().getTime(), |
| 30 | untilDate = new Date(until).getTime(); |
| 31 | |
| 32 | if ('' !== settings.serverSync) { |
| 33 | currentDate = new Date(settings.serverSync).getTime(); |
| 34 | } |
| 35 | |
| 36 | // Calculate the difference in seconds between the future and current date |
| 37 | var diff = Math.round(untilDate / 1000 - currentDate / 1000); |
| 38 | |
| 39 | if ('flipping' === settings.style) { |
| 40 | |
| 41 | var clock; |
| 42 | |
| 43 | // Run countdown timer |
| 44 | clock = $countDown.FlipClock(diff, { |
| 45 | clockFace: "DailyCounter", |
| 46 | countdown: true, |
| 47 | timeSeparator: settings.separator || '', |
| 48 | language: settings.lang, |
| 49 | callbacks: { |
| 50 | stop: function () { |
| 51 | |
| 52 | triggerExpirationAction(); |
| 53 | } |
| 54 | } |
| 55 | }); |
| 56 | |
| 57 | } else { |
| 58 | |
| 59 | // var single = settings.single.split(","), |
| 60 | // plural = settings.plural.split(","); |
| 61 | |
| 62 | $countDownElement.find('.countdown').countdown({ |
| 63 | $countDown: $countDown, |
| 64 | layout: layout, |
| 65 | // labels: single, |
| 66 | // labels1: plural, |
| 67 | until: diff, |
| 68 | format: settings.format, |
| 69 | style: settings.style, |
| 70 | timeSeparator: settings.separator || '', |
| 71 | unitsPos: settings.unitsPos, |
| 72 | id: $scope.data('id'), |
| 73 | circleStrokeWidth: computedStyle.getPropertyValue('--pa-countdown-stroke-width'), |
| 74 | unitsInside: $scope.hasClass('premium-countdown-uinside-yes'), |
| 75 | onExpiry: function () { |
| 76 | |
| 77 | triggerExpirationAction(); |
| 78 | |
| 79 | }, |
| 80 | }); |
| 81 | |
| 82 | //To unify digit unit width. |
| 83 | if ($scope.hasClass('premium-countdown-block')) { |
| 84 | var currentValueWidth = $countDown.find('.countdown-amount').last().outerWidth(); |
| 85 | |
| 86 | $countDown.find('.countdown-period span').css('width', currentValueWidth); |
| 87 | } |
| 88 | |
| 89 | //For evergreen timer reset. |
| 90 | if (settings.reset) { |
| 91 | $countDownElement.find('.premium-countdown-init').countdown('option', 'until', new Date(until)); |
| 92 | } |
| 93 | |
| 94 | if ('featured' === settings.style) { |
| 95 | var $targetUnit = $countDownElement.find('.countdown-section-' + settings.featuredUnit); |
| 96 | $targetUnit.parent().prepend($targetUnit); |
| 97 | } |
| 98 | |
| 99 | } |
| 100 | |
| 101 | if ('.' === settings.separator) { |
| 102 | $countDown.find('.countdown_separator span').addClass('countdown-separator-circle').text(''); |
| 103 | } |
| 104 | |
| 105 | if (diff < 0) |
| 106 | triggerExpirationAction(); |
| 107 | |
| 108 | function triggerExpirationAction() { |
| 109 | |
| 110 | if ('default' === settings.event && 'flipping' !== settings.style) { |
| 111 | setTimeout(function () { |
| 112 | if ('dash' === settings.changeTo) { |
| 113 | $countDown.find('.countdown-amount > span').text('-'); |
| 114 | } else if ('done' === settings.changeTo && $countDown.find('.countdown-show4').length > 0) { |
| 115 | var characters = ['D', 'O', 'N', 'E']; |
| 116 | |
| 117 | characters.map(function (char, index) { |
| 118 | $countDown.find('.countdown-amount > span').eq(index).text(char); |
| 119 | }); |
| 120 | |
| 121 | } |
| 122 | |
| 123 | }, 1000); |
| 124 | } else if ('text' === settings.event) { |
| 125 | $countDown.remove(); |
| 126 | $scope.find(".premium-addons__v-hidden").removeClass('premium-addons__v-hidden'); |
| 127 | } else if ('url' === settings.event && !elementorFrontend.isEditMode()) { |
| 128 | if ('' !== settings.text) { |
| 129 | var urlPattern = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.-]{2,})([\/\w \u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF%.-]*)*\/?$/i; |
| 130 | |
| 131 | // Test the string against the regular expression |
| 132 | if (urlPattern.test(settings.text)) |
| 133 | window.location.href = settings.text; |
| 134 | } |
| 135 | |
| 136 | } else if ('restart' === settings.event) { |
| 137 | |
| 138 | if ('flipping' === settings.style) { |
| 139 | setTimeout(function () { |
| 140 | clock.setTime(diff); // Restart with the same target seconds. |
| 141 | }, 1000); |
| 142 | |
| 143 | setTimeout(function () { |
| 144 | clock.start(); // Restart with the same target seconds. |
| 145 | }, 2000); |
| 146 | |
| 147 | } else { |
| 148 | setTimeout(function () { |
| 149 | $countDownElement.find('.premium-countdown-init').countdown('option', { until: diff }); |
| 150 | }, 1000); |
| 151 | } |
| 152 | |
| 153 | |
| 154 | } |
| 155 | |
| 156 | } |
| 157 | |
| 158 | |
| 159 | }; |
| 160 | |
| 161 | $(window).on('elementor/frontend/init', function () { |
| 162 | elementorFrontend.hooks.addAction('frontend/element_ready/premium-countdown-timer.default', PremiumCountDownHandler); |
| 163 | }); |
| 164 | })(jQuery); |
| 165 | |
| 166 |