diff --git a/lib/coder.js b/lib/coder.js index 3436ff7..849e87d 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -21,6 +21,9 @@ var ICEcoder = { selectedFiles: [], // Array of selected files findMode: false, // States if we're in find/replace mode lockedNav: true, // Nav is locked or not + codeAssist: true, // Assist user with their coding + mouseDown: false, // If the mouse is down or not + draggingFilesW: false, // If we're dragging the file manager width or not // Don't consider these tags as part of nesting as they're singles, JS or PHP code blocks tagNestExceptions: ["!DOCTYPE","meta","link","img","br","hr","input","script","?"], @@ -44,9 +47,7 @@ var ICEcoder = { // Set out our layout according to the browser size setLayout: function(dontSetEditor) { - var winW, winH, headerH, footerH, accountH, uploadH, tabsBarH, findBarH, cMCSS; - - //ICEcoder.content = top.document.getElementById('content'); + var winW, winH, headerH, footerH, accountH, tabsBarH, findBarH, cMCSS; // Determin width & height available if (window.innerWidth) { @@ -58,11 +59,11 @@ var ICEcoder = { } // Apply sizes to various elements of the page - headerH = 40, footerH = 30, accountH = 50, uploadH = 40, tabsBarH = 21, findBarH = 28; + headerH = 40, footerH = 30, accountH = 50, tabsBarH = 21, findBarH = 28; header.style.width = tabsBar.style.width = findBar.style.width = winW + "px"; files.style.width = editor.style.left = this.filesW + "px"; account.style.height = accountH + "px"; - filesFrame.style.height = (winH-headerH-accountH-footerH-uploadH) + "px"; + filesFrame.style.height = (winH-headerH-accountH-footerH) + "px"; if (!dontSetEditor) { editor.style.width = ICEcoder.content.style.width = (winW-this.filesW) + "px"; @@ -86,7 +87,7 @@ var ICEcoder = { var cM, content; cM = ICEcoder.getcMInstance(); content = cM.getValue(); - content = content.replace(/ & /g,' & '); + if (top.ICEcoder.codeAssist) {content = content.replace(/ & /g,' & ');}; content = content.replace(//g,''); // Then set the content in the editor & clear the history @@ -280,6 +281,29 @@ var ICEcoder = { ICEcoder.setLayout(); }, + // Can click-drag file manager width? + canResizeFilesW: function() { + // If we have the cursor set we must be able! + if (top.document.body.style.cursor == "w-resize") { + // If our mouse is down and we're within a 250-400px range + if (top.ICEcoder.mouseDown) { + if (top.ICEcoder.mouseX >=250 && top.ICEcoder.mouseX <= 400) { + top.ICEcoder.filesW = top.ICEcoder.maxFilesW = top.ICEcoder.mouseX; + } else if (top.ICEcoder.mouseX <250) { + top.ICEcoder.filesW = top.ICEcoder.maxFilesW = 250; + } else { + top.ICEcoder.filesW = top.ICEcoder.maxFilesW = 400; + } + // Set various widths based on the new width + top.ICEcoder.files.style.width = top.ICEcoder.account.style.width = top.ICEcoder.filesFrame.style.width = top.ICEcoder.filesW + "px"; + top.ICEcoder.setLayout(); + top.ICEcoder.draggingFilesW = true; + } + } else { + top.ICEcoder.draggingFilesW = false; + } + }, + // Change tabs by reloading content switchTab: function(newTab) { var cM; @@ -730,7 +754,7 @@ var ICEcoder = { if ("undefined" != typeof top.ICEcoder.thisFileFolderLink && top.ICEcoder.thisFileFolderLink!="") { document.getElementById('fileMenu').style.display = "inline-block"; document.getElementById('fileMenu').style.left = (top.ICEcoder.mouseX+20) + "px"; - document.getElementById('fileMenu').style.top = (top.ICEcoder.mouseY+80) + "px"; + document.getElementById('fileMenu').style.top = (top.ICEcoder.mouseY-top.document.getElementById('filesFrame').contentWindow.document.body.scrollTop+80) + "px"; } return false; }, @@ -953,9 +977,21 @@ var ICEcoder = { top.ICEcoder.mouseX = e.pageX; top.ICEcoder.mouseY = e.pageY; } + top.ICEcoder.dragCursorTest(); + }, - scrollTop = top.document.getElementById('filesFrame').contentWindow.document.body.scrollTop; - top.ICEcoder.mouseY -= scrollTop; + dragCursorTest: function() { + var winH; + + window.innerWidth ? var winH = window.innerHeight : var winH = document.body.clientHeight; + + if (!top.ICEcoder.mouseDown) {top.ICEcoder.draggingFilesW = false}; + + if ((top.ICEcoder.mouseX > top.ICEcoder.filesW-7 && top.ICEcoder.mouseX < top.ICEcoder.filesW+7 && top.ICEcoder.mouseY > 40+50 && top.ICEcoder.mouseY < winH-30-40) || top.ICEcoder.draggingFilesW) { + top.document.body.style.cursor = "w-resize"; + } else { + top.document.body.style.cursor = "auto"; + } }, // Update the file manager tree list on demand @@ -1047,5 +1083,9 @@ var ICEcoder = { targetElem = document.getElementById('filesFrame').contentWindow.document.getElementById(location.replace(/\//g,"|")+file); targetElem.parentNode.parentNode.style.display = "none"; } + }, + + codeAssistToggle: function() { + top.ICEcoder.codeAssist ? top.ICEcoder.codeAssist = false : top.ICEcoder.codeAssist = true; } }; \ No newline at end of file