树节点初始化状态 bug 修改

This commit is contained in:
Van 2014-11-17 11:37:26 +08:00
parent 2f0643c940
commit 2252a50979
4 changed files with 37 additions and 8 deletions

View File

@ -176,6 +176,10 @@
} }
}); });
$(window).resize(function () {
$(".dialog-background").height($("body").height());
});
if (typeof settings.afterInit === "function") { if (typeof settings.afterInit === "function") {
settings.afterInit(); settings.afterInit();
} }
@ -232,7 +236,7 @@
_document.ondragstart = null; _document.ondragstart = null;
_document.onselectstart = null; _document.onselectstart = null;
_document.onselect = null; _document.onselect = null;
} };
}); });
}, },
_close: function (id, settings) { _close: function (id, settings) {

View File

@ -63,7 +63,20 @@ var session = {
// expand tree // expand tree
for (var j = 0, jj = fileTree.length; j < jj; j++) { for (var j = 0, jj = fileTree.length; j < jj; j++) {
if (nodes[i].path === fileTree[j]) { if (nodes[i].path === fileTree[j]) {
tree.fileTree.expandNode(nodes[i], true, false, true); // 当父节点都展开时,才展开该节点
var parents = tree.getAllParents(tree.fileTree.getNodeByTId(nodes[i].tId)),
isOpen = true;
for (var l = 0, max = parents.length; l < max; l++) {
if (parents[l].open === false) {
isOpen = false;
}
}
if (isOpen) {
tree.fileTree.expandNode(nodes[i], true, false, true);
} else {
// 设置状态
nodes[i].open = true;
}
break; break;
} }
} }

View File

@ -77,7 +77,19 @@ var tree = {
return paths; return paths;
}, },
_isParents: function (tId, parentTId) { getAllParents: function (node, parents) {
if (!parents) {
parents = [];
}
if (!node || !node.parentTId) {
return parents;
} else {
parents.push(node.getParentNode());
return tree.getAllParents(node.getParentNode(), parents);
}
},
isParents: function (tId, parentTId) {
var node = tree.fileTree.getNodeByTId(tId); var node = tree.fileTree.getNodeByTId(tId);
if (!node || !node.parentTId) { if (!node || !node.parentTId) {
return false; return false;
@ -85,7 +97,7 @@ var tree = {
if (node.parentTId === parentTId) { if (node.parentTId === parentTId) {
return true; return true;
} else { } else {
return tree._isParents(node.parentTId, parentTId); return tree.isParents(node.parentTId, parentTId);
} }
} }
}, },

View File

@ -86,7 +86,7 @@ var wide = {
} }
} else { } else {
for (var i = 0, ii = editors.data.length; i < ii; i++) { for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (tree._isParents(editors.data[i].id, wide.curNode.tId)) { if (tree.isParents(editors.data[i].id, wide.curNode.tId)) {
$(".edit-panel .tabs > div[data-index=" + editors.data[i].id + "]").find(".ico-close").click(); $(".edit-panel .tabs > div[data-index=" + editors.data[i].id + "]").find(".ico-close").click();
i--; i--;
ii--; ii--;