From 572e000b6c271997d2c1469096b8794cf023bcc9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Jun 2014 07:03:03 -0400 Subject: [PATCH] refactor(edit) init --- lib/client/edit.js | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index d0ff8c40..ed4d427b 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -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) {