Skip to content

Latest commit

 

History

History
331 lines (245 loc) · 11.4 KB

JS.md

File metadata and controls

331 lines (245 loc) · 11.4 KB

Objects

settings : object

vulcanup settings by default.

External

jQuery

jQuery object.

jQuery.fn

The jQuery plugin namespace.

jQuery.vulcanup

The plugin global configuration object.

settings : object

vulcanup settings by default.

Kind: global namespace

settings.type : String

The kind of file the uploader will treat: all | image | pdf.

Kind: static property of settings
Default: 'all'

settings.url : String

This is the initial value.

Kind: static property of settings
Default: null

settings.name : String

If there is an url, the initial file name. Is optional.

Kind: static property of settings
Default: ''

settings.enableReupload : Boolean

Enable file reupload. If false, once the file is uploaded, you have to delete it in order to upload another in its place.

Kind: static property of settings
Default: true

settings.imageContain : Boolean

On type image, if the image is treated as background contain, instead of cover and being resized.

Kind: static property of settings
Default: false

settings.imageResize : Boolean

On type image, resize the image visualizator when the image is loaded. If this is set to false, the background will have to be resized manually.

Kind: static property of settings
Default: true

settings.imageMinHeight : Number

Minimum image height in pixels.

Kind: static property of settings
Default: 100

settings.imageMaxHeight : Number

Maximum image height in pixels.

Kind: static property of settings
Default: 400

settings.canRemove : Boolean

If the file can be removed, insert an option to do so.

Kind: static property of settings
Default: true

settings.showValidations : Boolean

Show the validations visually. Programmer has to attach an event handler to detect errors if set to false.

Kind: static property of settings
Default: true

settings.handler : function

Server response handler. If set, this will overwrite the way to treat the response from server when the file is uploaded. This function receives as first parameter the response from server and have to return an object with the an url property with the file url.

Kind: static property of settings
Default: null

settings.fileupload : Object

File upload plugin options.

Kind: static property of settings

fileupload.url : String

URL to upload files.

Kind: static property of fileupload
Default: '/api/files'

fileupload.type : String

XHR type.

Kind: static property of fileupload
Default: 'POST'

fileupload.paramName : String

The file param name.

Kind: static property of fileupload
Default: 'file'

fileupload.minFileSize : Number

minFileSize in bytes

Kind: static property of fileupload
Default: 1 (1 byte)

fileupload.maxFileSize : Number

maxFileSize in bytes

Kind: static property of fileupload
Default: 2000000 (2MB)

fileupload.acceptFileTypes : RegExp

acceptFileTypes

Kind: static property of fileupload
Default: undefined (any file)

settings.types : Object

The type of files accepted. Every property (the type id) should be an object describing:

  • {String} name - The name of the file for the user.
  • {RegExp} formats - The regexp to validate the file type.
  • {String} formatsText - The list of formats for the user.

Kind: static property of settings

settings.messages : Object

All messages used.

Kind: static property of settings

settings.icons : Object

All icons used.

Kind: static property of settings

jQuery

jQuery object.

Kind: global external
See: http://api.jquery.com/jQuery/

jQuery.fn

The jQuery plugin namespace.

Kind: global external
See: The jQuery Plugin Guide

jQuery.fn.vulcanup(update, fileInfo) ⇒ jQuery

Invoke over instantiated elements.

Update the current file as uploaded.

Kind: static method of jQuery.fn
Returns: jQuery - The same element.

Param Type Description
update String With value 'update'.
fileInfo Object The file details.
fileInfo.url String The file URL.
[fileInfo.name] String The file name.

Example

$('#inputFile').vulcanup('update', {
  url: '/path/to/file.ext'
});

jQuery.fn.vulcanup(get) ⇒ Object | null

Invoke over instantiated elements.

Get the current uploaded file.

Kind: static method of jQuery.fn
Returns: Object | null - The file info or null if there is no file.

Param Type Description
get String With value 'get'.

Example

const fileInfo = $('#inputFile').vulcanup('get');  // { url, name }

jQuery.fn.vulcanup([settings])

Invoke on a <input type="file"> to set it as a file uploader.

By default the configuration is settings but you can pass an object to configure it as you want.

Listen to event changes on the same input, review demo to see how to implement them and what parameters they receive:

vulcanup-val - On validation error. Receives as parameter an object with the error message.

vulcanup-upload - On file started to being uploaded.

vulcanup-progress - On upload progress update. Receives as parameter the progress number.

vulcanup-error - On server error. Receives as parameter an object with details.

vulcanup-change - On file change. This is triggered when the user uploads a file in the server, when it is deleted or when it is changed programmatically. Receives as parameter an object with the new file details.

vulcanup-delete - On file deleted. Receives as parameter the deleted file details.

vulcanup-uploaded - On file uploaded in the server.

vulcanup-complete - On upload process completed. This is fired when the XHR is finished, regardless of fail or success.

Kind: static method of jQuery.fn

Param Type Description
[settings] settings Optional configuration.

Example

$('input[type=file]').vulcanup({
  url: '/initial/file/url.ext'
});

jQuery.vulcanup

The plugin global configuration object.

Kind: global external
Properties

Name Type Description
version String The plugin version.
defaults settings The default configuration.
templates Object The default templates.