GIF94;
| Path : /var/www/wordpress/wp-content/plugins/oxymade/assets/js/ |
| Current File : /var/www/wordpress/wp-content/plugins/oxymade/assets/js/oxymade.js |
(function() {
'use strict';
let parentWindow = window.parent;
// Check if we have the required settings
if (typeof oxymadeSettings === 'undefined') {
return;
}
// Initialize all modules
function initModules() {
// Wait for all modules to be available
const checkModules = () => {
if (window.OxyMade &&
window.OxyMade.SpacingPicker &&
window.OxyMade.InputPicker &&
window.OxyMade.ColorPanel &&
window.OxyMade.ColorPalette &&
window.OxyMade.ColorUtils) {
// Initialize spacing picker
window.OxyMade.SpacingPicker.init(parentWindow);
// Initialize input picker (context-aware right-click)
window.OxyMade.InputPicker.init(parentWindow);
// Initialize color panel
window.OxyMade.ColorPanel.init();
return true;
}
return false;
};
// Try immediately
if (!checkModules()) {
// If not ready, wait a bit and try again
setTimeout(() => {
if (!checkModules()) {
console.error('🎨 OxyMade: Some modules failed to load');
}
}, 100);
}
}
// Simple button creation - using working code from backup
function createSimpleButton() {
// Check if button already exists
if (window.parent.document.getElementById('oxymade-button')) {
return;
}
// Find the toolbar
const toolbar = window.parent.document.querySelector('.undo-redo-top-bar-section');
if (!toolbar) {
return;
}
// Create button
const button = window.parent.document.createElement('div');
button.id = 'oxymade-button';
button.className = 'breakdance-toolbar-icon-button';
button.style.cssText = 'background: none !important; padding: 0 !important; border: none !important; box-shadow: none !important; margin-right: 0 !important;';
button.innerHTML = `
<div style="width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; cursor: pointer;">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="none" viewBox="0 0 63 64">
<rect width="62.837" height="63.526" fill="#EE6A5F" rx="20" transform="matrix(1 0 0 -1 0 63.527)"/>
<path fill="#fff" d="M28.726 12.038v12.769l-1.893-1.893c-2.366-2.35-6.951-6.878-6.976-6.878-.008 0-.914.897-2.015 1.99l-2 1.991 1.078 1.053c.595.57 2.586 2.513 4.422 4.3 1.844 1.794 3.362 3.288 3.37 3.328.016.041-2.636.066-6.323.066l-6.348-.017-.025 2.783L12 34.312h12.81l-2.31 2.26-4.462 4.406-2.162 2.146 1.958 1.958c1.077 1.077 1.99 1.958 2.04 1.958.04 0 2.056-1.975 4.47-4.39l4.39-4.381-.016 6.609-.008 6.608 2.782.025 2.782.016V38.35l4.39 4.39 4.39 4.39 1.974-2.024 1.974-2.023-2.676-2.627a957 957 0 0 0-4.463-4.366l-1.795-1.737 6.389-.025 6.38-.016v-5.548h-6.323c-3.558 0-6.324-.033-6.324-.074s.343-.391.767-.791c.947-.906 7.996-7.808 8.029-7.866.008-.024-.881-.938-1.983-2.04l-1.999-1.998-4.348 4.349c-2.383 2.382-4.357 4.34-4.382 4.34s-.032-2.847-.016-6.323l.016-6.323-.506-.017c-1.15-.032-5.042-.024-5.042.017"/>
</svg>
</div>
`;
// Add click handler
button.addEventListener('click', function() {
const panel = window.parent.document.getElementById('color-panel-slider');
if (panel) {
// Toggle existing panel
const currentRight = panel.style.right || '-350px';
const isVisible = currentRight === '0px';
if (!isVisible) {
// Sync CSS variables before showing panel (in case colors changed)
if (window.OxyMade && window.OxyMade.ColorPanel && window.OxyMade.ColorPanel.syncCSSVariablesToParent) {
window.OxyMade.ColorPanel.syncCSSVariablesToParent();
}
}
panel.style.right = isVisible ? '-350px' : '0px';
} else {
// Initialize color panel
if (window.OxyMade && window.OxyMade.ColorPanel) {
window.OxyMade.ColorPanel.init();
}
// Show the panel after creation
setTimeout(() => {
const newPanel = window.parent.document.getElementById('color-panel-slider');
if (newPanel) {
newPanel.style.right = '0px';
}
}, 100);
}
});
// Insert button to the left of existing buttons
const firstButton = toolbar.querySelector('.breakdance-toolbar-icon-button');
if (firstButton) {
toolbar.insertBefore(button, firstButton);
} else {
toolbar.appendChild(button);
}
}
// Initialize when page loads
function initialize() {
// Initialize modules first
initModules();
// Create button
createSimpleButton();
}
// Wait for DOM to be ready
if (document.readyState === 'complete') {
initialize();
} else {
window.addEventListener('load', initialize);
}
})();