diff options
| author | Eliot Whalan <contact@pantsu.cat> | 2015-09-22 01:35:19 +0200 |
|---|---|---|
| committer | Eliot Whalan <contact@pantsu.cat> | 2015-09-22 01:35:19 +0200 |
| commit | 6c82d36307a6955353c287fb7d3d66327bed1364 (patch) | |
| tree | 7b1413deadf5b196fd2b6e780a9229213fda302c /js/cabinet.js | |
| parent | cbe422bec354138cbaab4825cd3b821b0aa71eb4 (diff) | |
| parent | 50fdeded0b2ae6cf38d0719bfe3da30a73235020 (diff) | |
Merge branch 'jshint' into development
Diffstat (limited to 'js/cabinet.js')
| -rw-r--r-- | js/cabinet.js | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/js/cabinet.js b/js/cabinet.js index ebbae4f..cb8039b 100644 --- a/js/cabinet.js +++ b/js/cabinet.js @@ -1,36 +1,43 @@ -;(function($){ - $.hasFileAPI = function hasFileAPI () { - return (window.FormData !== undefined) - } - $.fn.cabinet = function (input) { - input = $(input) +/* jshint browser:true, jquery:true */ +(function($) { + $.hasFileAPI = function hasFileAPI() { + return (window.FormData !== undefined); + }; - var _this = this - var passthrough = function (outer, inner, prevent, fn) { - _this.on(outer, function (e) { - if (inner === 'click') - input[0].click() - else - input.trigger(inner) - if (prevent) e.preventDefault() - if (fn) fn(e) - }, false) - } + $.fn.cabinet = function(input) { + input = $(input); - input[0].filelist = Object.create(FileList) + var _this = this; + var passthrough = function(outer, inner, prevent, fn) { + _this.on(outer, function(e) { + if (inner === 'click') { + input[0].click(); + } else { + input.trigger(inner); + } + if (prevent) { + e.preventDefault(); + } + if (fn) { + fn(e); + } + }, false); + }; - input.on('change', function (e) { - this.filelist = e.target.files - _this.change() - }) + input[0].filelist = Object.create(FileList); - passthrough('dragenter', 'dragenter', true) - passthrough('dragover', 'dragover', true) - passthrough('dragleave', 'dragleave', true) - passthrough('click', 'click', false) - passthrough('drop', 'dragleave', true, function (e) { - input[0].filelist = e.dataTransfer.files - _this.change() - }) - } -})($) + input.on('change', function(e) { + this.filelist = e.target.files; + _this.change(); + }); + + passthrough('dragenter', 'dragenter', true); + passthrough('dragover', 'dragover', true); + passthrough('dragleave', 'dragleave', true); + passthrough('click', 'click', false); + passthrough('drop', 'dragleave', true, function(e) { + input[0].filelist = e.dataTransfer.files; + _this.change(); + }); + }; +})($); |
