|
@@ -1,228 +1,42 @@
|
|
|
---
|
|
|
title: Getting Started
|
|
|
type: guide
|
|
|
-order: 1
|
|
|
+order: 0
|
|
|
---
|
|
|
|
|
|
-Let's start with a quick tour of Uppy's data binding features. If you are more interested in a high-level overview first, check out this [blog post](http://transloadit.com/blog/2015/10/25/transloadit-re-introduction/).
|
|
|
+> **Compatibility Note:** Uppy does not support IE8 and below.
|
|
|
|
|
|
-The easiest way to try out Uppy is using the [JSFiddle Hello World example](https://jsfiddle.net/yyx990803/okv0rgrk/). Feel free to open it in another tab and follow along as we go through some basic examples. If you prefer downloading / installing from a package manager, check out the [Installation](/guide/installation.html) page.
|
|
|
+## NPM
|
|
|
|
|
|
-### Hello World
|
|
|
+NPM is the recommended installation method when building large scale apps with Uppy. It pairs nicely with a CommonJS module bundler such as [Webpack](http://webpack.github.io/) or [Browserify](http://browserify.org/).
|
|
|
|
|
|
-``` html
|
|
|
-<div id="app">
|
|
|
- {{ message }}
|
|
|
-</div>
|
|
|
-```
|
|
|
-``` js
|
|
|
-new Uppy({
|
|
|
- el: '#app',
|
|
|
- data: {
|
|
|
- message: 'Hello Uppy!'
|
|
|
- }
|
|
|
-})
|
|
|
+``` bash
|
|
|
+# latest stable
|
|
|
+$ npm install uppy
|
|
|
```
|
|
|
-{% raw %}
|
|
|
-<div id="app" class="demo">
|
|
|
- {{ message }}
|
|
|
-</div>
|
|
|
-<script>
|
|
|
-new Uppy({
|
|
|
- el: '#app',
|
|
|
- data: {
|
|
|
- message: 'Hello Uppy!'
|
|
|
- }
|
|
|
-})
|
|
|
-</script>
|
|
|
-{% endraw %}
|
|
|
|
|
|
-### Two-way Binding
|
|
|
+``` javascript
|
|
|
+import Uppy from 'uppy/core';
|
|
|
+import { DragDrop, Tus10 } from 'uppy/plugins';
|
|
|
|
|
|
-``` html
|
|
|
-<div id="app">
|
|
|
- <p>{{ message }}</p>
|
|
|
- <input v-model="message">
|
|
|
-</div>
|
|
|
-```
|
|
|
-``` js
|
|
|
-new Uppy({
|
|
|
- el: '#app',
|
|
|
- data: {
|
|
|
- message: 'Hello Uppy!'
|
|
|
- }
|
|
|
-})
|
|
|
+const uppy = new Uppy({wait: false});
|
|
|
+const files = uppy
|
|
|
+ .use(DragDrop, {selector: '#upload-target'})
|
|
|
+ .use(Tus10, {endpoint: 'http://master.tus.io:8080'})
|
|
|
+ .run();
|
|
|
```
|
|
|
-{% raw %}
|
|
|
-<div id="app2" class="demo">
|
|
|
- <p>{{ message }}</p>
|
|
|
- <input v-model="message">
|
|
|
-</div>
|
|
|
-<script>
|
|
|
-new Uppy({
|
|
|
- el: '#app2',
|
|
|
- data: {
|
|
|
- message: 'Hello Uppy!'
|
|
|
- }
|
|
|
-})
|
|
|
-</script>
|
|
|
-{% endraw %}
|
|
|
|
|
|
-### Render a List
|
|
|
+## Standalone & CDN
|
|
|
|
|
|
``` html
|
|
|
-<div id="app">
|
|
|
- <ul>
|
|
|
- <li v-for="todo in todos">
|
|
|
- {{ todo.text }}
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
-</div>
|
|
|
-```
|
|
|
-``` js
|
|
|
-new Uppy({
|
|
|
- el: '#app',
|
|
|
- data: {
|
|
|
- todos: [
|
|
|
- { text: 'Learn JavaScript' },
|
|
|
- { text: 'Learn Uppy' },
|
|
|
- { text: 'Build Something Awesome' }
|
|
|
- ]
|
|
|
- }
|
|
|
-})
|
|
|
-```
|
|
|
-{% raw %}
|
|
|
-<div id="app3" class="demo">
|
|
|
- <ul>
|
|
|
- <li v-for="todo in todos">
|
|
|
- {{ todo.text }}
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
-</div>
|
|
|
-<script>
|
|
|
-new Uppy({
|
|
|
- el: '#app3',
|
|
|
- data: {
|
|
|
- todos: [
|
|
|
- { text: 'Learn JavaScript' },
|
|
|
- { text: 'Learn Uppy' },
|
|
|
- { text: 'Build Something Awesome' }
|
|
|
- ]
|
|
|
- }
|
|
|
-})
|
|
|
-</script>
|
|
|
-{% endraw %}
|
|
|
+<div id="drag-drop"></div>
|
|
|
|
|
|
-### Handle User Input
|
|
|
-
|
|
|
-``` html
|
|
|
-<div id="app">
|
|
|
- <p>{{ message }}</p>
|
|
|
- <button v-on:click="reverseMessage">Reverse Message</button>
|
|
|
-</div>
|
|
|
-```
|
|
|
-``` js
|
|
|
-new Uppy({
|
|
|
- el: '#app',
|
|
|
- data: {
|
|
|
- message: 'Hello Uppy!'
|
|
|
- },
|
|
|
- methods: {
|
|
|
- reverseMessage: function () {
|
|
|
- this.message = this.message.split('').reverse().join('')
|
|
|
- }
|
|
|
- }
|
|
|
-})
|
|
|
-```
|
|
|
-{% raw %}
|
|
|
-<div id="app4" class="demo">
|
|
|
- <p>{{ message }}</p>
|
|
|
- <button v-on:click="reverseMessage">Reverse Message</button>
|
|
|
-</div>
|
|
|
+<script src="http://assets.transloadit.com/uppy.min.js" />
|
|
|
<script>
|
|
|
-new Uppy({
|
|
|
- el: '#app4',
|
|
|
- data: {
|
|
|
- message: 'Hello Uppy!'
|
|
|
- },
|
|
|
- methods: {
|
|
|
- reverseMessage: function () {
|
|
|
- this.message = this.message.split('').reverse().join('')
|
|
|
- }
|
|
|
- }
|
|
|
-})
|
|
|
+var uppy = new Uppy();
|
|
|
+uppy
|
|
|
+ .use(DragDrop, {selector: '#drag-drop'})
|
|
|
+ .use(Tus10, {endpoint: 'http://master.tus.io:8080'})
|
|
|
+ .run();
|
|
|
</script>
|
|
|
-{% endraw %}
|
|
|
-
|
|
|
-### All Together Now
|
|
|
-
|
|
|
-``` html
|
|
|
-<div id="app">
|
|
|
- <input v-model="newTodo" v-on:keyup.enter="addTodo">
|
|
|
- <ul>
|
|
|
- <li v-for="todo in todos">
|
|
|
- <span>{{ todo.text }}</span>
|
|
|
- <button v-on:click="removeTodo($index)">X</button>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
-</div>
|
|
|
-```
|
|
|
-``` js
|
|
|
-new Uppy({
|
|
|
- el: '#app',
|
|
|
- data: {
|
|
|
- newTodo: '',
|
|
|
- todos: [
|
|
|
- { text: 'Add some todos' }
|
|
|
- ]
|
|
|
- },
|
|
|
- methods: {
|
|
|
- addTodo: function () {
|
|
|
- var text = this.newTodo.trim()
|
|
|
- if (text) {
|
|
|
- this.todos.push({ text: text })
|
|
|
- this.newTodo = ''
|
|
|
- }
|
|
|
- },
|
|
|
- removeTodo: function (index) {
|
|
|
- this.todos.splice(index, 1)
|
|
|
- }
|
|
|
- }
|
|
|
-})
|
|
|
```
|
|
|
-{% raw %}
|
|
|
-<div id="app5" class="demo">
|
|
|
- <input v-model="newTodo" v-on:keyup.enter="addTodo">
|
|
|
- <ul>
|
|
|
- <li v-for="todo in todos">
|
|
|
- <span>{{ todo.text }}</span>
|
|
|
- <button v-on:click="removeTodo($index)">X</button>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
-</div>
|
|
|
-<script>
|
|
|
-new Uppy({
|
|
|
- el: '#app5',
|
|
|
- data: {
|
|
|
- newTodo: '',
|
|
|
- todos: [
|
|
|
- { text: 'Add some todos' }
|
|
|
- ]
|
|
|
- },
|
|
|
- methods: {
|
|
|
- addTodo: function () {
|
|
|
- var text = this.newTodo.trim()
|
|
|
- if (text) {
|
|
|
- this.todos.push({ text: text })
|
|
|
- this.newTodo = ''
|
|
|
- }
|
|
|
- },
|
|
|
- removeTodo: function (index) {
|
|
|
- this.todos.splice(index, 1)
|
|
|
- }
|
|
|
- }
|
|
|
-})
|
|
|
-</script>
|
|
|
-{% endraw %}
|
|
|
-
|
|
|
-I hope this gives you a basic idea of how Uppy works. I'm sure you also have many questions now - read along, and we will cover them in the rest of the guide.
|