From fc64bdc132c0b73cedf207b2bd566a855f245fbc Mon Sep 17 00:00:00 2001 From: jordan Date: Tue, 28 Dec 2010 13:39:32 +0000 Subject: [PATCH] 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 --- forum/skins/default/media/js/osqa.main.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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() { -- 2.39.5