new AttachmentViewer()
(view) Show attachment and preview if possible
- Source:
Methods
(private, static) addClipboardEventHandler()
attaches the clipboard attachment handler to the page
- Source:
(private, static) addDragDropHandler()
attaches the file attachment drag & drop handler to the page
- Source:
(static) clearDragAndDrop()
Cleares the drag & drop data.
- Source:
(static) getAttachmentMimeType(attachmentData)
Get attachment mime type
Parameters:
Name | Type | Description |
---|---|---|
attachmentData |
string | Base64 string |
- Source:
(static) getAttachmentPreview() → {jQuery}
getter for attachment preview
- Source:
Returns:
- Type
- jQuery
(static) getAttachments() → {array}
return the attachments
- Source:
Returns:
- Type
- array
(static) getAttachmentsData() → {Array.<string>}
getter for attachment data
- Source:
Returns:
- Type
- Array.<string>
(private, static) getBlobUrl(data, data) → {string}
get blob URL from string data and mime type
Parameters:
Name | Type | Description |
---|---|---|
data |
string | raw data of attachment |
data |
string | mime type of attachment |
- Source:
Returns:
objectURL
- Type
- string
(static) getFiles() → {Array.<FileList>}
getter for files data, returns the file list
- Source:
Returns:
- Type
- Array.<FileList>
(static) handleBlobAttachmentPreview($targetElement, file, mime)
handle the preview of files decoded to blob that can either be an image, video, audio or pdf element
Parameters:
Name | Type | Description |
---|---|---|
$targetElement |
jQuery | element where the preview should be appended |
file |
string | as a blob URL |
mime |
string | type |
- Source:
(static) hasAttachment()
checks if there is an attachment displayed
- Source:
(static) hasAttachmentData()
checks if there is attachment data (for preview!) available
It returns true, when there is data that needs to be encrypted.
- Source:
(static) hasAttachmentPreview() → {JQuery}
checks if has any attachment preview
- Source:
Returns:
- Type
- JQuery
(static) hideAttachment()
hides the attachment
This will not hide the preview (see AttachmentViewer.hideAttachmentPreview
for that) nor will it hide the attachment link if it was moved somewhere
else (see AttachmentViewer.moveAttachmentTo).
- Source:
(static) hideAttachmentPreview()
hides the attachment preview
- Source:
(static) init()
initiate
preloads jQuery elements
- Source:
(static) moveAttachmentTo($element, attachment, label)
moves the attachment link to another element
It is advisable to hide the attachment afterwards (AttachmentViewer.hideAttachment)
Parameters:
Name | Type | Description |
---|---|---|
$element |
jQuery | the wrapper/container element where this should be moved to |
attachment |
array | attachment data |
label |
string | the text to show (%s will be replaced with the file name), will automatically be translated |
- Source:
(private, static) printDragAndDropFileNames(fileNames)
Print file names added via drag & drop
Parameters:
Name | Type | Description |
---|---|---|
fileNames |
array |
- Source:
(private, static) readFileData(loadedFiles)
read files data as data URL using the FileReader API
Parameters:
Name | Type | Description |
---|---|---|
loadedFiles |
Array.<FileList> | (optional) loaded files array |
- Source:
- See:
(static) removeAttachment()
removes the attachment
This automatically hides the attachment containers too, to
prevent an inconsistent display.
- Source:
(static) removeAttachmentData()
removes the attachment data
This removes the data, which would be uploaded otherwise.
- Source:
(static) setAttachment(attachmentData, fileName)
sets the attachment but does not yet show it
Parameters:
Name | Type | Description |
---|---|---|
attachmentData |
string | base64-encoded data of file |
fileName |
string | optional, file name |
- Source:
(static) showAttachment()
displays the attachment
- Source: