diff --git a/lib/client/edit.js b/lib/client/edit.js index 90e56108..a5649643 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -1,4 +1,4 @@ -var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; +var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format; (function(CloudCmd, Util, DOM) { 'use strict'; @@ -16,7 +16,8 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; Menu, - Editor = 'edward', + EditorName = 'edward', + editor, TITLE = 'Edit', @@ -28,7 +29,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; exec.ifExist(Menu, 'hide'); }, afterShow: function() { - edward + editor .moveCursorTo(0, 0) .focus(); } @@ -86,11 +87,11 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; if (error) { Images.hide(); } else { - edward.setValueFirst(path, data); + editor.setValueFirst(path, data); setMsgChanged(name); - edward + editor .setModeForPath(name) .setOption('fontSize', 16); @@ -109,12 +110,12 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; this.create = function(element) { Element = element; - edward.on('save', function(value) { + editor.on('save', function(value) { var size = Format.size(value); DOM.setCurrentSize(size); }); - edward.addCommand({ + editor.addCommand({ name : 'hide', bindKey : { win: 'Esc', mac: 'Esc' }, exec : function () { @@ -130,15 +131,15 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; if (error) Dialog.alert(TITLE, error); else if (config.editor) - Editor = config.editor; + EditorName = config.editor; callback(); }); } function loadFiles(element, callback) { - var prefix = CloudCmd.PREFIX + '/' + Editor, - url = prefix + '/' + Editor + '.js'; + var prefix = CloudCmd.PREFIX + '/' + EditorName, + url = prefix + '/' + EditorName + '.js'; Util.time(Name + ' load'); @@ -148,9 +149,9 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; prefix: prefix }; - edward = window[Editor]; + editor = window[EditorName]; - edward(element, options, function() { + editor(element, options, function() { Util.timeEnd(Name + ' load'); Loading = false; exec(callback); @@ -173,27 +174,27 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; params.y -= 27; }, afterClick: function() { - edward.focus(); + editor.focus(); } }, menuData = { 'Save Ctrl+S' : function() { - edward.save(); + editor.save(); }, 'Go To Line Ctrl+L' : function() { - edward.goToLine(); + editor.goToLine(); }, 'Select All Ctrl+A' : function() { - edward.selectAll(); + editor.selectAll(); }, 'Delete Del' : function() { - edward.remove('right'); + editor.remove('right'); }, 'Beautify Ctrl+B' : function() { - edward.beautify(); + editor.beautify(); }, 'Minify Ctrl+M' : function() { - edward.minify(); + editor.minify(); }, 'Close Esc' : function() { Edit.hide(); @@ -216,13 +217,13 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; } function isChanged(fn) { - var is = edward.isChanged(); + var is = editor.isChanged(); if (!is) fn(); else Dialog.confirm(TITLE, MSG_CHANGED).then(function() { - edward.save(); + editor.save(); fn(); }).catch(fn); }