Browse Source

[IMP] Make web_drop_target IE11 compliant

pull/971/head
Akim Juillerat 6 years ago
committed by Pablo Fuentes
parent
commit
ca33fef877
  1. 14
      web_drop_target/static/src/js/web_drop_target.js

14
web_drop_target/static/src/js/web_drop_target.js

@ -29,20 +29,18 @@ odoo.define('web_drop_target', function(require) {
_on_drop: function(e) { _on_drop: function(e) {
var drop_items = this._get_drop_items(e); var drop_items = this._get_drop_items(e);
e.preventDefault();
this._remove_overlay();
if(!drop_items) { if(!drop_items) {
return; return;
} }
this._remove_overlay();
e.preventDefault();
this._handle_drop_items(drop_items, e) this._handle_drop_items(drop_items, e)
}, },
_on_dragenter: function(e) { _on_dragenter: function(e) {
if(this._get_drop_items(e)) {
e.preventDefault(); e.preventDefault();
this._add_overlay(); this._add_overlay();
return false; return false;
}
}, },
_on_dragleave: function(e) { _on_dragleave: function(e) {
@ -54,7 +52,7 @@ odoo.define('web_drop_target', function(require) {
var self = this, var self = this,
dataTransfer = e.originalEvent.dataTransfer, dataTransfer = e.originalEvent.dataTransfer,
drop_items = []; drop_items = [];
_.each(dataTransfer.items, function(item) {
_.each(dataTransfer.files, function(item) {
if( if(
_.contains(self._drop_allowed_types, item.type) || _.contains(self._drop_allowed_types, item.type) ||
_.isEmpty(self._drop_allowed_types) _.isEmpty(self._drop_allowed_types)
@ -108,7 +106,7 @@ odoo.define('web_drop_target', function(require) {
item, e, res_model, res_id, extra_data item, e, res_model, res_id, extra_data
) { ) {
var self = this; var self = this;
var file = item.getAsFile();
var file = item;
var reader = new FileReader(); var reader = new FileReader();
reader.onloadend = self.proxy( reader.onloadend = self.proxy(
_.partial(self._create_attachment, file, reader, e, res_model, res_id, extra_data) _.partial(self._create_attachment, file, reader, e, res_model, res_id, extra_data)
@ -135,9 +133,11 @@ odoo.define('web_drop_target', function(require) {
}, },
_remove_overlay: function() { _remove_overlay: function() {
if (this._drop_overlay) {
this._drop_overlay.remove(); this._drop_overlay.remove();
this._drop_overlay = null; this._drop_overlay = null;
},
}
}
}; };
// and here we apply the mixin to form views, allowing any files and // and here we apply the mixin to form views, allowing any files and

Loading…
Cancel
Save