From 811cf40cd7c897e15178be9d6ff2669bfe7aab41 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Thu, 31 Jan 2013 17:59:44 +0000 Subject: [PATCH] Close all tabs sets new arg for setPreviousFiles closeAllTabs now passes 2nd arg to closeTab, setting true if we've got more tabs to close, false if not. The dontSetPV arg determins if we should setPreviousFiles or not. This means we only set this once all tabs have been closed. Also fixed issue with setting previousFiles, wasn't setting on 'CLEAR', ie, no tabs open. Now sets a blank to handle this. --- lib/ice-coder.js | 3890 +++++++++++++++++++++++----------------------- lib/settings.php | 577 +++---- 2 files changed, 2237 insertions(+), 2230 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 5dc5c34..619680f 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -1,1945 +1,1947 @@ -var ICEcoder = { - -// ============== -// INIT -// ============== - - // Define settings - filesW: 250, // Initial width of the files pane - minFilesW: 14, // Min width of the files pane - maxFilesW: 250, // Max width of the files pane - selectedTab: 0, // The tab that's currently selected - changedContent: [], // Binary array to indicate which tabs have changed - ctrlKeyDown: false, // Indicates if CTRL keydown - shiftKeyDown: false, // Indicates if Shift keydown - delKeyDown: false, // Indicates if DEL keydown - canSwitchTabs: true, // Stops switching of tabs when trying to close - openFiles: [], // Array of open file URLs - openFileMDTs: [], // Array of open file modification datetimes - cMInstances: [], // List of CodeMirror instance no's - nextcMInstance: 1, // Next available CodeMirror instance no - selectedFiles: [], // Array of selected files - findMode: false, // States if we're in find/replace mode - lockedNav: true, // Nav is locked or not - htmlTagArray: [], // Array storing the nest of tags - codeAssist: true, // Assist user with their coding - snippetLine: false, // Line no of snippet, if shown - mouseDown: false, // If the mouse is down or not - draggingFilesW: false, // If we're dragging the file manager width or not - serverQueueItems: [], // Array of URLs to call in order - stickyTab: false, // Target variable for the sticky tab window - pluginIntervalRefs: [], // Array of plugin interval refs - dragSrcEl: null, // Tab element being dragged - ready: false, // Indicates if ICEcoder is ready for action - - // Don't consider these tags as part of nesting as they're singles, JS, PHP or Ruby code blocks - tagNestExceptions: ["!DOCTYPE","meta","link","img","br","hr","input","script","?php","?","%"], - - // Set our aliases - initAliases: function() { - var aliasArray = ["header","files","account","fmLock","filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","charDisplay"]; - - // Create our ID aliases - for (var i=0;i ICEcoder.minFilesW+1 ? ICEcoder.filesW -= Math.ceil((ICEcoder.filesW-ICEcoder.minFilesW)/2) : ICEcoder.filesW = ICEcoder.minFilesW; - } - if ((expandContract=="expand" && ICEcoder.filesW == ICEcoder.maxFilesW)||(expandContract=="contract" && ICEcoder.filesW == ICEcoder.minFilesW)) { - clearInterval(ICEcoder.changeFilesInt); - } - // Redo the layout to match - 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) { - top.ICEcoder.filesW = top.ICEcoder.maxFilesW = top.ICEcoder.mouseX >=250 && top.ICEcoder.mouseX <= 400 - ? top.ICEcoder.mouseX : top.ICEcoder.mouseX <250 ? 250 : 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; - } - }, - - // Lock & unlock the file manager navigation on demand - lockUnlockNav: function() { - var lockIcon; - - lockIcon = top.document.getElementById('fmLock'); - ICEcoder.lockedNav = ICEcoder.lockedNav ? false : true; - lockIcon.style.backgroundPosition = ICEcoder.lockedNav ? "-64px -16px" : "-80px -16px"; - }, - -// ============== -// EDITOR -// ============== - - // Clean up our loaded code - contentCleanUp: function() { - var fileName, cM, content; - - // If it's not a JS, CoffeeScript Ruby, CSS or LESS file, replace our temp value - fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1]; - if (["js","coffee","rb","css","less"].indexOf(fileName.split(".")[1])<0) { - cM = ICEcoder.getcMInstance(); - content = cM.getValue(); - content = content.replace(//g,''); - - // Then set the content in the editor & clear the history - cM.setValue(content); - cM.clearHistory(); - } - }, - - // Move current line up/down - moveLine: function(dir) { - var cM, line, swapLineNo, swapLine; - - cM = top.ICEcoder.getcMInstance(); - line = cM.getCursor().line; - if (dir=="up" && line>0) {swapLineNo = line-1} - if (dir=="down" && line0 ? cM.setOption("mode","javascript") - : fileName.indexOf('.coffee')>0 ? cM.setOption("mode","coffeescript") - : fileName.indexOf('.rb')>0 ? cM.setOption("mode","ruby") - : fileName.indexOf('.css')>0 ? cM.setOption("mode","css") - : fileName.indexOf('.less')>0 ? cM.setOption("mode","less") - : cM.setOption("mode","application/x-httpd-php"); - } - }, - - // Comment or uncomment line on keypress - lineCommentToggle: function() { - var cM, cursorPos, linePos, lineContent, lCLen, adjustCursor, startLine, endLine; - - cM = ICEcoder.getcMInstance(); - cursorPos = cM.getCursor().ch; - linePos = cM.getCursor().line; - lineContent = cM.getLine(linePos); - lCLen = lineContent.length; - adjustCursor = 2; - - if (["JavaScript","CoffeeScript","PHP","Ruby","CSS"].indexOf(ICEcoder.caretLocType)>-1) { - if (cM.somethingSelected()) { - if (ICEcoder.caretLocType=="Ruby") { - startLine = cM.getCursor(true).line; - endLine = cM.getCursor().line; - for (var i=startLine; i<=endLine; i++) { - cM.setLine(i, cM.getLine(i).slice(0,1)!="#" - ? "#" + cM.getLine(i) - : cM.getLine(i).slice(1,cM.getLine(i).length)); - } - } else { - cM.replaceSelection(cM.getSelection().slice(0,2)!="/*" - ? "/*" + cM.getSelection() + "*/" - : cM.getSelection().slice(2,cM.getSelection().length-2)); - } - } else { - if (["CoffeeScript","CSS"].indexOf(ICEcoder.caretLocType)>-1) { - cM.setLine(linePos, lineContent.slice(0,2)!="/*" - ? "/*" + lineContent + "*/" - : lineContent.slice(2,lCLen).slice(0,lCLen-4)); - if (lineContent.slice(0,2)=="/*") {adjustCursor = -adjustCursor}; - } else if (ICEcoder.caretLocType=="Ruby") { - cM.setLine(linePos, lineContent.slice(0,1)!="#" - ? "#" + lineContent - : lineContent.slice(1,lCLen)); - if (lineContent.slice(0,1)=="#") {adjustCursor = -adjustCursor}; - } else { - cM.setLine(linePos, lineContent.slice(0,2)!="//" - ? "//" + lineContent - : lineContent.slice(2,lCLen)); - if (lineContent.slice(0,2)=="//") {adjustCursor = -adjustCursor}; - } - } - } else { - if (cM.somethingSelected()) { - cM.replaceSelection(cM.getSelection().slice(0,4)!="" - : cM.getSelection().slice(4,cM.getSelection().length-5)); - } else { - cM.setLine(linePos, lineContent.slice(0,4)!="" - : lineContent.slice(4,lCLen).slice(0,lCLen-9)); - adjustCursor = lineContent.slice(0,4)=="" + : cM.getSelection().slice(4,cM.getSelection().length-5)); + } else { + cM.setLine(linePos, lineContent.slice(0,4)!="" + : lineContent.slice(4,lCLen).slice(0,lCLen-9)); + adjustCursor = lineContent.slice(0,4)=="