refactor(edit) init

This commit is contained in:
coderaiser 2014-06-02 07:03:03 -04:00
parent ab2a064544
commit 572e000b6c

View file

@ -22,7 +22,20 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
Events = DOM.Events,
Dialog = DOM.Dialog,
Images = DOM.Images,
Element, JSHintConfig, EditConfig;
Element, JSHintConfig, EditConfig,
ConfigView = {
beforeClose: function() {
isChanged();
if (Menu)
Menu.hide();
},
afterShow: function() {
Ace.clearSelection();
Ace.moveCursorTo(0, 0);
Ace.focus();
}
};
function init() {
Loading = true;
@ -38,12 +51,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
onMenu,
isStr = Util.isString(value),
name = Info.name,
isDir = Info.isDir,
focus = function() {
Ace.clearSelection();
Ace.moveCursorTo(0, 0);
Ace.focus();
};
isDir = Info.isDir;
if (!Loading) {
Images.showLoad();
@ -66,9 +74,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
Events.addOnce('contextmenu', Element, onMenu)
.add(Element, {
drop : onDrop,
dragover : function(event) {
event.preventDefault();
}
dragover : DOM.preventDefault
});
}
@ -93,15 +99,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
var UndoManager = ace.require('ace/undomanager').UndoManager;
Ace.setValue(Value);
CloudCmd.View.show(Element, {
beforeClose: function() {
isChanged();
if (Menu)
Menu.hide();
},
afterShow: focus
});
CloudCmd.View.show(Element, ConfigView);
Session.setUndoManager(new UndoManager());
}, function(callback) {