top: options.pos.y,\r
left: options.pos.x\r
});\r
-\r
+ \r
+ top_position_change = (options.dim.h / 2)\r
+ left_position_change = (options.dim.w / 2)\r
+ \r
+ new_top_position = options.pos.y - top_position_change\r
+ new_left_position = options.pos.x - left_position_change\r
+ \r
+ if (new_left_position < 0) {\r
+ left_position_change = 0\r
+ }\r
+ if (($(window).scrollTop() - new_top_position) > 0) {\r
+ top_position_change = 0\r
+ }\r
+ if ((options.event.pageY + options.dim.h) > ($(window).height() + $(window).scrollTop())) {\r
+ top_position_change = options.dim.h\r
+ }\r
+ \r
$dialog.animate({\r
- top: "-=" + (options.dim.h / 2),\r
- left: "-=" + (options.dim.w / 2),\r
+ top: "-=" + top_position_change,\r
+ left: "-=" + left_position_change,\r
width: options.dim.w,\r
height: options.dim.h\r
}, 200, function() {\r