From cfd36c55395fdcd433202f06eac80bf12411e6e9 Mon Sep 17 00:00:00 2001 From: rkarthik29 Date: Sun, 15 May 2016 17:24:24 -0400 Subject: [PATCH] fix for 1864 Signed-off-by: Matt Gilman --- .../webapp/js/nf/canvas/nf-context-menu.js | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js index ba20b45a97..a809f52ebe 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js @@ -495,19 +495,6 @@ nf.ContextMenu = (function () { {condition: isDeletable, menuItem: {img: 'images/iconDelete.png', text: 'Delete', action: 'delete'}} ]; - /** - * Positions and shows the context menu. - * - * @param {jQuery} contextMenu The context menu - * @param {object} options The context menu configuration - */ - var positionAndShow = function (contextMenu, options) { - contextMenu.css({ - 'left': options.x + 'px', - 'top': options.y + 'px' - }).show(); - }; - return { init: function () { $('#context-menu').on('contextmenu', function(evt) { @@ -521,8 +508,10 @@ nf.ContextMenu = (function () { * Shows the context menu. */ show: function () { - var canvasBody = $('#canvas-body').get(0); var contextMenu = $('#context-menu').empty(); + var canvasBody = $('#canvas-body').get(0); + var bannerFooter = $('#banner-footer').get(0); + var breadCrumb = $('#breadcrumbs').get(0); // get the current selection var selection = nf.CanvasUtils.getSelection(); @@ -547,6 +536,14 @@ nf.ContextMenu = (function () { // get the location for the context menu var position = d3.mouse(canvasBody); + // nifi 1864 make sure the context menu is not hidden by the browser boundaries + if (position[0] + contextMenu.width() > canvasBody.clientWidth) { + position[0] = canvasBody.clientWidth - contextMenu.width() - 2; + } + if (position[1] + contextMenu.height() > (canvasBody.clientHeight - breadCrumb.clientHeight - bannerFooter.clientHeight)) { + position[1] = canvasBody.clientHeight - breadCrumb.clientHeight - bannerFooter.clientHeight - contextMenu.height() - 3; + } + // show the context menu positionAndShow(contextMenu, { 'x': position[0],