New functions & Some Removals

Removed code realting to idea of slow clicking to begin rename process
New File function added
New Folder function added
Altered rename function to work with single file
Altered delete function to display better path in prompt
File Manager Menu positioning & display function
Mouse X & Y position function added to enable positioning
This commit is contained in:
Matt Pass
2012-02-12 14:35:03 +00:00
parent 31f634b395
commit 4cf6dac5f9

View File

@@ -564,32 +564,20 @@ var ICEcoder = {
}
// We are single clicking
} else {
if (top.ICEcoder.selectedFiles.length==1 && shortURL==top.ICEcoder.selectedFiles[0]) {
// Go into edit mode...
if (top.ICEcoder.slowClick) {top.ICEcoder.renameFile()}
} else {
// First deselect all files
for (i=0;i<top.ICEcoder.selectedFiles.length;i++) {
resetFile = ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.selectedFiles[i]);
resetFile.style.backgroundColor="#dddddd";
resetFile.style.color="#000000";
}
// Set our arrray to contain 0 items
top.ICEcoder.selectedFiles.length = 0;
// Add our URL and highlight the file
top.ICEcoder.selectedFiles.push(shortURL);
foundFile = ICEcoder.filesFrame.contentWindow.document.getElementById(shortURL);
foundFile.style.backgroundColor="#888888";
foundFile.style.color="#f8f8f8";
// Set a variable to test for slow double clicking (1-3secs)
top.ICEcoder.slowClick = false;
clearInterval(top.ICEcoder.slowClickS);
clearInterval(top.ICEcoder.slowClickE);
top.ICEcoder.slowClickS = setTimeout('top.ICEcoder.slowClick = true',1000);
top.ICEcoder.slowClickE = setTimeout('top.ICEcoder.slowClick = false',3000);
// First deselect all files
for (i=0;i<top.ICEcoder.selectedFiles.length;i++) {
resetFile = ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.selectedFiles[i]);
resetFile.style.backgroundColor="#dddddd";
resetFile.style.color="#000000";
}
// Set our arrray to contain 0 items
top.ICEcoder.selectedFiles.length = 0;
// Add our URL and highlight the file
top.ICEcoder.selectedFiles.push(shortURL);
foundFile = ICEcoder.filesFrame.contentWindow.document.getElementById(shortURL);
foundFile.style.backgroundColor="#888888";
foundFile.style.color="#f8f8f8";
}
}
// Adjust the file & replace select values depending on if we have files selected
@@ -602,6 +590,23 @@ var ICEcoder = {
}
},
// Create a new file (start & instant save)
newFile: function() {
top.ICEcoder.newTab();
top.ICEcoder.saveFile();
},
// Create a new folder
newFolder: function() {
var newFolder;
newFolder = prompt('Enter Folder Path','/');
if (newFolder) {
filesFrame.contentWindow.frames['fileControl'].location.href="lib/file-control.php?action=newFolder&file="+newFolder.replace(/\//g,"|");
}
},
// Open a file on demand
openFile: function() {
if (top.ICEcoder.thisFileFolderLink!="" && top.ICEcoder.thisFileFolderType=="file") {
@@ -654,7 +659,7 @@ var ICEcoder = {
renameFile: function() {
var renamedFile, shortURL;
shortURL = top.ICEcoder.thisFileFolderLink.replace(/\|/g,"/");
shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/");
renamedFile = false;
renamedFile = prompt('Please enter the new name for',shortURL);
@@ -669,7 +674,7 @@ var ICEcoder = {
top.document.getElementById('tab'+(i+1)).innerHTML = top.ICEcoder.openFiles[i] + " " + closeTabLink;
}
}
ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href = "lib/file-control.php?action=rename&file="+renamedFile+"&oldFileName="+top.ICEcoder.thisFileFolderLink;
ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href = "lib/file-control.php?action=rename&file="+renamedFile+"&oldFileName="+top.ICEcoder.rightClickedFile.replace(/\|/g,"/");
}
},
@@ -677,7 +682,7 @@ var ICEcoder = {
deleteFile: function() {
var delFiles, selectedFilesList;
delFiles = confirm('Delete: '+top.ICEcoder.selectedFiles+'?');
delFiles = confirm('Delete:\n\n'+top.ICEcoder.selectedFiles.toString().replace(/\|/g,"/").replace(/,/g,"\n")+'?');
// Upon supply a new name, rename tabs and update filename on server
if (delFiles) {
@@ -693,7 +698,9 @@ var ICEcoder = {
// Show menu on right clicking in file manager
showMenu: function() {
if ("undefined" != typeof top.ICEcoder.thisFileFolderLink && top.ICEcoder.thisFileFolderLink!="") {
alert('show menu');
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";
}
return false;
},
@@ -900,5 +907,25 @@ var ICEcoder = {
cM.setCursor(cM.getCursor().line, cursorPos-4);
}
}
},
// Get the mouse position on demand
getMouseXY: function(e) {
var tempX, tempY, scrollTop, IE;
IE = document.all ? true : false;
if (!IE) {document.captureEvents(Event.MOUSEMOVE)};
if (IE) {
top.ICEcoder.mouseX = event.clientX + document.body.scrollLeft;
top.ICEcoder.mouseY = event.clientY + document.body.scrollTop;
} else {
top.ICEcoder.mouseX = e.pageX;
top.ICEcoder.mouseY = e.pageY;
}
scrollTop = top.document.getElementById('filesFrame').contentWindow.document.body.scrollTop;
top.ICEcoder.mouseY -= scrollTop;
}
};