LP#1402797 Make grid context menu safer and more state-aware
authorMike Rylander <mrylander@gmail.com>
Mon, 9 Feb 2015 22:19:34 +0000 (17:19 -0500)
committerBill Erickson <berickxx@gmail.com>
Wed, 25 Feb 2015 16:16:08 +0000 (11:16 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/staff/services/grid.js

index f5f1237..42330b1 100644 (file)
@@ -501,17 +501,28 @@ angular.module('egGridMod',
                 $($scope.action_context_parent).append(menu_dom);
                 $scope.action_context_oldy = $scope.action_context_oldx = 0;
                 $('body').unbind('click.remove_context_menu');
+                $scope.action_context_showing = false;
             }
 
+            $scope.action_context_showing = false;
             $scope.showActionContextMenu = function ($event) {
-                var menu_dom = $($scope.grid_element).find('.grid-action-dropdown')[0];
-                $scope.action_context_width = $(menu_dom).css('width');
-                $scope.action_context_y = $(menu_dom).css('top');
-                $scope.action_context_x = $(menu_dom).css('left');
-                $scope.action_context_parent = $(menu_dom).parent();
-
-                $('body').append($(menu_dom));
-                $('body').bind('click.remove_context_menu', $scope.hideActionContextMenu);
+                var current_parent = $scope.grid_element;
+                if ($scope.action_context_showing) {
+                    current_parent = $('body');
+                }
+
+                var menu_dom = $(current_parent).find('.grid-action-dropdown')[0];
+
+                if (!$scope.action_context_showing) {
+                    $scope.action_context_width = $(menu_dom).css('width');
+                    $scope.action_context_y = $(menu_dom).css('top');
+                    $scope.action_context_x = $(menu_dom).css('left');
+                    $scope.action_context_parent = $(menu_dom).parent();
+                    $scope.action_context_showing = true;
+
+                    $('body').append($(menu_dom));
+                    $('body').bind('click.remove_context_menu', $scope.hideActionContextMenu);
+                }
 
                 $(menu_dom).css({
                     display: 'block',