summaryrefslogtreecommitdiff
path: root/js/cabinet.js
diff options
context:
space:
mode:
authorJuuso Lapinlampi <wub@partyvan.eu>2016-01-06 11:51:06 +0100
committerJuuso Lapinlampi <wub@partyvan.eu>2016-01-06 11:51:06 +0100
commitd601676c6c34a2ef6cbb3f00bdd8c0ae7eef6c08 (patch)
tree2d44dcdc1ab82ded1f08d71f18dfda6a32813f30 /js/cabinet.js
parentb8674df0d40f2534411c1000ab1f6696f9efb402 (diff)
parentc257a1c1d63197f5349c12962558eccc7837a0f5 (diff)
Merge branch 'fix-eslint-warnings-2' of wubthecaptain/pomf
Lint our spaghetti JavaScript code to be at least slightly more readable. Configuration used is ESLint 1.7.x and airbnb/legacy. It's been so long I cannot remember every change that was done, but long story short: all the ESLint errors are now gone, at least at the date of last commit. moep contributed some ideas for patches: some were implemented, some were discarded as the time and patience for merging this ran out. Thus, there are still ESLint warnings about anonymous functions. I don't feel like spending much more time on this. The future Pomf 2.1 development branch will replace the JavaScript code in its entirety, courtesy of luminarys@. Suggested-by: moep Tested-by: Eliot Whalan <ewhal@pantsu.cat> OK ewhal@, maybe a vague OK from luminarys@ a long time ago
Diffstat (limited to 'js/cabinet.js')
-rw-r--r--js/cabinet.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/js/cabinet.js b/js/cabinet.js
index f1ff071..ba28a33 100644
--- a/js/cabinet.js
+++ b/js/cabinet.js
@@ -20,37 +20,37 @@
* SOFTWARE.
*/
-(function($) {
- $.hasFileAPI = function hasFileAPI() {
- return (window.FormData !== undefined);
+(function(cabinet) {
+ cabinet.hasFileAPI = function hasFileAPI() {
+ return Boolean(window.FormData);
};
- $.fn.cabinet = function(input) {
- input = $(input);
+ $.fn.cabinet = function(uploadInput) {
+ var $input = $(uploadInput);
var _this = this;
var passthrough = function(outer, inner, prevent, fn) {
- _this.on(outer, function(e) {
+ _this.on(outer, function(evt) {
if (inner === 'click') {
- input[0].click();
+ $input[0].click();
} else {
- input.trigger(inner);
+ $input.trigger(inner);
}
if (prevent) {
- e.preventDefault();
+ evt.preventDefault();
}
if (fn) {
- fn(e);
+ fn(evt);
}
}, false);
};
- input[0].filelist = Object.create(FileList);
+ $input[0].filelist = Object.create(FileList);
- input.on('change', function(e) {
- this.filelist = e.target.files;
+ $input.on('change', function(evt) {
+ this.filelist = evt.target.files;
_this.change();
});
@@ -58,8 +58,8 @@
passthrough('dragover', 'dragover', true);
passthrough('dragleave', 'dragleave', true);
passthrough('click', 'click', false);
- passthrough('drop', 'dragleave', true, function(e) {
- input[0].filelist = e.dataTransfer.files;
+ passthrough('drop', 'dragleave', true, function(evt) {
+ $input[0].filelist = evt.dataTransfer.files;
_this.change();
});
};