Skip to content

Commit

Permalink
Fix drag/drop on IE9
Browse files Browse the repository at this point in the history
Closes #857
  • Loading branch information
marijnh committed Oct 15, 2012
1 parent eae22b7 commit 808cee0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/codemirror.js
Expand Up @@ -1258,7 +1258,7 @@ window.CodeMirror = (function() {
});
// Let the drag handler handle this.
if (webkit) display.scroller.draggable = true;
view.draggingText = true;
view.draggingText = dragEnd;
// IE's approach to draggable
if (display.scroller.dragDrop) display.scroller.dragDrop();
on(document, "mouseup", dragEnd);
Expand Down Expand Up @@ -1356,7 +1356,11 @@ window.CodeMirror = (function() {
for (var i = 0; i < n; ++i) loadFile(files[i], i);
} else {
// Don't do a replace if the drop happened inside of the selected text.
if (cm.view.draggingText && !(posLess(pos, cm.view.sel.from) || posLess(cm.view.sel.to, pos))) return;
if (cm.view.draggingText && !(posLess(pos, cm.view.sel.from) || posLess(cm.view.sel.to, pos))) {
cm.view.draggingText(e);
if (ie) setTimeout(bind(focusInput, cm), 50);
return;
}
try {
var text = e.dataTransfer.getData("Text");
if (text) {
Expand All @@ -1366,6 +1370,7 @@ window.CodeMirror = (function() {
if (cm.view.draggingText) replaceRange(cm, "", curFrom, curTo);
cm.replaceSelection(text);
focusInput(cm);
onFocus(cm);
});
}
}
Expand Down

0 comments on commit 808cee0

Please sign in to comment.