MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 9: Line 9:
     }
     }
   }  
   }  
}
};


/* ── Embed: dynamic height + anchor scroll ── */
/* ── Embed: dynamic height + anchor scroll ── */
Line 17: Line 17:
   function sendHeight() {
   function sendHeight() {
     var h = document.body ? document.body.scrollHeight : 0;
     var h = document.body ? document.body.scrollHeight : 0;
     if ( h > 0 ) window.parent.postMessage( { embedHeight: h }, '*' );
     if ( h > 0 ) window.parent.postMessage( { embedHeight: h + 10 }, '*' );
   }
   }


Line 43: Line 43:
} )();
} )();


/* ── Embed: open links in new tab ── */
/* ── Embed: open links in new tab (only when ?embed=1) ── */
( function () {
( function () {
   if ( window === window.top ) return;
   if ( window === window.top ) return;
  if ( !window.location.search.includes( 'embed=1' ) ) return;


   function retargetLinks() {
   function retargetLinks() {