OmniLink jQuery Plug-in

The OmniLink plug-in attaches OmniLink functionality to one or more elements.

var omnilink = $(selector).omnilink(options);

options parameterises the plug-in. The returned object can be used to set or get the node version reference, using setPath(nodeVersionReference), or getPath() to return the node version reference.

The options are described below.

context Reference for node from which the path is resolved and to which links will be created. This is typically the node on which the OmniLink is displayed. It defaults to the nodeVersionReference global variable.
folder The package to use for the creation of new nodes. Can be a node reference or a dynamic binding.
node The node to be initially selected.
selectionMode Indicates whether nodes or folders are being selected. Set to "node" or "folder". "node" is the default.

In folder selection mode, any items on which the user clicks are opened as folders, and the folder is returned as the selected path. In node selection mode, items on which the user clicks are simply highlighted and the node is returned as the selected path.

strictPath If set to true, prevents the user selecting a different path and the address bar is hidden. If select is false and strictPath is true, the selection area is hidden. strictPath defaults to false.
hide Whether to show the element to which the OmniLink is attached. Default is true.
collapsed Whether to show the OmniLink in an initial collapsed state as a button. The button acts as a drag target, and clicking on the button opens the OmniLink. Default is false.

Collapsed is assumed to be true if popup is true.

select If set to false, disables selection of existing nodes, disables selection of the path (i.e. implies strict path, too), and disables the ability to "unselect" a link. This only makes sense with the create, upload and shortcut options, as a way of creating a new node or shortcut or uploading a file.
selectButton If set to true, creates a button on the form for the user to confirm the selection. If collapsed is true, this will re-collapse the form. Default is false.
selectCaption Caption for the select button. Defaults to 'Done'.
cancelButton If select button is true and collapsed is true, will add a cancel button next to the select button. This is useful when the select button is used to perform some action and a method is required for the user to cancel the action.
closeCaption Caption for the cancel button. Defaults to 'Cancel'.
mode What modes to support:
  • both – support both modes, toggle between the two. This is the default.
  • drop – support drop mode only
  • form – support form mode only
initialMode When mode is both, which mode to show initially? Set to 'drop', 'form' or 'auto'. Default is 'auto', which is the last used one, or drop if none has been used.
remember Whether to remember the last path and the last mode when the user is reshown the same OmniLink again in the same session. Default is true.
refresh Whether the page should be refreshed when a selection has been made, or a new node, file upload or shortcut created.
submit If the OmniLink is on a form, whether the form should be submitted when a selection has been made, or a new node, file upload or shortcut created.
open Whether the selected node should be opened.
submitData An object containing properties and value which represent additional data to send when submitting the form. This is typically used to simulate a button press, e.g. "submitData":{"updateButton":"apply"}
tags The node version references of one or more tags to filter the selected nodes. Passed as a blank-delimited list.
strictTags If set to true, prevents the user selecting nodes that do not have the tag. If false (the default), an "All types" option is shown.
returnFolders Set to true to return nodes that look like folders even if they are not selected by the tags.
returnTypes Set to true to return nodes that look like types even if they are not selected by the tags.
link Whether to link the selected or created node to the context. Default is false. If the member type has a cardinality of 1, selection will replace existing targets. If a cardinality other than 1, it will be added to the existing targets.
link must be used in conjunction with select, create, upload or shortcut.
memberType The member type to use with the link.
linkText Text (node member value) to associate with the link. If cardinality of the member type is 1 and text is not given, existing text will be retained.
linkNumber Number (node member scale) to associate with the link. If cardinality of the member type is 1 and scale is not given, existing scale will be retained.
run Whether to run a script against the selected or created node. Default is false.

The script will be run passing it the context in the context parameter, and the selected or created node in the node parameter.

script The script to be run if the run option is set.
create Whether to allow creation of new nodes.
types If create is true, the node version references of one or more node types to offer the user. Passed as a blank-delimited list.
upload Whether to allow upload of files.
overwrite For uploads, if set to true, overwrites files with the same generated reference.
sequentialSuffix For uploads, if overwrite is false and this is true, uses sequential rather than random suffixes to distinguish file names. Suffixes start at _2, i.e. "my_file", "my_file_2", "my_file_3".
fileType If upload is true, the node version reference of the file type (only one allowed). Defaults to the user file type.
fileInfo Set to true to allow upload of files, but to return file info rather than create file nodes.
multiple Set to true to enable upload of multiple files (works with upload and fileInfo).
shortcut Whether to automatically create shortcuts for external URLs dragged into the drag area.
shortcutType If shortcut is true, type to use to create shortcuts. Default is library.core.RedirectNodeType. Type must support library.core.RedirectURL.
nameInput When using create, upload and multiple, whether to show a field for name input. Default is true.
showDragNotName When nameInput is false, replace the name input area with a drag legend. Has no effect if nameInput is not false.
dragCaption Caption to show in drag area. Defaults to "Drag here".
selectFunction Function to be called after a node is selected, or a new node, file upload or shortcut is created. It is passed three parameters:
  • reference - node version reference of selected node
  • name - name of selected node
  • finished - set to true if the user has finished the selection

If fileInfo is set, an array of all fileInfo objects is passed in reference and name is null.

folderSelect Set to true to turn on default folder selection options.
typeSelect Set to true to turn on default type selection options.
cssClass Additional class or classes to add to the omnilink-container. The following classes may be useful:
  • omnilink-drop-container – useful for formatting the form like the drop area, when using the form for file uploads only
  • omnilink-form-plain – turn off the border, background colour and padding for the form. Useful with omnilink-drop-container, and it further formatting is required.
buttonClass Classes for the Omnilink button. Default is "btn btn-info", or "btn btn-default btn-xs omnilink-button-margin-left" for buttons generated nexte to nodeReferenceInput fields.
iconClass Classes to format the omnilink icon. Defaults to "fa fa-link".
iconText Content for the icon. Defaults to "".
nameSelector When used with the omnilink-input class (see below), identifies an element which is a descendant of the input field's parent that should be set to the name of the selected node.
debug Set to true create console output showing options and web service calls.

onmilink class

The omnilink class is a convenience class for attaching omnilink functionality to an element. Options are read from the data-omnilink attribute on the same element as the class.

omnilink functionality is automatically added to all input fields with the class nodeReferenceInput in a manner suitable for standard node edit forms.

Options for reference input fields can be set using the system.PROPERTIES.omniLink member type display property.

Where the nodeReferenceInput method is not suitable (e.g. on a script-generated form), the omnilink-input class can be used in conjunction with omnilink to support input of node references. This makes the input readonly while the omnilink is active (and, by default, hides the input).

Add omnilink-fallback class on the element immediately after the element with omnilink to provide fallback capability. This will be hidden if the omnilink is active.