From: jordan Date: Tue, 28 Dec 2010 13:39:32 +0000 (+0000) Subject: We check if the AJAX dialogs get into the browser viewport. If not, we change their... X-Git-Tag: live~488 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/fc64bdc132c0b73cedf207b2bd566a855f245fbc We check if the AJAX dialogs get into the browser viewport. If not, we change their position. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@646 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/skins/default/media/js/osqa.main.js b/forum/skins/default/media/js/osqa.main.js index 43120b2..f83d3b5 100644 --- a/forum/skins/default/media/js/osqa.main.js +++ b/forum/skins/default/media/js/osqa.main.js @@ -185,10 +185,26 @@ function show_dialog (extern) { top: options.pos.y, left: options.pos.x }); - + + top_position_change = (options.dim.h / 2) + left_position_change = (options.dim.w / 2) + + new_top_position = options.pos.y - top_position_change + new_left_position = options.pos.x - left_position_change + + if (new_left_position < 0) { + left_position_change = 0 + } + if (($(window).scrollTop() - new_top_position) > 0) { + top_position_change = 0 + } + if ((options.event.pageY + options.dim.h) > ($(window).height() + $(window).scrollTop())) { + top_position_change = options.dim.h + } + $dialog.animate({ - top: "-=" + (options.dim.h / 2), - left: "-=" + (options.dim.w / 2), + top: "-=" + top_position_change, + left: "-=" + left_position_change, width: options.dim.w, height: options.dim.h }, 200, function() {