code: function(opt, x, y) {
              var $this = this,
                  offset;
              // determine contextMenu position
              if (!x && !y) {
                  opt.determinePosition.call(this, opt.$menu);
                  return;
              } else if (x === "maintain" && y === "maintain") {
                  // x and y must not be changed (after re-show on command click)
                  offset = opt.$menu.position();
              } else {
                  // x and y are given (by mouse event)
                  offset = {top: y, left: x};
              }
              
              // correct offset if viewport demands it
              var bottom = $win.scrollTop() + $win.height(),
                  right = $win.scrollLeft() + $win.width(),
                  height = opt.$menu.height(),
                  width = opt.$menu.width();
              
              if (offset.top + height > bottom) {
                  offset.top -= height;
              }
  
              if (offset.top<0) {
                  offset.top = 0;
              }
              
              if (offset.left + width > right) {
                  offset.left -= width;
              }
              
              opt.$menu.css(offset);
          }
docs: position menu