mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-03 23:34:01 +01:00
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
This commit is contained in:
29
lib/coder.js
29
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.ICEcoder.openFiles.length;i++) {
|
||||
if(top.ICEcoder.openFiles[i]==shortURL.replace(/\|/g,"/")) {
|
||||
// rename array item and the tab
|
||||
top.ICEcoder.openFiles[i] = renamedFile;
|
||||
top.ICEcoder.openFiles[i] = newName;
|
||||
closeTabLink = '<a nohref onClick="top.ICEcoder.files.contentWindow.closeTab('+(i+1)+')"><img src="images/nav-close.gif" id="closeTabButton'+(i+1)+'" class="closeTab"></a>';
|
||||
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('<b>Renaming to</b><br>'+renamedFile);
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=rename&file="+newName+"&oldFileName="+oldName);
|
||||
top.ICEcoder.serverMessage('<b>Renaming to</b><br>'+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;
|
||||
|
||||
Reference in New Issue
Block a user