1/** 2 * SmartVideo Elementor frontend handler. 3 * 4 * When a SmartVideo widget is added or updated in the Elementor editor, 5 * the <smartvideo> custom element is AJAX-rendered and inserted into the 6 * preview iframe. The player initializes but poster extraction can fail 7 * due to timing (video not yet loaded). Re-triggering the custom element 8 * after a short delay fixes this. 9 * @param {Function} $ jQuery. 10 */ 11(function ($) { 12 const handler = function ($scope) { 13 // Only act inside the Elementor editor, not on the live frontend. 14 if (!window.elementorFrontend || !elementorFrontend.isEditMode()) { 15 return; 16 } 17 18 const el = $scope.find('smartvideo')[0]; 19 if (!el || !el.parentNode) { 20 return; 21 } 22 23 // Short delay lets the AJAX-rendered content settle, then 24 // clone-and-replace to re-trigger connectedCallback. 25 setTimeout(function () { 26 if (!el.parentNode) { 27 return; 28 } 29 const clone = el.cloneNode(true); 30 // Clear any player-generated inner content so the custom 31 // element reinitializes from scratch. 32 clone.innerHTML = ''; 33 el.parentNode.replaceChild(clone, el); 34 }, 500); 35 }; 36 37 $(window).on('elementor/frontend/init', function () { 38 elementorFrontend.hooks.addAction( 39 'frontend/element_ready/smartvideo.default', 40 handler 41 ); 42 }); 43})(jQuery);
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.