MediaWiki:Common.js: Difference between revisions
Dragon 12dk (talk | contribs) No edit summary |
Dragon 12dk (talk | contribs) No edit summary |
||
| Line 11: | Line 11: | ||
} | } | ||
( function () { | ( function () { | ||
if ( window === window.top ) return; | if ( window === window.top ) return; | ||
function sendHeight() { | |||
var h = document.body ? document.body.scrollHeight : 0; | |||
if ( h > 0 ) window.parent.postMessage( { embedHeight: h }, '*' ); | |||
} | |||
function retargetLinks() { | function retargetLinks() { | ||
| Line 24: | Line 28: | ||
} | } | ||
function init() { | |||
retargetLinks(); | |||
sendHeight(); | sendHeight(); | ||
setTimeout( sendHeight, 500 ); | setTimeout( sendHeight, 500 ); | ||
setTimeout( sendHeight, 1500 ); | setTimeout( sendHeight, 1500 ); | ||
} ); | } | ||
document.addEventListener( 'DOMContentLoaded', retargetLinks ); | |||
window.addEventListener( 'load', init ); | |||
if ( typeof mw !== 'undefined' ) { | if ( typeof mw !== 'undefined' ) { | ||
mw.hook( 'wikipage.content' ).add( | mw.hook( 'wikipage.content' ).add( init ); | ||
} | } | ||