From 82c350444ae31ec7bea3645b80cfe37b723af1be Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Thu, 9 Feb 2012 07:53:59 +0000 Subject: [PATCH] Alterations to work with dynamic CM instances Various functions updates to work with dynamically generated CM instances New variables added to track the CM instance refs & next avail number CTRL+G now focuses on go to line box A few lines of now useless code removed --- lib/coder.js | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/lib/coder.js b/lib/coder.js index 5f77832..a2f2127 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -15,6 +15,8 @@ var ICEcoder = { delKeyDown: false, // Indicates if DEL keydown canSwitchTabs: true, // Stops switching of tabs when trying to close openFiles: [], // Array of open file URLs + cMInstances: [], // List of CodeMirror instance no's + nextcMInstance: 1, // Next available CodeMirror instance no selectedFiles: [], // Array of selected files findMode: false, // States if we're in find/replace mode lockedNav: false, // Nav is locked or not @@ -34,7 +36,6 @@ var ICEcoder = { // Set layout & the nest location ICEcoder.setLayout(); - ICEcoder.getNestLocation('yes'); }, // Set out our layout according to the browser size @@ -196,6 +197,11 @@ var ICEcoder = { top.document.getElementById('find').focus(); return false; + // CTRL+G (Go to Line) + } else if(key==71 && top.ICEcoder.ctrlKeyDown==true) { + top.document.getElementById('goToLineNo').focus(); + return false; + // CTRL+S (Save) } else if(key==83 && top.ICEcoder.ctrlKeyDown==true) { top.ICEcoder.saveFile(); @@ -261,9 +267,9 @@ var ICEcoder = { // Switch mode ICEcoder.switchMode(); - // Set all 10 cM instances to be hidden, then make our selected instance visable - for (var i=1;i<=10;i++) { - ICEcoder.content.contentWindow['cM'+i].setOption('theme','icecoder hidden'); + // Set all cM instances to be hidden, then make our selected instance visable + for (var i=0;i0 ? ICEcoder.selectedTab-=1 : ICEcoder.selectedTab = 0; if (ICEcoder.openFiles.length>0 && ICEcoder.selectedTab==0) {ICEcoder.selectedTab=1}; - // clear & hide the code textarea if we have no tabs open + // hide the content area if we have no tabs open if (ICEcoder.openFiles.length==0) { - // clear the value & HTML of the code textarea and also hide it - cM = ICEcoder.getcMInstance(); - cM.setValue(''); - cM.clearHistory(); ICEcoder.tD.getElementById('content').style.visibility = "hidden"; } else { // Switch the mode & the tab @@ -826,11 +841,11 @@ var ICEcoder = { var cM; if (newTab=="new") { - cM = top.ICEcoder.content.contentWindow['cM'+ICEcoder.openFiles.length]; + cM = top.ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[ICEcoder.selectedTab-1]]; } else if (ICEcoder.openFiles.length==0) { cM = top.ICEcoder.content.contentWindow['cM1']; } else { - cM = top.ICEcoder.content.contentWindow['cM'+ICEcoder.selectedTab]; + cM = top.ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[ICEcoder.selectedTab-1]]; } return cM; },