Only do layout things if ready, fix to path

Can only resize the file manager if ICEcoder is ready
Need a selectedFiles[0] in order to prefix to filePath
If we add a new file to the root, we end up with a ||[NEW], so replace
|| with | to fix this
Can only set tab widths if ICEcoder is ready
This commit is contained in:
Matt Pass
2013-05-31 14:32:02 +01:00
parent df2697c68b
commit 7bdeefd7e1

View File

@@ -138,7 +138,7 @@ var ICEcoder = {
// Can click-drag file manager width?
canResizeFilesW: function() {
// If we have the cursor set we must be able!
if (top.document.body.style.cursor == "w-resize") {
if (top.ICEcoder.ready && top.document.body.style.cursor == "w-resize") {
// If our mouse is down and we're within a 250-400px range
if (top.ICEcoder.mouseDown) {
top.ICEcoder.filesW = top.ICEcoder.maxFilesW = top.ICEcoder.mouseX >=250 && top.ICEcoder.mouseX <= 400
@@ -651,9 +651,10 @@ var ICEcoder = {
saveType = saveAs ? "saveAs" : "save";
filePath = ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,"").replace(/\//g,"|");
if (filePath=="|[NEW]") {
if (filePath=="|[NEW]" && top.ICEcoder.selectedFiles.length>0) {
filePath = top.ICEcoder.selectedFiles[0]+filePath;
}
filePath = filePath.replace("||","|");
top.ICEcoder.serverQueue("add","lib/file-control.php?action=save&file="+filePath+"&fileMDT="+ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]+"&saveType="+saveType);
top.ICEcoder.serverMessage('<b>Saving</b><br>'+ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,""));
},
@@ -1930,26 +1931,28 @@ var ICEcoder = {
setTabWidths: function(posOnlyNewTab) {
var availWidth, avgWidth, tabWidth, lastLeft, lastWidth;
availWidth = parseInt(top.ICEcoder.content.style.width,10)-41-24-10; // - left margin - new tab - right margin
avgWidth = (availWidth/top.ICEcoder.openFiles.length)-18;
tabWidth = -18; // Incl 18px offset
lastLeft = 41;
lastWidth = 0;
top.ICEcoder.tabLeftPos = [];
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
if (posOnlyNewTab) {i=top.ICEcoder.openFiles.length};
tabWidth = top.ICEcoder.openFiles.length*(150+18) > availWidth ? parseInt(avgWidth*i,10) - parseInt(avgWidth*(i-1),10) : 150;
lastLeft = i==0 ? 41 : parseInt(top.get('tab'+(i)).style.left,10);
lastWidth = i==0 ? 0 : parseInt(top.get('tab'+(i)).style.width,10)+18;
if (!posOnlyNewTab) {
top.get('tab'+(i+1)).style.left = (lastLeft+lastWidth) + "px";
top.get('tab'+(i+1)).style.width = tabWidth + "px";
} else {
tabWidth = -18;
if (top.ICEcoder.ready) {
availWidth = parseInt(top.ICEcoder.content.style.width,10)-41-24-10; // - left margin - new tab - right margin
avgWidth = (availWidth/top.ICEcoder.openFiles.length)-18;
tabWidth = -18; // Incl 18px offset
lastLeft = 41;
lastWidth = 0;
top.ICEcoder.tabLeftPos = [];
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
if (posOnlyNewTab) {i=top.ICEcoder.openFiles.length};
tabWidth = top.ICEcoder.openFiles.length*(150+18) > availWidth ? parseInt(avgWidth*i,10) - parseInt(avgWidth*(i-1),10) : 150;
lastLeft = i==0 ? 41 : parseInt(top.get('tab'+(i)).style.left,10);
lastWidth = i==0 ? 0 : parseInt(top.get('tab'+(i)).style.width,10)+18;
if (!posOnlyNewTab) {
top.get('tab'+(i+1)).style.left = (lastLeft+lastWidth) + "px";
top.get('tab'+(i+1)).style.width = tabWidth + "px";
} else {
tabWidth = -18;
}
top.ICEcoder.tabLeftPos.push(lastLeft+lastWidth);
}
top.ICEcoder.tabLeftPos.push(lastLeft+lastWidth);
top.get('newTab').style.left = (lastLeft+lastWidth+tabWidth+18) + "px";
}
top.get('newTab').style.left = (lastLeft+lastWidth+tabWidth+18) + "px";
},
// Tab dragging start