| 1 |
(function(){ |
| 2 |
//#region dev/js/common/utils.js |
| 3 |
/** |
| 4 |
* Master Addons - Shared Utilities |
| 5 |
* |
| 6 |
* Common helper functions used across all widget handlers. |
| 7 |
*/ |
| 8 |
/** |
| 9 |
* Get element settings from Elementor |
| 10 |
* |
| 11 |
* @param {jQuery} $element - The jQuery element |
| 12 |
* @param {string} setting - Optional specific setting key |
| 13 |
* @returns {*} Settings object or specific setting value |
| 14 |
*/ |
| 15 |
function getElementSettings($element, setting) { |
| 16 |
var elementSettings = {}, modelCID = $element.data("model-cid"); |
| 17 |
if (typeof elementorFrontend !== "undefined" && elementorFrontend.isEditMode() && modelCID) { |
| 18 |
var settings = elementorFrontend.config.elements.data[modelCID], type = settings.attributes.widgetType || settings.attributes.elType, settingsKeys = elementorFrontend.config.elements.keys[type]; |
| 19 |
if (!settingsKeys) { |
| 20 |
settingsKeys = elementorFrontend.config.elements.keys[type] = []; |
| 21 |
jQuery.each(settings.controls, function(name, control) { |
| 22 |
if (control.frontend_available) settingsKeys.push(name); |
| 23 |
}); |
| 24 |
} |
| 25 |
jQuery.each(settings.getActiveControls(), function(controlKey) { |
| 26 |
if (-1 !== settingsKeys.indexOf(controlKey)) elementSettings[controlKey] = settings.attributes[controlKey]; |
| 27 |
}); |
| 28 |
} else elementSettings = $element.data("settings") || {}; |
| 29 |
return getItems(elementSettings, setting); |
| 30 |
} |
| 31 |
/** |
| 32 |
* Get nested items from an object |
| 33 |
* |
| 34 |
* @param {Object} items - The items object |
| 35 |
* @param {string} itemKey - Dot-notation key path |
| 36 |
* @returns {*} The value at the key path |
| 37 |
*/ |
| 38 |
function getItems(items, itemKey) { |
| 39 |
if (itemKey) { |
| 40 |
var keyStack = itemKey.split("."), currentKey = keyStack.splice(0, 1); |
| 41 |
if (!keyStack.length) return items[currentKey]; |
| 42 |
if (!items[currentKey]) return; |
| 43 |
return getItems(items[currentKey], keyStack.join(".")); |
| 44 |
} |
| 45 |
return items; |
| 46 |
} |
| 47 |
/** |
| 48 |
* Get unique loop scope ID |
| 49 |
* |
| 50 |
* @param {jQuery} $scope - The scope element |
| 51 |
* @returns {string} The unique ID |
| 52 |
*/ |
| 53 |
function getUniqueLoopScopeId($scope) { |
| 54 |
if ($scope.data("jltma-template-widget-id")) return $scope.data("jltma-template-widget-id"); |
| 55 |
return $scope.data("id"); |
| 56 |
} |
| 57 |
/** |
| 58 |
* Observe target element with IntersectionObserver |
| 59 |
* |
| 60 |
* @param {Element} target - The target element to observe |
| 61 |
* @param {Function} callback - Callback when element intersects |
| 62 |
* @param {Object} options - IntersectionObserver options |
| 63 |
*/ |
| 64 |
function jltMAObserveTarget(target, callback, options = {}) { |
| 65 |
new IntersectionObserver(function(entries, observer) { |
| 66 |
entries.forEach(function(entry) { |
| 67 |
if (entry.isIntersecting) callback(entry); |
| 68 |
}); |
| 69 |
}, options).observe(target); |
| 70 |
} |
| 71 |
/** |
| 72 |
* Strip HTML tags from text |
| 73 |
* |
| 74 |
* @param {string} text - Text to strip |
| 75 |
* @returns {string} Text without HTML tags |
| 76 |
*/ |
| 77 |
function stripTags(text) { |
| 78 |
return text.replace(/<\/?[^>]+(>|$)/g, ""); |
| 79 |
} |
| 80 |
/** |
| 81 |
* Check if in Elementor edit mode |
| 82 |
* |
| 83 |
* @returns {boolean} True if in edit mode |
| 84 |
*/ |
| 85 |
function isEditMode() { |
| 86 |
return typeof elementorFrontend !== "undefined" && elementorFrontend.isEditMode(); |
| 87 |
} |
| 88 |
//#endregion |
| 89 |
//#region dev/js/addons/free/ma-progressbars.js |
| 90 |
/** |
| 91 |
* Progress Bars widget script |
| 92 |
*/ |
| 93 |
(function($, elementor) { |
| 94 |
"use strict"; |
| 95 |
var JLTMA_ProgressBars = function($scope, $) { |
| 96 |
jltMAObserveTarget($scope[0], function() { |
| 97 |
$scope.find(".jltma-stats-bar-content").each(function() { |
| 98 |
var dataperc = $(this).data("perc"); |
| 99 |
$(this).animate({ "width": dataperc + "%" }, dataperc * 20); |
| 100 |
}); |
| 101 |
}); |
| 102 |
}; |
| 103 |
$(window).on("elementor/frontend/init", function() { |
| 104 |
elementorFrontend.hooks.addAction("frontend/element_ready/ma-progressbars.default", JLTMA_ProgressBars); |
| 105 |
}); |
| 106 |
})(jQuery, window.elementorFrontend); |
| 107 |
//#endregion |
| 108 |
})(); |
| 109 |
|