Facebook dialog positioning
Project:
I am by no means a JQuery expert, but I pieced together this hack to reposition dialogs in facebook to where the viewport actually is. It is an ugly hack which scans for the tag in the common facebook dialog - which could break if they change the structure of the dialogs, but it should die gracefully in that event.
$(document).ready(function(){
(function($){
$.facebook_fixes = {
dialog_repositioner: function() {
if ( $('td.fb_pop_border').is(':visible') ) {
dialogHeight = ( parseInt($('table#RES_ID_fb_pop_dialog_table').css("height").replace("px",'')) || $('table#RES_ID_fb_pop_dialog_table').height() );
dialogWidth = ( parseInt($('table#RES_ID_fb_pop_dialog_table').css("width").replace("px",'')) || $('table#RES_ID_fb_pop_dialog_table').width() );
windowHeight = (
window.innerHeight && window.innerHeight <
$(window).height()) ? window.innerHeight : $(window).height();
if ( dialogHeight +55 < windowHeight ) {
var scrollTop = (document.documentElement.scrollTop || document.body.scrollTop)
var newPosition = scrollTop + 50;
$('table#RES_ID_fb_pop_dialog_table').css({
float:"left",
position:"absolute",
top:newPosition
});
}
if ( parseInt(dialogWidth) > 710 ) {
$('table#RES_ID_fb_pop_dialog_table').css({
float:"left",
position:"absolute",
left:-12
});
}
}
}
}
})(jQuery);
setInterval( "$.facebook_fixes.dialog_repositioner()", 100 )
});
