Class: FileActions

OCA.Files.FileActions

new FileActions()

Construct a new FileActions instance
Source:

Members

$el

Dummy jquery element, for events
Source:

_updateListeners :Array.<function()>

List of handlers to be notified whenever a register() or setDefault() was called.
Type:
  • Array.<function()>
Source:

currentFile

Deprecated:
  • Yes
Source:

Methods

(static) updateFileActionSpinner($downloadButtonElement, showIt)

Replaces the download icon with a loading spinner and vice versa - also adds the class disabled to the passed in element
Parameters:
Name Type Description
$downloadButtonElement jQuery download fileaction
showIt boolean whether to show the spinner(true) or to hide it(false)
Source:

_defaultRenderAction(actionSpec, isDefault, context)

Default function to render actions
Parameters:
Name Type Description
actionSpec OCA.Files.FileAction file action spec
isDefault boolean true if the action is a default one, false otherwise
context OCA.Files.FileActionContext action context
Source:
Renders the action link element
Parameters:
Name Type Description
params Object action params
Source:

_notifyUpdateListeners(eventName, data)

Notifies the event handlers
Parameters:
Name Type Description
eventName String event name
data Object data
Source:

_renderInlineAction(actionSpec, isDefault, context)

Renders the action element by calling actionSpec.render() and registers the click event to process the action.
Parameters:
Name Type Description
actionSpec OCA.Files.FileAction file action to render
isDefault boolean true if the action is a default action, false otherwise
context OCA.Files.FileActionContext rendering context
Source:

_renderMenuTrigger($tr, context)

Renders the menu trigger on the given file list row
Parameters:
Name Type Description
$tr Object file list row element
context OCA.Files.FileActionContext rendering context
Source:

_showMenu(fileName, context)

Displays the file actions dropdown menu
Parameters:
Name Type Description
fileName string file name
context OCA.Files.FileActionContext rendering context
Source:

clear()

Clears all registered file actions.
Source:

display(parent, triggerEvent, fileList)

Display file actions for the given element
Parameters:
Name Type Description
parent "td" element of the file for which to display actions
triggerEvent if true, triggers the fileActionsReady on the file list afterwards (false by default)
fileList OCA.Files.FileList instance on which the action is done, defaults to OCA.Files.App.fileList
Source:

get(mime, type, permissions) → {Object.<string, OCA.Files.FileActions~actionHandler>}

Returns a map of file actions handlers matching the given conditions
Parameters:
Name Type Description
mime string mime type
type string "dir" or "file"
permissions int permissions
Source:
Returns:
map of action name to action spec
Type
Object.<string, OCA.Files.FileActions~actionHandler>

getActions(mime, type, permissions) → {Array.<OCA.Files.FileAction>}

Returns an array of file actions matching the given conditions
Parameters:
Name Type Description
mime string mime type
type string "dir" or "file"
permissions int permissions
Source:
Returns:
array of action specs
Type
Array.<OCA.Files.FileAction>

getDefault(mime, type, permissions) → {OCA.Files.FileActions~actionHandler}

Returns the default file action handler for the given conditions
Parameters:
Name Type Description
mime string mime type
type string "dir" or "file"
permissions int permissions
Deprecated:
  • use getDefaultFileAction instead
Source:
Returns:
action handler
Type
OCA.Files.FileActions~actionHandler

getDefaultFileAction(mime, type, permissions) → {OCA.Files.FileActions~actionHandler}

Returns the default file action handler for the given conditions
Parameters:
Name Type Description
mime string mime type
type string "dir" or "file"
permissions int permissions
Since:
  • 8.2
Source:
Returns:
action handler
Type
OCA.Files.FileActions~actionHandler

merge(fileActions)

Merges the actions from the given fileActions into this instance.
Parameters:
Name Type Description
fileActions OCA.Files.FileActions instance of OCA.Files.FileActions
Source:

off(eventName, Function)

Removes an event handler
Parameters:
Name Type Description
eventName String event name
Function callback
Source:

on(eventName, callback)

Adds an event handler
Parameters:
Name Type Description
eventName String event name
callback function
Source:

register()

Deprecated:
  • use #registerAction() instead
Source:

registerAction(action)

Register action
Parameters:
Name Type Description
action OCA.Files.FileAction object
Source:

registerDefaultActions()

Register the actions that are used by default for the files app.
Source:

setDefault(mime, name)

Sets the default action for a given mime type.
Parameters:
Name Type Description
mime String mime type
name String action name
Source:

triggerAction(actionName, fileInfoModel, fileListopt) → {boolean}

Trigger the given action on the given file.
Parameters:
Name Type Attributes Description
actionName string action name
fileInfoModel OCA.Files.FileInfoModel file info model
fileList OCA.Files.FileList <optional>
file list, for compatibility with older action handlers [DEPRECATED]
Since:
  • 8.2
Source:
Returns:
true if the action handler was called, false otherwise
Type
boolean

Type Definitions

actionHandler(fileName, context, fileInfoModel)

Action handler function for file actions
Parameters:
Name Type Attributes Description
fileName String name of the file on which the action must be performed
context context
Properties
Name Type Description
dir String directory of the file
fileInfoModel OCA.Files.FileInfoModel file info model
context.$file Object <optional>
jQuery element of the file [DEPRECATED]
context.fileList OCA.Files.FileList <optional>
the FileList instance on which the action occurred [DEPRECATED]
context.fileActions OCA.Files.FileActions the FileActions instance on which the action occurred
Source:

displayNameFunction(context) → {String}

Display name function for actions. The function returns the display name of the action using the given context information..
Parameters:
Name Type Description
context OCA.Files.FileActionContext action context
Source:
Returns:
display name
Type
String

renderActionFunction(actionSpec, $row, isDefault) → {Object}

Render function for actions. The function must render a link element somewhere in the DOM and return it. The function should NOT register the event handler as this will be done after the link was returned.
Parameters:
Name Type Description
actionSpec OCA.Files.FileAction action definition
$row Object row container
isDefault boolean true if the action is the default one, false otherwise
Source:
Returns:
jQuery link object
Type
Object