Commit 0339c80e authored by Jérome Perrin's avatar Jérome Perrin

fixup! jsplumb: Internet Explorer only supports "text" as format for evt.dataTransfer.setData

parent 1e1d86f0
...@@ -785,15 +785,21 @@ ...@@ -785,15 +785,21 @@
function resolver(resolve, reject) { function resolver(resolve, reject) {
callback = function (evt) { callback = function (evt) {
try { try {
var class_name = JSON.parse( var class_name,
evt.dataTransfer.getData('text') offset = $(gadget.props.main).offset(),
), relative_position = convertToRelativePosition(
offset = $(gadget.props.main).offset(), gadget,
relative_position = convertToRelativePosition( evt.clientX - offset.left + "px",
gadget, evt.clientY - offset.top + "px"
evt.clientX - offset.left + "px", );
evt.clientY - offset.top + "px" try {
); // html5 compliant browser
class_name = JSON.parse(evt.dataTransfer.getData('application/json'));
} catch (e) {
// internet explorer
class_name = JSON.parse(evt.dataTransfer.getData('text'));
}
addNode(gadget, addNode(gadget,
generateNodeId(gadget, {_class: class_name}), generateNodeId(gadget, {_class: class_name}),
{ {
......
...@@ -184,8 +184,8 @@ ...@@ -184,8 +184,8 @@
e.dataTransfer = { e.dataTransfer = {
getData: function(type){ getData: function(type){
// make sure we are called properly // make sure we are called properly
equal('text', type, equal('application/json', type,
"The drag&dropped element must have data type text"); "The drag&dropped element must have data type application/json");
return JSON.stringify("Example.Node"); return JSON.stringify("Example.Node");
} }
}; };
...@@ -545,8 +545,8 @@ ...@@ -545,8 +545,8 @@
e.dataTransfer = { e.dataTransfer = {
getData: function(type){ getData: function(type){
// make sure we are called properly // make sure we are called properly
equal('text', type, equal('application/json', type,
"The drag&dropped element must have data type text"); "The drag&dropped element must have data type application/json");
return JSON.stringify("Example.Node"); return JSON.stringify("Example.Node");
} }
}; };
...@@ -647,8 +647,8 @@ ...@@ -647,8 +647,8 @@
e.dataTransfer = { e.dataTransfer = {
getData: function(type){ getData: function(type){
// make sure we are called properly // make sure we are called properly
equal('text', type, equal('application/json', type,
"The drag&dropped element must have data type text"); "The drag&dropped element must have data type application/json");
return JSON.stringify("Example.Node"); return JSON.stringify("Example.Node");
} }
}; };
......
...@@ -17,8 +17,16 @@ ...@@ -17,8 +17,16 @@
callback = function (evt) { callback = function (evt) {
try { try {
evt.dataTransfer.setData('text', // Internet explorer only accepts text and URI as types for dataTranser
tool.dataset.class_name); // but firefox will replace location.href with the data if type is set to
// text or URI. We try to use application/json as type, and if it fails
// fallback to text.
try {
// IE will raise an error setting this.
evt.dataTransfer.setData('application/json', tool.dataset.class_name);
} catch (e) {
evt.dataTransfer.setData('text', tool.dataset.class_name);
}
} catch (e) { } catch (e) {
reject(e); reject(e);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment