canmove, Confirmed users
1,584
edits
(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 | 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) | ; 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 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: | ||
}; | }; | ||
=== ContextHelper properties === | |||
==== 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: | ; 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 ==== | |||
; 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 | ; ContextHelper.popupState.linkURL: The address of the link. | ||
; ContextHelper.popupState.linkProtocol: The URI scheme of the link | ; ContextHelper.popupState.linkProtocol: The URI scheme of the link address. | ||
; ContextHelper.popupState.mediaURL: The image's | ; 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] | ||