CrowdStrike/EmberDroplet

Name: EmberDroplet

Owner: Crowdstrike

Description: Ember.js HTML5 file uploading with drag & drop and image/file preview.

Created: 2014-07-31 19:13:48.0

Updated: 2014-07-30 21:36:07.0

Pushed: 2014-10-20 21:56:17.0

Homepage: http://ember-droplet.herokuapp.com/

Size: 18564

Language: null

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Ember Droplet

Travis  

Demo: http://droplet.wildhoney.io/

Install via npm: npm install ember-droplet.

Ember Droplet allows HTML5 drag and drop functionality in Ember straight out-of-the-box. Its philosophy is that it doesn't impose anything, and instead allows each individual developer to decide how it should work. I've provided a view – DropletView that you're free to use in your views. However, most of the functionality exists in the controller mixin – DropletController).

For the time being, please refer to the example.

EmberDroplet Screenshot

Features
Methods

The DropletController exposes the following public methods:

In addition to the methods, DropletController also has the following computed properties for convenience:

Additional computed properties can be added to your controller that implements the mixin. To add additional computed properties, please refer to the protected _filesByProperties method in the mixin.

Getting Started

In order to begin using EmberDroplet, you need a controller. Within your controller you can implement the DropletController mixin, which will give you access to all methods defined in it.

IndexController = Ember.Controller.extend(DropletController, {


Properties that can be defined in your controller to interact with the mixin are as follows:

Now that your controller is using the mixin, it's time for your view to interact with your controller and its related mixin. For this we recommend using the in-built view, but it's not essential. In order to create your own, please refer to the example. The simplest way to use the in-built view is to embed it into your template.

IndexView = Ember.View.extend({

/**
 * @property DragDrop
 * @type DropletView
 */
DragDrop: DropletView.extend()


Once you have the property DragDrop defined, the view and all of its related functionality can be output into the DOM using {{view.DragDrop}}. It's worth bearing in mind that this view is quite abstract in order to be customisable – see index.html for an example.

Example

The example uses the Node.js server to upload files, which is available in example/node-server. Simply run: node server to create it.

Vagrant

As an alternative, if you have Vagrant installed then you can simply issue the vagrant up command and the Node.js server will be available on port 8889.

View Mixin

In order to use EmberDroplet it's not necessary for you to implement the DropletView mixin into your view. However, if you don't, then you'll need to communicate with the DropletController mixin yourself.

There is also DropletPreview which allows image uploads to be previewed immediately.

Testing

All of the related tests are written in Jasmine, and can be run with grunt test (assuming you have grunt installed – npm install grunt -g). You'll also need to run npm install to install the project's dependencies.

Jasmine


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.