summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/cabinet.js2
-rw-r--r--js/cheesesteak.js12
-rw-r--r--js/pomf.js5
3 files changed, 19 insertions, 0 deletions
diff --git a/js/cabinet.js b/js/cabinet.js
index f6f5f20..2f3a3a6 100644
--- a/js/cabinet.js
+++ b/js/cabinet.js
@@ -37,9 +37,11 @@
} else {
input.trigger(inner);
}
+
if (prevent) {
e.preventDefault();
}
+
if (fn) {
fn(e);
}
diff --git a/js/cheesesteak.js b/js/cheesesteak.js
index 112b2c7..75f837e 100644
--- a/js/cheesesteak.js
+++ b/js/cheesesteak.js
@@ -24,17 +24,21 @@
(function() {
/* Lightweight EventEmitter implementation */
EventEmitter = function() {};
+
EventEmitter.prototype.on = function(evt, fn) {
this._events = this._events || {};
this._events[evt] = this._events[evt] || [];
this._events[evt].push(fn);
};
+
EventEmitter.prototype.off = function(evt, fn) {
if (!this.hasOwnProperty('_events') || evt in this._events === false) {
return;
}
+
this._events[evt].splice(this._events[evt].indexOf(fn), 1);
};
+
EventEmitter.prototype.emit = function(evt) {
if (!this.hasOwnProperty('_events') || evt in this._events === false) {
return;
@@ -113,6 +117,7 @@
out[key] = overlay[key];
}
}
+
return out;
};
@@ -128,6 +133,7 @@
'data': {}
}, opts);
};
+
FileListUploader.prototype = Object.create(EventEmitter.prototype);
FileListUploader.prototype.upload = function(cb) {
if (cb) {
@@ -151,6 +157,7 @@
files[i].uploadedSize = 0;
}
});
+
xhr.upload.addEventListener('progress', function(e) {
if (e.lengthComputable) {
size = e.loaded;
@@ -168,17 +175,22 @@
}
}
}
+
events.emit('uploadprogress', e, files);
}, false);
+
xhr.upload.addEventListener('loadstart', function(e) {
events.emit('uploadstart', e);
});
+
xhr.upload.addEventListener('load', function(e) {
events.emit('uploadcomplete', e);
});
+
xhr.addEventListener('progress', function(e) {
events.emit('progress', e);
});
+
xhr.addEventListener('load', function(e) {
events.emit('load', e, xhr.responseText);
});
diff --git a/js/pomf.js b/js/pomf.js
index 2e810de..5690e60 100644
--- a/js/pomf.js
+++ b/js/pomf.js
@@ -131,6 +131,7 @@ $(function() {
eachRow(files, function(row, file, files) {
$('.progress-inner', row).width((file.percentUploaded * 100) + '%');
});
+
$('.progress-inner', totalRow).width((files.percentUploaded * 100) + '%');
});
@@ -148,6 +149,7 @@ $(function() {
totalName.text(UPLOAD_ERR_FAILED);
break;
}
+
eachRow(res.files, function(row, file, files) {
var link = $('<a>');
@@ -157,6 +159,7 @@ $(function() {
$('.file-url', row).append(link);
});
+
uploadFiles.addClass('completed');
totalName.text('Done!');
break;
@@ -168,7 +171,9 @@ $(function() {
uploadFiles.addClass('error completed');
totalName.text(UPLOAD_ERR_FAILED);
}
+
});
+
up.upload();
});
});