rollbackTabbarPosition => undoChangeTabbarPosition / redoChangeTabbarPosition
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5634 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
7c636fd212
commit
0d6aa6674b
@ -16,9 +16,14 @@ var TreeStyleTabService = {
|
|||||||
return this.utils.currentTabbarPosition = aValue;
|
return this.utils.currentTabbarPosition = aValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
rollbackTabbarPosition : function TSTService_rollbackTabbarPosition() /* PUBLIC API */
|
undoChangeTabbarPosition : function TSTService_undoChangeTabbarPosition() /* PUBLIC API */
|
||||||
{
|
{
|
||||||
return this.utils.rollbackTabbarPosition();
|
return this.utils.undoChangeTabbarPosition();
|
||||||
|
},
|
||||||
|
|
||||||
|
redoChangeTabbarPosition : function TSTService_redoChangeTabbarPosition() /* PUBLIC API */
|
||||||
|
{
|
||||||
|
return this.utils.redoChangeTabbarPosition();
|
||||||
},
|
},
|
||||||
|
|
||||||
get treeViewEnabled() /* PUBLIC API */
|
get treeViewEnabled() /* PUBLIC API */
|
||||||
|
@ -241,7 +241,7 @@ var TreeStyleTabUtils = {
|
|||||||
this.addPrefListener(this);
|
this.addPrefListener(this);
|
||||||
this.ObserverService.addObserver(this, 'private-browsing-change-granted', false);
|
this.ObserverService.addObserver(this, 'private-browsing-change-granted', false);
|
||||||
|
|
||||||
this._tabbarPositionHistory.push(this.currentTabbarPosition);
|
this.onChangeTabbarPosition(this.currentTabbarPosition);
|
||||||
|
|
||||||
this.onPrefChange('extensions.treestyletab.indent');
|
this.onPrefChange('extensions.treestyletab.indent');
|
||||||
this.onPrefChange('extensions.treestyletab.clickOnIndentSpaces.enabled');
|
this.onPrefChange('extensions.treestyletab.clickOnIndentSpaces.enabled');
|
||||||
@ -1395,25 +1395,72 @@ var TreeStyleTabUtils = {
|
|||||||
return aValue;
|
return aValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
rollbackTabbarPosition : function TSTUtils_rollbackTabbarPosition() /* PUBLIC API */
|
undoChangeTabbarPosition : function TSTUtils_undoChangeTabbarPosition() /* PUBLIC API */
|
||||||
{
|
{
|
||||||
if (!this._tabbarPositionHistory.length)
|
if (this._tabbarPositionHistoryIndex <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this._inRollbackTabbarPosition = true;
|
this._inRollbackTabbarPosition = true;
|
||||||
this.currentTabbarPosition = this._tabbarPositionHistory.pop();
|
|
||||||
|
var current = this.currentTabbarPosition;
|
||||||
|
var previous;
|
||||||
|
|
||||||
|
do {
|
||||||
|
previous = this._tabbarPositionHistory[--this._tabbarPositionHistoryIndex];
|
||||||
|
}
|
||||||
|
while (previous && current == previous);
|
||||||
|
|
||||||
|
this.currentTabbarPosition = previous;
|
||||||
|
|
||||||
this._inRollbackTabbarPosition = false;
|
this._inRollbackTabbarPosition = false;
|
||||||
|
|
||||||
return true;
|
return current != previous;
|
||||||
|
},
|
||||||
|
|
||||||
|
redoChangeTabbarPosition : function TSTUtils_redoChangeTabbarPosition() /* PUBLIC API */
|
||||||
|
{
|
||||||
|
if (this._tabbarPositionHistoryIndex >= this._tabbarPositionHistory.length-1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this._inRollbackTabbarPosition = true;
|
||||||
|
|
||||||
|
var current = this.currentTabbarPosition;
|
||||||
|
var next;
|
||||||
|
|
||||||
|
do {
|
||||||
|
next = this._tabbarPositionHistory[++this._tabbarPositionHistoryIndex];
|
||||||
|
}
|
||||||
|
while (next && current == next);
|
||||||
|
|
||||||
|
this.currentTabbarPosition = next;
|
||||||
|
|
||||||
|
this._inRollbackTabbarPosition = false;
|
||||||
|
|
||||||
|
return current != next;
|
||||||
},
|
},
|
||||||
|
|
||||||
onChangeTabbarPosition : function TSTUtils_onChangeTabbarPosition(aPosition)
|
onChangeTabbarPosition : function TSTUtils_onChangeTabbarPosition(aPosition)
|
||||||
{
|
{
|
||||||
if (this._inRollbackTabbarPosition) return;
|
var history = this._tabbarPositionHistory;
|
||||||
this._tabbarPositionHistory.push(aPosition);
|
var current = history[this._tabbarPositionHistoryIndex];
|
||||||
|
if (
|
||||||
|
this._inRollbackTabbarPosition ||
|
||||||
|
(current && current == aPosition)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
history = history.slice(0, this._tabbarPositionHistoryIndex+1);
|
||||||
|
history.push(aPosition);
|
||||||
|
history = history.slice(-this.kMAX_TABBAR_POSITION_HISTORY);
|
||||||
|
|
||||||
|
this._tabbarPositionHistory = history;
|
||||||
|
this._tabbarPositionHistoryIndex = history.length-1;
|
||||||
},
|
},
|
||||||
|
|
||||||
_tabbarPositionHistory : [],
|
_tabbarPositionHistory : [],
|
||||||
|
_tabbarPositionHistoryIndex : -1,
|
||||||
|
|
||||||
|
kMAX_TABBAR_POSITION_HISTORY : 999,
|
||||||
|
|
||||||
/* Pref Listener */
|
/* Pref Listener */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user