| 1 |
// noinspection SpellCheckingInspection |
| 2 |
|
| 3 |
"use strict"; |
| 4 |
(function ($) { |
| 5 |
$(window).on('elementor/frontend/init', function () { |
| 6 |
let KngParallaxBackgroundHandler = elementorModules.frontend.handlers.Base.extend({ |
| 7 |
onInit: function onInit() { |
| 8 |
if (this.$element.hasClass('kng-parallax-bg-yes')) { |
| 9 |
this.applyKngParallaxBackground(); |
| 10 |
} |
| 11 |
}, |
| 12 |
getReadySettings: function getReadySettings() { |
| 13 |
let settings = { |
| 14 |
kng_parallax_bg_image: this.getElementSettings('kng_parallax_bg_image'), |
| 15 |
kng_parallax_bg_speed: this.getElementSettings('kng_parallax_bg_speed'), |
| 16 |
kng_parallax_bg_type: this.getElementSettings('kng_parallax_bg_type') |
| 17 |
}; |
| 18 |
return $.extend({}, settings); |
| 19 |
}, |
| 20 |
onElementChange: function onElementChange() { |
| 21 |
if (this.$element.hasClass('kng-parallax-bg-yes')) { |
| 22 |
if (!this.$element.hasClass('kng-parallax-bg-applied')) { |
| 23 |
this.applyKngParallaxBackground(); |
| 24 |
} |
| 25 |
} |
| 26 |
}, |
| 27 |
applyKngParallaxBackground: function applyKngParallaxBackground() { |
| 28 |
let options = this.getReadySettings(); |
| 29 |
let element_ID = this.$element.data('id'); |
| 30 |
this.$element.addClass('kng-parallax-bg-applied'); |
| 31 |
this.$element.before('<style>.king-addons-parallax-container {position: absolute;top: 0;left: 0;width: 100%;height: 100%;z-index: -100 !important;} .jarallax div {will-change: transform;}</style>'); |
| 32 |
this.$element.before('<style>.kng-parallax-bg-yes {background-image: none !important;} section:not(.kng-parallax-bg-yes) .king-addons-parallax-container {display: none;}</style>'); |
| 33 |
this.$element.append('<div data-jarallax data-speed="' + options.kng_parallax_bg_speed + '" data-type="' + options.kng_parallax_bg_type + '" class="jarallax king-addons-parallax-container ' + 'kng-parallax-bg-' + element_ID + '" style="background-image: url(' + options.kng_parallax_bg_image.url + ');"></div>'); |
| 34 |
this.$element.after('<script>jarallax(document.querySelectorAll(".kng-parallax-bg-' + element_ID + '"), {});</script>'); |
| 35 |
} |
| 36 |
}); |
| 37 |
|
| 38 |
elementorFrontend.hooks.addAction('frontend/element_ready/global', function ($scope) { |
| 39 |
elementorFrontend.elementsHandler.addHandler(KngParallaxBackgroundHandler, { |
| 40 |
$element: $scope |
| 41 |
}); |
| 42 |
}); |
| 43 |
|
| 44 |
}); |
| 45 |
})(jQuery); |