树节点 bug 修改
This commit is contained in:
parent
dbf3b37741
commit
6f960c3760
|
@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue