From eb9cba13577cab764fa6eb1edd71fd667becbb62 Mon Sep 17 00:00:00 2001 From: Piotr Grzelka Date: Thu, 8 Jan 2015 09:40:15 +0100 Subject: [PATCH 1/3] Update bootstrap-contextmenu.js Added ability: menu position will be calculated relative to defined container block --- bootstrap-contextmenu.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bootstrap-contextmenu.js b/bootstrap-contextmenu.js index dc1e38bc..3c8d3a8c 100644 --- a/bootstrap-contextmenu.js +++ b/bootstrap-contextmenu.js @@ -23,6 +23,7 @@ this.before = options.before || this.before; this.onItem = options.onItem || this.onItem; this.scopes = options.scopes || null; + this.container = options.container || window; if (options.target) { this.$element.data('target', options.target); @@ -137,23 +138,23 @@ ,getPosition: function(e, $menu) { var mouseX = e.clientX , mouseY = e.clientY - , boundsX = $(window).width() - , boundsY = $(window).height() + , boundsX = $(this.container).width() + , boundsY = $(this.container).height() , menuWidth = $menu.find('.dropdown-menu').outerWidth() , menuHeight = $menu.find('.dropdown-menu').outerHeight() , tp = {"position":"absolute","z-index":9999} , Y, X, parentOffset; if (mouseY + menuHeight > boundsY) { - Y = {"top": mouseY - menuHeight + $(window).scrollTop()}; + Y = {"top": mouseY - menuHeight + $(this.container).scrollTop()}; } else { - Y = {"top": mouseY + $(window).scrollTop()}; + Y = {"top": mouseY + $(this.container).scrollTop()}; } if ((mouseX + menuWidth > boundsX) && ((mouseX - menuWidth) > 0)) { - X = {"left": mouseX - menuWidth + $(window).scrollLeft()}; + X = {"left": mouseX - menuWidth + $(this.container).scrollLeft()}; } else { - X = {"left": mouseX + $(window).scrollLeft()}; + X = {"left": mouseX + $(this.container).scrollLeft()}; } // If context-menu's parent is positioned using absolute or relative positioning, From 89cf040e02086e74055f81d5c34b8068a30e2fc6 Mon Sep 17 00:00:00 2001 From: Piotr Grzelka Date: Thu, 8 Jan 2015 09:55:15 +0100 Subject: [PATCH 2/3] Update bower.json Change version to 0.3.3 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index c422ee8f..4d34ce75 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "bootstrap-contextmenu", "main": "bootstrap-contextmenu.js", - "version": "0.3.2", + "version": "0.3.3", "homepage": "https://github.com/sydcanem/bootstrap-contextmenu", "authors": [ "sydcanem " From 07369d50270c1bf17431d20a99283696e8450b36 Mon Sep 17 00:00:00 2001 From: Piotr Grzelka Date: Thu, 8 Jan 2015 09:55:48 +0100 Subject: [PATCH 3/3] Update package.json Change version to 0.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b289c62..23e770bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-contextmenu", - "version": "0.3.2", + "version": "0.3.3", "description": "Context-menu extension for the Bootstrap framework", "main": "bootstrap-contextmenu.js", "directories": {