jQuery(document).ready(function($) {
// Function to open your popup
function openCharitonPopup() {
console.log('Opening popup 5313...');
if (typeof elementorProFrontend !== 'undefined') {
elementorProFrontend.modules.popup.showPopup(5313);
} else {
// Fallback: try to find any Elementor popup trigger
$('[data-elementor-open-popup="5313"]').click();
}
return false;
}
// Method 1: Disable MeanMenu completely and use our own click handler
// Save the original meanmenu function
if ($.fn.meanmenu) {
var originalMeanMenu = $.fn.meanmenu;
// Override it
$.fn.meanmenu = function() {
// Don't initialize meanmenu on #mobile-menu
if (this.selector === '#mobile-menu' || this.is('#mobile-menu')) {
console.log('Blocked MeanMenu on #mobile-menu');
// Instead, add our own click handler to the parent or create a toggle
setTimeout(function() {
// Create our own menu button if it doesn't exist
if ($('.custom-popup-trigger').length === 0) {
$('header').append('
');
}
// Attach click handler
$(document).on('click', '.custom-popup-trigger, .meanmenu-reveal', function(e) {
e.preventDefault();
e.stopPropagation();
openCharitonPopup();
});
}, 100);
return this;
}
// For other elements, use the original function
return originalMeanMenu.apply(this, arguments);
};
}
// Method 2: Direct approach - remove meanmenu and add our own trigger
if ($('#mobile-menu').length > 0) {
// Check if meanmenu is initialized
if ($('#mobile-menu').hasClass('mean-container')) {
console.log('MeanMenu already initialized, removing...');
// Remove meanmenu classes
$('#mobile-menu').removeClass('mean-container');
$('.mean-bar, .meanmenu-reveal').remove();
}
// Add our own custom mobile menu button
if ($('.chariton-mobile-trigger').length === 0) {
$('header.header4 .new-main-header').append(`
`);
}
// Attach click handler to our custom button
$(document).on('click', '.chariton-mobile-trigger', function(e) {
e.preventDefault();
e.stopPropagation();
openCharitonPopup();
});
// Also hijack any existing meanmenu buttons
$(document).on('click', '.meanmenu-reveal', function(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
openCharitonPopup();
return false;
});
}
// Method 3: Most aggressive - override the entire meanmenu plugin for this element
setTimeout(function() {
// Remove any existing meanmenu event listeners
$('#mobile-menu').off();
$('.meanmenu-reveal').off().remove();
// Create our own button
var $header = $('header.header4 .new-main-header');
if ($header.find('.custom-mean-trigger').length === 0) {
$header.append(`