stickyTab, login, plugin & settings improvements/features

New vars for stickyTab and plugin interval refs
New login container, adjusts to width of file manager
Upon login, slide login box up to reveal icons
New vars to allow stickyTab on CTRL+S+Enter
Improvement so you don't end up with a locked nav thats collapsed
Fix so we only switchtab if we have associated CM instance
Also updates found results display on switching tab
SwitchMode only does this if there is a filename (tab name) available
Plugin timers now created under vars so they can be cleared
If there is a login attempt, slide login box up to reveal icons
New function to show settings screen on demand
New function to update theme, tabsIndent, lockedNav, visibleTabs & file manager
(This is so changed settings can be applied straight away)
File manager refresh only happens if it needs to, for efficiency
This commit is contained in:
Matt Pass
2012-05-01 08:18:46 +01:00
parent ed8fb0dd67
commit c56af14f52

View File

@@ -25,13 +25,16 @@ var ICEcoder = {
mouseDown: false, // If the mouse is down or not
draggingFilesW: false, // If we're dragging the file manager width or not
serverQueueItems: [], // Array of URLs to call in order
stickyTab: false, // If we have a sticky tab open or not
stickyTabWindow: false, // Target variable for the sticky tab window
pluginIntervalRefs: [], // Array of plugin interval refs
// Don't consider these tags as part of nesting as they're singles, JS, PHP or Ruby code blocks
tagNestExceptions: ["!DOCTYPE","meta","link","img","br","hr","input","script","?php","?","%"],
// On load, set aliases, set the layout and get the nest location
init: function() {
var aliasArray = ["header","files","account","fmLock","filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","charDisplay"];
init: function(login) {
var aliasArray = ["header","files","account","accountLogin","fmLock","filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","charDisplay"];
// Create our ID aliases
for (var i=0;i<aliasArray.length;i++) {
@@ -43,6 +46,12 @@ var ICEcoder = {
// Hide the loading screen
top.document.getElementById('loadingMask').style.visibility = "hidden";
// If we're logging in, slide the login area to reveal the icons
if (login) {
top.document.getElementById('accountLogin').style.top = "-50px";
setTimeout(function() {top.document.getElementById('accountLoginContainer').style.display = "none";},300);
}
},
// Set our layout according to the browser size
@@ -56,7 +65,7 @@ var ICEcoder = {
// Apply sizes to various elements of the page
headerH = 40, footerH = 30, accountH = 50, tabsBarH = 21, findBarH = 28;
header.style.width = tabsBar.style.width = findBar.style.width = winW + "px";
files.style.width = editor.style.left = this.filesW + "px";
files.style.width = accountLogin.style.width = editor.style.left = this.filesW + "px";
account.style.height = accountH + "px";
fmLock.style.marginLeft = (this.filesW-27) + "px";
filesFrame.style.height = (winH-headerH-accountH-footerH) + "px";
@@ -238,12 +247,17 @@ var ICEcoder = {
} else {
top.ICEcoder.saveFile();
}
top.ICEcoder.ctrlKeyDown = false;
top.ICEcoder.stickyTabMaybe = true;
return false;
// CTRL+Enter (Open Webpage)
} else if(key==13 && top.ICEcoder.ctrlKeyDown==true && top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1] != "/[NEW]") {
window.open(top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]);
if (top.ICEcoder.stickyTabMaybe) {
top.ICEcoder.stickyTabWindow = window.open(top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1],"stickyTab");
top.ICEcoder.stickyTab = true;
} else {
window.open(top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]);
}
top.ICEcoder.ctrlKeyDown = false;
return false;
@@ -269,7 +283,7 @@ var ICEcoder = {
key = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
if (key==17) {top.ICEcoder.ctrlKeyDown = false;}
if (key==17) {top.ICEcoder.ctrlKeyDown = false; top.ICEcoder.stickyTabMaybe = false;}
if (key==16) {top.ICEcoder.shiftKeyDown = false;}
if (key==46) {top.ICEcoder.delKeyDown = false;}
},
@@ -277,7 +291,7 @@ var ICEcoder = {
// Set the width of the file manager on demand
changeFilesW: function(expandContract) {
if (!ICEcoder.lockedNav) {
if (!ICEcoder.lockedNav||(ICEcoder.lockedNav && ICEcoder.filesW==ICEcoder.minFilesW)) {
if ("undefined" != typeof ICEcoder.changeFilesInt) {clearInterval(ICEcoder.changeFilesInt)};
ICEcoder.changeFilesInt = setInterval(function() {ICEcoder.changeFilesWStep(expandContract)},10);
}
@@ -328,21 +342,26 @@ var ICEcoder = {
ICEcoder.selectedTab = newTab;
cM = ICEcoder.getcMInstance();
// Switch mode to HTML, PHP, CSS etc
ICEcoder.switchMode();
if (cM) {
// Switch mode to HTML, PHP, CSS etc
ICEcoder.switchMode();
// Set all cM instances to be hidden, then make our selected instance visable
for (var i=0;i<ICEcoder.cMInstances.length;i++) {
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption('theme',top.theme+' hidden');
// Set all cM instances to be hidden, then make our selected instance visable
for (var i=0;i<ICEcoder.cMInstances.length;i++) {
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption('theme',top.theme+' hidden');
}
cM.setOption('theme',top.theme+' visible');
// Focus on & refresh our selected instance
cM.focus();
cM.refresh();
// Highlight the selected tab
ICEcoder.redoTabHighlight(ICEcoder.selectedTab);
// Redo our find display
ICEcoder.findReplace('find',true);
}
cM.setOption('theme',top.theme+' visible');
// Focus on & refresh our selected instance
cM.focus();
cM.refresh();
// Highlight the selected tab
ICEcoder.redoTabHighlight(ICEcoder.selectedTab);
},
// Reset all tabs to be without a highlight and then highlight the selected
@@ -927,14 +946,16 @@ var ICEcoder = {
cM = ICEcoder.getcMInstance();
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
if (fileName.indexOf('.js')>0) {
cM.setOption("mode","javascript");
} else if (fileName.indexOf('.rb')>0) {
cM.setOption("mode","ruby");
} else if (fileName.indexOf('.css')>0) {
cM.setOption("mode","css");
} else {
cM.setOption("mode","application/x-httpd-php");
if (fileName) {
if (fileName.indexOf('.js')>0) {
cM.setOption("mode","javascript");
} else if (fileName.indexOf('.rb')>0) {
cM.setOption("mode","ruby");
} else if (fileName.indexOf('.css')>0) {
cM.setOption("mode","css");
} else {
cM.setOption("mode","application/x-httpd-php");
}
}
},
@@ -960,19 +981,22 @@ var ICEcoder = {
},
// Start running plugin intervals according to given specifics
startPluginIntervals: function(plugURL,plugTarget,plugTimer) {
startPluginIntervals: function(plugRef,plugURL,plugTarget,plugTimer) {
// For this window instances
if (plugTarget=="_parent"||plugTarget=="_top"||plugTarget=="_self"||plugTarget=="") {
setInterval('window.location=\''+plugURL+'\'',plugTimer*1000*60);
top.ICEcoder['plugTimer'+plugRef] = setInterval('window.location=\''+plugURL+'\'',plugTimer*1000*60);
// for fileControl iframe instances
} else if (plugTarget.indexOf("fileControl")==0) {
setInterval(function() {top.ICEcoder.serverQueue("add",plugURL);top.ICEcoder.serverMessage(plugTarget.split(":")[1]);},plugTimer*1000*60);
top.ICEcoder['plugTimer'+plugRef] = setInterval(function() {top.ICEcoder.serverQueue("add",plugURL);top.ICEcoder.serverMessage(plugTarget.split(":")[1]);},plugTimer*1000*60);
// for _blank or named target window instances
} else {
setInterval('window.open(\''+plugURL+'\',\''+plugTarget+'\')',plugTimer*1000*60);
top.ICEcoder['plugTimer'+plugRef] = setInterval('window.open(\''+plugURL+'\',\''+plugTarget+'\')',plugTimer*1000*60);
}
// push the plugin ref into our array
top.ICEcoder.pluginIntervalRefs.push(plugRef);
},
// Comment or uncomment line on keypress
@@ -1363,13 +1387,65 @@ var ICEcoder = {
},
// Refresh file manager on demand
refreshFileManager: function() {
refreshFileManager: function(loginAttempt) {
top.document.getElementById('loadingMask').style.visibility = "visible";
top.ICEcoder.filesFrame.src="files.php";
top.ICEcoder.filesFrame.style.opacity="0";
top.ICEcoder.filesFrame.onload = function() {
top.ICEcoder.filesFrame.style.opacity="1";
top.document.getElementById('loadingMask').style.visibility = "hidden";
if (loginAttempt) {
if (loginAttempt == "loginOK") {
top.document.getElementById('accountLogin').style.top = "-50px";
setTimeout(function() {top.document.getElementById('accountLoginContainer').style.display = "none";},300);
} else {
alert('Sorry, that\'s not correct.');
}
}
}
},
// Show the settings screen
settingsScreen: function(vis) {
if (vis=="show") {
top.document.getElementById('mediaContainer').innerHTML = '<iframe src="lib/settings-screen.php" class="whiteGlow" style="width: 970px; height: 600px"></iframe>';
}
top.ICEcoder.showHide(vis,top.document.getElementById('blackMask'));
},
// Update the settings used when we make a change to them
useNewSettings: function(themeURL,tabsIndent,codeAssist,lockedNav,visibleTabs,refreshFM) {
var styleNode, strCSS, cMCSS;
// Add new stylesheet for selected theme
top.theme = themeURL.slice(themeURL.lastIndexOf("/")+1,themeURL.lastIndexOf("."));
if (top.theme=="editor") {top.theme="icecoder"};
styleNode = document.createElement('link');
styleNode.setAttribute('rel', 'stylesheet');
styleNode.setAttribute('type', 'text/css');
styleNode.setAttribute('href', themeURL);
top.ICEcoder.content.contentWindow.document.getElementsByTagName('head')[0].appendChild(styleNode);
top.ICEcoder.switchTab(top.ICEcoder.selectedTab);
// Tabs indent setting
top.tabsIndent = tabsIndent;
// Check/uncheck Code Assist setting
top.document.getElementById('codeAssist').checked = codeAssist;
// Unlock/lock the file manager
if (lockedNav != top.ICEcoder.lockedNav) {top.ICEcoder.lockUnlockNav()};
if (!lockedNav) {
ICEcoder.changeFilesW('contract');
top.document.getElementById('fileMenu').style.display='none';
}
// Show visible tabs or not
document.all ? strCSS = 'rules' : strCSS = 'cssRules';
cMCSS = ICEcoder.content.contentWindow.document;
visibleTabs ? cMCSS.styleSheets[2][strCSS][5].style['content'] = '"\\21e5"' : cMCSS.styleSheets[2][strCSS][5].style['content'] = '" "';
// Finally, refresh the file manager if we need to
if (refreshFM) {top.ICEcoder.refreshFileManager()};
}
};