1/** 2 * @file 3 * See Issue "autoresize" https://www.drupal.org/node/360549. 4 */ 5(function ($) { 6 Drupal.behaviors.iframeModule = { 7 attach(context, settings) { 8 $('iframe.autoresize').each(function () { 9 const offsetHeight = 20; 10 const thisIframe = $(this); 11 let iframeWaitInterval; 12 let elem; 13 let msg = ''; 14 15 function resizeHeight(iframe) { 16 if ($(iframe).length) { 17 /* Iframe yet loaded ? */ 18 const iframeDoc = 19 $(iframe)[0].contentDocument || 20 $(iframe)[0].contentWindow.document; 21 let contentheight = 0; 22 23 try { 24 contentheight = $(iframeDoc).find('body').height(); 25 } catch (e) { 26 elem = $(iframe)[0]; 27 msg = $( 28 `<p><small>(${Drupal.t( 29 'Iframe URL is not from the same domain - autoresize not working.', 30 )})</small></p>`, 31 ); 32 $(elem).after(msg); 33 clearInterval(iframeWaitInterval); 34 } 35 36 if (contentheight > 0) { 37 clearInterval(iframeWaitInterval); 38 try { 39 const frameElement = $(iframe)[0].frameElement || $(iframe)[0]; 40 frameElement.style.height = `${contentheight + offsetHeight}px`; 41 frameElement.scrolling = 'no'; 42 } catch (e) { 43 /* here, ist not a correctable error */ 44 } 45 } 46 } 47 } 48 const delayedResize = function () { 49 resizeHeight(thisIframe); 50 }; 51 52 iframeWaitInterval = setInterval(delayedResize, 300); 53 }); 54 }, 55 }; 56})(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.