From 7bdeefd7e185baf334fbf970a0b8d4fef9c41c41 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Fri, 31 May 2013 14:32:02 +0100 Subject: [PATCH] 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 --- lib/ice-coder.js | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 56efa9a..0368ef4 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -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('Saving
'+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 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 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