Created
May 30, 2012 17:30
-
-
Save RalfAlbert/2837799 to your computer and use it in GitHub Desktop.
Groesse der Thickbox automatisch an den Inhalt anpassen. Thickbox automatically adjust the size of the content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready( | |
function($){ | |
resize_thickbox_iframe(); | |
/* | |
* | |
* some other jQuery code | |
* | |
*/ | |
function resize_thickbox_iframe(){ | |
//padding | |
var pad = 50; | |
// give the body a height | |
$( 'body' ).css( 'height', 'auto' ); | |
// read the bodys height and add some padding | |
var mh = parseInt( $( 'body' ).height() ) + pad; | |
var max_height = mh + 'px'; | |
// get the parent window dimensions | |
var parent = $( window.parent.document ); | |
var ph = parent.height(); | |
// get the ID of this iframe and the iframe itself | |
frame_id = frameElement.id; | |
frame = $( '#'+frame_id, window.parent.document ); | |
// get the id of the overlay-div and the overlay-div itself | |
div_id = frame.parent().attr( 'id' ); | |
div = $( '#'+div_id, window.parent.document ); | |
// first set the hight for the frame, than set the hight for the overlay-div | |
frame.css( 'height', max_height ); | |
div.css( 'height', max_height ); | |
// calculate the new top position | |
var tb = Math.round( ( ( ph - mh ) / 2 ) - pad ) + 'px'; | |
// set the new top position | |
frame.css( 'top', tb ); | |
div.css( 'top', tb ); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment