Preventing a dialog from going outside the document view

Preventing a dialog from going outside the document view


Hi,
Is there a way to prevent the dialog from going outside the document
view when dragging it ?
This must be something like this but I don't how to complete:
dialog({
dragStop: function(ev, ui){
if (ui.position.top < 0) {
/* Missing code to prevent further move */;
}
}
})
Olivier.