树节点初始化状态 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

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

View File

@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*/
var session = {
init: function () {
@ -63,7 +63,20 @@ var session = {
// expand tree
for (var j = 0, jj = fileTree.length; j < jj; 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;
}
}
@ -78,7 +91,7 @@ var session = {
if (nodes[i].path === currentFile) {
id = nodes[i].tId;
// FIXME: 上面的展开是异步进行的,所以执行到这里的时候可能还没有展开完,导致定位不了可视区域
tree.fileTree.selectNode(nodes[i]);
wide.curNode = nodes[i];

View File

@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*/
var tree = {
fileTree: undefined,
@ -77,7 +77,19 @@ var tree = {
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);
if (!node || !node.parentTId) {
return false;
@ -85,7 +97,7 @@ var tree = {
if (node.parentTId === parentTId) {
return true;
} else {
return tree._isParents(node.parentTId, parentTId);
return tree.isParents(node.parentTId, parentTId);
}
}
},

View File

@ -86,7 +86,7 @@ var wide = {
}
} else {
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();
i--;
ii--;