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

Jump to navigation Jump to search
m
formatting
(new in 2.0)
m (formatting)
Line 9: Line 9:
Add-ons can use the site panel to display additional information or actions related to the current page.
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:


   <hbox id="pageactions-container">
   <hbox id="pageactions-container">
Line 20: Line 20:
== Changing Site Menu items ==
== Changing Site Menu items ==


'''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:
'''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(id, callback, thisObject); // Requires Fennec 2.0a1 or higher.
  PageActions.register(id, callback, thisObject); // Requires Fennec 2.0a1 or higher.
Line 28: 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.


For example:
'''Example'''


  PageActions.register("sayhello-action", function(element) {
  PageActions.register("sayhello-action", function(element) {
Line 41: Line 41:
  });
  });


== Examples ==
== Sample Code ==


* For a basic XUL example, see the [http://bitbucket.org/mbrubeck/readlater/src/tip/content/overlay.xul Read Later source code].
* For a basic XUL example, see the [http://bitbucket.org/mbrubeck/readlater/src/tip/content/overlay.xul Read Later source code].
* See the [http://hg.mozilla.org/users/mfinkle_mozilla.com/mobiletools/file/9eaf872b5184/content/overlay.js Mobile Tools source code] for an add-on that inserts a new pageaction using JavaScript.
* See the [http://hg.mozilla.org/users/mfinkle_mozilla.com/mobiletools/file/9eaf872b5184/content/overlay.js Mobile Tools source code] for an add-on that inserts a new pageaction using JavaScript.
* See the PageActions.init function in [http://mxr.mozilla.org/mobile-browser/source/chrome/content/browser-ui.js Fennec's browser-ui.js] for examples using the PageActions.register API.
* See the PageActions.init function in [http://mxr.mozilla.org/mobile-browser/source/chrome/content/browser-ui.js Fennec's browser-ui.js] for examples using the PageActions.register API.
canmove, Confirmed users
1,584

edits

Navigation menu