| 1 |
(function(){ |
| 2 |
(function($, elementor) { |
| 3 |
"use strict"; |
| 4 |
var JLTMA_CountdownTimer = function($scope, $2) { |
| 5 |
var $countdownWidget = $scope.find(".jltma-widget-countdown"); |
| 6 |
$2.fn.MasterCountDownTimer = function() { |
| 7 |
var $wrapper = $2(this).find(".jltma-countdown-wrapper"), data = { |
| 8 |
year: $wrapper.data("countdown-year"), |
| 9 |
month: $wrapper.data("countdown-month"), |
| 10 |
day: $wrapper.data("countdown-day"), |
| 11 |
hour: $wrapper.data("countdown-hour"), |
| 12 |
min: $wrapper.data("countdown-min"), |
| 13 |
sec: $wrapper.data("countdown-sec") |
| 14 |
}, isInfinite = $wrapper.data("countdown-infinite") === "yes", targetDate = new Date(data.year, data.month, data.day, data.hour, data.min, data.sec); |
| 15 |
var $year = $wrapper.find(".jltma-countdown-year"), $month = $wrapper.find(".jltma-countdown-month"), $day = $wrapper.find(".jltma-countdown-day"), $hour = $wrapper.find(".jltma-countdown-hour"), $min = $wrapper.find(".jltma-countdown-min"), $sec = $wrapper.find(".jltma-countdown-sec"); |
| 16 |
var countdownInterval = setInterval(function() { |
| 17 |
var currentTime = /* @__PURE__ */ new Date(); |
| 18 |
var diffTime = (Date.parse(targetDate) - Date.parse(currentTime)) / 1e3; |
| 19 |
if (diffTime <= 0) { |
| 20 |
$year.text(0); |
| 21 |
$month.text(0); |
| 22 |
$day.text(0); |
| 23 |
$hour.text(0); |
| 24 |
$min.text(0); |
| 25 |
$sec.text(0); |
| 26 |
clearInterval(countdownInterval); |
| 27 |
return; |
| 28 |
} |
| 29 |
var totalSeconds = diffTime; |
| 30 |
var years = Math.floor(totalSeconds / 31536e3); |
| 31 |
totalSeconds %= 31536e3; |
| 32 |
var months = Math.floor(totalSeconds / 2592e3); |
| 33 |
totalSeconds %= 2592e3; |
| 34 |
var days = Math.floor(totalSeconds / 86400); |
| 35 |
totalSeconds %= 86400; |
| 36 |
var hours = Math.floor(totalSeconds / 3600); |
| 37 |
totalSeconds %= 3600; |
| 38 |
var minutes = Math.floor(totalSeconds / 60); |
| 39 |
var seconds = Math.floor(totalSeconds % 60); |
| 40 |
$year.text(years); |
| 41 |
$month.text(months); |
| 42 |
$day.text(days); |
| 43 |
$hour.text(hours); |
| 44 |
$min.text(minutes); |
| 45 |
$sec.text(seconds); |
| 46 |
}, 1e3); |
| 47 |
}; |
| 48 |
$countdownWidget.each(function() { |
| 49 |
$2(this).MasterCountDownTimer(); |
| 50 |
}); |
| 51 |
}; |
| 52 |
$(window).on("elementor/frontend/init", function() { |
| 53 |
elementorFrontend.hooks.addAction("frontend/element_ready/ma-el-countdown-timer.default", JLTMA_CountdownTimer); |
| 54 |
}); |
| 55 |
})(jQuery, window.elementorFrontend); |
| 56 |
})(); |
| 57 |
|