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

Jump to navigation Jump to search
m
minor fixes
(new)
 
m (minor fixes)
Line 16: Line 16:
== Target types ==
== Target types ==


The '''type''' attribute contains a space-delimited list of type names.  If the the element that the user touches matches any of the included types, then the menu item will be displayed.  Otherwise  
The '''type''' attribute contains a space-delimited list of type names.  If the the target element (the page element the user touched) matches any of the included types, then the menu item will be visible.  Otherwise it will be hidden.


The available types are:
The available types are:
Line 27: Line 27:
; video: (new in Fennec 2.0b1) A <video> element.
; video: (new in Fennec 2.0b1) A <video> element.
; link-saveable: (new in Fennec 2.0a1) Any link type except mailto:, javascript:, and news:.
; link-saveable: (new in Fennec 2.0a1) Any link type except mailto:, javascript:, and news:.
; link-shareable, image-shareable, video-shareable: (new in Fennec 2.0a1): Any link type except chrome:, about:, file:, javascript:, or resource:.
; link-shareable, image-shareable, video-shareable: (new in Fennec 2.0a1) Any link type except chrome:, about:, file:, javascript:, or resource:.
 
== Adding new target types ==


'''New in Fennec 2.0a1:''' If the built-in types do not work for your add-on,
'''New in Fennec 2.0a1:''' If the built-in types do not work for your add-on,
Line 38: Line 40:
the target DOM element.  It can modify the popupState to add new data that
the target DOM element.  It can modify the popupState to add new data that
will be passed to the commands' onclick handlers (see below).  The callback
will be passed to the commands' onclick handlers (see below).  The callback
can return ''true'' if the element "matches" the new type, or ''false''
can return ''true'' if the target element "matches" the new type, or ''false''
otherwise.
otherwise.


Line 67: Line 69:


  ShowTitle.onclick = function() {
  ShowTitle.onclick = function() {
  var state = ContextHelper.popupState || ContextHelper.popupNode;
   var text = ContextHelper.popupNode.title || ContextHelper.popupNode.title || 'no text';
   var text = ContextHelper.popupNode.title || ContextHelper.popupNode.title || 'no text';
   setTimeout(function() {
   setTimeout(function() {
Line 77: Line 78:
  };
  };


Here is a reference to the ContextHelper API:
=== ContextHelper properties ===


'''Fennec 1.1'''
==== Fennec 1.1 ====


; ContextHelper.popupNode: The DOM element that received the long-tap gesture.
; ContextHelper.popupNode: The DOM element that received the long-tap gesture.
; ContextHelper.linkURL: The address of the link.
; ContextHelper.linkURL: The address of the link.
; ContextHelper.mediaURL: The address of the image.
; ContextHelper.mediaURL: The address of the image.
; ContextHelper.onSaveableLink: (boolean) true if the link is not a javascript/mailto/news link.
; ContextHelper.popupState.linkProtocol: The URI scheme of the link address.
; ContextHelper.onSaveableLink: ''true'' if the link is not a javascript/mailto/news link.


'''Fennec 2.0'''
==== Fennec 2.0 ====


; ContextHelper.popupState: An object containing more information about the target element.
; ContextHelper.popupState: An object containing more information about the target element.
Line 92: Line 94:
; ContextHelper.popupState.label: A string describing the target element.
; ContextHelper.popupState.label: A string describing the target element.
; ContextHelper.popupState.linkTitle: The text of the link.
; ContextHelper.popupState.linkTitle: The text of the link.
; ContextHelper.popupState.linkURL: The address of the link (or null).
; ContextHelper.popupState.linkURL: The address of the link.
; ContextHelper.popupState.linkProtocol: The URI scheme of the link href (or null).
; ContextHelper.popupState.linkProtocol: The URI scheme of the link address.
; ContextHelper.popupState.mediaURL: The image's src address (or null).
; ContextHelper.popupState.mediaURL: The image or video's source address.


== Sample Code ==
== Sample Code ==


* [http://bitbucket.org/mbrubeck/showtitle/src/tip/content/ Show Image Title source code]
* [http://bitbucket.org/mbrubeck/showtitle/src/tip/content/ Show Image Title source code]
canmove, Confirmed users
1,584

edits

Navigation menu