frontblocks-gf-inline-option.js
7 months ago
frontblocks-gf-inline-option.jsx
1 month ago
frontblocks-gf-inline.css
4 months ago
frontblocks-gf-inline.js
7 months ago
frontblocks-gf-inline.js
44 lines
| 1 | /** |
| 2 | * FrontBlocks - Gravity Forms Inline Layout Runtime |
| 3 | * |
| 4 | * @package FrontBlocks |
| 5 | * @author Closemarketing |
| 6 | * @copyright 2025 Closemarketing |
| 7 | */ |
| 8 | |
| 9 | (function() { |
| 10 | 'use strict'; |
| 11 | |
| 12 | /** |
| 13 | * Initialize inline layout for Gravity Forms. |
| 14 | */ |
| 15 | function initGfInlineLayout() { |
| 16 | // Find all inline form blocks (multiple class options). |
| 17 | const gfInlineBlocks = document.querySelectorAll('.frontblocks-gf-inline, .frontblocks-gf-inline-wrapper'); |
| 18 | |
| 19 | gfInlineBlocks.forEach(function(block) { |
| 20 | const gap = block.getAttribute('data-gf-inline-gap') || 10; |
| 21 | |
| 22 | // Set CSS custom property for gap. |
| 23 | block.style.setProperty('--gf-inline-gap', gap + 'px'); |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | // Initialize on DOM ready. |
| 28 | if (document.readyState === 'loading') { |
| 29 | document.addEventListener('DOMContentLoaded', initGfInlineLayout); |
| 30 | } else { |
| 31 | initGfInlineLayout(); |
| 32 | } |
| 33 | |
| 34 | // Re-initialize after Gravity Forms AJAX submission. |
| 35 | document.addEventListener('gform_post_render', initGfInlineLayout); |
| 36 | |
| 37 | // Also initialize with jQuery if available (for compatibility). |
| 38 | if (typeof jQuery !== 'undefined') { |
| 39 | jQuery(document).on('gform_post_render', initGfInlineLayout); |
| 40 | } |
| 41 | |
| 42 | })(); |
| 43 | |
| 44 |