Created
December 4, 2011 21:22
-
-
Save kmaglione/1431321 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let objects = Class({ | |
get eventTarget() this, | |
fooEvents: { | |
popupshowing: function onPopupShowing(event) { | |
mow.contextEvents.popupshowing.call(mow, event); | |
} | |
}, | |
events: { | |
popupshowing: function onPopupShowing(event) { | |
let menu = DOM(this.menu); | |
menu.empty().append( | |
template.map(iter(bookmarks.searchEngines, bookmarkcache.keywords), | |
function ([keyword, item]) | |
<menuitem xmlns={XUL} xmlns:dactyl={NS} | |
dactyl:command="search.searchSelection" | |
label={item.title} | |
image={item.icon} | |
keyword={item.keyword}/>)); | |
} | |
} | |
})(); | |
overlay.overlayWindow(window, { | |
objects: objects, | |
after: <e4x xmlns={XUL} xmlns:dactyl={NS}> | |
<menuitem id="context-searchselect" style="visibility: collapse;"> | |
<menu id="dactyl-context-search" | |
label="Search Selection" | |
group="selection" | |
class="menu-iconic"><menupopup key="menu" highlight="Events"/></menu> | |
</menuitem> | |
</e4x>.elements() | |
}); | |
events.listen(document.getElementById("contentAreaContextMenu"), objects, "fooEvents"); | |
dactyl.commands["search.searchSelection"] = function searchSelection(event) { | |
let elem = DOM(event.originalTarget); | |
dactyl.open(elem.attr("keyword") + " " + document.popupNode.ownerDocument.defaultView.getSelection(), | |
{ from: "context-search" }); | |
}; | |
options.get("activate") | |
.values["context-search"] = "Context menu search"; | |
options.get("newtab") | |
.values["context-search"] = "Context menu search"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment