Working with FM menu and new functions

Setup namespaces for nav and 4 x list ID's
No longer updating fullscreen icon on change of mode
accountH is now fileNavH
Set the width of the 4 x lists -60px of width of file manager
account DIV no longer there and use new spritesheet positions for lock
icon
undo and redo functions added, plus indent function to handle more and
less indenting
autocomplete function added also
searchForSelected function added too, so not part of key handling
function, but function called upon, removed voke.fm usage
No longer need to change opacity levels on file manager icons
Stop using rightClickedFile and instead look to last item in
selectedFiles array
Function added to show/hide file menu, includes fade in/out effect
Function to handle clicking on file manager icons removed
Manual is now shown in popup at larger size
This commit is contained in:
Matt Pass
2014-02-21 09:26:55 +00:00
parent 116f8bdff7
commit 1bcc773bba
2 changed files with 154 additions and 126 deletions

View File

@@ -49,7 +49,7 @@ var ICEcoder = {
// Set our aliases
initAliases: function() {
var aliasArray = ["header","files","account","filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","charDisplay","byteDisplay"];
var aliasArray = ["header","files", "fileOptions", "optionsFile", "optionsEdit", "optionsRemote", "optionsHelp", "filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","charDisplay","byteDisplay"];
// Create our ID aliases
for (var i=0;i<aliasArray.length;i++) {
@@ -76,13 +76,6 @@ var ICEcoder = {
// Update the nesting indicator every 30ms
setInterval(ICEcoder.updateNestingIndicator,30);
// Setup fullscreen detection and change icon
screenIcon = top.get('screenMode');
sISrc = ["images/restored-screen.gif","images/full-screen.gif"];
document.addEventListener("fullscreenchange", function () {screenIcon.src = document.fullscreen ? sISrc[0] : sISrc[1];}, false);
document.addEventListener("mozfullscreenchange", function () {screenIcon.src = document.mozFullScreen ? sISrc[0] : sISrc[1];}, false);
document.addEventListener("webkitfullscreenchange", function () {screenIcon.src = document.webkitIsFullScreen ? sISrc[0] : sISrc[1];}, false);
// ICEcoder is ready to start using
top.ICEcoder.ready = true;
},
@@ -93,18 +86,18 @@ var ICEcoder = {
// Set our layout according to the browser size
setLayout: function(dontSetEditor) {
var winW, winH, headerH, accountH, tabsBarH, findBarH;
var winW, winH, headerH, fileNavH, tabsBarH, findBarH;
// Determin width & height available
winW = window.innerWidth;
winH = window.innerHeight;
// Apply sizes to various elements of the page
headerH = 25, accountH = 45, tabsBarH = 21, findBarH = 28;
headerH = 25, fileNavH = 45, tabsBarH = 21, findBarH = 28;
this.header.style.width = this.tabsBar.style.width = this.findBar.style.width = winW + "px";
this.files.style.width = this.editor.style.left = this.filesW + "px";
this.account.style.height = this.accountH + "px";
this.filesFrame.style.height = (winH-headerH-accountH) + "px";
this.optionsFile.style.width = this.optionsEdit.style.width = this.optionsRemote.style.width = this.optionsHelp.style.width = (this.filesW-60) + "px";
this.filesFrame.style.height = (winH-headerH-fileNavH) + "px";
this.nestValid.style.left = (this.filesW+10) + "px";
this.nestDisplay.style.left = (this.filesW+17) + "px";
top.ICEcoder.setTabWidths();
@@ -154,7 +147,7 @@ var ICEcoder = {
top.ICEcoder.filesW = top.ICEcoder.maxFilesW = top.ICEcoder.mouseX >=250 && top.ICEcoder.mouseX <= 400
? top.ICEcoder.mouseX : top.ICEcoder.mouseX <250 ? 250 : 400;
// Set various widths based on the new width
top.ICEcoder.files.style.width = top.ICEcoder.account.style.width = top.ICEcoder.filesFrame.style.width = top.ICEcoder.filesW + "px";
top.ICEcoder.files.style.width = top.ICEcoder.filesFrame.style.width = top.ICEcoder.filesW + "px";
top.ICEcoder.setLayout();
top.ICEcoder.draggingFilesW = true;
}
@@ -169,7 +162,7 @@ var ICEcoder = {
lockIcon = top.filesFrame.contentWindow.document.getElementById('fmLock');
ICEcoder.lockedNav = !ICEcoder.lockedNav;
lockIcon.style.backgroundPosition = ICEcoder.lockedNav ? "-64px -16px" : "-80px -16px";
lockIcon.style.backgroundPosition = ICEcoder.lockedNav ? "0 0" : "-16px 0";
},
// Show/hide the plugins on demand
@@ -200,6 +193,34 @@ var ICEcoder = {
top.ICEcoder.savedPoints[top.ICEcoder.selectedTab-1] = cM.changeGeneration();
},
// Undo last change
undo: function() {
var cM;
cM = ICEcoder.getcMInstance();
cM.undo();
},
// Redo change
redo: function() {
var cM;
cM = ICEcoder.getcMInstance();
cM.redo();
},
// Indent more/less
indent: function(moreLess) {
var cM;
cM = ICEcoder.getcMInstance();
if (moreLess=="more") {
top.ICEcoder.content.contentWindow.CodeMirror.commands.indentMore(cM);
} else {
top.ICEcoder.content.contentWindow.CodeMirror.commands.indentLess(cM);
}
},
// Move current line up/down
moveLines: function(dir) {
var cM, lineStart, lineEnd, swapLineNo, swapLine;
@@ -528,6 +549,14 @@ var ICEcoder = {
}
},
// Autocomplete
autocomplete: function() {
var cM;
cM = ICEcoder.getcMInstance();
top.ICEcoder.content.contentWindow.CodeMirror.commands.autocomplete(cM);
},
// Paste a URL, locally or absolutely if CTRL/Cmd key down
pasteURL: function(url) {
var cM;
@@ -539,6 +568,21 @@ var ICEcoder = {
cM.replaceSelection(url);
},
// Search for selected text online
searchForSelected: function() {
if (top.ICEcoder.caretLocType) {
if (top.ICEcoder.getcMInstance().getSelection() != "") {
var searchPrefix = top.ICEcoder.caretLocType.toLowerCase()+" ";
if (top.ICEcoder.caretLocType=="Content") {
searchPrefix = "";
}
window.open("http://www.google.com/#output=search&q="+searchPrefix+top.ICEcoder.getcMInstance().getSelection());
} else {
top.ICEcoder.message('No text selected to search on');
}
}
},
// ==============
// FILES
// ==============
@@ -642,12 +686,6 @@ var ICEcoder = {
document.findAndReplace.target[2].innerHTML = !top.ICEcoder.selectedFiles[0] ? "all files" : "selected files";
document.findAndReplace.target[3].innerHTML = !top.ICEcoder.selectedFiles[0] ? "all filenames" : "selected filenames";
// Finally, show or grey out the relevant file manager icons
top.ICEcoder.fMIconVis('fMOpen',top.ICEcoder.selectedFiles.length == 1 ? 1 : 0.3);
top.ICEcoder.fMIconVis('fMNewFile',top.ICEcoder.selectedFiles.length == 1 && top.ICEcoder.thisFileFolderType == "folder" ? 1 : 0.3);
top.ICEcoder.fMIconVis('fMNewFolder',top.ICEcoder.selectedFiles.length == 1 && top.ICEcoder.thisFileFolderType == "folder" ? 1 : 0.3);
top.ICEcoder.fMIconVis('fMDelete',top.ICEcoder.selectedFiles.length > 0 ? 1 : 0.3);
top.ICEcoder.fMIconVis('fMRename',top.ICEcoder.selectedFiles.length == 1 ? 1 : 0.3);
// Hide the file menu incase it's showing
top.ICEcoder.hideFileMenu();
},
@@ -692,7 +730,7 @@ var ICEcoder = {
newFolder: function() {
var shortURL, newFolder;
shortURL = top.ICEcoder.rightClickedFile.replace(/\|/g,"/");
shortURL = top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/");
newFolder = top.ICEcoder.getInput('Enter new folder name at '+shortURL,'');
if (newFolder) {
newFolder = (shortURL + "/" + newFolder).replace(/\/\//,"/");
@@ -742,7 +780,7 @@ var ICEcoder = {
// Open selected files
openFilesFromList: function(fileList) {
for (var i=0;i<fileList.length;i++) {
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=fileList[i].replace('|','/');
top.ICEcoder.thisFileFolderLink=fileList[i].replace('|','/');
top.ICEcoder.thisFileFolderType='file';
top.ICEcoder.openFile();
}
@@ -787,8 +825,8 @@ var ICEcoder = {
var shortURL, fileName, i;
if (!oldName) {
shortURL = top.ICEcoder.rightClickedFile.replace(/\|/g,"/");
oldName = top.ICEcoder.rightClickedFile.replace(/\|/g,"/");
shortURL = top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/");
oldName = top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/");
} else {
shortURL = oldName.replace(/\|/g,"/");
}
@@ -907,12 +945,39 @@ var ICEcoder = {
}
},
// Show/hide file manager nav options
showHideFileNav: function(vis,elem) {
var options = ["optionsFile","optionsEdit","optionsRemote","optionsHelp"];
if (vis=="hide") {
fileNavInt = setTimeout(function() {
for (var i=0; i<options.length; i++) {
top.ICEcoder.showHide('hide',top.get(options[i]));
top.get(options[i]+'Nav').style.color = '';
}
},150);
} else {
for (var i=0; i<options.length; i++) {
top.ICEcoder.showHide('hide',top.get(options[i]));
top.get(options[i]+'Nav').style.color = '';
}
}
get('fileOptions').style.opacity = 0;
if (vis=="show") {
if ("undefined" != typeof fileNavInt) {
clearTimeout(fileNavInt);
}
top.ICEcoder.showHide(vis,top.get(elem));
top.get(elem+'Nav').style.color = '#fff';
get('fileOptions').style.opacity = 1;
}
},
// Show menu on right clicking in file manager
showMenu: function(evt) {
var menuType, menuHeight, winH, fmYPos;
if ( top.ICEcoder.selectedFiles.length == 0 ||
top.ICEcoder.selectedFiles.indexOf(top.ICEcoder.rightClickedFile.replace(/\//g,"|")) == -1) {
top.ICEcoder.selectedFiles.indexOf(top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\//g,"|")) == -1) {
top.ICEcoder.selectFileFolder(evt);
}
@@ -1051,7 +1116,7 @@ var ICEcoder = {
// Chmod on files
if (action=="chmod") {
// Get short URL for our file and get our target elem based on this
shortURL = top.ICEcoder.rightClickedFile.replace(/\|/g,"/");
shortURL = top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/");
targetElem = top.get('filesFrame').contentWindow.document.getElementById(shortURL.replace(/\//g,"|")+"_perms");
// Set the new perms
targetElem.innerHTML = perms;
@@ -1066,30 +1131,6 @@ var ICEcoder = {
}
},
// Carry out actions when clicking icons above file manager
fMIcon: function(action) {
if (action=="save" && ICEcoder.openFiles.length>0) {
top.ICEcoder.saveFile();
}
if (ICEcoder.selectedFiles.length==1) {
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.ICEcoder.selectedFiles[0].replace('|','/');
if (action=="open" && ICEcoder.selectedFiles[0].indexOf(".")>-1) {
top.ICEcoder.thisFileFolderType='file';
top.ICEcoder.openFile();
}
else if (action=="newFile") {top.ICEcoder.newFile();}
else if (action=="newFolder") {top.ICEcoder.newFolder();}
else if (action=="rename") {top.ICEcoder.renameFile(top.ICEcoder.rightClickedFile);}
}
if (action=="delete" && ICEcoder.selectedFiles.length>0) {
top.ICEcoder.deleteFiles();
}
},
// Refresh file manager
refreshFileManager: function() {
top.ICEcoder.showHide('show',top.get('loadingMask'));
@@ -1747,7 +1788,7 @@ var ICEcoder = {
autoOpenFiles: function() {
if (top.ICEcoder.previousFiles.length>0 && top.ICEcoder.ask('Open previous files?\n\n'+top.ICEcoder.previousFiles.length+' files:\n'+top.ICEcoder.previousFiles.join('\n').replace(/\|/g,"/").replace(new RegExp(top.docRoot+top.iceRoot,'gi'),""))) {
for (var i=0;i<top.ICEcoder.previousFiles.length;i++) {
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.ICEcoder.previousFiles[i].replace('|','/');
top.ICEcoder.thisFileFolderLink=top.ICEcoder.previousFiles[i].replace('|','/');
top.ICEcoder.thisFileFolderType='file';
top.ICEcoder.openFile();
}
@@ -1773,7 +1814,7 @@ var ICEcoder = {
var sectionExtra;
sectionExtra = section ? "#"+section : "";
top.get('mediaContainer').innerHTML = '<iframe src="http://icecoder.net/manual?version='+version+sectionExtra+'" class="whiteGlow" style="width: 500px; height: 500px"></iframe>';
top.get('mediaContainer').innerHTML = '<iframe src="http://icecoder.net/manual?version='+version+sectionExtra+'" class="whiteGlow" style="width: 800px; height: 470px"></iframe>';
top.ICEcoder.showHide('show',top.get('blackMask'));
},
@@ -2098,9 +2139,6 @@ var ICEcoder = {
top.get('tab'+i).style.color = tColor;
top.get('tab'+i).style.background = i==selectedTab ? top.ICEcoder.tabBGcurrent : top.ICEcoder.tabBGopen;
}
if (top.ICEcoder.getcMInstance(selectedTab)) {
top.ICEcoder.fMIconVis('fMSave',ICEcoder.savedPoints[selectedTab-1]!=top.ICEcoder.getcMInstance(selectedTab).changeGeneration() ? 1 : 0.3);
}
},
// Close the tab upon request
@@ -2429,16 +2467,7 @@ var ICEcoder = {
// CTRL/Cmd+I (Get info)
} else if(key==73 && (evt.ctrlKey||top.ICEcoder.cmdKey) && area == "content") {
top.ICEcoder.resetKeys(evt);
var searchPrefix = top.ICEcoder.caretLocType.toLowerCase()+" ";
if (top.ICEcoder.caretLocType=="CSS"||top.ICEcoder.caretLocType=="PHP") {
window.open("http://voke.fm/"+searchPrefix+top.ICEcoder.getcMInstance().getSelection());
} else {
if (top.ICEcoder.caretLocType=="Content") {
searchPrefix = "";
}
window.open("http://www.google.com/#output=search&q="+searchPrefix+top.ICEcoder.getcMInstance().getSelection());
}
top.ICEcoder.searchForSelected();
return false;
// CTRL/Cmd+right arrow (Next tab)