detect whether an item in folder list is file or folder depending on its <a> item class, rather then the fact, that it has a dot in its name (I have lots of folders named like example.com which were treated as files)

This commit is contained in:
Andrey Grinenko
2015-02-22 00:44:37 +03:00
parent fac5bf8662
commit 4d7ac54e6b
2 changed files with 45 additions and 29 deletions

View File

@@ -1396,6 +1396,22 @@ var ICEcoder = {
get('fileOptions').style.opacity = 1;
}
},
/**
* returns true if path is a folder
* @param path string encoded path with / replaced with |
* @return boolean true if path is a folder, false if path is file
*/
isPathFolder: function(path){
// let's enumerate all folders to find whether clicked file is a folder or not
var dir = top.filesFrame.contentDocument.getElementsByClassName("pft-directory");
var thisFileId = top.ICEcoder.selectedFiles[0];
for (var i = 0 ; i < dir.length; i++){
if (thisFileId === dir[i].childNodes[0].childNodes[1].getAttribute('id')){
return true;
}
}
return false;
},
// Show menu on right clicking in file manager
showMenu: function(evt) {
@@ -1409,7 +1425,7 @@ var ICEcoder = {
menuHeight = 124+5; // general options height in px plus 5px space
winH = window.innerHeight;
if ("undefined" != typeof top.ICEcoder.thisFileFolderLink && top.ICEcoder.thisFileFolderLink!="") {
menuType = top.ICEcoder.selectedFiles[0].indexOf(".")>-1 ? "file" : "folder";
menuType = this.isPathFolder(top.ICEcoder.selectedFiles[0]) ? "folder" : "file";
top.get('folderMenuItems').style.display = menuType == "folder" && top.ICEcoder.selectedFiles.length == 1 ? "block" : "none";
if (menuType == "folder" && top.ICEcoder.selectedFiles.length == 1) {
menuHeight += 20+20+1+23+1+2; // new file, new folder, hr, upload files(s), hr, padding