Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #657 from abbeyj/operator-context-menu
Browse files Browse the repository at this point in the history
Fix the context menu not appearing when clicking on a call to operator()
  • Loading branch information
abbeyj committed Jan 26, 2018
2 parents d257b14 + c0c162f commit 7d42537
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions dxr/static_unhashed/js/context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,16 @@ $(function() {

word = selectedTxtString.substr(startIndex, endIndex - startIndex);

// No word was clicked on, nothing to search.
if (word === '') {
return;
}
var menuItems = [];

// Build the Object needed for the context-menu template.
var contextMenu = {},
menuItems = [{
if (word !== '') {
// A word was clicked on.
menuItems.push({
html: 'Search for the substring <strong>' + htmlEscape(word) + '</strong>',
href: dxr.wwwRoot + "/" + encodeURIComponent(dxr.tree) + "/search?q=" + encodeURIComponent(word),
icon: 'search'
}];
});
}

var currentNode = $(node).closest('a');
// Only check for the data-menu attribute if the current node has an
Expand All @@ -168,13 +166,17 @@ $(function() {
menuItems = menuItems.concat(currentNodeData);
}

contextMenu.menuItems = menuItems;
if (menuItems.length === 0) {
// Nothing to display.
return;
}

// Rather than putting the context menu in the file container,
// attaching it to the body makes the re-layout much quicker
// because the lines of the file do not need to be re-flowed.
// In the end they're the same, since the menu will be absolute'd
// to where it should go.
setContextMenu($('body'), contextMenu, event);
setContextMenu($('body'), { menuItems: menuItems }, event);
}
});

Expand Down

0 comments on commit 7d42537

Please sign in to comment.