src/sap.ui.dt/src/sap/ui/dt/ContextMenuControl.js
function (oSource, bContextMenu) {
			this.getPopover().setShowArrow(true);
			var sOverlayId = (oSource.getId && oSource.getId()) || oSource.getAttribute("overlay");
			var sFakeDivId = "contextMenuFakeDiv";

			// get Dimensions of Overlay and Viewport
			var oOverlayDimensions = this._getOverlayDimensions(sOverlayId);
			var oViewportDimensions = this._getViewportDimensions();

			this._oContextMenuPosition.x = this._oContextMenuPosition.x || parseInt(oOverlayDimensions.left + 20);
			this._oContextMenuPosition.y = this._oContextMenuPosition.y || parseInt(oOverlayDimensions.top + 20);


			// if the Overlay is near the top position of the Viewport, the Popover makes wrong calculation for positioning it.
			// The MiniMenu has been placed above the Overlay even if there has not been enough place.
			// Therefore we have to calculate the top position and also consider the high of the Toolbar (46 Pixels).
			var iFakeDivTop = oOverlayDimensions.top - 50 > oViewportDimensions.top ? 0 : oViewportDimensions.top - (oOverlayDimensions.top - 50);

			// place a Target DIV (for the moment at wrong position)
			jQuery("#" + sFakeDivId).remove();
			jQuery("#" + sOverlayId).append("<div id=\"" + sFakeDivId + "\" overlay=\"" + sOverlayId + "\" style = \"position: absolute; top: " + iFakeDivTop + "px; left: 0px;\" />");
			var oFakeDiv = document.getElementById(sFakeDivId);

			// place the Popover invisible
			this.getPopover().setContentWidth(undefined);
			this.getPopover().setContentHeight(undefined);
			this.getPopover().openBy(oFakeDiv);

			// get Dimensions of Popover
			var oPopoverDimensions = this._getPopoverDimensions(!bContextMenu);

			// check if vertical scrolling should be done
			if (oPopoverDimensions.height >= oViewportDimensions.height * 2 / 3) {
				this.getPopover().setVerticalScrolling(true);
				oPopoverDimensions.height = (oViewportDimensions.height * 2 / 3).toFixed(0);
				this.getPopover().setContentHeight(oPopoverDimensions.height + "px");
			} else {
				this.getPopover().setVerticalScrolling(false);
				this.getPopover().setContentHeight(undefined);
			}

			// check if horizontal size is too big
			if (oPopoverDimensions.width > 400) {
				oPopoverDimensions.width = 400;
				this.getPopover().setContentWidth("400px");
			} else {
				this.getPopover().setContentWidth(undefined);
			}

			// calculate exact position
			var oPosition = {};

			if (bContextMenu) {
				oPosition = this._placeAsExpandedContextMenu(this._oContextMenuPosition, oPopoverDimensions, oViewportDimensions);
			} else {
				oPosition = this._placeAsCompactContextMenu(this._oContextMenuPosition, oPopoverDimensions, oViewportDimensions);
			}

			oPosition.top -= oOverlayDimensions.top;
			oPosition.left -= oOverlayDimensions.left;
			oPosition.top = (oPosition.top < 0) ? 0 : oPosition.top;
			oPosition.left = (oPosition.left < 0) ? 0 : oPosition.left;

			// set the correct position to the target DIV
			oFakeDiv.style.top = oPosition.top.toFixed(0) + "px";
			oFakeDiv.style.left = oPosition.left.toFixed(0) + "px";

			sOverlayId = null;

			return oFakeDiv;
		}
function (oSource, bContextMenu) {
			this.getPopover().setShowArrow(true);
			var sOverlayId = (oSource.getId && oSource.getId()) || oSource.getAttribute("overlay");
			var sFakeDivId = "contextMenuFakeDiv";

			// get Dimensions of Overlay and Viewport
			var oOverlayDimensions = this._getOverlayDimensions(sOverlayId);
			var oViewportDimensions = this._getViewportDimensions();

			this._oContextMenuPosition.x = this._oContextMenuPosition.x || parseInt(oOverlayDimensions.left + 20);
			this._oContextMenuPosition.y = this._oContextMenuPosition.y || parseInt(oOverlayDimensions.top + 20);


			// if the Overlay is near the top position of the Viewport, the Popover makes wrong calculation for positioning it.
			// The MiniMenu has been placed above the Overlay even if there has not been enough place.
			// Therefore we have to calculate the top position and also consider the high of the Toolbar (46 Pixels).
			var iFakeDivTop = oOverlayDimensions.top - 50 > oViewportDimensions.top ? 0 : oViewportDimensions.top - (oOverlayDimensions.top - 50);

			// place a Target DIV (for the moment at wrong position)
			jQuery("#" + sFakeDivId).remove();
			jQuery("#" + sOverlayId).append("<div id=\"" + sFakeDivId + "\" overlay=\"" + sOverlayId + "\" style = \"position: absolute; top: " + iFakeDivTop + "px; left: 0px;\" />");
			var oFakeDiv = document.getElementById(sFakeDivId);

			// place the Popover invisible
			this.getPopover().setContentWidth(undefined);
			this.getPopover().setContentHeight(undefined);
			this.getPopover().openBy(oFakeDiv);

			// get Dimensions of Popover
			var oPopoverDimensions = this._getPopoverDimensions(!bContextMenu);

			// check if vertical scrolling should be done
			if (oPopoverDimensions.height >= oViewportDimensions.height * 2 / 3) {
				this.getPopover().setVerticalScrolling(true);
				oPopoverDimensions.height = (oViewportDimensions.height * 2 / 3).toFixed(0);
				this.getPopover().setContentHeight(oPopoverDimensions.height + "px");
			} else {
				this.getPopover().setVerticalScrolling(false);
				this.getPopover().setContentHeight(undefined);
			}

			// check if horizontal size is too big
			if (oPopoverDimensions.width > 400) {
				oPopoverDimensions.width = 400;
				this.getPopover().setContentWidth("400px");
			} else {
				this.getPopover().setContentWidth(undefined);
			}

			// calculate exact position
			var oPosition = {};

			if (bContextMenu) {
				oPosition = this._placeAsExpandedContextMenu(this._oContextMenuPosition, oPopoverDimensions, oViewportDimensions);
			} else {
				oPosition = this._placeAsCompactContextMenu(this._oContextMenuPosition, oPopoverDimensions, oViewportDimensions);
			}

			oPosition.top -= oOverlayDimensions.top;
			oPosition.left -= oOverlayDimensions.left;
			oPosition.top = (oPosition.top < 0) ? 0 : oPosition.top;
			oPosition.left = (oPosition.left < 0) ? 0 : oPosition.left;

			// set the correct position to the target DIV
			oFakeDiv.style.top = oPosition.top.toFixed(0) + "px";
			oFakeDiv.style.left = oPosition.left.toFixed(0) + "px";

			sOverlayId = null;

			return oFakeDiv;
		}
