From 6f960c3760c57f86ebb68ebadeafc0c4b29e8ac4 Mon Sep 17 00:00:00 2001 From: Van Date: Thu, 25 Sep 2014 11:35:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=91=E8=8A=82=E7=82=B9=20bug=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/wide.json | 5 +++-- static/js/hotkeys.js | 20 +++++++++++--------- static/js/tree.js | 23 ++++++++++------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/conf/wide.json b/conf/wide.json index 790d257..bed25cf 100644 --- a/conf/wide.json +++ b/conf/wide.json @@ -25,9 +25,10 @@ "Files": [ "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\1123", "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\main.go", - "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\hello\\2.json" + "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\hello\\2.json", + "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\hello\\main.go" ], - "CurrentFile": "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\1123" + "CurrentFile": "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\hello\\main.go" } } ] diff --git a/static/js/hotkeys.js b/static/js/hotkeys.js index 4567141..847089b 100644 --- a/static/js/hotkeys.js +++ b/static/js/hotkeys.js @@ -57,9 +57,10 @@ var hotkeys = { which: 117 } }, - _bindFileTree: function() { - // TODO: 滚动处理 - $("#files").keydown(function(event) { + _bindFileTree: function () { + $("#files").keydown(function (event) { + event.preventDefault(); + switch (event.which) { case 46: // 删除 tree.removeIt(); @@ -132,8 +133,11 @@ var hotkeys = { } } - wide.curNode = node; - tree.fileTree.selectNode(node); + if (node) { + wide.curNode = node; + tree.fileTree.selectNode(node); + } + $("#files").focus(); break; case 37: // 左 @@ -168,15 +172,13 @@ var hotkeys = { break; } - - event.preventDefault(); }); }, - init: function() { + init: function () { this._bindFileTree(); var hotKeys = this.defaultKeyMap; - $(document).keydown(function(event) { + $(document).keydown(function (event) { if (event.ctrlKey === hotKeys.goEditor.ctrlKey && event.which === hotKeys.goEditor.which) { // Ctrl+0 焦点切换到当前编辑器 if (wide.curEditor) { diff --git a/static/js/tree.js b/static/js/tree.js index a3e58c3..2dec82a 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -136,16 +136,16 @@ var tree = { }); }, _onClick: function (treeNode) { - if (wide.curNode) { - for (var i = 0, ii = editors.data.length; i < ii; i++) { - // 该节点文件已经打开 - if (editors.data[i].id === treeNode.tId) { - editors.tabs.setCurrent(treeNode.tId); - wide.curNode = treeNode; - wide.curEditor = editors.data[i].editor; - wide.curEditor.focus(); - return false; - } + wide.curNode = treeNode; + + for (var i = 0, ii = editors.data.length; i < ii; i++) { + // 该节点文件已经打开 + if (editors.data[i].id === treeNode.tId) { + editors.tabs.setCurrent(treeNode.tId); + wide.curNode = treeNode; + wide.curEditor = editors.data[i].editor; + wide.curEditor.focus(); + return false; } } @@ -166,12 +166,9 @@ var tree = { return false; } - wide.curNode = treeNode; - if ("img" === data.mode) { // 是图片文件的话新建 tab 打开 // 最好是开 tab,但这个最终取决于浏览器设置 var w = window.open(data.path); - return false; }