Only use location if iceRoot is blank

Because setting an root path has its own relative file path
This commit is contained in:
Matt Pass
2014-04-11 08:50:23 +01:00
parent dff16e9b3f
commit 641ff79493
2 changed files with 11 additions and 9 deletions

View File

@@ -1065,7 +1065,9 @@ var ICEcoder = {
// Deleting files
if (action=="delete") {
// Simply get our target and make it dissapear
targetElem = top.get('filesFrame').contentWindow.document.getElementById(location.replace(/\/$/, "").replace(/\//g,"|")+"|"+file).parentNode.parentNode;
targetElem = top.get('filesFrame').contentWindow.document.getElementById(
(top.iceRoot == "" ? location.replace(/\/$/, "").replace(/\//g,"|") : "")
+"|"+file).parentNode.parentNode;
top.ICEcoder.openCloseDir(targetElem.childNodes[0],false);
targetElem.parentNode.removeChild(targetElem);
}

16
lib/ice-coder.min.js vendored
View File

@@ -42,14 +42,14 @@ a[0].lastIndexOf("|"));top.ICEcoder.pasteFiles(a);"undefined"!=typeof b&&(top.IC
"").replace(/\//g,"|")+"|"+c+'_perms">'+d+"</span></a>";if(3>k.childNodes.length)l=document.createElement("ul"),k=h.parentNode.parentNode,k.parentNode.insertBefore(l,k.nextSibling),l=document.createElement("li"),l.className=m,l.draggable=!0,l.ondrag=function(a){top.ICEcoder.draggingWithKeyTest(a);top.ICEcoder.getcMInstance()&&top.ICEcoder.getcMInstance().focus()},l.ondragend=function(){top.ICEcoder.dropFile(this)},l.innerHTML=p,k.nextSibling.appendChild(l),k.nextSibling.appendChild(n);else for(h=
0;h<k.childNodes.length;h++)if(k.childNodes[h].className&&(l=0<k.childNodes[h].className.indexOf("directory")?"folder":"file",r=k.childNodes[h].getElementsByTagName("span")[0].innerHTML,l==g&&r>c||"folder"==g&&"file"==l||h==k.childNodes.length-1)){l=document.createElement("li");l.className=m;l.draggable=!0;l.ondrag=function(a){top.ICEcoder.draggingWithKeyTest(a);top.ICEcoder.getcMInstance()&&top.ICEcoder.getcMInstance().focus()};l.ondragend=function(){top.ICEcoder.dropFile(this)};l.innerHTML=p;h==
k.childNodes.length-1?(k.appendChild(l),k.appendChild(n)):(k.insertBefore(l,k.childNodes[h]),k.insertBefore(n,k.childNodes[h+1]));break}"file"!=g||f||(top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]=b+c)}"rename"==a&&(f=e.replace(/\//g,"|"),h=top.get("filesFrame").contentWindow.document.getElementById(f),h.innerHTML=c,h.id=b.replace(/\//g,"|")+"|"+c,h.parentNode.title=h.id.replace(/\|/g,"/"),targetElemPerms=top.get("filesFrame").contentWindow.document.getElementById(f+"_perms"),targetElemPerms.id=
b.replace(/\//g,"|")+"|"+c+"_perms");"move"==a&&(top.ICEcoder.updateFileManagerList("add",b,c),top.ICEcoder.updateFileManagerList("delete",e.substr(0,e.lastIndexOf("/")),c));"chmod"==a&&(f=top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/"),h=top.get("filesFrame").contentWindow.document.getElementById(f.replace(/\//g,"|")+"_perms"),h.innerHTML=d);"delete"==a&&(h=top.get("filesFrame").contentWindow.document.getElementById(b.replace(/\/$/,"").replace(/\//g,"|")+"|"+c).parentNode.parentNode,
top.ICEcoder.openCloseDir(h.childNodes[0],!1),h.parentNode.removeChild(h))},refreshFileManager:function(){top.ICEcoder.showHide("show",top.get("loadingMask"));top.ICEcoder.filesFrame.src="files.php";top.ICEcoder.filesFrame.style.opacity="0";top.ICEcoder.filesFrame.onload=function(){top.ICEcoder.filesFrame.style.opacity="1";top.ICEcoder.showHide("hide",top.get("loadingMask"))}},draggingWithKeyTest:function(a){var b;b=a.keyCode?a.keyCode:a.which?a.which:a.charCode;if(224==b||91==b||93==b)top.ICEcoder.cmdKey=
!0;top.ICEcoder.draggingWithKey=a.ctrlKey||top.ICEcoder.cmdKey?"CTRL":!1},dropFile:function(a){var b,c;b=a.childNodes[0].childNodes[1].id.replace(/\|/g,"/");fileName=b.substr(b.lastIndexOf("/")+1);"editor"==top.ICEcoder.area&&top.ICEcoder.pasteURL(b);"files"==top.ICEcoder.area&&setTimeout(function(){c="folder"==ICEcoder.thisFileFolderType?ICEcoder.thisFileFolderLink:ICEcoder.thisFileFolderLink.substr(0,ICEcoder.thisFileFolderLink.lastIndexOf("|"));"CTRL"==top.ICEcoder.draggingWithKey?(top.ICEcoder.copyFiles(top.ICEcoder.selectedFiles),
top.ICEcoder.pasteFiles(c)):top.ICEcoder.moveFile(b,c.replace(/\|/g,"/")+"/"+fileName)},4);top.ICEcoder.mouseDown=!1},findReplaceOptions:function(){top.get("rText").style.display=top.get("replace").style.display=top.get("rTarget").style.display="and"==document.findAndReplace.connector.value?"inline-block":"none"},findReplace:function(a,b,c){var d,e,f;d=a.toLowerCase();e=top.get("replace").value;f=top.get("results");if((a=ICEcoder.getcMInstance())&&0<d.length&&"this document"==document.findAndReplace.target.value){a.getValue().toLowerCase();
"and"==document.findAndReplace.connector.value&&c&&("replace"==document.findAndReplace.replaceAction.value&&a.getSelection().toLowerCase()==d?a.replaceSelection(e):"replace all"==document.findAndReplace.replaceAction.value&&(c=RegExp(d,"gi"),a.setValue(a.getValue().replace(c,e))));c=a.getValue().toLowerCase();if(!top.ICEcoder.findMode||d!=top.ICEcoder.lastsearch){ICEcoder.results=[];ICEcoder.resultsLines=[];for(e=0;e<c.length;e++)c.substr(e,d.length)==d&&-1==ICEcoder.results.indexOf(e)&&(ICEcoder.results.push(e),
-1==ICEcoder.resultsLines.indexOf(a.posFromIndex(e).line+1)&&ICEcoder.resultsLines.push(a.posFromIndex(e).line+1));ICEcoder.lastsearch=d}if(0<ICEcoder.results.length){c=a.getScrollInfo().height>a.getScrollInfo().clientHeight;if(b)f.innerHTML=ICEcoder.results.length+" results";else{for(e=ICEcoder.findResult=0;e<ICEcoder.results.length;e++)ICEcoder.results[e]<a.indexFromPos(a.getCursor())&&ICEcoder.findResult++;ICEcoder.findResult>ICEcoder.results.length-1&&(ICEcoder.findResult=0);f.innerHTML="Highlighted result "+
(ICEcoder.findResult+1)+" of "+ICEcoder.results.length+" results";b=a.getSearchCursor(d,a.getCursor(),!0);b.findNext();b.from()||(b=a.getSearchCursor(d,{line:0,ch:0},!0),b.findNext());a.setSelection(b.from(),b.to());top.ICEcoder.focus();top.ICEcoder.findMode=!0}d=c?parseInt(top.ICEcoder.content.style.height,10)/a.lineCount():a.defaultTextHeight();b=c?0:a.heightAtLine(0);top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").style.right=c?"17px":"0";f="";for(e=1;e<=a.lineCount();e++)c=
-1<ICEcoder.resultsLines.indexOf(e)?a.getCursor().line+1==e?"#b00":"#888":"transparent",f+='<div style="position: absolute; display: block; width: 5px; height:'+d+"px; background: "+c+"; top: "+parseInt(d*(e-1)+b,10)+'px"></div>';top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").innerHTML=f;top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").style.display="inline-block";return!0}f.innerHTML="No results";top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").innerHTML=
b.replace(/\//g,"|")+"|"+c+"_perms");"move"==a&&(top.ICEcoder.updateFileManagerList("add",b,c),top.ICEcoder.updateFileManagerList("delete",e.substr(0,e.lastIndexOf("/")),c));"chmod"==a&&(f=top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/"),h=top.get("filesFrame").contentWindow.document.getElementById(f.replace(/\//g,"|")+"_perms"),h.innerHTML=d);"delete"==a&&(h=top.get("filesFrame").contentWindow.document.getElementById((""==top.iceRoot?b.replace(/\/$/,"").replace(/\//g,
"|"):"")+"|"+c).parentNode.parentNode,top.ICEcoder.openCloseDir(h.childNodes[0],!1),h.parentNode.removeChild(h))},refreshFileManager:function(){top.ICEcoder.showHide("show",top.get("loadingMask"));top.ICEcoder.filesFrame.src="files.php";top.ICEcoder.filesFrame.style.opacity="0";top.ICEcoder.filesFrame.onload=function(){top.ICEcoder.filesFrame.style.opacity="1";top.ICEcoder.showHide("hide",top.get("loadingMask"))}},draggingWithKeyTest:function(a){var b;b=a.keyCode?a.keyCode:a.which?a.which:a.charCode;
if(224==b||91==b||93==b)top.ICEcoder.cmdKey=!0;top.ICEcoder.draggingWithKey=a.ctrlKey||top.ICEcoder.cmdKey?"CTRL":!1},dropFile:function(a){var b,c;b=a.childNodes[0].childNodes[1].id.replace(/\|/g,"/");fileName=b.substr(b.lastIndexOf("/")+1);"editor"==top.ICEcoder.area&&top.ICEcoder.pasteURL(b);"files"==top.ICEcoder.area&&setTimeout(function(){c="folder"==ICEcoder.thisFileFolderType?ICEcoder.thisFileFolderLink:ICEcoder.thisFileFolderLink.substr(0,ICEcoder.thisFileFolderLink.lastIndexOf("|"));"CTRL"==
top.ICEcoder.draggingWithKey?(top.ICEcoder.copyFiles(top.ICEcoder.selectedFiles),top.ICEcoder.pasteFiles(c)):top.ICEcoder.moveFile(b,c.replace(/\|/g,"/")+"/"+fileName)},4);top.ICEcoder.mouseDown=!1},findReplaceOptions:function(){top.get("rText").style.display=top.get("replace").style.display=top.get("rTarget").style.display="and"==document.findAndReplace.connector.value?"inline-block":"none"},findReplace:function(a,b,c){var d,e,f;d=a.toLowerCase();e=top.get("replace").value;f=top.get("results");if((a=
ICEcoder.getcMInstance())&&0<d.length&&"this document"==document.findAndReplace.target.value){a.getValue().toLowerCase();"and"==document.findAndReplace.connector.value&&c&&("replace"==document.findAndReplace.replaceAction.value&&a.getSelection().toLowerCase()==d?a.replaceSelection(e):"replace all"==document.findAndReplace.replaceAction.value&&(c=RegExp(d,"gi"),a.setValue(a.getValue().replace(c,e))));c=a.getValue().toLowerCase();if(!top.ICEcoder.findMode||d!=top.ICEcoder.lastsearch){ICEcoder.results=
[];ICEcoder.resultsLines=[];for(e=0;e<c.length;e++)c.substr(e,d.length)==d&&-1==ICEcoder.results.indexOf(e)&&(ICEcoder.results.push(e),-1==ICEcoder.resultsLines.indexOf(a.posFromIndex(e).line+1)&&ICEcoder.resultsLines.push(a.posFromIndex(e).line+1));ICEcoder.lastsearch=d}if(0<ICEcoder.results.length){c=a.getScrollInfo().height>a.getScrollInfo().clientHeight;if(b)f.innerHTML=ICEcoder.results.length+" results";else{for(e=ICEcoder.findResult=0;e<ICEcoder.results.length;e++)ICEcoder.results[e]<a.indexFromPos(a.getCursor())&&
ICEcoder.findResult++;ICEcoder.findResult>ICEcoder.results.length-1&&(ICEcoder.findResult=0);f.innerHTML="Highlighted result "+(ICEcoder.findResult+1)+" of "+ICEcoder.results.length+" results";b=a.getSearchCursor(d,a.getCursor(),!0);b.findNext();b.from()||(b=a.getSearchCursor(d,{line:0,ch:0},!0),b.findNext());a.setSelection(b.from(),b.to());top.ICEcoder.focus();top.ICEcoder.findMode=!0}d=c?parseInt(top.ICEcoder.content.style.height,10)/a.lineCount():a.defaultTextHeight();b=c?0:a.heightAtLine(0);top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").style.right=
c?"17px":"0";f="";for(e=1;e<=a.lineCount();e++)c=-1<ICEcoder.resultsLines.indexOf(e)?a.getCursor().line+1==e?"#b00":"#888":"transparent",f+='<div style="position: absolute; display: block; width: 5px; height:'+d+"px; background: "+c+"; top: "+parseInt(d*(e-1)+b,10)+'px"></div>';top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").innerHTML=f;top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").style.display="inline-block";return!0}f.innerHTML="No results";top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").innerHTML=
"";top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").style.display="none";return!1}""!=d&&c?(f=b=a="","and"==document.findAndReplace.connector.value&&(a="&replace="+e),0<=document.findAndReplace.target.value.indexOf("file")&&(b="&target="+document.findAndReplace.target.value.replace(/ /g,"-")),"selected files"==document.findAndReplace.target.value&&(f="&selectedFiles="+top.ICEcoder.selectedFiles.join(":")),d=d.replace(/\'/g,"&#39;"),d!=encodeURIComponent(d)?d="ICEcoder:"+encodeURIComponent(d):
d,top.ICEcoder.showHide("show",top.get("loadingMask")),top.get("mediaContainer").innerHTML='<iframe src="lib/multiple-results.php?find='+d+a+b+f+'" class="whiteGlow" style="width: 700px; height: 500px"></iframe>'):(f.innerHTML="No results",top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").innerHTML="",top.ICEcoder.content.contentWindow.document.getElementById("resultsBar").style.display="none")},replaceInFile:function(a,b,c){top.ICEcoder.serverQueue("add","lib/file-control.php?action=replaceText&fileRef="+
a.replace(/\//g,"|")+"&find="+b+"&replace="+c);top.ICEcoder.serverMessage("<b>Replacing text in</b><br>"+a)},getNestLocation:function(a){var b,c,d;if(b=ICEcoder.getcMInstance()){c=b.getValue();b=b.getTokenAt(b.getCursor()).state;d=!1;"undefined"!=typeof b&&(d=b.context);"undefined"!=typeof b.curState&&"undefined"!=typeof b.curState.htmlState&&(d=b.curState.htmlState.context);ICEcoder.htmlTagArray=[];if(d)for(;d;d=d.prev)"undefined"!=typeof d.tagName&&ICEcoder.htmlTagArray.unshift(d.tagName);ICEcoder.tagString=