diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 111cb0c..9df4a10 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -28,6 +28,7 @@ var ICEcoder = { mouseDown: false, // If the mouse is down draggingFilesW: false, // If we're dragging the file manager width draggingTab: false, // If we're dragging a tab + draggingWithKey: false, // The key that's down while dragging, false if no key tabLeftPos: [], // Array of left positions of tabs inside content area tabBGcurrent: '#141414', // BG of current tab tabBGselected: '#49d', // BG of selected tab @@ -527,6 +528,17 @@ var ICEcoder = { } }, + // Paste a URL, locally or absolutely if CTRL/Cmd key down + pasteURL: function(url) { + var cM; + + cM = ICEcoder.getcMInstance(); + if(top.ICEcoder.draggingWithKey == "CTRL") { + url = window.location.protocol + "//" + window.location.hostname + url; + } + cM.replaceSelection(url); + }, + // ============== // FILES // ============== @@ -1056,6 +1068,31 @@ var ICEcoder = { } }, + // Detect CTRL/Cmd key whilst dragging files + draggingWithKeyTest: function(evt) { + var key; + + key = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode; + + // Mac command key handling (224 = Moz, 91/93 = Webkit Left/Right Apple) + if (key==224 || key==91 || key==93) { + top.ICEcoder.cmdKey = true; + } + + top.ICEcoder.draggingWithKey = evt.ctrlKey||top.ICEcoder.cmdKey ? "CTRL" : false; + }, + + // On dropping a file, do something + dropFile: function(elem) { + 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!'); + }; + top.ICEcoder.mouseDown=false; + }, + // ============== // FIND & REPLACE // ============== @@ -1370,7 +1407,8 @@ var ICEcoder = { top.ICEcoder.mouseX = e.pageX ? e.pageX : e.clientX + document.body.scrollLeft; top.ICEcoder.mouseY = e.pageY ? e.pageY : e.clientY + document.body.scrollTop; - + + top.ICEcoder.area = area; if (area!="top") { top.ICEcoder.mouseY += 25 + 45; }