From ffed16ef154a2e1690616bf4f7aced32c23dac1a Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Sun, 8 Dec 2013 16:11:59 +0000 Subject: [PATCH] Only setOption if we have a CM instance Only focus on editor if we have a CM instance On dragging files/folders, get the path if a file, otherwise go with the folder path. If we have CTRL key down, copy the selectedFiles and paste to the tgtPath just established Display temp message about move function coming soon --- lib/ice-coder.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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; },