").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cc=a.document.documentElement;function dc(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dc(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cc;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cc})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dc(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=La(k.pixelPosition,function(a,c){return c?(c=Ja(a,b),Ha.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ec=a.jQuery,fc=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fc),b&&a.jQuery===m&&(a.jQuery=ec),m},typeof b===K&&(a.jQuery=a.$=m),m});
-
-/**
- * http://github.com/valums/file-uploader
- *
- * Multiple file upload component with progress-bar, drag-and-drop.
- * © 2010 Andrew Valums ( andrew(at)valums.com )
- *
- * Licensed under GNU GPL 2 or later and GNU LGPL 2 or later, see license.txt.
- */
-
-//
-// Helper functions
-//
-
-var qq = qq || {};
-
-/**
- * Adds all missing properties from second obj to first obj
- */
-qq.extend = function(first, second){
- for (var prop in second){
- first[prop] = second[prop];
- }
-};
-
-/**
- * Searches for a given element in the array, returns -1 if it is not present.
- * @param {Number} [from] The index at which to begin the search
- */
-qq.indexOf = function(arr, elt, from){
- if (arr.indexOf) return arr.indexOf(elt, from);
-
- from = from || 0;
- var len = arr.length;
-
- if (from < 0) from += len;
-
- for (; from < len; from++){
- if (from in arr && arr[from] === elt){
- return from;
- }
- }
- return -1;
-};
-
-qq.getUniqueId = (function(){
- var id = 0;
- return function(){ return id++; };
-})();
-
-//
-// Events
-
-qq.attach = function(element, type, fn){
- if (element.addEventListener){
- element.addEventListener(type, fn, false);
- } else if (element.attachEvent){
- element.attachEvent('on' + type, fn);
- }
-};
-qq.detach = function(element, type, fn){
- if (element.removeEventListener){
- element.removeEventListener(type, fn, false);
- } else if (element.attachEvent){
- element.detachEvent('on' + type, fn);
- }
-};
-
-qq.preventDefault = function(e){
- if (e.preventDefault){
- e.preventDefault();
- } else{
- e.returnValue = false;
- }
-};
-
-//
-// Node manipulations
-
-/**
- * Insert node a before node b.
- */
-qq.insertBefore = function(a, b){
- b.parentNode.insertBefore(a, b);
-};
-qq.remove = function(element){
- element.parentNode.removeChild(element);
-};
-
-qq.contains = function(parent, descendant){
- // compareposition returns false in this case
- if (parent == descendant) return true;
-
- if (parent.contains){
- return parent.contains(descendant);
- } else {
- return !!(descendant.compareDocumentPosition(parent) & 8);
- }
-};
-
-/**
- * Creates and returns element from html string
- * Uses innerHTML to create an element
- */
-qq.toElement = (function(){
- var div = document.createElement('div');
- return function(html){
- div.innerHTML = html;
- var element = div.firstChild;
- div.removeChild(element);
- return element;
- };
-})();
-
-//
-// Node properties and attributes
-
-/**
- * Sets styles for an element.
- * Fixes opacity in IE6-8.
- */
-qq.css = function(element, styles){
- if (styles.opacity != null){
- if (typeof element.style.opacity != 'string' && typeof(element.filters) != 'undefined'){
- styles.filter = 'alpha(opacity=' + Math.round(100 * styles.opacity) + ')';
- }
- }
- qq.extend(element.style, styles);
-};
-qq.hasClass = function(element, name){
- var re = new RegExp('(^| )' + name + '( |$)');
- return re.test(element.className);
-};
-qq.addClass = function(element, name){
- if (!qq.hasClass(element, name)){
- element.className += ' ' + name;
- }
-};
-qq.removeClass = function(element, name){
- var re = new RegExp('(^| )' + name + '( |$)');
- element.className = element.className.replace(re, ' ').replace(/^\s+|\s+$/g, "");
-};
-qq.setText = function(element, text){
- element.innerText = text;
- element.textContent = text;
-};
-
-//
-// Selecting elements
-
-qq.children = function(element){
- var children = [],
- child = element.firstChild;
-
- while (child){
- if (child.nodeType == 1){
- children.push(child);
- }
- child = child.nextSibling;
- }
-
- return children;
-};
-
-qq.getByClass = function(element, className){
- if (element.querySelectorAll){
- return element.querySelectorAll('.' + className);
- }
-
- var result = [];
- var candidates = element.getElementsByTagName("*");
- var len = candidates.length;
-
- for (var i = 0; i < len; i++){
- if (qq.hasClass(candidates[i], className)){
- result.push(candidates[i]);
- }
- }
- return result;
-};
-
-/**
- * obj2url() takes a json-object as argument and generates
- * a querystring. pretty much like jQuery.param()
- *
- * how to use:
- *
- * `qq.obj2url({a:'b',c:'d'},'http://any.url/upload?otherParam=value');`
- *
- * will result in:
- *
- * `http://any.url/upload?otherParam=value&a=b&c=d`
- *
- * @param Object JSON-Object
- * @param String current querystring-part
- * @return String encoded querystring
- */
-qq.obj2url = function(obj, temp, prefixDone){
- var uristrings = [],
- prefix = '&',
- add = function(nextObj, i){
- var nextTemp = temp
- ? (/\[\]$/.test(temp)) // prevent double-encoding
- ? temp
- : temp+'['+i+']'
- : i;
- if ((nextTemp != 'undefined') && (i != 'undefined')) {
- uristrings.push(
- (typeof nextObj === 'object')
- ? qq.obj2url(nextObj, nextTemp, true)
- : (Object.prototype.toString.call(nextObj) === '[object Function]')
- ? encodeURIComponent(nextTemp) + '=' + encodeURIComponent(nextObj())
- : encodeURIComponent(nextTemp) + '=' + encodeURIComponent(nextObj)
- );
- }
- };
-
- if (!prefixDone && temp) {
- prefix = (/\?/.test(temp)) ? (/\?$/.test(temp)) ? '' : '&' : '?';
- uristrings.push(temp);
- uristrings.push(qq.obj2url(obj));
- } else if ((Object.prototype.toString.call(obj) === '[object Array]') && (typeof obj != 'undefined') ) {
- // we wont use a for-in-loop on an array (performance)
- for (var i = 0, len = obj.length; i < len; ++i){
- add(obj[i], i);
- }
- } else if ((typeof obj != 'undefined') && (obj !== null) && (typeof obj === "object")){
- // for anything else but a scalar, we will use for-in-loop
- for (var i in obj){
- add(obj[i], i);
- }
- } else {
- uristrings.push(encodeURIComponent(temp) + '=' + encodeURIComponent(obj));
- }
-
- return uristrings.join(prefix)
- .replace(/^&/, '')
- .replace(/%20/g, '+');
-};
-
-//
-//
-// Uploader Classes
-//
-//
-
-var qq = qq || {};
-
-/**
- * Creates upload button, validates upload, but doesn't create file list or dd.
- */
-qq.FileUploaderBasic = function(o){
- this._options = {
- // set to true to see the server response
- debug: false,
- action: '/upload',
- params: {},
- button: null,
- multiple: true,
- maxConnections: 3,
- // validation
- allowedExtensions: [],
- sizeLimit: 2147483648,
- minSizeLimit: 0,
- // events
- // return false to cancel submit
- onSubmit: function(id, fileName){ document.getElementById("toggleme").style.display = "block";},
- onProgress: function(id, fileName, loaded, total){},
- onComplete: function(id, fileName, responseJSON){},
- onCancel: function(id, fileName){},
- // messages
- messages: {
- typeError: "{file} has invalid extension. Only {extensions} are allowed.",
- //sizeError: "{file} is too large, maximum file size is {sizeLimit}.",
- sizeError: "test",
- minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.",
- emptyError: "{file} is empty, please select files again without it.",
- onLeave: "The files are being uploaded, if you leave now the upload will be cancelled."
- },
- showMessage: function(message){
- if (message == "test") {
-
- if (confirm("Uploading a large file, redirecting to a stable uploader. \nCancel if you currently have files already uploaded.")) {
- document.getElementById("html5").style.display = "none";
- document.getElementById("flash").style.display = "block";
-
-
- //window.location = "/stable";
- }
- }
- else {
- alert(message);
- }
- }
- };
- qq.extend(this._options, o);
-
- // number of files being uploaded
- this._filesInProgress = 0;
- this._handler = this._createUploadHandler();
-
- if (this._options.button){
- this._button = this._createUploadButton(this._options.button);
- }
-
- this._preventLeaveInProgress();
-};
-
-qq.FileUploaderBasic.prototype = {
- setParams: function(params){
- this._options.params = params;
- },
- getInProgress: function(){
- return this._filesInProgress;
- },
- _createUploadButton: function(element){
- var self = this;
-
- return new qq.UploadButton({
- element: element,
- multiple: this._options.multiple && qq.UploadHandlerXhr.isSupported(),
- onChange: function(input){
- self._onInputChange(input);
- }
- });
- },
- _createUploadHandler: function(){
- var self = this,
- handlerClass;
-
- if(qq.UploadHandlerXhr.isSupported()){
- handlerClass = 'UploadHandlerXhr';
- } else {
- handlerClass = 'UploadHandlerForm';
- }
-
- var handler = new qq[handlerClass]({
- debug: this._options.debug,
- action: this._options.action,
- maxConnections: this._options.maxConnections,
- onProgress: function(id, fileName, loaded, total){
- self._onProgress(id, fileName, loaded, total);
- self._options.onProgress(id, fileName, loaded, total);
- },
- onComplete: function(id, fileName, result){
- self._onComplete(id, fileName, result);
- self._options.onComplete(id, fileName, result);
- },
- onCancel: function(id, fileName){
- self._onCancel(id, fileName);
- self._options.onCancel(id, fileName);
- }
- });
-
- return handler;
- },
- _preventLeaveInProgress: function(){
- var self = this;
-
- qq.attach(window, 'beforeunload', function(e){
- if (!self._filesInProgress){return;}
-
- var e = e || window.event;
- // for ie, ff
- e.returnValue = self._options.messages.onLeave;
- // for webkit
- return self._options.messages.onLeave;
- });
- },
- _onSubmit: function(id, fileName){
- this._filesInProgress++;
- },
- _onProgress: function(id, fileName, loaded, total){
- },
- _onComplete: function(id, fileName, result){
- this._filesInProgress--;
- if (result.error){
- this._options.showMessage(result.error);
- }
- },
- _onCancel: function(id, fileName){
- this._filesInProgress--;
- },
- _onInputChange: function(input){
- if (this._handler instanceof qq.UploadHandlerXhr){
- this._uploadFileList(input.files);
- } else {
- if (this._validateFile(input)){
- this._uploadFile(input);
- }
- }
- this._button.reset();
- },
- _uploadFileList: function(files){
- for (var i=0; i
this._options.sizeLimit){
- this._error('sizeError', name);
- return false;
-
- } else if (size && size < this._options.minSizeLimit){
- this._error('minSizeError', name);
- return false;
- }
-
- return true;
- },
- _error: function(code, fileName){
- var message = this._options.messages[code];
- function r(name, replacement){ message = message.replace(name, replacement); }
-
- r('{file}', this._formatFileName(fileName));
- r('{extensions}', this._options.allowedExtensions.join(', '));
- r('{sizeLimit}', this._formatSize(this._options.sizeLimit));
- r('{minSizeLimit}', this._formatSize(this._options.minSizeLimit));
-
- this._options.showMessage(message);
- },
- _formatFileName: function(name){
- if (name.length > 33){
- name = name.slice(0, 19) + '...' + name.slice(-13);
- }
- return name;
- },
- _isAllowedExtension: function(fileName){
- var ext = (-1 !== fileName.indexOf('.')) ? fileName.replace(/.*[.]/, '').toLowerCase() : '';
- var allowed = this._options.allowedExtensions;
-
- if (!allowed.length){return true;}
-
- for (var i=0; i 99);
-
- return Math.max(bytes, 0.1).toFixed(1) + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
- }
-};
-
-
-/**
- * Class that creates upload widget with drag-and-drop and file list
- * @inherits qq.FileUploaderBasic
- */
-qq.FileUploader = function(o){
- // call parent constructor
- qq.FileUploaderBasic.apply(this, arguments);
-
- // additional options
- qq.extend(this._options, {
- element: null,
- // if set, will be used instead of qq-upload-list in template
- listElement: null,
-
- template: '' +
- '
Drop files here to upload
' +
- '
Click or Drop file(s)
' +
-
- '
' +
-
- '
',
-
- // template for one item in file list
- fileTemplate: '' +
- '' +
- '' +
- '' +
- 'Cancel' +
- 'Failed' +
- '',
-
- classes: {
- // used to get elements from templates
- button: 'qq-upload-button',
- drop: 'qq-upload-drop-area',
- dropActive: 'qq-upload-drop-area-active',
- list: 'qq-upload-list',
-
- file: 'qq-upload-file',
- spinner: 'qq-upload-spinner',
- size: 'qq-upload-size',
- cancel: 'qq-upload-cancel',
-
- // added to list item when upload completes
- // used in css to hide progress spinner
- success: 'qq-upload-success',
- fail: 'qq-upload-fail'
- }
- });
- // overwrite options with user supplied
- qq.extend(this._options, o);
-
- this._element = this._options.element;
- this._element.innerHTML = this._options.template;
- this._listElement = this._options.listElement || this._find(this._element, 'list');
-
- this._classes = this._options.classes;
-
- this._button = this._createUploadButton(this._find(this._element, 'button'));
-
- this._bindCancelEvent();
- this._setupDragDrop();
-};
-
-// inherit from Basic Uploader
-qq.extend(qq.FileUploader.prototype, qq.FileUploaderBasic.prototype);
-
-qq.extend(qq.FileUploader.prototype, {
- /**
- * Gets one of the elements listed in this._options.classes
- **/
- _find: function(parent, type){
- var element = qq.getByClass(parent, this._options.classes[type])[0];
- if (!element){
- throw new Error('element not found ' + type);
- }
-
- return element;
- },
- _setupDragDrop: function(){
- var self = this,
- dropArea = this._find(this._element, 'drop');
-
- var dz = new qq.UploadDropZone({
- element: dropArea,
- onEnter: function(e){
- qq.addClass(dropArea, self._classes.dropActive);
- e.stopPropagation();
- },
- onLeave: function(e){
- e.stopPropagation();
- },
- onLeaveNotDescendants: function(e){
- qq.removeClass(dropArea, self._classes.dropActive);
- },
- onDrop: function(e){
- dropArea.style.display = 'none';
- qq.removeClass(dropArea, self._classes.dropActive);
- self._uploadFileList(e.dataTransfer.files);
- }
- });
-
- dropArea.style.display = 'none';
-
- qq.attach(document, 'dragenter', function(e){
- if (!dz._isValidFileDrag(e)) return;
-
- dropArea.style.display = 'block';
- });
- qq.attach(document, 'dragleave', function(e){
- if (!dz._isValidFileDrag(e)) return;
-
- var relatedTarget = document.elementFromPoint(e.clientX, e.clientY);
- // only fire when leaving document out
- if ( ! relatedTarget || relatedTarget.nodeName == "HTML"){
- dropArea.style.display = 'none';
- }
- });
- },
- _onSubmit: function(id, fileName){
- qq.FileUploaderBasic.prototype._onSubmit.apply(this, arguments);
- this._addToList(id, fileName);
- },
- _onProgress: function(id, fileName, loaded, total){
- qq.FileUploaderBasic.prototype._onProgress.apply(this, arguments);
-
- var item = this._getItemByFileId(id);
- var size = this._find(item, 'size');
- size.style.display = 'inline';
-
- var text;
- if (loaded != total){
- text = Math.round(loaded / total * 100) + '% from ' + this._formatSize(total);
- } else {
- text = this._formatSize(total);
- }
-
- qq.setText(size, text);
- },
- _onComplete: function(id, fileName, result){
- qq.FileUploaderBasic.prototype._onComplete.apply(this, arguments);
-
- // mark completed
- var item = this._getItemByFileId(id);
- qq.remove(this._find(item, 'cancel'));
- qq.remove(this._find(item, 'spinner'));
-
- if (result){
- qq.addClass(item, this._classes.success);
- item.innerHTML = '' + result.url + '
'
- } else {
- qq.addClass(item, this._classes.fail);
- }
- },
- _addToList: function(id, fileName){
- var item = qq.toElement(this._options.fileTemplate);
- item.qqFileId = id;
-
- var fileElement = this._find(item, 'file');
- qq.setText(fileElement, this._formatFileName(fileName));
- this._find(item, 'size').style.display = 'none';
-
- this._listElement.appendChild(item);
- },
- _getItemByFileId: function(id){
- var item = this._listElement.firstChild;
-
- // there can't be txt nodes in dynamically created list
- // and we can use nextSibling
- while (item){
- if (item.qqFileId == id) return item;
- item = item.nextSibling;
- }
- },
- /**
- * delegate click event for cancel link
- **/
- _bindCancelEvent: function(){
- var self = this,
- list = this._listElement;
-
- qq.attach(list, 'click', function(e){
- e = e || window.event;
- var target = e.target || e.srcElement;
-
- if (qq.hasClass(target, self._classes.cancel)){
- qq.preventDefault(e);
-
- var item = target.parentNode;
- self._handler.cancel(item.qqFileId);
- qq.remove(item);
- }
- });
- }
-});
-
-qq.UploadDropZone = function(o){
- this._options = {
- element: null,
- onEnter: function(e){},
- onLeave: function(e){},
- // is not fired when leaving element by hovering descendants
- onLeaveNotDescendants: function(e){},
- onDrop: function(e){}
- };
- qq.extend(this._options, o);
-
- this._element = this._options.element;
-
- this._disableDropOutside();
- this._attachEvents();
-};
-
-qq.UploadDropZone.prototype = {
- _disableDropOutside: function(e){
- // run only once for all instances
- if (!qq.UploadDropZone.dropOutsideDisabled ){
-
- qq.attach(document, 'dragover', function(e){
- if (e.dataTransfer){
- e.dataTransfer.dropEffect = 'none';
- e.preventDefault();
- }
- });
-
- qq.UploadDropZone.dropOutsideDisabled = true;
- }
- },
- _attachEvents: function(){
- var self = this;
-
- qq.attach(self._element, 'dragover', function(e){
- if (!self._isValidFileDrag(e)) return;
-
- var effect = e.dataTransfer.effectAllowed;
- if (effect == 'move' || effect == 'linkMove'){
- e.dataTransfer.dropEffect = 'move'; // for FF (only move allowed)
- } else {
- e.dataTransfer.dropEffect = 'copy'; // for Chrome
- }
-
- e.stopPropagation();
- e.preventDefault();
- });
-
- qq.attach(self._element, 'dragenter', function(e){
- if (!self._isValidFileDrag(e)) return;
-
- self._options.onEnter(e);
- });
-
- qq.attach(self._element, 'dragleave', function(e){
- if (!self._isValidFileDrag(e)) return;
-
- self._options.onLeave(e);
-
- var relatedTarget = document.elementFromPoint(e.clientX, e.clientY);
- // do not fire when moving a mouse over a descendant
- if (qq.contains(this, relatedTarget)) return;
-
- self._options.onLeaveNotDescendants(e);
- });
-
- qq.attach(self._element, 'drop', function(e){
- if (!self._isValidFileDrag(e)) return;
-
- e.preventDefault();
- self._options.onDrop(e);
- });
- },
- _isValidFileDrag: function(e){
- var dt = e.dataTransfer,
- // do not check dt.types.contains in webkit, because it crashes safari 4
- isWebkit = navigator.userAgent.indexOf("AppleWebKit") > -1;
-
- // dt.effectAllowed is none in Safari 5
- // dt.types.contains check is for firefox
- return dt && dt.effectAllowed != 'none' &&
- (dt.files || (!isWebkit && dt.types.contains && dt.types.contains('Files')));
-
- }
-};
-
-qq.UploadButton = function(o){
- this._options = {
- element: null,
- // if set to true adds multiple attribute to file input
- multiple: false,
- // name attribute of file input
- name: 'file',
- onChange: function(input){},
- hoverClass: 'qq-upload-button-hover',
- focusClass: 'qq-upload-button-focus'
- };
-
- qq.extend(this._options, o);
-
- this._element = this._options.element;
-
- // make button suitable container for input
- qq.css(this._element, {
- position: 'relative',
- overflow: 'hidden',
- // Make sure browse button is in the right side
- // in Internet Explorer
- direction: 'ltr'
- });
-
- this._input = this._createInput();
-};
-
-qq.UploadButton.prototype = {
- /* returns file input element */
- getInput: function(){
- return this._input;
- },
- /* cleans/recreates the file input */
- reset: function(){
- if (this._input.parentNode){
- qq.remove(this._input);
- }
-
- qq.removeClass(this._element, this._options.focusClass);
- this._input = this._createInput();
- },
- _createInput: function(){
- var input = document.createElement("input");
-
- if (this._options.multiple){
- input.setAttribute("multiple", "multiple");
- }
-
- input.setAttribute("type", "file");
- input.setAttribute("name", this._options.name);
-
- qq.css(input, {
- position: 'absolute',
- // in Opera only 'browse' button
- // is clickable and it is located at
- // the right side of the input
- right: 0,
- top: 0,
- fontFamily: 'Arial',
- // 4 persons reported this, the max values that worked for them were 243, 236, 236, 118
- fontSize: '118px',
- margin: 0,
- padding: 0,
- cursor: 'pointer',
- opacity: 0
- });
-
- this._element.appendChild(input);
-
- var self = this;
- qq.attach(input, 'change', function(){
- self._options.onChange(input);
- });
-
- qq.attach(input, 'mouseover', function(){
- qq.addClass(self._element, self._options.hoverClass);
- });
- qq.attach(input, 'mouseout', function(){
- qq.removeClass(self._element, self._options.hoverClass);
- });
- qq.attach(input, 'focus', function(){
- qq.addClass(self._element, self._options.focusClass);
- });
- qq.attach(input, 'blur', function(){
- qq.removeClass(self._element, self._options.focusClass);
- });
-
- // IE and Opera, unfortunately have 2 tab stops on file input
- // which is unacceptable in our case, disable keyboard access
- if (window.attachEvent){
- // it is IE or Opera
- input.setAttribute('tabIndex', "-1");
- }
-
- return input;
- }
-};
-
-/**
- * Class for uploading files, uploading itself is handled by child classes
- */
-qq.UploadHandlerAbstract = function(o){
- this._options = {
- debug: false,
- action: '/testest',
- // maximum number of concurrent uploads
- maxConnections: 999,
- onProgress: function(id, fileName, loaded, total){},
- onComplete: function(id, fileName, response){},
- onCancel: function(id, fileName){}
- };
- qq.extend(this._options, o);
-
- this._queue = [];
- // params for files in queue
- this._params = [];
-};
-qq.UploadHandlerAbstract.prototype = {
- log: function(str){
- if (this._options.debug && window.console) console.log('[uploader] ' + str);
- },
- /**
- * Adds file or file input to the queue
- * @returns id
- **/
- add: function(file){},
- /**
- * Sends the file identified by id and additional query params to the server
- */
- upload: function(id, params){
- var len = this._queue.push(id);
-
- var copy = {};
- qq.extend(copy, params);
- this._params[id] = copy;
-
- // if too many active uploads, wait...
- if (len <= this._options.maxConnections){
- this._upload(id, this._params[id]);
- }
- },
- /**
- * Cancels file upload by id
- */
- cancel: function(id){
- this._cancel(id);
- this._dequeue(id);
- },
- /**
- * Cancells all uploads
- */
- cancelAll: function(){
- for (var i=0; i= max && i < max){
- var nextId = this._queue[max-1];
- this._upload(nextId, this._params[nextId]);
- }
- }
-};
-
-/**
- * Class for uploading files using form and iframe
- * @inherits qq.UploadHandlerAbstract
- */
-qq.UploadHandlerForm = function(o){
- qq.UploadHandlerAbstract.apply(this, arguments);
-
- this._inputs = {};
-};
-// @inherits qq.UploadHandlerAbstract
-qq.extend(qq.UploadHandlerForm.prototype, qq.UploadHandlerAbstract.prototype);
-
-qq.extend(qq.UploadHandlerForm.prototype, {
- add: function(fileInput){
- fileInput.setAttribute('name', 'qqfile');
- var id = 'qq-upload-handler-iframe' + qq.getUniqueId();
-
- this._inputs[id] = fileInput;
-
- // remove file input from DOM
- if (fileInput.parentNode){
- qq.remove(fileInput);
- }
-
- return id;
- },
- getName: function(id){
- // get input value and remove path to normalize
- return this._inputs[id].value.replace(/.*(\/|\\)/, "");
- },
- _cancel: function(id){
- this._options.onCancel(id, this.getName(id));
-
- delete this._inputs[id];
-
- var iframe = document.getElementById(id);
- if (iframe){
- // to cancel request set src to something else
- // we use src="javascript:false;" because it doesn't
- // trigger ie6 prompt on https
- iframe.setAttribute('src', 'javascript:false;');
-
- qq.remove(iframe);
- }
- },
- _upload: function(id, params){
- var input = this._inputs[id];
-
- if (!input){
- throw new Error('file with passed id was not added, or already uploaded or cancelled');
- }
-
- var fileName = this.getName(id);
-
- var iframe = this._createIframe(id);
- var form = this._createForm(iframe, params);
- form.appendChild(input);
-
- var self = this;
- this._attachLoadEvent(iframe, function(){
- self.log('iframe loaded');
-
- var response = self._getIframeContentJSON(iframe);
-
- self._options.onComplete(id, fileName, response);
- self._dequeue(id);
-
- delete self._inputs[id];
- // timeout added to fix busy state in FF3.6
- setTimeout(function(){
- qq.remove(iframe);
- }, 1);
- });
-
- form.submit();
- qq.remove(form);
-
- return id;
- },
- _attachLoadEvent: function(iframe, callback){
- qq.attach(iframe, 'load', function(){
- // when we remove iframe from dom
- // the request stops, but in IE load
- // event fires
- if (!iframe.parentNode){
- return;
- }
-
- // fixing Opera 10.53
- if (iframe.contentDocument &&
- iframe.contentDocument.body &&
- iframe.contentDocument.body.innerHTML == "false"){
- // In Opera event is fired second time
- // when body.innerHTML changed from false
- // to server response approx. after 1 sec
- // when we upload file with iframe
- return;
- }
-
- callback();
- });
- },
- /**
- * Returns json object received by iframe from server.
- */
- _getIframeContentJSON: function(iframe){
- // iframe.contentWindow.document - for IE<7
- var doc = iframe.contentDocument ? iframe.contentDocument: iframe.contentWindow.document,
- response;
-
- this.log("converting iframe's innerHTML to JSON");
- this.log("innerHTML = " + doc.body.innerHTML);
-
- try {
- response = eval("(" + doc.body.innerHTML + ")");
- } catch(err){
- response = {};
- }
-
- return response;
- },
- /**
- * Creates iframe with unique name
- */
- _createIframe: function(id){
- // We can't use following code as the name attribute
- // won't be properly registered in IE6, and new window
- // on form submit will open
- // var iframe = document.createElement('iframe');
- // iframe.setAttribute('name', id);
-
- var iframe = qq.toElement('');
- // src="javascript:false;" removes ie6 prompt on https
-
- iframe.setAttribute('id', id);
-
- iframe.style.display = 'none';
- document.body.appendChild(iframe);
-
- return iframe;
- },
- /**
- * Creates form, that will be submitted to iframe
- */
- _createForm: function(iframe, params){
- // We can't use the following code in IE6
- // var form = document.createElement('form');
- // form.setAttribute('method', 'post');
- // form.setAttribute('enctype', 'multipart/form-data');
- // Because in this case file won't be attached to request
- var form = qq.toElement('');
-
- var queryString = qq.obj2url(params, this._options.action);
-
- form.setAttribute('action', queryString);
- form.setAttribute('target', iframe.name);
- form.style.display = 'none';
- document.body.appendChild(form);
-
- return form;
- }
-});
-
-/**
- * Class for uploading files using xhr
- * @inherits qq.UploadHandlerAbstract
- */
-qq.UploadHandlerXhr = function(o){
- qq.UploadHandlerAbstract.apply(this, arguments);
-
- this._files = [];
- this._xhrs = [];
-
- // current loaded size in bytes for each file
- this._loaded = [];
-};
-
-// static method
-qq.UploadHandlerXhr.isSupported = function(){
- var input = document.createElement('input');
- input.type = 'file';
-
- return (
- 'multiple' in input &&
- typeof File != "undefined" &&
- typeof (new XMLHttpRequest()).upload != "undefined" );
-};
-
-// @inherits qq.UploadHandlerAbstract
-qq.extend(qq.UploadHandlerXhr.prototype, qq.UploadHandlerAbstract.prototype)
-
-qq.extend(qq.UploadHandlerXhr.prototype, {
- /**
- * Adds file to the queue
- * Returns id to use with upload, cancel
- **/
- add: function(file){
- if (!(file instanceof File)){
- throw new Error('Passed obj in not a File (in qq.UploadHandlerXhr)');
- }
-
- return this._files.push(file) - 1;
- },
- getName: function(id){
- var file = this._files[id];
- // fix missing name in Safari 4
- return file.fileName != null ? file.fileName : file.name;
- },
- getSize: function(id){
- var file = this._files[id];
- return file.fileSize != null ? file.fileSize : file.size;
- },
- /**
- * Returns uploaded bytes for file identified by id
- */
- getLoaded: function(id){
- return this._loaded[id] || 0;
- },
- /**
- * Sends the file identified by id and additional query params to the server
- * @param {Object} params name-value string pairs
- */
- _upload: function(id, params){
- var file = this._files[id],
- name = this.getName(id),
- size = this.getSize(id);
-
- this._loaded[id] = 0;
-
- var xhr = this._xhrs[id] = new XMLHttpRequest();
- var self = this;
-
- xhr.upload.onprogress = function(e){
- if (e.lengthComputable){
- self._loaded[id] = e.loaded;
- self._options.onProgress(id, name, e.loaded, e.total);
- }
- };
-
- xhr.onreadystatechange = function(){
- if (xhr.readyState == 4){
- self._onComplete(id, xhr);
- }
- };
-
- // build query string
- params = params || {};
- params['qqfile'] = name;
- var queryString = qq.obj2url(params, this._options.action);
-
- xhr.open("POST", queryString, true);
- xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
- xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
- xhr.setRequestHeader("Content-Type", "application/octet-stream");
- xhr.setRequestHeader("Accept", "application/json");
- xhr.send(file);
- },
- _onComplete: function(id, xhr){
- // the request was aborted/cancelled
- if (!this._files[id]) return;
-
- var name = this.getName(id);
- var size = this.getSize(id);
-
- this._options.onProgress(id, name, size, size);
-
- if (xhr.status == 200){
- this.log("xhr - server response received");
- this.log("responseText = " + xhr.responseText);
-
- var response;
-
- try {
- response = eval("(" + xhr.responseText + ")");
- } catch(err){
- response = {};
- }
-
- this._options.onComplete(id, name, response);
-
- } else {
- this._options.onComplete(id, name, {});
- }
-
- this._files[id] = null;
- this._xhrs[id] = null;
- this._dequeue(id);
- },
- _cancel: function(id){
- this._options.onCancel(id, this.getName(id));
-
- this._files[id] = null;
-
- if (this._xhrs[id]){
- this._xhrs[id].abort();
- this._xhrs[id] = null;
- }
- }
-});
-
-
-var uploader = new qq.FileUploader({
- element: document.getElementById('file-uploader'),
- action: '/upload',
- params: {
- expires: $('#expires').val(),
- randomize: true,
- },
-
- messages: {
- typeError: "{file} has invalid extension. Only {extensions} are allowed.",
- sizeError: "{file} is too large, maximum file size is {sizeLimit}.",
- minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.",
- emptyError: "{file} is empty, please select files again without it.",
- onLeave: "The files are being uploaded, if you leave now the upload will be cancelled."
- },
- showMessage: function(message){
- alert(message);
- },
- });
diff --git a/static/js/dropzone.js b/static/js/dropzone.js
new file mode 100644
index 0000000..36a3ef5
--- /dev/null
+++ b/static/js/dropzone.js
@@ -0,0 +1,1729 @@
+
+/*
+ *
+ * More info at [www.dropzonejs.com](http://www.dropzonejs.com)
+ *
+ * Copyright (c) 2012, Matias Meno
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+(function() {
+ var Dropzone, Emitter, camelize, contentLoaded, detectVerticalSquash, drawImageIOSFix, noop, without,
+ __slice = [].slice,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ noop = function() {};
+
+ Emitter = (function() {
+ function Emitter() {}
+
+ Emitter.prototype.addEventListener = Emitter.prototype.on;
+
+ Emitter.prototype.on = function(event, fn) {
+ this._callbacks = this._callbacks || {};
+ if (!this._callbacks[event]) {
+ this._callbacks[event] = [];
+ }
+ this._callbacks[event].push(fn);
+ return this;
+ };
+
+ Emitter.prototype.emit = function() {
+ var args, callback, callbacks, event, _i, _len;
+ event = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ this._callbacks = this._callbacks || {};
+ callbacks = this._callbacks[event];
+ if (callbacks) {
+ for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
+ callback = callbacks[_i];
+ callback.apply(this, args);
+ }
+ }
+ return this;
+ };
+
+ Emitter.prototype.removeListener = Emitter.prototype.off;
+
+ Emitter.prototype.removeAllListeners = Emitter.prototype.off;
+
+ Emitter.prototype.removeEventListener = Emitter.prototype.off;
+
+ Emitter.prototype.off = function(event, fn) {
+ var callback, callbacks, i, _i, _len;
+ if (!this._callbacks || arguments.length === 0) {
+ this._callbacks = {};
+ return this;
+ }
+ callbacks = this._callbacks[event];
+ if (!callbacks) {
+ return this;
+ }
+ if (arguments.length === 1) {
+ delete this._callbacks[event];
+ return this;
+ }
+ for (i = _i = 0, _len = callbacks.length; _i < _len; i = ++_i) {
+ callback = callbacks[i];
+ if (callback === fn) {
+ callbacks.splice(i, 1);
+ break;
+ }
+ }
+ return this;
+ };
+
+ return Emitter;
+
+ })();
+
+ Dropzone = (function(_super) {
+ var extend, resolveOption;
+
+ __extends(Dropzone, _super);
+
+ Dropzone.prototype.Emitter = Emitter;
+
+
+ /*
+ This is a list of all available events you can register on a dropzone object.
+
+ You can register an event handler like this:
+
+ dropzone.on("dragEnter", function() { });
+ */
+
+ Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "addedfile", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded", "maxfilesreached", "queuecomplete"];
+
+ Dropzone.prototype.defaultOptions = {
+ url: null,
+ method: "post",
+ withCredentials: false,
+ parallelUploads: 2,
+ uploadMultiple: false,
+ maxFilesize: 256,
+ paramName: "file",
+ createImageThumbnails: true,
+ maxThumbnailFilesize: 10,
+ thumbnailWidth: 120,
+ thumbnailHeight: 120,
+ filesizeBase: 1000,
+ maxFiles: null,
+ filesizeBase: 1000,
+ params: {},
+ clickable: true,
+ ignoreHiddenFiles: true,
+ acceptedFiles: null,
+ acceptedMimeTypes: null,
+ autoProcessQueue: true,
+ autoQueue: true,
+ addRemoveLinks: false,
+ previewsContainer: null,
+ capture: null,
+ dictDefaultMessage: "Drop files here to upload",
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
+ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
+ dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",
+ dictInvalidFileType: "You can't upload files of this type.",
+ dictResponseError: "Server responded with {{statusCode}} code.",
+ dictCancelUpload: "Cancel upload",
+ dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
+ dictRemoveFile: "Remove file",
+ dictRemoveFileConfirmation: null,
+ dictMaxFilesExceeded: "You can not upload any more files.",
+ accept: function(file, done) {
+ return done();
+ },
+ init: function() {
+ return noop;
+ },
+ forceFallback: false,
+ fallback: function() {
+ var child, messageElement, span, _i, _len, _ref;
+ this.element.className = "" + this.element.className + " dz-browser-not-supported";
+ _ref = this.element.getElementsByTagName("div");
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ child = _ref[_i];
+ if (/(^| )dz-message($| )/.test(child.className)) {
+ messageElement = child;
+ child.className = "dz-message";
+ continue;
+ }
+ }
+ if (!messageElement) {
+ messageElement = Dropzone.createElement("
");
+ this.element.appendChild(messageElement);
+ }
+ span = messageElement.getElementsByTagName("span")[0];
+ if (span) {
+ span.textContent = this.options.dictFallbackMessage;
+ }
+ return this.element.appendChild(this.getFallbackForm());
+ },
+ resize: function(file) {
+ var info, srcRatio, trgRatio;
+ info = {
+ srcX: 0,
+ srcY: 0,
+ srcWidth: file.width,
+ srcHeight: file.height
+ };
+ srcRatio = file.width / file.height;
+ info.optWidth = this.options.thumbnailWidth;
+ info.optHeight = this.options.thumbnailHeight;
+ if ((info.optWidth == null) && (info.optHeight == null)) {
+ info.optWidth = info.srcWidth;
+ info.optHeight = info.srcHeight;
+ } else if (info.optWidth == null) {
+ info.optWidth = srcRatio * info.optHeight;
+ } else if (info.optHeight == null) {
+ info.optHeight = (1 / srcRatio) * info.optWidth;
+ }
+ trgRatio = info.optWidth / info.optHeight;
+ if (file.height < info.optHeight || file.width < info.optWidth) {
+ info.trgHeight = info.srcHeight;
+ info.trgWidth = info.srcWidth;
+ } else {
+ if (srcRatio > trgRatio) {
+ info.srcHeight = file.height;
+ info.srcWidth = info.srcHeight * trgRatio;
+ } else {
+ info.srcWidth = file.width;
+ info.srcHeight = info.srcWidth / trgRatio;
+ }
+ }
+ info.srcX = (file.width - info.srcWidth) / 2;
+ info.srcY = (file.height - info.srcHeight) / 2;
+ return info;
+ },
+
+ /*
+ 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) {
+ return this.element.classList.remove("dz-drag-hover");
+ },
+ dragstart: noop,
+ dragend: function(e) {
+ return this.element.classList.remove("dz-drag-hover");
+ },
+ dragenter: function(e) {
+ return this.element.classList.add("dz-drag-hover");
+ },
+ dragover: function(e) {
+ return this.element.classList.add("dz-drag-hover");
+ },
+ dragleave: function(e) {
+ return this.element.classList.remove("dz-drag-hover");
+ },
+ paste: noop,
+ reset: function() {
+ return this.element.classList.remove("dz-started");
+ },
+ addedfile: function(file) {
+ var node, removeFileEvent, removeLink, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
+ if (this.element === this.previewsContainer) {
+ this.element.classList.add("dz-started");
+ }
+ if (this.previewsContainer) {
+ file.previewElement = Dropzone.createElement(this.options.previewTemplate.trim());
+ file.previewTemplate = file.previewElement;
+ this.previewsContainer.appendChild(file.previewElement);
+ _ref = file.previewElement.querySelectorAll("[data-dz-name]");
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ node = _ref[_i];
+ node.textContent = file.name;
+ }
+ _ref1 = file.previewElement.querySelectorAll("[data-dz-size]");
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ node = _ref1[_j];
+ node.innerHTML = this.filesize(file.size);
+ }
+ if (this.options.addRemoveLinks) {
+ file._removeLink = Dropzone.createElement("" + this.options.dictRemoveFile + "");
+ file.previewElement.appendChild(file._removeLink);
+ }
+ removeFileEvent = (function(_this) {
+ return function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (file.status === Dropzone.UPLOADING) {
+ return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() {
+ return _this.removeFile(file);
+ });
+ } else {
+ if (_this.options.dictRemoveFileConfirmation) {
+ return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() {
+ return _this.removeFile(file);
+ });
+ } else {
+ return _this.removeFile(file);
+ }
+ }
+ };
+ })(this);
+ _ref2 = file.previewElement.querySelectorAll("[data-dz-remove]");
+ _results = [];
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+ removeLink = _ref2[_k];
+ _results.push(removeLink.addEventListener("click", removeFileEvent));
+ }
+ return _results;
+ }
+ },
+ removedfile: function(file) {
+ var _ref;
+ if (file.previewElement) {
+ if ((_ref = file.previewElement) != null) {
+ _ref.parentNode.removeChild(file.previewElement);
+ }
+ }
+ return this._updateMaxFilesReachedClass();
+ },
+ thumbnail: function(file, dataUrl) {
+ var thumbnailElement, _i, _len, _ref;
+ if (file.previewElement) {
+ file.previewElement.classList.remove("dz-file-preview");
+ _ref = file.previewElement.querySelectorAll("[data-dz-thumbnail]");
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ thumbnailElement = _ref[_i];
+ thumbnailElement.alt = file.name;
+ thumbnailElement.src = dataUrl;
+ }
+ return setTimeout(((function(_this) {
+ return function() {
+ return file.previewElement.classList.add("dz-image-preview");
+ };
+ })(this)), 1);
+ }
+ },
+ error: function(file, message) {
+ var node, _i, _len, _ref, _results;
+ if (file.previewElement) {
+ file.previewElement.classList.add("dz-error");
+ if (typeof message !== "String" && message.error) {
+ message = message.error;
+ }
+ _ref = file.previewElement.querySelectorAll("[data-dz-errormessage]");
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ node = _ref[_i];
+ _results.push(node.textContent = message);
+ }
+ return _results;
+ }
+ },
+ errormultiple: noop,
+ processing: function(file) {
+ if (file.previewElement) {
+ file.previewElement.classList.add("dz-processing");
+ if (file._removeLink) {
+ return file._removeLink.textContent = this.options.dictCancelUpload;
+ }
+ }
+ },
+ processingmultiple: noop,
+ uploadprogress: function(file, progress, bytesSent) {
+ var node, _i, _len, _ref, _results;
+ if (file.previewElement) {
+ _ref = file.previewElement.querySelectorAll("[data-dz-uploadprogress]");
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ node = _ref[_i];
+ if (node.nodeName === 'PROGRESS') {
+ _results.push(node.value = progress);
+ } else {
+ _results.push(node.style.width = "" + progress + "%");
+ }
+ }
+ return _results;
+ }
+ },
+ totaluploadprogress: noop,
+ sending: noop,
+ sendingmultiple: noop,
+ success: function(file) {
+ if (file.previewElement) {
+ return file.previewElement.classList.add("dz-success");
+ }
+ },
+ successmultiple: noop,
+ canceled: function(file) {
+ return this.emit("error", file, "Upload canceled.");
+ },
+ canceledmultiple: noop,
+ complete: function(file) {
+ if (file._removeLink) {
+ file._removeLink.textContent = this.options.dictRemoveFile;
+ }
+ if (file.previewElement) {
+ return file.previewElement.classList.add("dz-complete");
+ }
+ },
+ completemultiple: noop,
+ maxfilesexceeded: noop,
+ maxfilesreached: noop,
+ queuecomplete: noop,
+ previewTemplate: "\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
"
+ };
+
+ 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];
+ for (key in object) {
+ val = object[key];
+ target[key] = val;
+ }
+ }
+ return target;
+ };
+
+ function Dropzone(element, options) {
+ var elementOptions, fallback, _ref;
+ this.element = element;
+ this.version = Dropzone.version;
+ this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
+ this.clickableElements = [];
+ this.listeners = [];
+ this.files = [];
+ if (typeof this.element === "string") {
+ this.element = document.querySelector(this.element);
+ }
+ if (!(this.element && (this.element.nodeType != null))) {
+ throw new Error("Invalid dropzone element.");
+ }
+ if (this.element.dropzone) {
+ throw new Error("Dropzone already attached.");
+ }
+ Dropzone.instances.push(this);
+ this.element.dropzone = this;
+ elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {};
+ this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
+ if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {
+ return this.options.fallback.call(this);
+ }
+ if (this.options.url == null) {
+ this.options.url = this.element.getAttribute("action");
+ }
+ if (!this.options.url) {
+ throw new Error("No URL provided.");
+ }
+ if (this.options.acceptedFiles && this.options.acceptedMimeTypes) {
+ throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");
+ }
+ if (this.options.acceptedMimeTypes) {
+ this.options.acceptedFiles = this.options.acceptedMimeTypes;
+ delete this.options.acceptedMimeTypes;
+ }
+ this.options.method = this.options.method.toUpperCase();
+ if ((fallback = this.getExistingFallback()) && fallback.parentNode) {
+ fallback.parentNode.removeChild(fallback);
+ }
+ if (this.options.previewsContainer !== false) {
+ if (this.options.previewsContainer) {
+ this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer");
+ } else {
+ this.previewsContainer = this.element;
+ }
+ }
+ if (this.options.clickable) {
+ if (this.options.clickable === true) {
+ this.clickableElements = [this.element];
+ } else {
+ this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable");
+ }
+ }
+ this.init();
+ }
+
+ Dropzone.prototype.getAcceptedFiles = function() {
+ var file, _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.accepted) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.getRejectedFiles = function() {
+ var file, _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (!file.accepted) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.getFilesWithStatus = function(status) {
+ var file, _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.status === status) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.getQueuedFiles = function() {
+ return this.getFilesWithStatus(Dropzone.QUEUED);
+ };
+
+ Dropzone.prototype.getUploadingFiles = function() {
+ return this.getFilesWithStatus(Dropzone.UPLOADING);
+ };
+
+ Dropzone.prototype.getActiveFiles = function() {
+ var file, _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.status === Dropzone.UPLOADING || file.status === Dropzone.QUEUED) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.init = function() {
+ var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1;
+ if (this.element.tagName === "form") {
+ this.element.setAttribute("enctype", "multipart/form-data");
+ }
+ if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) {
+ this.element.appendChild(Dropzone.createElement("" + this.options.dictDefaultMessage + "
"));
+ }
+ if (this.clickableElements.length) {
+ setupHiddenFileInput = (function(_this) {
+ return function() {
+ if (_this.hiddenFileInput) {
+ document.body.removeChild(_this.hiddenFileInput);
+ }
+ _this.hiddenFileInput = document.createElement("input");
+ _this.hiddenFileInput.setAttribute("type", "file");
+ if ((_this.options.maxFiles == null) || _this.options.maxFiles > 1) {
+ _this.hiddenFileInput.setAttribute("multiple", "multiple");
+ }
+ _this.hiddenFileInput.className = "dz-hidden-input";
+ if (_this.options.acceptedFiles != null) {
+ _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles);
+ }
+ if (_this.options.capture != null) {
+ _this.hiddenFileInput.setAttribute("capture", _this.options.capture);
+ }
+ _this.hiddenFileInput.style.visibility = "hidden";
+ _this.hiddenFileInput.style.position = "absolute";
+ _this.hiddenFileInput.style.top = "0";
+ _this.hiddenFileInput.style.left = "0";
+ _this.hiddenFileInput.style.height = "0";
+ _this.hiddenFileInput.style.width = "0";
+ document.body.appendChild(_this.hiddenFileInput);
+ return _this.hiddenFileInput.addEventListener("change", function() {
+ var file, files, _i, _len;
+ files = _this.hiddenFileInput.files;
+ if (files.length) {
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ _this.addFile(file);
+ }
+ }
+ return setupHiddenFileInput();
+ });
+ };
+ })(this);
+ setupHiddenFileInput();
+ }
+ this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
+ _ref1 = this.events;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ eventName = _ref1[_i];
+ this.on(eventName, this.options[eventName]);
+ }
+ this.on("uploadprogress", (function(_this) {
+ return function() {
+ return _this.updateTotalUploadProgress();
+ };
+ })(this));
+ this.on("removedfile", (function(_this) {
+ return function() {
+ return _this.updateTotalUploadProgress();
+ };
+ })(this));
+ this.on("canceled", (function(_this) {
+ return function(file) {
+ return _this.emit("complete", file);
+ };
+ })(this));
+ this.on("complete", (function(_this) {
+ return function(file) {
+ if (_this.getUploadingFiles().length === 0 && _this.getQueuedFiles().length === 0) {
+ return setTimeout((function() {
+ return _this.emit("queuecomplete");
+ }), 0);
+ }
+ };
+ })(this));
+ noPropagation = function(e) {
+ e.stopPropagation();
+ if (e.preventDefault) {
+ return e.preventDefault();
+ } else {
+ return e.returnValue = false;
+ }
+ };
+ this.listeners = [
+ {
+ element: this.element,
+ events: {
+ "dragstart": (function(_this) {
+ return function(e) {
+ return _this.emit("dragstart", e);
+ };
+ })(this),
+ "dragenter": (function(_this) {
+ return function(e) {
+ noPropagation(e);
+ return _this.emit("dragenter", e);
+ };
+ })(this),
+ "dragover": (function(_this) {
+ return function(e) {
+ var efct;
+ try {
+ efct = e.dataTransfer.effectAllowed;
+ } catch (_error) {}
+ e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';
+ noPropagation(e);
+ return _this.emit("dragover", e);
+ };
+ })(this),
+ "dragleave": (function(_this) {
+ return function(e) {
+ return _this.emit("dragleave", e);
+ };
+ })(this),
+ "drop": (function(_this) {
+ return function(e) {
+ noPropagation(e);
+ return _this.drop(e);
+ };
+ })(this),
+ "dragend": (function(_this) {
+ return function(e) {
+ return _this.emit("dragend", e);
+ };
+ })(this)
+ }
+ }
+ ];
+ this.clickableElements.forEach((function(_this) {
+ return function(clickableElement) {
+ return _this.listeners.push({
+ element: clickableElement,
+ events: {
+ "click": function(evt) {
+ if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {
+ return _this.hiddenFileInput.click();
+ }
+ }
+ }
+ });
+ };
+ })(this));
+ this.enable();
+ return this.options.init.call(this);
+ };
+
+ Dropzone.prototype.destroy = function() {
+ var _ref;
+ this.disable();
+ this.removeAllFiles(true);
+ if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) {
+ this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
+ this.hiddenFileInput = null;
+ }
+ delete this.element.dropzone;
+ return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1);
+ };
+
+ Dropzone.prototype.updateTotalUploadProgress = function() {
+ var activeFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref;
+ totalBytesSent = 0;
+ totalBytes = 0;
+ activeFiles = this.getActiveFiles();
+ if (activeFiles.length) {
+ _ref = this.getActiveFiles();
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ totalBytesSent += file.upload.bytesSent;
+ totalBytes += file.upload.total;
+ }
+ totalUploadProgress = 100 * totalBytesSent / totalBytes;
+ } else {
+ totalUploadProgress = 100;
+ }
+ return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);
+ };
+
+ Dropzone.prototype._getParamName = function(n) {
+ if (typeof this.options.paramName === "function") {
+ return this.options.paramName(n);
+ } else {
+ return "" + this.options.paramName + (this.options.uploadMultiple ? "[" + n + "]" : "");
+ }
+ };
+
+ Dropzone.prototype.getFallbackForm = function() {
+ var existingFallback, fields, fieldsString, form;
+ if (existingFallback = this.getExistingFallback()) {
+ return existingFallback;
+ }
+ fieldsString = "";
+ fields = Dropzone.createElement(fieldsString);
+ if (this.element.tagName !== "FORM") {
+ form = Dropzone.createElement("");
+ form.appendChild(fields);
+ } else {
+ this.element.setAttribute("enctype", "multipart/form-data");
+ this.element.setAttribute("method", this.options.method);
+ }
+ return form != null ? form : fields;
+ };
+
+ 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)) {
+ return el;
+ }
+ }
+ };
+ _ref = ["div", "form"];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ tagName = _ref[_i];
+ if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {
+ return fallback;
+ }
+ }
+ };
+
+ Dropzone.prototype.setupEventListeners = function() {
+ var elementListeners, event, listener, _i, _len, _ref, _results;
+ _ref = this.listeners;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ elementListeners = _ref[_i];
+ _results.push((function() {
+ var _ref1, _results1;
+ _ref1 = elementListeners.events;
+ _results1 = [];
+ for (event in _ref1) {
+ listener = _ref1[event];
+ _results1.push(elementListeners.element.addEventListener(event, listener, false));
+ }
+ return _results1;
+ })());
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.removeEventListeners = function() {
+ var elementListeners, event, listener, _i, _len, _ref, _results;
+ _ref = this.listeners;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ elementListeners = _ref[_i];
+ _results.push((function() {
+ var _ref1, _results1;
+ _ref1 = elementListeners.events;
+ _results1 = [];
+ for (event in _ref1) {
+ listener = _ref1[event];
+ _results1.push(elementListeners.element.removeEventListener(event, listener, false));
+ }
+ return _results1;
+ })());
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.disable = function() {
+ var file, _i, _len, _ref, _results;
+ this.clickableElements.forEach(function(element) {
+ return element.classList.remove("dz-clickable");
+ });
+ this.removeEventListeners();
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ _results.push(this.cancelUpload(file));
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.enable = function() {
+ this.clickableElements.forEach(function(element) {
+ return element.classList.add("dz-clickable");
+ });
+ return this.setupEventListeners();
+ };
+
+ Dropzone.prototype.filesize = function(size) {
+ var cutoff, i, selectedSize, selectedUnit, unit, units, _i, _len;
+ units = ['TB', 'GB', 'MB', 'KB', 'b'];
+ selectedSize = selectedUnit = null;
+ for (i = _i = 0, _len = units.length; _i < _len; i = ++_i) {
+ unit = units[i];
+ cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;
+ if (size >= cutoff) {
+ selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i);
+ selectedUnit = unit;
+ break;
+ }
+ }
+ selectedSize = Math.round(10 * selectedSize) / 10;
+ return "" + selectedSize + " " + selectedUnit;
+ };
+
+ Dropzone.prototype._updateMaxFilesReachedClass = function() {
+ if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) {
+ if (this.getAcceptedFiles().length === this.options.maxFiles) {
+ this.emit('maxfilesreached', this.files);
+ }
+ return this.element.classList.add("dz-max-files-reached");
+ } else {
+ return this.element.classList.remove("dz-max-files-reached");
+ }
+ };
+
+ Dropzone.prototype.drop = function(e) {
+ var files, items;
+ if (!e.dataTransfer) {
+ return;
+ }
+ this.emit("drop", e);
+ files = e.dataTransfer.files;
+ if (files.length) {
+ items = e.dataTransfer.items;
+ if (items && items.length && (items[0].webkitGetAsEntry != null)) {
+ this._addFilesFromItems(items);
+ } else {
+ this.handleFiles(files);
+ }
+ }
+ };
+
+ Dropzone.prototype.paste = function(e) {
+ var items, _ref;
+ if ((e != null ? (_ref = e.clipboardData) != null ? _ref.items : void 0 : void 0) == null) {
+ return;
+ }
+ this.emit("paste", e);
+ items = e.clipboardData.items;
+ if (items.length) {
+ return this._addFilesFromItems(items);
+ }
+ };
+
+ Dropzone.prototype.handleFiles = function(files) {
+ var file, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ _results.push(this.addFile(file));
+ }
+ return _results;
+ };
+
+ Dropzone.prototype._addFilesFromItems = function(items) {
+ var entry, item, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
+ item = items[_i];
+ if ((item.webkitGetAsEntry != null) && (entry = item.webkitGetAsEntry())) {
+ if (entry.isFile) {
+ _results.push(this.addFile(item.getAsFile()));
+ } else if (entry.isDirectory) {
+ _results.push(this._addFilesFromDirectory(entry, entry.name));
+ } else {
+ _results.push(void 0);
+ }
+ } else if (item.getAsFile != null) {
+ if ((item.kind == null) || item.kind === "file") {
+ _results.push(this.addFile(item.getAsFile()));
+ } else {
+ _results.push(void 0);
+ }
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.prototype._addFilesFromDirectory = function(directory, path) {
+ var dirReader, entriesReader;
+ dirReader = directory.createReader();
+ entriesReader = (function(_this) {
+ return function(entries) {
+ var entry, _i, _len;
+ for (_i = 0, _len = entries.length; _i < _len; _i++) {
+ entry = entries[_i];
+ if (entry.isFile) {
+ entry.file(function(file) {
+ if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {
+ return;
+ }
+ file.fullPath = "" + path + "/" + file.name;
+ return _this.addFile(file);
+ });
+ } else if (entry.isDirectory) {
+ _this._addFilesFromDirectory(entry, "" + path + "/" + entry.name);
+ }
+ }
+ };
+ })(this);
+ return dirReader.readEntries(entriesReader, function(error) {
+ return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0;
+ });
+ };
+
+ Dropzone.prototype.accept = function(file, done) {
+ if (file.size > this.options.maxFilesize * 1024 * 1024) {
+ return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
+ } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
+ return done(this.options.dictInvalidFileType);
+ } else if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) {
+ done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
+ return this.emit("maxfilesexceeded", file);
+ } else {
+ return this.options.accept.call(this, file, done);
+ }
+ };
+
+ Dropzone.prototype.addFile = function(file) {
+ file.upload = {
+ progress: 0,
+ total: file.size,
+ bytesSent: 0
+ };
+ this.files.push(file);
+ file.status = Dropzone.ADDED;
+ this.emit("addedfile", file);
+ this._enqueueThumbnail(file);
+ return this.accept(file, (function(_this) {
+ return function(error) {
+ if (error) {
+ file.accepted = false;
+ _this._errorProcessing([file], error);
+ } else {
+ file.accepted = true;
+ if (_this.options.autoQueue) {
+ _this.enqueueFile(file);
+ }
+ }
+ return _this._updateMaxFilesReachedClass();
+ };
+ })(this));
+ };
+
+ Dropzone.prototype.enqueueFiles = function(files) {
+ var file, _i, _len;
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ this.enqueueFile(file);
+ }
+ return null;
+ };
+
+ Dropzone.prototype.enqueueFile = function(file) {
+ if (file.status === Dropzone.ADDED && file.accepted === true) {
+ file.status = Dropzone.QUEUED;
+ if (this.options.autoProcessQueue) {
+ return setTimeout(((function(_this) {
+ return function() {
+ return _this.processQueue();
+ };
+ })(this)), 0);
+ }
+ } else {
+ throw new Error("This file can't be queued because it has already been processed or was rejected.");
+ }
+ };
+
+ Dropzone.prototype._thumbnailQueue = [];
+
+ Dropzone.prototype._processingThumbnail = false;
+
+ Dropzone.prototype._enqueueThumbnail = function(file) {
+ if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
+ this._thumbnailQueue.push(file);
+ return setTimeout(((function(_this) {
+ return function() {
+ return _this._processThumbnailQueue();
+ };
+ })(this)), 0);
+ }
+ };
+
+ Dropzone.prototype._processThumbnailQueue = function() {
+ if (this._processingThumbnail || this._thumbnailQueue.length === 0) {
+ return;
+ }
+ this._processingThumbnail = true;
+ return this.createThumbnail(this._thumbnailQueue.shift(), (function(_this) {
+ return function() {
+ _this._processingThumbnail = false;
+ return _this._processThumbnailQueue();
+ };
+ })(this));
+ };
+
+ Dropzone.prototype.removeFile = function(file) {
+ if (file.status === Dropzone.UPLOADING) {
+ this.cancelUpload(file);
+ }
+ this.files = without(this.files, file);
+ this.emit("removedfile", file);
+ if (this.files.length === 0) {
+ return this.emit("reset");
+ }
+ };
+
+ Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) {
+ var file, _i, _len, _ref;
+ if (cancelIfNecessary == null) {
+ cancelIfNecessary = false;
+ }
+ _ref = this.files.slice();
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {
+ this.removeFile(file);
+ }
+ }
+ return null;
+ };
+
+ Dropzone.prototype.createThumbnail = function(file, callback) {
+ var fileReader;
+ fileReader = new FileReader;
+ fileReader.onload = (function(_this) {
+ return function() {
+ if (file.type === "image/svg+xml") {
+ _this.emit("thumbnail", file, fileReader.result);
+ if (callback != null) {
+ callback();
+ }
+ return;
+ }
+ return _this.createThumbnailFromUrl(file, fileReader.result, callback);
+ };
+ })(this);
+ return fileReader.readAsDataURL(file);
+ };
+
+ Dropzone.prototype.createThumbnailFromUrl = function(file, imageUrl, callback) {
+ var img;
+ img = document.createElement("img");
+ img.onload = (function(_this) {
+ return function() {
+ var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
+ file.width = img.width;
+ file.height = img.height;
+ resizeInfo = _this.options.resize.call(_this, file);
+ if (resizeInfo.trgWidth == null) {
+ resizeInfo.trgWidth = resizeInfo.optWidth;
+ }
+ if (resizeInfo.trgHeight == null) {
+ resizeInfo.trgHeight = resizeInfo.optHeight;
+ }
+ canvas = document.createElement("canvas");
+ ctx = canvas.getContext("2d");
+ canvas.width = resizeInfo.trgWidth;
+ canvas.height = resizeInfo.trgHeight;
+ drawImageIOSFix(ctx, img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
+ thumbnail = canvas.toDataURL("image/png");
+ _this.emit("thumbnail", file, thumbnail);
+ if (callback != null) {
+ return callback();
+ }
+ };
+ })(this);
+ if (callback != null) {
+ img.onerror = callback;
+ }
+ return img.src = imageUrl;
+ };
+
+ Dropzone.prototype.processQueue = function() {
+ var i, parallelUploads, processingLength, queuedFiles;
+ parallelUploads = this.options.parallelUploads;
+ processingLength = this.getUploadingFiles().length;
+ i = processingLength;
+ if (processingLength >= parallelUploads) {
+ return;
+ }
+ queuedFiles = this.getQueuedFiles();
+ if (!(queuedFiles.length > 0)) {
+ return;
+ }
+ if (this.options.uploadMultiple) {
+ return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength));
+ } else {
+ while (i < parallelUploads) {
+ if (!queuedFiles.length) {
+ return;
+ }
+ this.processFile(queuedFiles.shift());
+ i++;
+ }
+ }
+ };
+
+ Dropzone.prototype.processFile = function(file) {
+ return this.processFiles([file]);
+ };
+
+ Dropzone.prototype.processFiles = function(files) {
+ var file, _i, _len;
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ file.processing = true;
+ file.status = Dropzone.UPLOADING;
+ this.emit("processing", file);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("processingmultiple", files);
+ }
+ return this.uploadFiles(files);
+ };
+
+ Dropzone.prototype._getFilesWithXhr = function(xhr) {
+ var file, files;
+ return files = (function() {
+ var _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.xhr === xhr) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ }).call(this);
+ };
+
+ Dropzone.prototype.cancelUpload = function(file) {
+ var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref;
+ if (file.status === Dropzone.UPLOADING) {
+ groupedFiles = this._getFilesWithXhr(file.xhr);
+ for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) {
+ groupedFile = groupedFiles[_i];
+ groupedFile.status = Dropzone.CANCELED;
+ }
+ file.xhr.abort();
+ for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) {
+ groupedFile = groupedFiles[_j];
+ this.emit("canceled", groupedFile);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("canceledmultiple", groupedFiles);
+ }
+ } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) {
+ file.status = Dropzone.CANCELED;
+ this.emit("canceled", file);
+ if (this.options.uploadMultiple) {
+ this.emit("canceledmultiple", [file]);
+ }
+ }
+ if (this.options.autoProcessQueue) {
+ return this.processQueue();
+ }
+ };
+
+ resolveOption = function() {
+ var args, option;
+ option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ if (typeof option === 'function') {
+ return option.apply(this, args);
+ }
+ return option;
+ };
+
+ Dropzone.prototype.uploadFile = function(file) {
+ return this.uploadFiles([file]);
+ };
+
+ Dropzone.prototype.uploadFiles = function(files) {
+ var file, formData, handleError, headerName, headerValue, headers, i, input, inputName, inputType, key, method, option, progressObj, response, updateProgress, url, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
+ xhr = new XMLHttpRequest();
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ file.xhr = xhr;
+ }
+ method = resolveOption(this.options.method, files);
+ url = resolveOption(this.options.url, files);
+ xhr.open(method, url, true);
+ xhr.withCredentials = !!this.options.withCredentials;
+ response = null;
+ handleError = (function(_this) {
+ return function() {
+ var _j, _len1, _results;
+ _results = [];
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
+ file = files[_j];
+ _results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr));
+ }
+ return _results;
+ };
+ })(this);
+ updateProgress = (function(_this) {
+ return function(e) {
+ var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results;
+ if (e != null) {
+ progress = 100 * e.loaded / e.total;
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
+ file = files[_j];
+ file.upload = {
+ progress: progress,
+ total: e.total,
+ bytesSent: e.loaded
+ };
+ }
+ } else {
+ allFilesFinished = true;
+ progress = 100;
+ for (_k = 0, _len2 = files.length; _k < _len2; _k++) {
+ file = files[_k];
+ if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) {
+ allFilesFinished = false;
+ }
+ file.upload.progress = progress;
+ file.upload.bytesSent = file.upload.total;
+ }
+ if (allFilesFinished) {
+ return;
+ }
+ }
+ _results = [];
+ for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
+ file = files[_l];
+ _results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent));
+ }
+ return _results;
+ };
+ })(this);
+ xhr.onload = (function(_this) {
+ return function(e) {
+ var _ref;
+ if (files[0].status === Dropzone.CANCELED) {
+ return;
+ }
+ if (xhr.readyState !== 4) {
+ return;
+ }
+ response = xhr.responseText;
+ if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
+ try {
+ response = JSON.parse(response);
+ } catch (_error) {
+ e = _error;
+ response = "Invalid JSON response from server.";
+ }
+ }
+ updateProgress();
+ if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
+ return handleError();
+ } else {
+ return _this._finished(files, response, e);
+ }
+ };
+ })(this);
+ xhr.onerror = (function(_this) {
+ return function() {
+ if (files[0].status === Dropzone.CANCELED) {
+ return;
+ }
+ return handleError();
+ };
+ })(this);
+ progressObj = (_ref = xhr.upload) != null ? _ref : xhr;
+ progressObj.onprogress = updateProgress;
+ headers = {
+ "Accept": "application/json",
+ "Cache-Control": "no-cache",
+ "X-Requested-With": "XMLHttpRequest"
+ };
+ if (this.options.headers) {
+ extend(headers, this.options.headers);
+ }
+ for (headerName in headers) {
+ headerValue = headers[headerName];
+ xhr.setRequestHeader(headerName, headerValue);
+ }
+ formData = new FormData();
+ if (this.options.params) {
+ _ref1 = this.options.params;
+ for (key in _ref1) {
+ value = _ref1[key];
+ formData.append(key, value);
+ }
+ }
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
+ file = files[_j];
+ this.emit("sending", file, xhr, formData);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("sendingmultiple", files, xhr, formData);
+ }
+ if (this.element.tagName === "FORM") {
+ _ref2 = this.element.querySelectorAll("input, textarea, select, button");
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+ input = _ref2[_k];
+ inputName = input.getAttribute("name");
+ inputType = input.getAttribute("type");
+ if (input.tagName === "SELECT" && input.hasAttribute("multiple")) {
+ _ref3 = input.options;
+ for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
+ option = _ref3[_l];
+ if (option.selected) {
+ formData.append(inputName, option.value);
+ }
+ }
+ } else if (!inputType || ((_ref4 = inputType.toLowerCase()) !== "checkbox" && _ref4 !== "radio") || input.checked) {
+ formData.append(inputName, input.value);
+ }
+ }
+ }
+ for (i = _m = 0, _ref5 = files.length - 1; 0 <= _ref5 ? _m <= _ref5 : _m >= _ref5; i = 0 <= _ref5 ? ++_m : --_m) {
+ formData.append(this._getParamName(i), files[i], files[i].name);
+ }
+ return xhr.send(formData);
+ };
+
+ Dropzone.prototype._finished = function(files, responseText, e) {
+ var file, _i, _len;
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ file.status = Dropzone.SUCCESS;
+ this.emit("success", file, responseText, e);
+ this.emit("complete", file);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("successmultiple", files, responseText, e);
+ this.emit("completemultiple", files);
+ }
+ if (this.options.autoProcessQueue) {
+ return this.processQueue();
+ }
+ };
+
+ Dropzone.prototype._errorProcessing = function(files, message, xhr) {
+ var file, _i, _len;
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ file.status = Dropzone.ERROR;
+ this.emit("error", file, message, xhr);
+ this.emit("complete", file);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("errormultiple", files, message, xhr);
+ this.emit("completemultiple", files);
+ }
+ if (this.options.autoProcessQueue) {
+ return this.processQueue();
+ }
+ };
+
+ return Dropzone;
+
+ })(Emitter);
+
+ Dropzone.version = "4.0.1";
+
+ Dropzone.options = {};
+
+ Dropzone.optionsForElement = function(element) {
+ if (element.getAttribute("id")) {
+ return Dropzone.options[camelize(element.getAttribute("id"))];
+ } else {
+ return void 0;
+ }
+ };
+
+ Dropzone.instances = [];
+
+ Dropzone.forElement = function(element) {
+ if (typeof element === "string") {
+ element = document.querySelector(element);
+ }
+ if ((element != null ? element.dropzone : void 0) == null) {
+ throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");
+ }
+ return element.dropzone;
+ };
+
+ Dropzone.autoDiscover = true;
+
+ Dropzone.discover = function() {
+ var checkElements, dropzone, dropzones, _i, _len, _results;
+ if (document.querySelectorAll) {
+ 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];
+ if (/(^| )dropzone($| )/.test(el.className)) {
+ _results.push(dropzones.push(el));
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+ checkElements(document.getElementsByTagName("div"));
+ checkElements(document.getElementsByTagName("form"));
+ }
+ _results = [];
+ for (_i = 0, _len = dropzones.length; _i < _len; _i++) {
+ dropzone = dropzones[_i];
+ if (Dropzone.optionsForElement(dropzone) !== false) {
+ _results.push(new Dropzone(dropzone));
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
+
+ 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"))) {
+ capableBrowser = false;
+ } else {
+ _ref = Dropzone.blacklistedBrowsers;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ regex = _ref[_i];
+ if (regex.test(navigator.userAgent)) {
+ capableBrowser = false;
+ continue;
+ }
+ }
+ }
+ } else {
+ capableBrowser = false;
+ }
+ return capableBrowser;
+ };
+
+ without = function(list, rejectedItem) {
+ var item, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
+ item = list[_i];
+ if (item !== rejectedItem) {
+ _results.push(item);
+ }
+ }
+ return _results;
+ };
+
+ camelize = function(str) {
+ return str.replace(/[\-_](\w)/g, function(match) {
+ return match.charAt(1).toUpperCase();
+ });
+ };
+
+ Dropzone.createElement = function(string) {
+ var div;
+ div = document.createElement("div");
+ div.innerHTML = string;
+ return div.childNodes[0];
+ };
+
+ Dropzone.elementInside = function(element, container) {
+ if (element === container) {
+ return true;
+ }
+ while (element = element.parentNode) {
+ if (element === container) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ Dropzone.getElement = function(el, name) {
+ var element;
+ if (typeof el === "string") {
+ element = document.querySelector(el);
+ } else if (el.nodeType != null) {
+ element = el;
+ }
+ if (element == null) {
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element.");
+ }
+ return element;
+ };
+
+ Dropzone.getElements = function(els, name) {
+ var e, el, elements, _i, _j, _len, _len1, _ref;
+ if (els instanceof Array) {
+ elements = [];
+ try {
+ for (_i = 0, _len = els.length; _i < _len; _i++) {
+ el = els[_i];
+ elements.push(this.getElement(el, name));
+ }
+ } catch (_error) {
+ e = _error;
+ elements = null;
+ }
+ } else if (typeof els === "string") {
+ elements = [];
+ _ref = document.querySelectorAll(els);
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
+ el = _ref[_j];
+ elements.push(el);
+ }
+ } else if (els.nodeType != null) {
+ elements = [els];
+ }
+ if (!((elements != null) && elements.length)) {
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");
+ }
+ return elements;
+ };
+
+ Dropzone.confirm = function(question, accepted, rejected) {
+ if (window.confirm(question)) {
+ return accepted();
+ } else if (rejected != null) {
+ return rejected();
+ }
+ };
+
+ Dropzone.isValidFile = function(file, acceptedFiles) {
+ var baseMimeType, mimeType, validType, _i, _len;
+ if (!acceptedFiles) {
+ return true;
+ }
+ acceptedFiles = acceptedFiles.split(",");
+ mimeType = file.type;
+ baseMimeType = mimeType.replace(/\/.*$/, "");
+ for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) {
+ validType = acceptedFiles[_i];
+ validType = validType.trim();
+ if (validType.charAt(0) === ".") {
+ if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {
+ return true;
+ }
+ } else if (/\/\*$/.test(validType)) {
+ if (baseMimeType === validType.replace(/\/.*$/, "")) {
+ return true;
+ }
+ } else {
+ if (mimeType === validType) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+
+ if (typeof jQuery !== "undefined" && jQuery !== null) {
+ jQuery.fn.dropzone = function(options) {
+ return this.each(function() {
+ return new Dropzone(this, options);
+ });
+ };
+ }
+
+ if (typeof module !== "undefined" && module !== null) {
+ module.exports = Dropzone;
+ } else {
+ window.Dropzone = Dropzone;
+ }
+
+ Dropzone.ADDED = "added";
+
+ Dropzone.QUEUED = "queued";
+
+ Dropzone.ACCEPTED = Dropzone.QUEUED;
+
+ Dropzone.UPLOADING = "uploading";
+
+ Dropzone.PROCESSING = Dropzone.UPLOADING;
+
+ Dropzone.CANCELED = "canceled";
+
+ Dropzone.ERROR = "error";
+
+ Dropzone.SUCCESS = "success";
+
+
+ /*
+
+ Bugfix for iOS 6 and 7
+ Source: http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios
+ based on the work of https://github.com/stomita/ios-imagefile-megapixel
+ */
+
+ detectVerticalSquash = function(img) {
+ var alpha, canvas, ctx, data, ey, ih, iw, py, ratio, sy;
+ iw = img.naturalWidth;
+ ih = img.naturalHeight;
+ canvas = document.createElement("canvas");
+ canvas.width = 1;
+ canvas.height = ih;
+ ctx = canvas.getContext("2d");
+ ctx.drawImage(img, 0, 0);
+ data = ctx.getImageData(0, 0, 1, ih).data;
+ sy = 0;
+ ey = ih;
+ py = ih;
+ while (py > sy) {
+ alpha = data[(py - 1) * 4 + 3];
+ if (alpha === 0) {
+ ey = py;
+ } else {
+ sy = py;
+ }
+ py = (ey + sy) >> 1;
+ }
+ ratio = py / ih;
+ if (ratio === 0) {
+ return 1;
+ } else {
+ return ratio;
+ }
+ };
+
+ drawImageIOSFix = function(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) {
+ var vertSquashRatio;
+ vertSquashRatio = detectVerticalSquash(img);
+ return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);
+ };
+
+
+ /*
+ * contentloaded.js
+ *
+ * Author: Diego Perini (diego.perini at gmail.com)
+ * Summary: cross-browser wrapper for DOMContentLoaded
+ * Updated: 20101020
+ * License: MIT
+ * Version: 1.2
+ *
+ * URL:
+ * http://javascript.nwbox.com/ContentLoaded/
+ * http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
+ */
+
+ contentLoaded = function(win, fn) {
+ var add, doc, done, init, poll, pre, rem, root, top;
+ done = false;
+ top = true;
+ doc = win.document;
+ root = doc.documentElement;
+ add = (doc.addEventListener ? "addEventListener" : "attachEvent");
+ rem = (doc.addEventListener ? "removeEventListener" : "detachEvent");
+ pre = (doc.addEventListener ? "" : "on");
+ init = function(e) {
+ if (e.type === "readystatechange" && doc.readyState !== "complete") {
+ return;
+ }
+ (e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
+ if (!done && (done = true)) {
+ return fn.call(win, e.type || e);
+ }
+ };
+ poll = function() {
+ var e;
+ try {
+ root.doScroll("left");
+ } catch (_error) {
+ e = _error;
+ setTimeout(poll, 50);
+ return;
+ }
+ return init("poll");
+ };
+ if (doc.readyState !== "complete") {
+ if (doc.createEventObject && root.doScroll) {
+ try {
+ top = !win.frameElement;
+ } catch (_error) {}
+ if (top) {
+ poll();
+ }
+ }
+ doc[add](pre + "DOMContentLoaded", init, false);
+ doc[add](pre + "readystatechange", init, false);
+ return win[add](pre + "load", init, false);
+ }
+ };
+
+ Dropzone._autoDiscoverFunction = function() {
+ if (Dropzone.autoDiscover) {
+ return Dropzone.discover();
+ }
+ };
+
+ contentLoaded(window, Dropzone._autoDiscoverFunction);
+
+}).call(this);
+
diff --git a/static/js/upload.js b/static/js/upload.js
new file mode 100644
index 0000000..d86f456
--- /dev/null
+++ b/static/js/upload.js
@@ -0,0 +1,74 @@
+Dropzone.options.dropzone = {
+ addedfile: function(file) {
+ var upload = document.createElement("div");
+ upload.className = "upload";
+
+ var left = document.createElement("span");
+ left.innerHTML = file.name;
+ file.leftElement = left;
+ upload.appendChild(left);
+
+ var right = document.createElement("div");
+ right.className = "right";
+ var rightleft = document.createElement("span");
+ rightleft.className = "cancel";
+ rightleft.innerHTML = "Cancel";
+ rightleft.onclick = function(ev) {
+ this.removeFile(file);
+ }.bind(this);
+
+ var rightright = document.createElement("span");
+ right.appendChild(rightleft);
+ file.rightLeftElement = rightleft;
+ right.appendChild(rightright);
+ file.rightRightElement = rightright;
+ file.rightElement = right;
+ upload.appendChild(right);
+ file.uploadElement = upload;
+ document.getElementById("uploads").appendChild(upload);
+ },
+ uploadprogress: function(file, p, bytesSent) {
+ p = parseInt(p);
+ file.rightRightElement.innerHTML = p + "%";
+ file.uploadElement.setAttribute("style", 'background-image: -webkit-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: -moz-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: -ms-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: -o-linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%); background-image: linear-gradient(left, #F2F4F7 ' + p + '%, #E2E2E2 ' + p + '%)');
+ },
+ success: function(file, resp) {
+ file.rightLeftElement.innerHTML = "";
+ file.leftElement.innerHTML = '' + resp.url + '';
+ file.rightRightElement.innerHTML = "Delete";
+ file.rightRightElement.className = "cancel";
+ file.rightRightElement.style.color = "#E68181";
+ file.rightRightElement.onclick = function(ev) {
+ xhr = new XMLHttpRequest();
+ xhr.open("DELETE", resp.url, true);
+ xhr.setRequestHeader("X-Delete-Key", resp.delete_key);
+ xhr.onreadystatechange = function(file) {
+ if (xhr.status === 404) {
+ file.leftElement.innerHTML = 'Deleted ' + resp.url + '';
+ file.leftElement.style.color = "#E68181";
+ file.rightRightElement.onclick = null;
+ file.rightRightElement.innerHTML = "";
+ }
+ }.bind(this, file);
+ xhr.send();
+ }.bind(this);
+ },
+ error: function(file, errMsg, xhrO) {
+ file.rightLeftElement.onclick = null;
+ file.rightLeftElement.innerHTML = "";
+ file.rightRightElement.innerHTML = "";
+ if (file.status === "canceled") {
+ file.leftElement.innerHTML = "Canceled " + file.name;
+ }
+ else {
+ file.leftElement.innerHTML = "Could not upload " + file.name;
+ }
+ file.leftElement.style.color = "#E68181";
+ },
+ maxFilesize: 4096,
+ previewsContainer: "#uploads",
+ parallelUploads: 5,
+ headers: {"Accept": "application/json"},
+ dictDefaultMessage: "Click or Drop file(s)",
+ dictFallbackMessage: ""
+};
diff --git a/templates/index.html b/templates/index.html
index ea52d16..7a1c434 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,58 +1,45 @@
{% extends "base.html" %}
+{% block head %}
+
+{% endblock %}
+
{% block content %}
-
-
-
+
+
{% endblock %}
\ No newline at end of file
diff --git a/upload.go b/upload.go
index e053ecb..1091f69 100644
--- a/upload.go
+++ b/upload.go
@@ -40,17 +40,7 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
contentType := r.Header.Get("Content-Type")
- if contentType == "application/octet-stream" {
- if r.URL.Query().Get("randomize") == "true" {
- upReq.randomBarename = true
- }
- upReq.expiry = parseExpiry(r.URL.Query().Get("expires"))
-
- defer r.Body.Close()
- upReq.src = r.Body
- upReq.filename = r.URL.Query().Get("qqfile")
-
- } else if strings.HasPrefix(contentType, "multipart/form-data") {
+ if strings.HasPrefix(contentType, "multipart/form-data") {
file, headers, err := r.FormFile("file")
if err != nil {
oopsHandler(c, w, r)
@@ -66,6 +56,7 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
upReq.src = file
upReq.filename = headers.Filename
} else {
+ fmt.Println(r.Header.Get("Content-Type"))
if r.FormValue("content") == "" {
oopsHandler(c, w, r)
return