brush up codes
This commit is contained in:
parent
3de7d79b67
commit
a706c81340
@ -2313,20 +2313,15 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var id = this.mTabBrowser.getAttribute('id');
|
var id = this.mTabBrowser.getAttribute('id');
|
||||||
var tabs = this.getAllTabsArray(this.mTabBrowser);
|
var tabs = this.getAllTabsArray(this.mTabBrowser);
|
||||||
treeStructures[id] = {
|
treeStructures[id] = {
|
||||||
id : tabs.map(function(aTab) {
|
|
||||||
return this.getTabValue(aTab, this.kID);
|
|
||||||
}, this),
|
|
||||||
tree : this.getTreeStructureFromTabs(tabs),
|
tree : this.getTreeStructureFromTabs(tabs),
|
||||||
collapsed : tabs.filter(function(aTab) {
|
state : tabs.map(function(aTab) {
|
||||||
return this.isCollapsed(aTab);
|
var state = { id : this.getTabValue(aTab, this.kID) };
|
||||||
}, this).map(function(aTab) {
|
if (this.isCollapsed(aTab))
|
||||||
return aTab._tPos;
|
state.collapsed = true;
|
||||||
}),
|
if (this.isSubtreeCollapsed(aTab))
|
||||||
treeCollapsed : tabs.filter(function(aTab) {
|
state.subTreeCollapsed = true;
|
||||||
return this.isSubtreeCollapsed(aTab);
|
return state;
|
||||||
}, this).map(function(aTab) {
|
}, this)
|
||||||
return aTab._tPos;
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
this.SessionStore.setWindowValue(this.window, this.kSTRUCTURE, JSON.stringify(treeStructures))
|
this.SessionStore.setWindowValue(this.window, this.kSTRUCTURE, JSON.stringify(treeStructures))
|
||||||
},
|
},
|
||||||
@ -2341,17 +2336,22 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var treeStructure = id in treeStructures ? treeStructures[id] : null ;
|
var treeStructure = id in treeStructures ? treeStructures[id] : null ;
|
||||||
if (
|
if (
|
||||||
!treeStructure ||
|
!treeStructure ||
|
||||||
!treeStructure.id ||
|
!treeStructure.state ||
|
||||||
!treeStructure.id.length ||
|
!treeStructure.state.length ||
|
||||||
!treeStructure.tree ||
|
!treeStructure.tree ||
|
||||||
!treeStructure.tree.length
|
!treeStructure.tree.length
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var tabs = this.getAllTabsArray(this.mTabBrowser);
|
var tabs = this.getAllTabsArray(this.mTabBrowser);
|
||||||
if (tabs.map(function(aTab) {
|
|
||||||
|
var actualTabs = tabs.map(function(aTab) {
|
||||||
return this.getTabValue(aTab, this.kID);
|
return this.getTabValue(aTab, this.kID);
|
||||||
}, this).join('\n') != treeStructure.id.join('\n'))
|
}, this).join('\n');
|
||||||
|
var expectedTabs = treeStructure.state.map(function(aState) {
|
||||||
|
return aState.id;
|
||||||
|
}).join('\n');
|
||||||
|
if (actualTabs != expectedTabs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var relations = tabs.map(function(aTab) {
|
var relations = tabs.map(function(aTab) {
|
||||||
@ -2374,17 +2374,16 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
this.tabsHash[relation.id] = aTab;
|
this.tabsHash[relation.id] = aTab;
|
||||||
|
|
||||||
if (treeStructure.treeCollapsed)
|
var state = treeStructure.state[aIndex];
|
||||||
this.setTabValue(aTab, this.kSUBTREE_COLLAPSED, treeStructure.treeCollapsed.indexOf(aIndex) > -1);
|
this.setTabValue(aTab, this.kSUBTREE_COLLAPSED, state.subTreeCollapsed || null);
|
||||||
|
this.collapseExpandTab(aTab, state.collapsed || false);
|
||||||
if (treeStructure.collapsed)
|
|
||||||
this.collapseExpandTab(aTab, treeStructure.collapsed.indexOf(aIndex) > -1, true);
|
|
||||||
|
|
||||||
this.setTabValue(aTab, this.kID, relation.id);
|
this.setTabValue(aTab, this.kID, relation.id);
|
||||||
this.setTabValue(aTab, this.kPARENT, relation.parent);
|
this.setTabValue(aTab, this.kPARENT, relation.parent);
|
||||||
this.setTabValue(aTab, this.kCHILDREN, relation.children);
|
this.setTabValue(aTab, this.kCHILDREN, relation.children);
|
||||||
this.setTabValue(aTab, this.kINSERT_BEFORE, relation.insertBefore);
|
this.setTabValue(aTab, this.kINSERT_BEFORE, relation.insertBefore);
|
||||||
this.setTabValue(aTab, this.kINSERT_AFTER, relation.insertAfter);
|
this.setTabValue(aTab, this.kINSERT_AFTER, relation.insertAfter);
|
||||||
|
|
||||||
aTab.__treestyletab__structureRestored = true;
|
aTab.__treestyletab__structureRestored = true;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user