This mixin can be used to wrap HTML elements in a widget with an anchor element that allows users to use the browser context-menu to copy or open the link in a new tab or window. This works around the fact that all Aikau navigation is achieved via publishing requests to be handled by the Navigation Service.
This should be mixed into a widget and then the makeAnchor function should be called by the postCreate function (or any function called after the widgets DOM has been created). In order for this to work the getAnchorTargetSelectors should be overridden to return an array of the CSS selectors needed to identify the elements to be wrapped with an anchor element.
- Copyright:
- Copyright (C) 2005-2020 Alfresco Software Limited
- License:
- GNU Lesser General Public License, see: Open Source Licensing
- Source:
Extends
Members
-
cssRequirements :object[]
-
An array of the CSS files to use with this widget.
Type:
- object[]
- Default Value:
- [{cssFile:"./css/_HtmlAnchorMixin.css"}]
- Source:
-
excludeFromTabOrder :boolean
-
When set to true, the resulting anchor(s) will be removed from the page tab-order by setting their tabindex to -1.
Type:
- boolean
- Since:
- 1.0.40
- Default Value:
- true
- Source:
-
label :string
-
The title text to put on the generated link(s).
Type:
- string
- Default Value:
- null
- Source:
-
wrapAllChildren :boolean
-
When set to true, all of the direct children of this widget's root node will be wrapped in a single anchor, when makeAnchor() is called.
Type:
- boolean
- Since:
- 1.0.40
- Default Value:
- false
- Source:
Methods
-
_addAnchors(url)
-
This function is called for any menu item with a targetUrl. By default it addresses the known menu items DOM structures of the AlfMenuItem and AlfMenuBarItem. However, it can be extended or updated to handle the DOM structure of additional menu widgets.
Parameters:
Name Type Description url
string The URL to use for the anchor - Source:
-
getAnchorTargetSelectors() → {array}
-
This function should be overridden to provide an array of the CSS selectors to use to identify the elements to wrap in an anchor. By default this will return an empty array.
- Source:
Returns:
- Type
- array
-
makeAnchor(url, type)
-
When a targetUrl is specified we want to wrap menu item labels in elements to allow the browsers context menu to access the URL (most commonly used for opening a page in a new tab). However, we aren't going to allow the browser to process the link as we still want it to go via the NavigationService...
Parameters:
Name Type Description url
string The URL configured type
string The target configured - Source: