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 @@
function resolver(resolve, reject) {
callback = function (evt) {
try {
var class_name = JSON.parse(
evt.dataTransfer.getData('text')
),
offset = $(gadget.props.main).offset(),
relative_position = convertToRelativePosition(
gadget,
evt.clientX - offset.left + "px",
evt.clientY - offset.top + "px"
);
var class_name,
offset = $(gadget.props.main).offset(),
relative_position = convertToRelativePosition(
gadget,
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,
generateNodeId(gadget, {_class: class_name}),
{
......
......@@ -184,8 +184,8 @@
e.dataTransfer = {
getData: function(type){
// make sure we are called properly
equal('text', type,
"The drag&dropped element must have data type text");
equal('application/json', type,
"The drag&dropped element must have data type application/json");
return JSON.stringify("Example.Node");
}
};
......@@ -545,8 +545,8 @@
e.dataTransfer = {
getData: function(type){
// make sure we are called properly
equal('text', type,
"The drag&dropped element must have data type text");
equal('application/json', type,
"The drag&dropped element must have data type application/json");
return JSON.stringify("Example.Node");
}
};
......@@ -647,8 +647,8 @@
e.dataTransfer = {
getData: function(type){
// make sure we are called properly
equal('text', type,
"The drag&dropped element must have data type text");
equal('application/json', type,
"The drag&dropped element must have data type application/json");
return JSON.stringify("Example.Node");
}
};
......
......@@ -17,8 +17,16 @@
callback = function (evt) {
try {
evt.dataTransfer.setData('text',
tool.dataset.class_name);
// Internet explorer only accepts text and URI as types for dataTranser
// 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) {
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