docs: function (size) {
              var position, isInViewSet;
              if (this.conf.maximized) {
                  var offset = this.conf.offset;
                  var containerScroll = this.popupContainer.getContainerScroll();
                  position = {
                      top : containerScroll.scrollTop - offset.top,
                      left : containerScroll.scrollLeft - offset.left
                  };
              } else if (this.conf.center) {
                  // apply the offset (both left and right, and also top and bottom)
                  // before centering the whole thing in the container
                  var offset = this.conf.offset;
                  var newSize = {
                      width : size.width + offset.left + offset.right,
                      height : size.height + offset.top + offset.bottom
                  };
                  position = this.popupContainer.centerInside(newSize, this.reference);
                  position = this.popupContainer.fitInside(position, newSize, this.reference);
              } else {
                  var i = 0, preferredPosition;
                  do {
                      preferredPosition = this.preferredPositions[i];
                      // Calculate position for a given anchor
                      position = this._getPositionForAnchor(preferredPosition, size);
                      // If this position+size is out of the container, try the
                      // next anchor available
                      isInViewSet = this.popupContainer.isInside(position, size);
                      i++;
                  } while (!isInViewSet && this.preferredPositions[i]);
  
                  var positionEvent = {
                      name : "onPositioned"
                  };
  
                  // If all anchors setting were out of the container, fallback
                  if (!isInViewSet) {
                      // Currently simply fallback to first anchor ...
                      position = this._getPositionForAnchor(this.preferredPositions[0], size);
                      position = this.popupContainer.fitInside(position, size);
                  } else {
                      positionEvent.position = this.preferredPositions[i - 1];
                  }
                  this.$raiseEvent(positionEvent);
              }
              return position;
          }