diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 9de46ee..edad266 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -275,9 +275,9 @@ var ICEcoder = { cM = ICEcoder.getcMInstance(); fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1]; - if (mode) { + if (cM && mode) { cM.setOption("mode",mode); - } else if (fileName) { + } else if (cM && fileName) { fileName.indexOf('.js')>0 ? cM.setOption("mode","javascript") : fileName.indexOf('.coffee')>0 ? cM.setOption("mode","coffeescript") : fileName.indexOf('.rb')>0 ? cM.setOption("mode","ruby") @@ -964,7 +964,7 @@ var ICEcoder = { newLI = document.createElement("li"); newLI.className = cssStyle; newLI.draggable = true; - newLI.ondrag = function(event) {top.ICEcoder.draggingWithKeyTest(event);top.ICEcoder.getcMInstance().focus()}; + newLI.ondrag = function(event) {top.ICEcoder.draggingWithKeyTest(event);if(top.ICEcoder.getcMInstance()){top.ICEcoder.getcMInstance().focus()}}; newLI.ondragend = function() {top.ICEcoder.dropFile(this)}; newLI.innerHTML = innerLI locNest.nextSibling.appendChild(newLI); @@ -985,7 +985,7 @@ var ICEcoder = { newLI = document.createElement("li"); newLI.className = cssStyle; newLI.draggable = true; - newLI.ondrag = function(event) {top.ICEcoder.draggingWithKeyTest(event);top.ICEcoder.getcMInstance().focus()}; + newLI.ondrag = function(event) {top.ICEcoder.draggingWithKeyTest(event);if(top.ICEcoder.getcMInstance()){top.ICEcoder.getcMInstance().focus()}}; newLI.ondragend = function() {top.ICEcoder.dropFile(this)}; newLI.innerHTML = innerLI; // Append or insert depending on which of the above if statements is true @@ -1090,11 +1090,21 @@ var ICEcoder = { // On dropping a file, do something dropFile: function(elem) { + var tgtPath; + if (top.ICEcoder.area=='editor') { top.ICEcoder.pasteURL(elem.childNodes[0].childNodes[1].id.replace(/\|/g,"/")); }; if (top.ICEcoder.area=='files') { - alert('Will drag files/folders soon!'); + setTimeout(function() { + tgtPath = ICEcoder.thisFileFolderType == "folder" ? ICEcoder.thisFileFolderLink : ICEcoder.thisFileFolderLink.substr(0,ICEcoder.thisFileFolderLink.lastIndexOf("|")); + if(top.ICEcoder.draggingWithKey == "CTRL") { + top.ICEcoder.copyFiles(top.ICEcoder.selectedFiles); + top.ICEcoder.pasteFiles(tgtPath); + } else { + top.ICEcoder.message("Move files/folders coming soon!\n\nFor now you can hold CTRL/Cmd to copy to that location"); + } + },4); }; top.ICEcoder.mouseDown=false; },