From 781e2fe821ac5d79feadb2b17d64b1c865213c89 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 28 Aug 2014 23:23:50 -0500
Subject: [PATCH] forms: Honor maxfiles setting

---
 js/filedrop.field.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/js/filedrop.field.js b/js/filedrop.field.js
index d63316235..eeb1e8aa4 100644
--- a/js/filedrop.field.js
+++ b/js/filedrop.field.js
@@ -35,6 +35,12 @@
         this.$element.css('background-color', 'rgba(0, 0, 0, 0.3)');
     },
     beforeEach: function (file) {
+      if (this.options.maxfiles && this.uploads.length >= this.options.maxfiles) {
+          // This file is not allowed to be added to the list. It's over the
+          // limit
+          this.handleError('TooManyFiles', file);
+          return false;
+      }
       var node = this.addNode(file).data('file', file);
       node.find('.progress').show();
       node.find('.progress-bar').width('100%').addClass('progress-bar-striped active');
@@ -201,7 +207,8 @@
   $.fn.filedropbox.defaults = {
     files: [],
     deletable: true,
-    shim: !window.FileReader
+    shim: !window.FileReader,
+    queuefiles: 2
   };
 
   $.fn.filedropbox.messages = {
-- 
GitLab