PageSourceSearch

https://alfredcurrier.com/wp-content/themes/word4ya/cm-blocks/cm-c…/centralized.js?ver=1772919555

js alfredcurrier.com collected 2026-10-02 14:17:10 UTC 2,884 bytes, 87 lines download raw bytes

1/**
2 * Container Columns Block - Universal JavaScript
3 * Works in frontend, FSE editor, and block editor environments
4 */
5
6(function() {
7    'use strict';
8    
9    // Environment detection
10    const isWordPressEditor = typeof wp !== 'undefined' && wp.blocks;
11    const isFSE = (document.body && document.body.classList && document.body.classList.contains('block-editor-page')) ||
12                  document.querySelector('.editor-styles-wrapper') !== null;
13    const isFrontend = !isWordPressEditor && !isFSE;
14    
15    // Configuration from PHP - no hardcoded values
16    const CONFIG = window.cmContainerColumnsConfig || {};
17    
18    // Fail gracefully if configuration missing
19    if (!CONFIG.defaults || !CONFIG.selectors) {
20        console.error('Container Columns Block: PHP configuration not loaded. Block will not function.');
21        return;
22    }
23    
24    /**
25     * Initialize block functionality
26     */
27    function initializeBlock() {
28        const blocks = document.querySelectorAll(CONFIG.selectors.wrapper);
29        
30        blocks.forEach(block => {
31            setupBlockBehavior(block);
32        });
33    }
34    
35    /**
36     * Setup individual block behavior
37     */
38    function setupBlockBehavior(blockElement) {
39        // Add any interactive functionality here
40        // For now, just log that the block was initialized
41        if (CONFIG.environment && CONFIG.environment.isWordPress) {
42            console.log('Container Columns block initialized:', blockElement);
43        }
44        
45        // Example: Add responsive behavior if needed
46        const leftColumn = blockElement.querySelector(CONFIG.selectors.leftColumn);
47        const rightColumn = blockElement.querySelector(CONFIG.selectors.rightColumn);
48        
49        if (leftColumn && rightColumn) {
50            // Add any dynamic behavior here
51            console.log('Container Columns columns found:', leftColumn, rightColumn);
52        }
53        
54        // Add a data attribute to mark as initialized
55        blockElement.setAttribute('data-initialized', 'true');
56    }
57    
58    /**
59     * Environment-aware initialization
60     */
61    function initialize() {
62        if (isFrontend) {
63            // Frontend initialization
64            if (document.readyState === 'loading') {
65                document.addEventListener('DOMContentLoaded', initializeBlock);
66            } else {
67                initializeBlock();
68            }
69        } else if (isFSE) {
70            // FSE editor initialization
71            const observer = new MutationObserver(() => {
72                initializeBlock();
73            });
74            
75            observer.observe(document.body, {
76                childList: true,
77                subtree: true
78            });
79            
80            // Initial setup
81            initializeBlock();
82        }
83    }
84    
85    // Initialize based on environment
86    initialize();
87})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.