FM visually linked to tabs & file setting updates

Changed content indicator in tab doesn't count if undo history is back
to the start
File highlighting now visually linked with the tabs of open docs
Selected file have blue BG, other open files 15% white BG
lastOpenedFiles now previousFiles in a few places
This commit is contained in:
Matt Pass
2012-06-09 18:43:57 +01:00
parent 1fbe9df342
commit 2b5a16be70

View File

@@ -369,13 +369,18 @@ var ICEcoder = {
// Reset all tabs to be without a highlight and then highlight the selected
redoTabHighlight: function(selectedTab) {
var bgVPos, tColor;
var cM, bgVPos, tColor, fileLink;
cM = ICEcoder.getcMInstance();
for(var i=1;i<=ICEcoder.changedContent.length;i++) {
if (document.getElementById('closeTabButton'+i)) {
ICEcoder.changedContent[i-1]==1 ? document.getElementById('closeTabButton'+i).style.backgroundColor = "#b00" : document.getElementById('closeTabButton'+i).style.backgroundColor = "rgba(255,255,255,0.3)";
ICEcoder.changedContent[i-1]==1 && cM.historySize().undo>0 ? document.getElementById('closeTabButton'+i).style.backgroundColor = "#b00" : document.getElementById('closeTabButton'+i).style.backgroundColor = "rgba(255,255,255,0.3)";
}
i==selectedTab ? tColor = "#000" : tColor = "#fff";
if ("undefined" != typeof top.ICEcoder.openFiles[i-1] && top.ICEcoder.openFiles[i-1] != "/[NEW]") {
fileLink = top.ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.openFiles[i-1].replace(/\//g,"|"));
i==selectedTab ? fileLink.style.backgroundColor = "#4499dd" : fileLink.style.backgroundColor = "rgba(255,255,255,0.15)";
}
document.getElementById('tab'+i).style.color = tColor;
i==selectedTab ? bgVPos = -22 : bgVPos = 0;
document.getElementById('tab'+i).style.backgroundPosition = "0 "+bgVPos+"px";
@@ -422,7 +427,7 @@ var ICEcoder = {
// Add a new value ready to indicate if this content has been changed
top.ICEcoder.changedContent.push(0);
top.ICEcoder.setLastOpenedFiles();
top.ICEcoder.setPreviousFiles();
},
// Create a new tab for a file
@@ -565,7 +570,7 @@ var ICEcoder = {
top.ICEcoder.changedContent.splice(closeTabNum-1,1);
top.parent.ICEcoder.redoTabHighlight(ICEcoder.selectedTab);
top.ICEcoder.setLastOpenedFiles();
top.ICEcoder.setPreviousFiles();
}
// Lastly, stop it from trying to also switch tab
top.ICEcoder.canSwitchTabs=false;
@@ -693,7 +698,19 @@ var ICEcoder = {
// Select or deselect file
selectDeselectFile: function(action,file) {
action == "select" ? file.style.backgroundColor="#888" : file.style.backgroundColor="transparent";
var isOpen;
top.ICEcoder.openFiles.indexOf(file.id.replace(/\|/g,"/")) > -1 ? isOpen = true : isOpen = false;
if (top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1] == file.id.replace(/\|/g,"/")) {
file.style.backgroundColor="#4499dd";
} else {
if (action=="select") {
file.style.backgroundColor="#888";
} else {
isOpen ? file.style.backgroundColor = "rgba(255,255,255,0.15)" : file.style.backgroundColor="transparent";
}
}
action == "select" ? file.style.color="#fff" : file.style.color="#eee";
},
@@ -789,7 +806,7 @@ var ICEcoder = {
top.ICEcoder.serverQueue("add","lib/file-control.php?action=rename&file="+renamedFile+"&oldFileName="+top.ICEcoder.rightClickedFile.replace(/\|/g,"/"));
top.ICEcoder.serverMessage('<b>Renaming to</b><br>'+renamedFile);
top.ICEcoder.setLastOpenedFiles();
top.ICEcoder.setPreviousFiles();
}
},
@@ -1392,27 +1409,27 @@ var ICEcoder = {
top.ICEcoder.dontSelect = true;
},
// Set the current lastOpenedFiles in the settings file
setLastOpenedFiles: function() {
var lastOpenedFiles;
// Set the current previousFiles in the settings file
setPreviousFiles: function() {
var previousFiles;
lastOpenedFiles = "";
previousFiles = "";
// Generate a comma seperated list
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
if (top.ICEcoder.openFiles[i]!="" && top.ICEcoder.openFiles[i].indexOf("[NEW]")==-1) {
lastOpenedFiles += top.ICEcoder.openFiles[i].replace(/\//g,"|");
if (i<top.ICEcoder.openFiles.length-1) {lastOpenedFiles += ","};
previousFiles += top.ICEcoder.openFiles[i].replace(/\//g,"|");
if (i<top.ICEcoder.openFiles.length-1) {previousFiles += ","};
}
}
if (lastOpenedFiles=="") {lastOpenedFiles="CLEAR"};
if (previousFiles=="") {previousFiles="CLEAR"};
// Then send through to the settings page to update setting
top.ICEcoder.serverQueue("add","lib/settings.php?saveFiles="+lastOpenedFiles);
top.ICEcoder.serverQueue("add","lib/settings.php?saveFiles="+previousFiles);
},
// Opens the last files we had open
autoOpenFiles: function() {
for (var i=0;i<=top.lastOpenFiles.length-1;i++) {
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.fullPath+top.lastOpenFiles[i].replace('|','/');
for (var i=0;i<=top.previousFiles.length-1;i++) {
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.fullPath+top.previousFiles[i].replace('|','/');
top.ICEcoder.thisFileFolderType='file';
top.ICEcoder.openFile();
}