From dc051e993b0dfafbe5a0e1ff6b34c33055359aa2 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Tue, 10 Jul 2012 07:17:37 +0100 Subject: [PATCH] closeTab CM 2.3 fix & new params Fix to closing tabs as now using CodeMirror 2.3 oldName & newName params passed to renameFile This is used by the replace in filenames function, but can also be API updateFileManagerList now has new param This again is so it can be used by find/replace, passed from file-control.php --- lib/coder.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/coder.js b/lib/coder.js index 1e6287e..424af21 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -565,7 +565,7 @@ var ICEcoder = { top.document.getElementById('tab'+i).innerHTML = top.document.getElementById('tab'+i).innerHTML.replace(("closeTab("+(i+1)+")"),"closeTab("+i+")").replace(("closeTabButton("+(i+1)+")"),"closeTabButton("+i+")"); } // hide the instance we're closing by setting the hide class and removing from the array - ICEcoder.content.contentWindow['cM'+top.ICEcoder.cMInstances[closeTabNum-1]].setOption('theme',top.theme+' hidden'); + ICEcoder.content.contentWindow['cM'+top.ICEcoder.cMInstances[closeTabNum-1]].getWrapperElement().style.display = "none"; top.ICEcoder.cMInstances.splice(closeTabNum-1,1); // clear the rightmost tab (or only one left in a 1 tab scenario) & remove from the array top.document.getElementById('tab'+ICEcoder.openFiles.length).style.display = "none"; @@ -805,22 +805,29 @@ var ICEcoder = { }, // Prompt a rename dialog on demand - renameFile: function() { - var renamedFile, shortURL; + renameFile: function(oldName,newName) { + var shortURL; - shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/"); - renamedFile = top.ICEcoder.getInput('Please enter the new name for',shortURL); - if (renamedFile) { + if (!oldName) { + shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/"); + oldName = top.ICEcoder.rightClickedFile.replace(/\|/g,"/"); + } else { + shortURL = oldName.substr((oldName.indexOf(shortURLStarts)+top.shortURLStarts.length),oldName.length).replace(/\|/g,"/"); + } + if (!newName) { + newName = top.ICEcoder.getInput('Please enter the new name for',shortURL); + } + if (newName) { for (var i=0;i'; top.document.getElementById('tab'+(i+1)).innerHTML = top.ICEcoder.openFiles[i] + " " + closeTabLink; } } - top.ICEcoder.serverQueue("add","lib/file-control.php?action=rename&file="+renamedFile+"&oldFileName="+top.ICEcoder.rightClickedFile.replace(/\|/g,"/")); - top.ICEcoder.serverMessage('Renaming to
'+renamedFile); + top.ICEcoder.serverQueue("add","lib/file-control.php?action=rename&file="+newName+"&oldFileName="+oldName); + top.ICEcoder.serverMessage('Renaming to
'+newName); top.ICEcoder.setPreviousFiles(); } @@ -1153,7 +1160,7 @@ var ICEcoder = { }, // Update the file manager tree list on demand - updateFileManagerList: function(action,location,file,perms) { + updateFileManagerList: function(action,location,file,perms,oldName) { var actionElemType, cssStyle, hrefLink, targetElem, locNest, newUL, newLI, nameLI, shortURL, newMouseOver; // Adding files @@ -1215,7 +1222,7 @@ var ICEcoder = { // Renaming files if (action=="rename") { // Identify a shortened URL for our right clicked file and get our target element based on this - shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/"); + shortURL = oldName; targetElem = document.getElementById('filesFrame').contentWindow.document.getElementById(shortURL.replace(/\//g,"|")); // Set the name to be as per our new file/folder name targetElem.innerHTML = file;