树节点 bug 修改

This commit is contained in:
Van 2014-09-25 11:35:28 +08:00
parent dbf3b37741
commit 6f960c3760
3 changed files with 24 additions and 24 deletions

View File

@ -25,9 +25,10 @@
"Files": [ "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\\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\\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"
} }
} }
] ]

View File

@ -57,9 +57,10 @@ var hotkeys = {
which: 117 which: 117
} }
}, },
_bindFileTree: function() { _bindFileTree: function () {
// TODO: 滚动处理 $("#files").keydown(function (event) {
$("#files").keydown(function(event) { event.preventDefault();
switch (event.which) { switch (event.which) {
case 46: // 删除 case 46: // 删除
tree.removeIt(); tree.removeIt();
@ -132,8 +133,11 @@ var hotkeys = {
} }
} }
wide.curNode = node; if (node) {
tree.fileTree.selectNode(node); wide.curNode = node;
tree.fileTree.selectNode(node);
}
$("#files").focus(); $("#files").focus();
break; break;
case 37: // 左 case 37: // 左
@ -168,15 +172,13 @@ var hotkeys = {
break; break;
} }
event.preventDefault();
}); });
}, },
init: function() { init: function () {
this._bindFileTree(); this._bindFileTree();
var hotKeys = this.defaultKeyMap; var hotKeys = this.defaultKeyMap;
$(document).keydown(function(event) { $(document).keydown(function (event) {
if (event.ctrlKey === hotKeys.goEditor.ctrlKey if (event.ctrlKey === hotKeys.goEditor.ctrlKey
&& event.which === hotKeys.goEditor.which) { // Ctrl+0 焦点切换到当前编辑器 && event.which === hotKeys.goEditor.which) { // Ctrl+0 焦点切换到当前编辑器
if (wide.curEditor) { if (wide.curEditor) {

View File

@ -136,16 +136,16 @@ var tree = {
}); });
}, },
_onClick: function (treeNode) { _onClick: function (treeNode) {
if (wide.curNode) { wide.curNode = treeNode;
for (var i = 0, ii = editors.data.length; i < ii; i++) {
// 该节点文件已经打开 for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.data[i].id === treeNode.tId) { // 该节点文件已经打开
editors.tabs.setCurrent(treeNode.tId); if (editors.data[i].id === treeNode.tId) {
wide.curNode = treeNode; editors.tabs.setCurrent(treeNode.tId);
wide.curEditor = editors.data[i].editor; wide.curNode = treeNode;
wide.curEditor.focus(); wide.curEditor = editors.data[i].editor;
return false; wide.curEditor.focus();
} return false;
} }
} }
@ -166,12 +166,9 @@ var tree = {
return false; return false;
} }
wide.curNode = treeNode;
if ("img" === data.mode) { // 是图片文件的话新建 tab 打开 if ("img" === data.mode) { // 是图片文件的话新建 tab 打开
// 最好是开 tab但这个最终取决于浏览器设置 // 最好是开 tab但这个最终取决于浏览器设置
var w = window.open(data.path); var w = window.open(data.path);
return false; return false;
} }