Skip to content

Commit

Permalink
Highlight closed private tabs in History - Recently Closed Tabs menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Infocatcher committed Aug 14, 2014
1 parent 622dbd7 commit 324eea2
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ var privateTab = {
this.initControls(document);
window.setTimeout(function() {
this.setupListAllTabs(window, true);
this.setupUndoCloseTabs(window, true);
}.bind(this), 0);
window.setTimeout(function() {
this.setHotkeysText(document);
Expand Down Expand Up @@ -509,6 +510,7 @@ var privateTab = {
this.destroyWindowClosingHandler(window);
}
this.setupListAllTabs(window, false);
this.setupUndoCloseTabs(window, false);
this.destroyControls(window, force);

window.privateTab._destroy();
Expand Down Expand Up @@ -1837,6 +1839,8 @@ var privateTab = {
this.updatePageContext(window);
else if(id == "alltabs-popup" || id == "tm-tabsList-menu")
this.updateListAllTabs(window, popup);
else if(id == "historyUndoPopup")
this.updateUndoCloseTabs(popup);
else if(id == "tabContextMenu")
this.updateTabContext(window);
else if(
Expand Down Expand Up @@ -2876,6 +2880,42 @@ var privateTab = {
else
mi.removeAttribute(this.privateAttr);
},
setupUndoCloseTabs: function(window, init) {
var undoPopup = window.document.getElementById("historyUndoPopup");
if(init) {
if(undoPopup)
undoPopup.addEventListener("popupshowing", this, false);
}
else {
if(undoPopup)
undoPopup.removeEventListener("popupshowing", this, false);
}
},
updateUndoCloseTabs: function(popup) {
_log("updateUndoCloseTabs()");
var window = popup.ownerDocument.defaultView;
var items = popup.getElementsByTagName("menuitem");
var undoTabItems = JSON.parse(this.ss.getClosedTabData(window));
Array.forEach(items, function(item) {
var indx = item.getAttribute("value");
if(!/^\d+$/.test(indx))
return;
// Original: undoCloseTab(0);
// Tab Mix Plus: TMP_ClosedTabs.restoreTab('original', 0);
if(!/undoCloseTab|restoreTab/i.test(item.getAttribute("oncommand")))
return;
var undoItem = undoTabItems[indx];
var state = undoItem && undoItem.state;
if(
state
&& "attributes" in state
&& this.privateAttr in state.attributes
)
item.setAttribute(this.privateAttr, "true");
else
item.removeAttribute(this.privateAttr);
}, this);
},
destroyControls: function(window, force) {
_log("destroyControls(), force: " + force);
var document = window.document;
Expand Down

0 comments on commit 324eea2

Please sign in to comment.