Clearing global vars

theme, tabsIndent, openLastFiles, tabWidth, previousFiles, showFileMenu
& foldStyle all now contained within ICEcoder object
showFileMenu is a function to ensure file manager menu continues to show
The few instances of i now have scope
Initing the var fileName
This is to reduce the number of global vars
The only global vars should now be ICEcoder, docRoot & iceRoot
This commit is contained in:
Matt Pass
2012-10-20 23:52:36 +01:00
parent 2988de5501
commit 13255bc58b
4 changed files with 51 additions and 44 deletions

View File

@@ -92,16 +92,16 @@ span.CodeMirror-matchhighlight {background: #555}
<script>
function createNewCMInstance(num) {
var fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
top.foldStyle = '<span style="position: absolute; display: inline-block; width: 13px; height: 13px; left: 0; background-color: #b00; color: #fff; text-align: center; cursor: pointer"><span style="position: relative; left: -1px">+</span></span> %N%';
var codeFoldTag = CodeMirror.newFoldFunction(CodeMirror.tagRangeFinder,top.foldStyle);
var codeFoldBrace = CodeMirror.newFoldFunction(CodeMirror.braceRangeFinder,top.foldStyle);
top.ICEcoder.foldStyle = '<span style="position: absolute; display: inline-block; width: 13px; height: 13px; left: 0; background-color: #b00; color: #fff; text-align: center; cursor: pointer"><span style="position: relative; left: -1px">+</span></span> %N%';
var codeFoldTag = CodeMirror.newFoldFunction(CodeMirror.tagRangeFinder,top.ICEcoder.foldStyle);
var codeFoldBrace = CodeMirror.newFoldFunction(CodeMirror.braceRangeFinder,top.ICEcoder.foldStyle);
window['cM'+num] = CodeMirror(document.body, {
mode: "application/x-httpd-php",
lineNumbers: true,
lineWrapping: true,
indentUnit: top.tabWidth,
tabSize: top.tabWidth,
indentUnit: top.ICEcoder.tabWidth,
tabSize: top.ICEcoder.tabWidth,
indentWithTabs: true,
electricChars: false,
onCursorActivity: function(thisCM) {
@@ -175,7 +175,7 @@ function createNewCMInstance(num) {
},
onGutterClick: !fileName || (fileName && fileName.indexOf(".js") == -1 && fileName.indexOf(".coffee") == -1 && fileName.indexOf(".php") && fileName.indexOf(".rb") == -1) ? codeFoldTag : codeFoldBrace,
extraKeys: {
"Tab": function(cm) {CodeMirror.commands[top.tabsIndent ? "defaultTab" : "insertTab"](cm);},
"Tab": function(cm) {CodeMirror.commands[top.ICEcoder.tabsIndent ? "defaultTab" : "insertTab"](cm);},
"Shift-Tab": "indentLess",
"Ctrl-Up": function() {},
"Ctrl-Down": function() {}