[Pkg-mozext-commits] [tabmixplus] 44/147: Add option to toggle 'Keep Undo close tab menu open', changeset f4f77cf52577
David Prévot
taffit at moszumanska.debian.org
Sat Aug 5 15:27:35 UTC 2017
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit eab07aa60f3bfa40cff4c12813c9f358d0a6135c
Author: onemen <tabmix.onemen at gmail.com>
Date: Sat Dec 3 17:44:56 2016 +0200
Add option to toggle 'Keep Undo close tab menu open', changeset f4f77cf52577
---
chrome/content/session/sessionStore.js | 68 ++++++++++++++++++++++-----------
chrome/locale/en-US/tabmix.properties | 2 +
chrome/skin/pin.png | Bin 0 -> 3449 bytes
3 files changed, 48 insertions(+), 22 deletions(-)
diff --git a/chrome/content/session/sessionStore.js b/chrome/content/session/sessionStore.js
index f996614..dea3d1e 100644
--- a/chrome/content/session/sessionStore.js
+++ b/chrome/content/session/sessionStore.js
@@ -332,11 +332,17 @@ var TMP_ClosedTabs = {
/* .......... functions for closedtabs list menu and context menu .......... */
get keepMenuOpen() {
- return true;
+ return TabmixSvc.prefs.get("extensions.tabmix.undoClose.keepMenuOpen", false);
+ },
+
+ set keepMenuOpen(val) {
+ val = Boolean(val);
+ const fn = val ? "set" : "reset";
+ TabmixSvc.prefs[fn]("extensions.tabmix.undoClose.keepMenuOpen", val);
+ return val;
},
populateUndoSubmenu: function ct_populateUndoSubmenu(aPopup) {
- /* eslint-disable tabmix/balanced-listeners */
if (TabmixAllTabs.isAfterCtrlClick(aPopup.parentNode))
return false;
@@ -382,36 +388,44 @@ var TMP_ClosedTabs = {
m.setAttribute("class", "menuitem-iconic bookmark-item menuitem-with-favicon");
m.setAttribute("value", i);
m.setAttribute("closemenu", this.keepMenuOpen ? "none" : "auto");
+ /* eslint-disable tabmix/balanced-listeners */
m.addEventListener("command", this, false);
m.addEventListener("click", this, false);
+ /* eslint-enable tabmix/balanced-listeners */
if (i === 0)
m.setAttribute("key", "key_undoCloseTab");
aPopup.appendChild(m);
}
aPopup.appendChild(document.createElement("menuseparator"));
- function addKey(item, id) {
- if (document.getElementById("key_tm_" + id)) {
- item.setAttribute("key", "key_tm_" + id);
- }
- }
- // "Clear Closed Tabs List"
- m = aPopup.appendChild(document.createElement("menuitem"));
- m.setAttribute("id", "clearClosedTabsList");
- m.setAttribute("label", TabmixSvc.getString("undoclosetab.clear.label"));
- m.setAttribute("value", -1);
- addKey(m, "clearClosedTabs");
- m.addEventListener("command", this);
+ const addMenu = this.addMenuItem.bind(this, aPopup);
+ // "Keep menu open"
+ m = addMenu("lockedClosedTabsList", TabmixSvc.getString("undoclosetab.keepOpen.label"), -3);
+ m.setAttribute("description", TabmixSvc.getString("undoclosetab.keepOpen.description"));
+ m.setAttribute("closemenu", "none");
+ const image = this.keepMenuOpen ? "chrome://tabmixplus/skin/pin.png" : "";
+ m.setAttribute("image", image);
+ // "Clear Closed Tabs List"
+ addMenu("clearClosedTabsList", TabmixSvc.getString("undoclosetab.clear.label"), -1, "clearClosedTabs");
// "Restore All Tabs"
- m = aPopup.appendChild(document.createElement("menuitem"));
- m.setAttribute("id", "restoreAllClosedTabs");
- m.setAttribute("label", gNavigatorBundle.getString("menuRestoreAllTabs.label"));
- m.setAttribute("value", -2);
- addKey(m, "ucatab");
- m.addEventListener("command", this);
+ addMenu("restoreAllClosedTabs", gNavigatorBundle.getString("menuRestoreAllTabs.label"), -2, "ucatab");
+
return true;
- /* eslint-enable tabmix/balanced-listeners */
+ },
+
+ addMenuItem: function(popup, id, label, val, keyId) {
+ const m = popup.appendChild(document.createElement("menuitem"));
+ m.setAttribute("id", id);
+ m.setAttribute("label", label);
+ m.setAttribute("value", val);
+ m.setAttribute("class", "menuitem-iconic");
+ if (keyId && document.getElementById("key_tm_" + keyId)) {
+ m.setAttribute("key", "key_tm_" + keyId);
+ }
+ /* eslint-disable tabmix/balanced-listeners */
+ m.addEventListener("command", this);
+ return m;
},
handleEvent: function(event) {
@@ -426,7 +440,17 @@ var TMP_ClosedTabs = {
},
restoreCommand: function(aEvent) {
- this.doCommand("restoreTab", "original", aEvent.originalTarget);
+ const item = aEvent.originalTarget;
+ const index = Number(item.getAttribute("value"));
+ if (index == -3) {
+ this.keepMenuOpen = !this.keepMenuOpen;
+ const image = this.keepMenuOpen ? "chrome://tabmixplus/skin/pin.png" : "";
+ item.setAttribute("image", image);
+ this.populateUndoSubmenu(item.parentNode);
+ return;
+ }
+
+ this.doCommand("restoreTab", "original", item);
},
checkForMiddleClick: function ct_checkForMiddleClick(aEvent) {
diff --git a/chrome/locale/en-US/tabmix.properties b/chrome/locale/en-US/tabmix.properties
index afb2e4c..21cea2d 100644
--- a/chrome/locale/en-US/tabmix.properties
+++ b/chrome/locale/en-US/tabmix.properties
@@ -13,6 +13,8 @@ flstOn.label= Tabs Focus to Last Selected - Press F9 to swap preference
flstOff.label= Tabs Focus to Right - Press F9 to swap preference
slideshowOn.label= Tab Rotation is On - Press F8 to turn off
slideshowOff.label= Tab Rotation Off - Press F8 to turn on
+undoclosetab.keepOpen.label= Keep menu open
+undoclosetab.keepOpen.description= click to toggle
undoclosetab.clear.label= Clear Closed Tabs List
undoclosetab.clear.accesskey= C
undoClosedWindows.clear.label= Clear Closed Windows List
diff --git a/chrome/skin/pin.png b/chrome/skin/pin.png
new file mode 100644
index 0000000..b1d0180
Binary files /dev/null and b/chrome/skin/pin.png differ
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list