| 1 |
"use strict"; |
| 2 |
|
| 3 |
(function ($) { |
| 4 |
const shouldShowForDevice = (device) => { |
| 5 |
if (device === "all") return true; |
| 6 |
const isMobile = window.matchMedia("(max-width: 767px)").matches; |
| 7 |
if (device === "mobile") return isMobile; |
| 8 |
if (device === "desktop") return !isMobile; |
| 9 |
return true; |
| 10 |
}; |
| 11 |
|
| 12 |
const initPhoneCallButton = ($scope) => { |
| 13 |
const $btn = $scope.find(".king-addons-phone-call__button"); |
| 14 |
if (!$btn.length) return; |
| 15 |
|
| 16 |
const device = $btn.data("device") || "all"; |
| 17 |
if (!shouldShowForDevice(device)) { |
| 18 |
$btn.hide(); |
| 19 |
return; |
| 20 |
} |
| 21 |
}; |
| 22 |
|
| 23 |
$(window).on("elementor/frontend/init", function () { |
| 24 |
elementorFrontend.hooks.addAction( |
| 25 |
"frontend/element_ready/king-addons-phone-call-button.default", |
| 26 |
function ($scope) { |
| 27 |
initPhoneCallButton($scope); |
| 28 |
} |
| 29 |
); |
| 30 |
}); |
| 31 |
})(jQuery); |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|