Skip to content

Commit 344bd2d

Browse files
committed
Handle dragging files setting drag cursor
On drag over CM instance, call setDragCursor with event and 'editor' string Set ondragover function call upon this function too with folder/file string, same as when init'ing via get branch setDragCursor function added, handles cursor for dropping files editior, folder and file including if we have the CTRL key down or not
1 parent 875d8a7 commit 344bd2d

2 files changed

Lines changed: 60 additions & 30 deletions

File tree

lib/ice-coder.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ var ICEcoder = {
478478
top.ICEcoder.mouseDownInCM = "editor";
479479
},
480480

481+
// On drag over
482+
cMonDragOver: function(thisCM,evt,cMinstance) {
483+
top.ICEcoder.setDragCursor(evt,'editor');
484+
},
485+
481486
// On render line
482487
cMonRenderLine: function(thisCM,cMinstance,line,element) {
483488
var paneMatch;
@@ -1787,6 +1792,7 @@ var ICEcoder = {
17871792
newLI.draggable = false;
17881793
newLI.ondragstart = function(event) {top.ICEcoder.addDefaultDragData(this,event)};
17891794
newLI.ondrag = function(event) {top.ICEcoder.draggingWithKeyTest(event);if(top.ICEcoder.getcMInstance()){top.ICEcoder.editorFocusInstance.indexOf('diff') == -1 ? top.ICEcoder.getcMInstance().focus() : top.ICEcoder.getcMdiffInstance().focus()}};
1795+
newLI.ondragover = function(event) {top.ICEcoder.setDragCursor(event,actionElemType=="folder" ? 'folder' : 'file')};
17901796
newLI.ondragend = function() {top.ICEcoder.dropFile(this)};
17911797
newLI.innerHTML = innerLI
17921798
locNest.nextSibling.appendChild(newLI);
@@ -1809,6 +1815,7 @@ var ICEcoder = {
18091815
newLI.draggable = false;
18101816
newLI.ondragstart = function(event) {top.ICEcoder.addDefaultDragData(this,event)};
18111817
newLI.ondrag = function(event) {top.ICEcoder.draggingWithKeyTest(event);if(top.ICEcoder.getcMInstance()){top.ICEcoder.editorFocusInstance.indexOf('diff') == -1 ? top.ICEcoder.getcMInstance().focus() : top.ICEcoder.getcMdiffInstance().focus()}};
1818+
newLI.ondragover = function(event) {top.ICEcoder.setDragCursor(event,actionElemType=="folder" ? 'folder' : 'file')};
18121819
newLI.ondragend = function() {top.ICEcoder.dropFile(this)};
18131820
newLI.innerHTML = innerLI;
18141821
// Append or insert depending on which of the above if statements is true
@@ -1933,6 +1940,28 @@ var ICEcoder = {
19331940
evt.dataTransfer.setData('Text', elem.id);
19341941
},
19351942

1943+
// Set a copy, move or none drag cursor type
1944+
setDragCursor: function(evt,dropType) {
1945+
var cursorIcon;
1946+
1947+
// Prevent the default and establish if CTRL key is down
1948+
evt.preventDefault();
1949+
top.ICEcoder.draggingWithKeyTest(evt);
1950+
// Establish the cursor to show
1951+
cursorIcon =
1952+
dropType == "editor"
1953+
? top.ICEcoder.draggingWithKey == "CTRL"
1954+
? "copy"
1955+
: "link"
1956+
: dropType == "folder"
1957+
? top.ICEcoder.draggingWithKey == "CTRL"
1958+
? "copy"
1959+
: "move"
1960+
: "none";
1961+
1962+
evt.dataTransfer.dropEffect = cursorIcon;
1963+
},
1964+
19361965
// On dropping a file, do something
19371966
dropFile: function(elem) {
19381967
var filePath, tgtPath;

0 commit comments

Comments
 (0)