Skip to content

Instantly share code, notes, and snippets.

@kmaglione
Created December 4, 2011 21:22
Show Gist options
  • Save kmaglione/1431321 to your computer and use it in GitHub Desktop.
Save kmaglione/1431321 to your computer and use it in GitHub Desktop.
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