Labs/Jetpack/Reboot/JEP/112: Difference between revisions

Line 139: Line 139:
Important points so far:
Important points so far:


# Domain of API must be all browser pages, not just a single node or page.
# Consumers must specify a context.  They can game the system by specifying a universal context, but being forced to specify a context nudges them to not abuse the <em>context</em> menu and consider alternative UI if their context is truly universal.
# Consumers must specify a context.  They can game the system by specifying a universal context, but being forced to specify a context nudges them to not abuse the <em>context</em> menu and consider alternative UI if their context is truly universal.
# Contexts can be specified in different ways: selectors, functions, nodes?, ...
# Contexts can be specified in different ways: selectors, functions, nodes?, ...
Line 155: Line 156:


* <tt>context</tt>: Describes the context in which the modifications should occur.  It can be any of the following types:
* <tt>context</tt>: Describes the context in which the modifications should occur.  It can be any of the following types:
** string: A CSS selector.  The <tt>"*"</tt> selector is not allowed.  (That limitation is easy to circumvent, e.g., <tt>"html *"</tt>, but at least that gives people who find examples in random places a better understanding of the param's purpose than what <tt>"*"</tt> would encourage.)
** string: A CSS selector.  Selectors that match the <tt>html</tt> and <tt>body</tt> elements (such as <tt>"*"</tt>) are not allowed.
** function: An arbitrary predicate.  Will be invoked just before the menu is shown.  If it returns true, the modifications will occur.  It will be called as <tt>function(node)</tt>.  <tt>node</tt> is the node the user clicked to invoke the menu.
** function: An arbitrary predicate.  Will be invoked just before the menu is shown.  If it returns true, the modifications will occur.  It will be called as <tt>function(node)</tt>.  <tt>node</tt> is the node the user clicked to invoke the menu.
* <tt>target</tt>: A string, regular expression, or integer describing an existing menuitem.  Same as the prototype's menu implementation.
* <tt>target</tt>: A string, regular expression, or integer describing an existing menuitem.  Same as the prototype's menu implementation.
Confirmed users
764

edits