Add namespace to drop event bindings to easily remove only the ones the widget added.

This commit is contained in:
Nathan Gray 2013-08-27 16:29:13 +00:00
parent 7ee2c05955
commit 3d12c2b591

View File

@ -193,11 +193,13 @@ var et2_file = et2_inputWidget.extend(
{ {
var widget = this.getRoot().getWidgetById(this.options.drop_target); var widget = this.getRoot().getWidgetById(this.options.drop_target);
var drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target); var drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target);
//$j(drop_target).off("."+this.id); $j(drop_target).off("."+this.id);
} }
this.options.drop_target = new_target; this.options.drop_target = new_target;
if(!this.options.drop_target) return;
// Set up new drop target // Set up new drop target
var widget = this.getRoot().getWidgetById(this.options.drop_target); var widget = this.getRoot().getWidgetById(this.options.drop_target);
var drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target); var drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target);
@ -210,7 +212,7 @@ var et2_file = et2_inputWidget.extend(
return false; return false;
}; };
$j(drop_target) $j(drop_target)
.on("drop", jQuery.proxy(function(event) { .on("drop."+this.id, jQuery.proxy(function(event) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
this.input.removeClass("ui-state-active"); this.input.removeClass("ui-state-active");
@ -220,7 +222,7 @@ var et2_file = et2_inputWidget.extend(
} }
return false; return false;
}, this)) }, this))
.on("dragenter",function(e) { .on("dragenter."+this.id,function(e) {
// Accept the drop if at least one mimetype matches // Accept the drop if at least one mimetype matches
// Individual files will be rejected later // Individual files will be rejected later
var mime_ok = false; var mime_ok = false;
@ -235,16 +237,16 @@ var et2_file = et2_inputWidget.extend(
// Returning true cancels, return false to allow // Returning true cancels, return false to allow
return self.disabled || !mime_ok; return self.disabled || !mime_ok;
}) })
.on("dragleave", function(e) { .on("dragleave."+this.id, function(e) {
self.input.removeClass("ui-state-active"); self.input.removeClass("ui-state-active");
// Returning true cancels, return false to allow // Returning true cancels, return false to allow
return self.disabled return self.disabled
}) })
.on("dragover", function(e) { .on("dragover."+this.id, function(e) {
// Returning true cancels, return false to allow // Returning true cancels, return false to allow
return self.disabled; return self.disabled;
}) })
.on("dragend", false); .on("dragend."+this.id, false);
} }
else else
{ {