Mobile/Fennec/Extensions/UserInterface/Site Menu: Difference between revisions

new in 2.0
(document the new PageActions.register API)
 
(new in 2.0)
Line 1: Line 1:
== Introduction ==
[http://www.flickr.com/photos/madhava_work/4521940382/ http://farm3.static.flickr.com/2708/4521940382_8c2f403cd5_m.jpg]
[http://www.flickr.com/photos/madhava_work/4521940382/ http://farm3.static.flickr.com/2708/4521940382_8c2f403cd5_m.jpg]


Line 7: Line 5:
By default it shows security information, controls to add a search providers and clear site-specific preferences, and commands to share, save, or find within the page.
By default it shows security information, controls to add a search providers and clear site-specific preferences, and commands to share, save, or find within the page.


Add-ons can use the site panel to display additional information or actions related to the current page.  To extend the site menu, add a new <tt>pageaction</tt> element within the <tt>#pageactions-container</tt> hbox.
== Adding to the Site Menu ==


== Adding to the Site Menu ==
Add-ons can use the site panel to display additional information or actions related to the current page.


To add a command to the site menu, add a ''pageaction'' element to the ''#pageactions-container'' box.  For example, in a [https://developer.mozilla.org/en/XUL_Overlays XUL overlay] you could write:
To add a command to the site menu, add a ''pageaction'' element to the ''#pageactions-container'' box.  For example, in a [https://developer.mozilla.org/en/XUL_Overlays XUL overlay] you could write:
Line 22: Line 20:
== Changing Site Menu items ==
== Changing Site Menu items ==


If you want to enable, disable, or change your pageaction, you can register a method to be called each time the menu appears.  Use the ''PageActions.register'' function.
'''New in Fennec 2.0:''' If you want to enable, disable, or change your pageaction, you can register a method to be called each time the menu appears.  Use the ''PageActions.register'' function:
 
=== PageActions.register API ===


  PageActions.register(id, callback, thisObject);
  PageActions.register(id, callback, thisObject); // Requires Fennec 2.0a1 or higher.


; id: The ID of your pageaction element.  (Remember, your IDs should include a string that is unique to your add-on, to avoid conflicting with Fennec code or other add-ons.)
; id: The ID of your pageaction element.  (Remember, your IDs should include a string that is unique to your add-on, to avoid conflicting with Fennec code or other add-ons.)
Line 32: Line 28:
; thisObject: (optional) An object to use as "this" in the callback function.
; thisObject: (optional) An object to use as "this" in the callback function.


=== Example ===
For example:


  PageActions.register("sayhello-action", function(element) {
  PageActions.register("sayhello-action", function(element) {
canmove, Confirmed users
1,584

edits