Confirmed users
764
edits
(→Separator: Separators don't take options, can't be added to top-level menu) |
(Updated: 1) onCommand -> onClick, and 2) onClick is passed the clicked item, not data) |
||
Line 153: | Line 153: | ||
; label: The label of the menuitem, a string. Required. | ; label: The label of the menuitem, a string. Required. | ||
; | ; onClick: An optional function that will be called when the menuitem is clicked. It is called as <tt>onClick(contextObj, item)</tt>. <tt>contextObj</tt> is an object describing the context in which the menu was invoked. See [[#Context Descriptions]]. <tt>item</tt> is the item itself. | ||
</blockquote> | </blockquote> | ||
Line 175: | Line 175: | ||
; label: The label of the menuitem, a string. | ; label: The label of the menuitem, a string. | ||
; | ; onClick: An optional function that will be called when any of the item's descendants is clicked. (The commands of descendants are invoked first, in a bottom-up, bubbling manner.) It is called as <tt>onClick(contextObj, item)</tt>. <tt>contextObj</tt> is an object describing the context in which the menu was invoked. See [[#Context Descriptions]]. <tt>item</tt> is the item that was clicked. | ||
</blockquote> | </blockquote> | ||
Line 218: | Line 218: | ||
var editImageItem = contextMenu.Item({ | var editImageItem = contextMenu.Item({ | ||
label: "Edit Image", | label: "Edit Image", | ||
onClick: function (context) { | |||
editImage(context.node.src); | editImage(context.node.src); | ||
}, | }, | ||
Line 235: | Line 235: | ||
var searchMenu = contextMenu.Menu({ | var searchMenu = contextMenu.Menu({ | ||
label: "Search", | label: "Search", | ||
onClick: function (context, item) { | |||
context.window.location.href = data + selection.text; | context.window.location.href = item.data + selection.text; | ||
}, | }, | ||
context: selectionExists, | context: selectionExists, | ||
Line 256: | Line 256: | ||
var pageSourceItem = contextMenu.Item({ | var pageSourceItem = contextMenu.Item({ | ||
label: "Edit Page Source", | label: "Edit Page Source", | ||
onClick: function (context) { | |||
editSource(context.document.URL); | editSource(context.document.URL); | ||
}, | }, | ||
Line 269: | Line 269: | ||
var editImagesItem = contextMenu.Item({ | var editImagesItem = contextMenu.Item({ | ||
label: "Edit Page Images", | label: "Edit Page Images", | ||
onClick: function (context) { | |||
var imgNodes = context.document.querySelectorAll("img"); | var imgNodes = context.document.querySelectorAll("img"); | ||
editImages(imgNodes); | editImages(imgNodes); |