Skip to content

Commit

Permalink
Download files are generated with grunt now.
Browse files Browse the repository at this point in the history
  • Loading branch information
enyo committed Apr 3, 2013
1 parent 6c68c7d commit 4ba3313
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 61 deletions.
2 changes: 2 additions & 0 deletions AMD_footer
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
return module.exports;
}));
11 changes: 11 additions & 0 deletions AMD_header
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Uses AMD or browser globals to create a jQuery plugin.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
factory(jQuery);
}
} (function (jQuery) {
var module = { exports: { } }; // Fake component
77 changes: 77 additions & 0 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
module.exports = (grunt) ->

grunt.initConfig
pkg: grunt.file.readJSON "package.json"


stylus:
options:
compress: false
default:
paths: [ "node_modules/nib/lib/" ]
files: [
"downloads/css/basic.css": "downloads/css/stylus/basic.styl"
"downloads/css/dropzone.css": "downloads/css/stylus/dropzone.styl"
]

coffee:
default:
files:
"lib/dropzone.js": "src/dropzone.coffee"


component:
app:
output: "build/"
name: "build"
config: "component.json"
styles: false
scripts: true
standalone: "Dropzone"

copy:
component:
src: "build/build.js"
dest: "downloads/dropzone.js"

concat:
amd:
src: [
"AMD_header"
"components/component-emitter/index.js"
"lib/dropzone.js"
"AMD_footer"
]
dest: "downloads/dropzone-amd-module.js"



# watch:
# shop:
# files: "public_src/js/shop/**/*.coffee"
# tasks: [ "shop" ]
# options: nospawn: on
# admin:
# files: "public_src/js/admin/**/*.coffee"
# tasks: [ "admin" ]
# options: nospawn: on
# css:
# files: [ "public_src/css/**/*.styl", "public_src/css/**/*.css" ]
# tasks: [ "css" ]
# options: nospawn: on



grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-component-build"
grunt.loadNpmTasks "grunt-contrib-stylus"
grunt.loadNpmTasks "grunt-contrib-copy"
grunt.loadNpmTasks "grunt-contrib-concat"
grunt.loadNpmTasks "grunt-contrib-watch"

# Default tasks
grunt.registerTask "default", [ "coffee" ]

grunt.registerTask "css", [ "stylus" ]

grunt.registerTask "downloads", [ "coffee", "stylus", "component", "copy", "concat" ]
19 changes: 0 additions & 19 deletions Makefile

This file was deleted.

57 changes: 43 additions & 14 deletions downloads/dropzone-amd-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
}
} (function (jQuery) {
var module = { exports: { } }; // Fake component



/**
* Expose `Emitter`.
*/
Expand Down Expand Up @@ -158,8 +159,6 @@ Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};

// Generated by CoffeeScript 1.4.0

/*
#
# More info at [www.dropzonejs.com](http://www.dropzonejs.com)
Expand Down Expand Up @@ -199,15 +198,14 @@ Emitter.prototype.hasListeners = function(event){
noop = function() {};

Dropzone = (function(_super) {

__extends(Dropzone, _super);

/*
This is a list of all available events you can register on a dropzone object.
This is a list of all available events you can register on a dropzone object.
You can register an event handler like this:
You can register an event handler like this:
dropzone.on("dragEnter", function() { });
dropzone.on("dragEnter", function() { });
*/


Expand Down Expand Up @@ -238,6 +236,7 @@ Emitter.prototype.hasListeners = function(event){
},
fallback: function() {
var child, messageElement, span, _i, _len, _ref;

this.element.className = "" + this.element.className + " browser-not-supported";
_ref = this.element.getElementsByTagName("div");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
Expand All @@ -259,12 +258,12 @@ Emitter.prototype.hasListeners = function(event){
return this.element.appendChild(this.getFallbackForm());
},
/*
Those functions register themselves to the events on init and handle all
the user interface specific stuff. Overwriting them won't break the upload
but can break the way it's displayed.
You can overwrite them if you don't like the default behavior. If you just
want to add an additional event handler, register it on the dropzone object
and don't overwrite those options.
Those functions register themselves to the events on init and handle all
the user interface specific stuff. Overwriting them won't break the upload
but can break the way it's displayed.
You can overwrite them if you don't like the default behavior. If you just
want to add an additional event handler, register it on the dropzone object
and don't overwrite those options.
*/

drop: function(e) {
Expand Down Expand Up @@ -325,6 +324,7 @@ Emitter.prototype.hasListeners = function(event){

function Dropzone(element, options) {
var elementId, elementOptions, extend, fallback, _ref;

this.element = element;
this.version = Dropzone.version;
this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
Expand All @@ -342,6 +342,7 @@ Emitter.prototype.hasListeners = function(event){
elementOptions = (_ref = (elementId ? Dropzone.options[camelize(elementId)] : void 0)) != null ? _ref : {};
extend = function() {
var key, object, objects, target, val, _i, _len;

target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
for (_i = 0, _len = objects.length; _i < _len; _i++) {
object = objects[_i];
Expand Down Expand Up @@ -384,6 +385,7 @@ Emitter.prototype.hasListeners = function(event){
Dropzone.prototype.init = function() {
var eventName, noPropagation, _i, _len, _ref, _ref1,
_this = this;

if (this.element.tagName === "form") {
this.element.setAttribute("enctype", "multipart/form-data");
}
Expand All @@ -398,6 +400,7 @@ Emitter.prototype.hasListeners = function(event){
document.body.appendChild(this.hiddenFileInput);
this.hiddenFileInput.addEventListener("change", function() {
var files;

files = _this.hiddenFileInput.files;
if (files.length) {
_this.emit("selectedfiles", files);
Expand Down Expand Up @@ -460,6 +463,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.getFallbackForm = function() {
var existingFallback, fields, fieldsString, form;

if (existingFallback = this.getExistingFallback()) {
return existingFallback;
}
Expand All @@ -481,8 +485,10 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.getExistingFallback = function() {
var fallback, getFallback, tagName, _i, _len, _ref;

getFallback = function(elements) {
var el, _i, _len;

for (_i = 0, _len = elements.length; _i < _len; _i++) {
el = elements[_i];
if (/(^| )fallback($| )/.test(el.className)) {
Expand All @@ -501,6 +507,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.setupEventListeners = function() {
var event, listener, _ref, _results;

_ref = this.listeners;
_results = [];
for (event in _ref) {
Expand All @@ -512,6 +519,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.removeEventListeners = function() {
var event, listener, _ref, _results;

_ref = this.listeners;
_results = [];
for (event in _ref) {
Expand Down Expand Up @@ -539,6 +547,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.filesize = function(size) {
var string;

if (size >= 100000000000) {
size = size / 100000000000;
string = "TB";
Expand All @@ -560,6 +569,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.drop = function(e) {
var files;

if (!e.dataTransfer) {
return;
}
Expand All @@ -572,6 +582,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.handleFiles = function(files) {
var file, _i, _len, _results;

_results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
Expand All @@ -590,6 +601,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.addFile = function(file) {
var _this = this;

this.files.push(file);
this.emit("addedfile", file);
if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
Expand Down Expand Up @@ -621,6 +633,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.removeAllFiles = function() {
var file, _i, _len, _ref;

_ref = this.files.slice();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
file = _ref[_i];
Expand All @@ -634,12 +647,15 @@ Emitter.prototype.hasListeners = function(event){
Dropzone.prototype.createThumbnail = function(file) {
var fileReader,
_this = this;

fileReader = new FileReader;
fileReader.onload = function() {
var img;

img = new Image;
img.onload = function() {
var canvas, ctx, srcHeight, srcRatio, srcWidth, srcX, srcY, thumbnail, trgHeight, trgRatio, trgWidth, trgX, trgY;

canvas = document.createElement("canvas");
ctx = canvas.getContext("2d");
srcX = 0;
Expand Down Expand Up @@ -681,6 +697,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.processQueue = function() {
var i, parallelUploads, processingLength;

parallelUploads = this.options.parallelUploads;
processingLength = this.filesProcessing.length;
i = processingLength;
Expand All @@ -703,13 +720,15 @@ Emitter.prototype.hasListeners = function(event){
Dropzone.prototype.uploadFile = function(file) {
var formData, handleError, input, inputName, inputType, key, progressObj, value, xhr, _i, _len, _ref, _ref1, _ref2,
_this = this;

xhr = new XMLHttpRequest();
xhr.open(this.options.method, this.options.url, true);
handleError = function() {
return _this.errorProcessing(file, xhr.responseText || ("Server responded with " + xhr.status + " code."));
};
xhr.onload = function(e) {
var response, _ref;

if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
return handleError();
} else {
Expand Down Expand Up @@ -785,6 +804,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.forElement = function(element) {
var instance, _i, _len, _ref;

if (typeof element === "string") {
element = document.querySelector(element);
}
Expand All @@ -802,6 +822,7 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.isBrowserSupported = function() {
var capableBrowser, regex, _i, _len, _ref;

capableBrowser = true;
if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
if (!("classList" in document.createElement("a"))) {
Expand All @@ -824,6 +845,7 @@ Emitter.prototype.hasListeners = function(event){

without = function(list, rejectedItem) {
var item, _i, _len, _results;

_results = [];
for (_i = 0, _len = list.length; _i < _len; _i++) {
item = list[_i];
Expand All @@ -842,6 +864,7 @@ Emitter.prototype.hasListeners = function(event){

createElement = function(string) {
var div;

div = document.createElement("div");
div.innerHTML = string;
return div.childNodes[0];
Expand All @@ -863,6 +886,7 @@ Emitter.prototype.hasListeners = function(event){

contentLoaded = function(win, fn) {
var add, doc, done, init, poll, pre, rem, root, top;

done = false;
top = true;
doc = win.document;
Expand All @@ -880,9 +904,12 @@ Emitter.prototype.hasListeners = function(event){
}
};
poll = function() {
var e;

try {
root.doScroll("left");
} catch (e) {
} catch (_error) {
e = _error;
setTimeout(poll, 50);
return;
}
Expand All @@ -905,12 +932,14 @@ Emitter.prototype.hasListeners = function(event){

contentLoaded(window, function() {
var checkElements, dropzone, dropzones, _i, _len, _results;

if (false) {
dropzones = document.querySelectorAll(".dropzone");
} else {
dropzones = [];
checkElements = function(elements) {
var el, _i, _len, _results;

_results = [];
for (_i = 0, _len = elements.length; _i < _len; _i++) {
el = elements[_i];
Expand Down
Loading

0 comments on commit 4ba3313

Please sign in to comment.