diff --git a/etemplate/js/et2_widget_file.js b/etemplate/js/et2_widget_file.js index 3638facba3..ca6cd26aa5 100644 --- a/etemplate/js/et2_widget_file.js +++ b/etemplate/js/et2_widget_file.js @@ -113,7 +113,7 @@ var et2_file = et2_inputWidget.extend( return self.onStart(event, file_count); }, onFinish: function(event, file_count) { - self.onFinish(event, file_count); + self.onFinish.apply(self, [event, file_count]); // Fire legacy change action when done self.change(self.input); @@ -209,18 +209,38 @@ var et2_file = et2_inputWidget.extend( }; $j(drop_target) .on("drop", jQuery.proxy(function(event) { + event.stopPropagation(); + event.preventDefault(); + this.input.removeClass("ui-state-active"); if(event.dataTransfer && event.dataTransfer.files.length > 0) { this.input[0].files = event.dataTransfer.files; - this.input.trigger("start.html5_upload"); } + return false; }, this)) .on("dragenter",function(e) { - return !self.disabled; - //self.checkMime(this.files[index])) + // Accept the drop if at least one mimetype matches + // Individual files will be rejected later + var mime_ok = false; + for(var file in e.dataTransfer.files) + { + mime_ok = mime_ok || self.checkMime(file); + } + if(!self.disabled && mime_ok) + { + self.input.addClass("ui-state-active"); + } + // Returning true cancels, return false to allow + return self.disabled || !mime_ok; + }) + .on("dragleave", function(e) { + self.input.removeClass("ui-state-active"); + // Returning true cancels, return false to allow + return self.disabled }) .on("dragover", function(e) { - return !self.disabled; + // Returning true cancels, return false to allow + return self.disabled; }) .on("dragend", false); } @@ -381,7 +401,7 @@ var et2_file = et2_inputWidget.extend( $j("div.remove",status).click(this, this.cancel); if(error != "") { - status.addClass("message validation_error"); + status.addClass("message ui-state-error"); status.append("