uppy/website/src/api/docs.md
Andrew Murray 97dca2c651 Fixed typo
2016-07-23 00:24:56 +10:00

14 KiB
Raw Blame History

type order title
api 1 Generated API Docs

Uppy Core & Plugins

Core

src/core/Core.js:10-353

Main Uppy core

Parameters

  • opts object general options, like locales, to show modal or not to show

actions

src/core/Core.js:94-208

Registers listeners for all global actions, like: file-add, file-remove, upload-progress, reset

getPlugin

src/core/Core.js:251-260

Find one Plugin by name

Parameters

  • string name description
  • name

getState

src/core/Core.js:85-87

Gets current state, making sure to make a copy of the state object and pass that, instead of an actual reference to this.state

iteratePlugins

src/core/Core.js:267-271

Iterate through all used plugins

Parameters

  • function method description
  • method

log

src/core/Core.js:278-288

Logs stuff to console, only if debug is set to true. Silent in production.

Parameters

  • msg

Returns (String|Object) to log

resetState

src/core/Core.js:65-67

Reset state to defaultState, used when Modal is closed, for example

run

src/core/Core.js:310-352

Runs a waterfall of runType plugin packs, like so: All preseters(data) --> All acquirers(data) --> All uploaders(data) --> done

runType

src/core/Core.js:297-304

Runs all plugins of the same type in parallel

Parameters

  • type string that wants to set progress
  • method
  • files array

Returns Promise of all methods

setState

src/core/Core.js:74-78

Updates state

Parameters

  • object newState
  • newState

updateAll

src/core/Core.js:53-59

Iterate on all plugins and run update on them. Called when state changes

use

src/core/Core.js:217-244

Registers a plugin with Core

Parameters

  • Plugin Class object
  • options Object object that will be passed to Plugin later
  • opts

Returns Object self for chaining

Utils

src/core/Utils.js:16-23

A collection of small utility functions that help with dom manipulation, adding listeners, promises and other good things.

Parameters

  • methods

addListenerMulti

src/core/Utils.js:35-40

Adds multiple listeners to to a DOM element Equvalent to jQuerys $form.on('drag dragstart dragend dragover dragenter dragleave drop').

Parameters

  • el String selector
  • events String to add, like drag dragstart dragend dragover dragenter dragleave drop
  • cb requestCallback

Returns String

promiseWaterfall

src/core/Utils.js:16-23

Runs a waterfall of promises: calls each task, passing the result from the previous one as an argument. The first task is run with an empty array.

Parameters

  • methods array of Promises to run waterfall on

Returns Promise of the final task

DragDrop

src/plugins/DragDrop.js:10-196

Drag & Drop plugin

checkDragDropSupport

src/plugins/DragDrop.js:93-109

Checks if the browser supports Drag & Drop, not supported on mobile devices, for example.

Returns Boolean true if supported, false otherwise

Dummy

src/plugins/Dummy.js:8-34

Dummy

flatten

src/core/Utils.js:45-47

Shallow flatten nested arrays.

Parameters

  • arr

generateFileID

src/core/Utils.js:63-68

Takes a fileName and turns it into fileID, by converting to lowercase, removing extra characters and adding unix timestamp

Parameters

Plugin

src/plugins/Plugin.js:10-57

Boilerplate that all Plugins share - and should not be used directly. It also shows which methods final plugins should implement/override, this deciding on structure.

Parameters

  • main object Uppy core object
  • object object with plugin options

Returns (array|string) files or success/fail message

getTarget

src/plugins/Plugin.js:27-39

Check if supplied target is a string or an object. If object (that means its a plugin), search plugins for a plugin with same name and return its target.

Parameters

Translator

src/core/Translator.js:14-69

Translates strings with interpolation & pluralization support.Extensible with custom dictionaries and pluralization functions.

Borrows heavily from and inspired by Polyglot https://github.com/airbnb/polyglot.js, basically a stripped-down version of it. Differences: pluralization functions are not hardcoded and can be easily added among with dictionaries, nested objects are used for pluralization as opposed to |||| delimeter

Usage example: translator.translate('files_chosen', {smart_count: 3})

Parameters

interpolate

src/core/Translator.js:31-52

Takes a string with placeholder variables like %{smart_count} file selected and replaces it with values from options {smart_count: 5}

Parameters

  • phrase string that needs interpolation, with placeholders
  • options object with values that will be used to replace placeholders

Returns string interpolated

Meta

translate

src/core/Translator.js:61-68

Public translate method

Parameters

  • key string
  • options object with values that will be used later to replace placeholders in string

Returns string translated (and interpolated)

Modal

src/plugins/Modal.js:8-193

Modal

Present

src/plugins/Present.js:7-69

Present

ProgressBar

src/plugins/ProgressBar.js:7-62

Progress bar

qsa

src/core/Utils.js:52-54

querySelectorAll that returns a normal array instead of fileList

Parameters

  • selector
  • context

Tus10

src/plugins/Tus10.js:8-113

Tus resumable file uploader

run

src/plugins/Tus10.js:87-112

Add files to an array of upload() calles, passing the current and total file count numbers

Parameters

Returns Promise of parallel uploads Promise.all(uploaders)

upload

src/plugins/Tus10.js:28-60

Create a new Tus upload

Parameters

  • file object for use with upload
  • current integer file in a queue
  • total integer number of files in a queue

Returns Promise

Spinner

src/plugins/Spinner.js:7-52

Spinner

then

src/plugins/GoogleDrive.js:78-108

Leave this here