From 2c4a7fed227c3f81cfc45381bde0f9ff36b12ae5 Mon Sep 17 00:00:00 2001 From: Pavel Kosko Date: Wed, 30 May 2018 17:10:48 +0300 Subject: [PATCH 1/8] Add ability to close menu on touch devices --- contextMenu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contextMenu.js b/contextMenu.js index c798590..9431d45 100644 --- a/contextMenu.js +++ b/contextMenu.js @@ -510,7 +510,7 @@ } function removeAllContextMenus(e) { - $document.find('body').off('mousedown', removeOnOutsideClickEvent); + $document.find('body').off('mousedown touchstart', removeOnOutsideClickEvent); $document.off('scroll', removeOnScrollEvent); $(_clickedElement).removeClass('context'); removeContextMenus(); @@ -579,7 +579,7 @@ } // Remove if the user clicks outside - $document.find('body').on('mousedown', removeOnOutsideClickEvent); + $document.find('body').on('mousedown touchstart', removeOnOutsideClickEvent); // Remove the menu when the scroll moves $document.on('scroll', removeOnScrollEvent); From 04a019413dd2a96fff0d4720ab933014094b952a Mon Sep 17 00:00:00 2001 From: Hieu Tran AGI 47 Date: Wed, 25 Jul 2018 14:52:24 +0800 Subject: [PATCH 2/8] Add an option to compile html string to help user can add html string with their custom directives. --- README.md | 1 + contextMenu.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 155dfbe..a19dca2 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ Every menu option is represented by an Object containing the following propertie | -------- | ---- | ----------- | | text | Function/String | A function that returns the string or the actual string itself. Either text or html must be specified | | html | Function/String | A function or string that returns the html to be used for this menu option. Either text or html must be specified | +| compile | Boolean | To compile html string to use a custom directive in the html string | | click | Function | The function to be called on click of the option| | enabled | Function/Boolean | A function returning whether the option is enabled or not, or a boolean | | displayed | Function/Boolean | A function returning whether the option is displayed or not, or a boolean. If not displayed, no element is created at all and nothing related to the item will be executed (events, functions returning children, etc.) | diff --git a/contextMenu.js b/contextMenu.js index c798590..4c7f658 100644 --- a/contextMenu.js +++ b/contextMenu.js @@ -23,8 +23,8 @@ // Triggers right after any context menu is opened ContextMenuOpened: 'context-menu-opened' }) - .directive('contextMenu', ['$rootScope', 'ContextMenuEvents', '$parse', '$q', 'CustomService', '$sce', '$document', '$window', - function ($rootScope, ContextMenuEvents, $parse, $q, custom, $sce, $document, $window) { + .directive('contextMenu', ['$rootScope', 'ContextMenuEvents', '$parse', '$q', 'CustomService', '$sce', '$document', '$window', '$compile', + function ($rootScope, ContextMenuEvents, $parse, $q, custom, $sce, $document, $window, $compile) { var _contextMenus = []; // Contains the element that was clicked to show the context menu @@ -50,8 +50,13 @@ // runs the function that expects a jQuery/jqLite element optionText = item.html($scope); } else { - // Assumes that the developer already placed a valid jQuery/jqLite element - optionText = item.html; + // Incase we want to compile html string to initialize their custom directive in html string + if (item.compile) { + optionText = $compile(item.html)($scope); + } else { + // Assumes that the developer already placed a valid jQuery/jqLite element + optionText = item.html; + } } } else { From 29e9d1488c37254549d09f91a6963ab0646c4338 Mon Sep 17 00:00:00 2001 From: Ilya Skiba Date: Thu, 9 Aug 2018 14:58:26 +0300 Subject: [PATCH 3/8] Adding possibility to specify custom close event close-menu-on attribute is added for handling the situations, when menu should be closed programmatically. Fix for (https://github.com/Templarian/ui.bootstrap.contextMenu/issues/120) --- contextMenu.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contextMenu.js b/contextMenu.js index c798590..79c0eda 100644 --- a/contextMenu.js +++ b/contextMenu.js @@ -617,6 +617,12 @@ }); }); }); + + if (attrs.closeMenuOn) { + $scope.$on(attrs.closeMenuOn, function () { + removeAllContextMenus(); + }); + } }; }]); // eslint-disable-next-line angular/window-service From 24b3d27fe1135d63cff0c9eddf70fc8d79dc780e Mon Sep 17 00:00:00 2001 From: Ilya Skiba Date: Tue, 14 Aug 2018 10:59:34 +0300 Subject: [PATCH 4/8] Adding possibility to specify custom close event Added some documentation for a new parameter --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 155dfbe..6286f28 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Add a reference to `contextMenu.js`. In your app config add `ui.bootstrap.contex - `context-menu-class` - A string literal containing a custom class to be added to the context menu (The <ul> elements) - `allow-event-propagation` - (Default: false) A boolean determining whether to allow event propagation. Note that if you set this to true, and don’t catch it with something else the browser’s context menu will be shown on top of this library’s context menu. - `model` - (See Model Attribute below) +- `close-menu-on` - (Default: '') A string literal containing event for triggering menu close action. ### View From 61ec34c1937f9779c801c2b97ef1af97950aa789 Mon Sep 17 00:00:00 2001 From: Pem Taira Date: Tue, 14 Aug 2018 23:44:40 +0800 Subject: [PATCH 5/8] Add .DS_Store to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5b04c74..04c4687 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea node_modules/ +.DS_Store \ No newline at end of file From c43433e1a250e8eaff9a68fb29e87a2970830f39 Mon Sep 17 00:00:00 2001 From: Pablo Villaverde Date: Thu, 18 Oct 2018 09:18:19 +0200 Subject: [PATCH 6/8] chore: set version to 1.2.0 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 49072f5..c1c081b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-bootstrap-contextmenu", - "version": "1.1.0", + "version": "1.2.0", "main": [ "contextMenu.js" ], diff --git a/package.json b/package.json index cf7cbf8..2cb3672 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-bootstrap-contextmenu", - "version": "1.1.0", + "version": "1.2.0", "description": "Angular Bootstrap Context Menu", "main": "contextMenu.js", "scripts": { From a077335b840c7419422b0f35a731f49b58ee0014 Mon Sep 17 00:00:00 2001 From: verbeurk Date: Fri, 18 Jan 2019 09:24:11 +0100 Subject: [PATCH 7/8] Fix contextmenu not reposition at bottom of screen on IE Fix contextmenu not closing on touch Fix case were no event got triggered to close a previous contextmenu, so we are clearing them before opening a new one --- contextMenu.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contextMenu.js b/contextMenu.js index f2b443a..fe8b000 100644 --- a/contextMenu.js +++ b/contextMenu.js @@ -386,7 +386,8 @@ $q.all($promises).then(function () { var topCoordinate = event.pageY; var menuHeight = angular.element($ul[0]).prop('offsetHeight'); - var winHeight = $window.scrollY + event.view.innerHeight; + var winHeight = $window.pageYOffset + event.view.innerHeight; + /// the 20 pixels in second condition are considering the browser status bar that sometimes overrides the element if (topCoordinate > menuHeight && winHeight - topCoordinate < menuHeight + 20) { topCoordinate = event.pageY - menuHeight; @@ -515,7 +516,7 @@ } function removeAllContextMenus(e) { - $document.find('body').off('mousedown', removeOnOutsideClickEvent); + $document.find('body').off('mousedown touchstart', removeOnOutsideClickEvent); $document.off('scroll', removeOnScrollEvent); $(_clickedElement).removeClass('context'); removeContextMenus(); @@ -573,6 +574,10 @@ angular.forEach(openMenuEvents, function (openMenuEvent) { element.on(openMenuEvent.trim(), function (event) { + // Cleanup any leftover contextmenus(there are cases with longpress on touch where we + // still see multiple contextmenus) + removeAllContextMenus(); + if(!attrs.allowEventPropagation) { event.stopPropagation(); event.preventDefault(); @@ -584,7 +589,7 @@ } // Remove if the user clicks outside - $document.find('body').on('mousedown', removeOnOutsideClickEvent); + $document.find('body').on('mousedown touchstart', removeOnOutsideClickEvent); // Remove the menu when the scroll moves $document.on('scroll', removeOnScrollEvent); From 08b66bc3854ffe874b50fedd1597587059edc687 Mon Sep 17 00:00:00 2001 From: Pem Taira Date: Tue, 26 Mar 2019 08:52:33 -0600 Subject: [PATCH 8/8] Chore: change version to 1.2.1 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index c1c081b..daf4522 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-bootstrap-contextmenu", - "version": "1.2.0", + "version": "1.2.1", "main": [ "contextMenu.js" ], diff --git a/package.json b/package.json index 2cb3672..acd65df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-bootstrap-contextmenu", - "version": "1.2.0", + "version": "1.2.1", "description": "Angular Bootstrap Context Menu", "main": "contextMenu.js", "scripts": {