code: function(pos) {
                                  var l = pos.left < 0 ? 0 : pos.left,
                                  t = pos.top < 0 ? 0 : pos.top;
  
                                  $(this).css({
                                      left: l,
                                      top: t
                                  });
                              }
docs: make sure dialog stays in viewport