function ( oSource , bContextMenu ) { this . getPopover ( ) . setShowArrow ( true ) ; var sOverlayId = ( oSource . getId && oSource . getId ( ) ) || oSource . getAttribute ( "overlay" ) ; var sFakeDivId = "contextMenuFakeDiv" ; // get Dimensions of Overlay and Viewport var oOverlayDimensions = this . _getOverlayDimensions ( sOverlayId ) ; var oViewportDimensions = this . _getViewportDimensions ( ) ; this . _oContextMenuPosition . x = this . _oContextMenuPosition . x || parseInt ( oOverlayDimensions . left + 20 ) ; this . _oContextMenuPosition . y = this . _oContextMenuPosition . y || parseInt ( oOverlayDimensions . top + 20 ) ; // if the Overlay is near the top position of the Viewport, the Popover makes wrong calculation for positioning it. // The MiniMenu has been placed above the Overlay even if there has not been enough place. // Therefore we have to calculate the top position and also consider the high of the Toolbar (46 Pixels). var iFakeDivTop = oOverlayDimensions . top - 50 > oViewportDimensions . top ? 0 : oViewportDimensions . top - ( oOverlayDimensions . top - 50 ) ; // place a Target DIV (for the moment at wrong position) jQuery ( "#" + sFakeDivId ) . remove ( ) ; jQuery ( "#" + sOverlayId ) . append ( "<div id=\"" + sFakeDivId + "\" overlay=\"" + sOverlayId + "\" style = \"position: absolute; top: " + iFakeDivTop + "px; left: 0px;\" />" ) ; var oFakeDiv = document . getElementById ( sFakeDivId ) ; // place the Popover invisible this . getPopover ( ) . setContentWidth ( undefined ) ; this . getPopover ( ) . setContentHeight ( undefined ) ; this . getPopover ( ) . openBy ( oFakeDiv ) ; // get Dimensions of Popover var oPopoverDimensions = this . _getPopoverDimensions ( ! bContextMenu ) ; // check if vertical scrolling should be done if ( oPopoverDimensions . height >= oViewportDimensions . height * 2 / 3 ) { this . getPopover ( ) . setVerticalScrolling ( true ) ; oPopoverDimensions . height = ( oViewportDimensions . height * 2 / 3 ) . toFixed ( 0 ) ; this . getPopover ( ) . setContentHeight ( oPopoverDimensions . height + "px" ) ; } else { this . getPopover ( ) . setVerticalScrolling ( false ) ; this . getPopover ( ) . setContentHeight ( undefined ) ; } // check if horizontal size is too big if ( oPopoverDimensions . width > 400 ) { oPopoverDimensions . width = 400 ; this . getPopover ( ) . setContentWidth ( "400px" ) ; } else { this . getPopover ( ) . setContentWidth ( undefined ) ; } // calculate exact position var oPosition = { } ; if ( bContextMenu ) { oPosition = this . _placeAsExpandedContextMenu ( this . _oContextMenuPosition , oPopoverDimensions , oViewportDimensions ) ; } else { oPosition = this . _placeAsCompactContextMenu ( this . _oContextMenuPosition , oPopoverDimensions , oViewportDimensions ) ; } oPosition . top -= oOverlayDimensions . top ; oPosition . left -= oOverlayDimensions . left ; oPosition . top = ( oPosition . top < 0 ) ? 0 : oPosition . top ; oPosition . left = ( oPosition . left < 0 ) ? 0 : oPosition . left ; // set the correct position to the target DIV oFakeDiv . style . top = oPosition . top . toFixed ( 0 ) + "px" ; oFakeDiv . style . left = oPosition . left . toFixed ( 0 ) + "px" ; sOverlayId = null ; return oFakeDiv ; }
Works out how the ContextMenu shall be placed
Sets the placement property of the popover
Places a "fakeDiv" in the DOM which the popover can be opened by
@param {sap.m.Control} oSource the overlay
@param {boolean} bContextMenu whether the ContextMenu should be opened as a context menu
@return {div} the "fakeDiv"
@private
Works out how the ContextMenu shall be placed Sets the placement property of the popover Places a fakeDiv in the DOM which the popover can be opened by