forked from ZenBrowserMirrors/zen-desktop
Added preference to disable tab renaming, refactored inline styles to css files, changed listener to blur, refactored code
This commit is contained in:
parent
34355d8e00
commit
d56f4962bf
4 changed files with 42 additions and 54 deletions
|
@ -80,6 +80,7 @@ pref('zen.welcome-screen.seen', false);
|
||||||
|
|
||||||
pref('zen.tabs.vertical', true);
|
pref('zen.tabs.vertical', true);
|
||||||
pref('zen.tabs.vertical.right-side', false);
|
pref('zen.tabs.vertical.right-side', false);
|
||||||
|
pref('zen.tabs.rename-tabs', true);
|
||||||
pref('zen.theme.accent-color', "#ffb787");
|
pref('zen.theme.accent-color', "#ffb787");
|
||||||
pref('zen.theme.content-element-separation', 6); // In pixels
|
pref('zen.theme.content-element-separation', 6); // In pixels
|
||||||
pref('zen.theme.pill-button', false);
|
pref('zen.theme.pill-button', false);
|
||||||
|
|
|
@ -212,7 +212,6 @@ var gZenUIManager = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var gZenVerticalTabsManager = {
|
var gZenVerticalTabsManager = {
|
||||||
_tabEdited: null,
|
|
||||||
init() {
|
init() {
|
||||||
this._multiWindowFeature = new ZenMultiWindowFeature();
|
this._multiWindowFeature = new ZenMultiWindowFeature();
|
||||||
this._initWaitPromise();
|
this._initWaitPromise();
|
||||||
|
@ -250,11 +249,8 @@ var gZenVerticalTabsManager = {
|
||||||
document.documentElement.setAttribute('zen-window-buttons-reversed', true);
|
document.documentElement.setAttribute('zen-window-buttons-reversed', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tabs) {
|
this._tabEdited = null;
|
||||||
tabs.addEventListener('mouseup', this.openNewTabOnTabsMiddleClick.bind(this));
|
this._renameTabHalt = this.renameTabHalt.bind(this);
|
||||||
}
|
|
||||||
|
|
||||||
//this._insertDoubleClickListenerPinnedTabs();
|
|
||||||
gBrowser.tabContainer.addEventListener('dblclick', this.renameTabStart.bind(this));
|
gBrowser.tabContainer.addEventListener('dblclick', this.renameTabStart.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -630,13 +626,6 @@ var gZenVerticalTabsManager = {
|
||||||
target.appendChild(child);
|
target.appendChild(child);
|
||||||
},
|
},
|
||||||
|
|
||||||
//_insertDoubleClickListenerPinnedTabs() {
|
|
||||||
// const tabs = gBrowser.tabs;
|
|
||||||
// for (const tab of tabs) {
|
|
||||||
// tab.addEventListener('dblclick', this.renameTabStart.bind(this));
|
|
||||||
// }
|
|
||||||
//},
|
|
||||||
|
|
||||||
renameTabKeydown(event) {
|
renameTabKeydown(event) {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
let label = this._tabEdited.querySelector('.tab-label-container-editing');
|
let label = this._tabEdited.querySelector('.tab-label-container-editing');
|
||||||
|
@ -648,41 +637,37 @@ var gZenVerticalTabsManager = {
|
||||||
this._tabEdited.label = newName;
|
this._tabEdited.label = newName;
|
||||||
this._tabEdited.setAttribute('zen-has-static-label', 'true');
|
this._tabEdited.setAttribute('zen-has-static-label', 'true');
|
||||||
} else {
|
} else {
|
||||||
// If the page is loaded, get the title of the page. Otherwise, keep name as is
|
this._tabEdited.removeAttribute('zen-has-static-label');
|
||||||
this._tabEdited.label = gBrowser.getBrowserForTab(this._tabEdited).contentTitle || this._tabEdited.label;
|
gBrowser.setTabTitle(this._tabEdited);
|
||||||
// If the page had a title, reset the zen-has-static-label attribute
|
|
||||||
if (gBrowser.getBrowserForTab(this._tabEdited).contentTitle) {
|
|
||||||
this._tabEdited.removeAttribute('zen-has-static-label');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._tabEdited.querySelector('.tab-editor-container').remove();
|
this._tabEdited.querySelector('.tab-editor-container').remove();
|
||||||
label.style.display = '';
|
label.classList.remove('tab-label-container-editing');
|
||||||
label.className = label.className.replace(' tab-label-container-editing', '');
|
|
||||||
document.removeEventListener('click', this.renameTabHalt.bind(this));
|
|
||||||
|
|
||||||
this._tabEdited = null;
|
this._tabEdited = null;
|
||||||
} else if (event.key === 'Escape') {
|
} else if (event.key === 'Escape') {
|
||||||
let label = this._tabEdited.querySelector('.tab-label-container-editing');
|
let label = this._tabEdited.querySelector('.tab-label-container-editing');
|
||||||
this._tabEdited.querySelector('.tab-editor-container').remove();
|
this._tabEdited.querySelector('.tab-editor-container').remove();
|
||||||
|
|
||||||
label.style.display = '';
|
label.classList.remove('tab-label-container-editing');
|
||||||
label.className = label.className.replace(' tab-label-container-editing', '');
|
|
||||||
document.removeEventListener('click', this.renameTabHalt.bind(this));
|
|
||||||
this._tabEdited = null;
|
this._tabEdited = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
renameTabStart(event) {
|
renameTabStart(event) {
|
||||||
if (this._tabEdited) return;
|
if (
|
||||||
|
this._tabEdited ||
|
||||||
|
!Services.prefs.getBoolPref('zen.tabs.rename-tabs') ||
|
||||||
|
Services.prefs.getBoolPref('browser.tabs.closeTabByDblclick')
|
||||||
|
)
|
||||||
|
return;
|
||||||
this._tabEdited = event.target.closest('.tabbrowser-tab');
|
this._tabEdited = event.target.closest('.tabbrowser-tab');
|
||||||
if (!this._tabEdited || !this._tabEdited.pinned) {
|
if (!this._tabEdited || !this._tabEdited.pinned || this._tabEdited.hasAttribute('zen-essential')) {
|
||||||
this._tabEdited = null;
|
this._tabEdited = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const label = this._tabEdited.querySelector('.tab-label-container');
|
const label = this._tabEdited.querySelector('.tab-label-container');
|
||||||
label.style.display = 'none';
|
label.classList.add('tab-label-container-editing');
|
||||||
label.className += ' tab-label-container-editing';
|
|
||||||
|
|
||||||
const container = window.MozXULElement.parseXULToFragment(`
|
const container = window.MozXULElement.parseXULToFragment(`
|
||||||
<vbox class="tab-label-container tab-editor-container" flex="1" align="start" pack="center"></vbox>
|
<vbox class="tab-label-container tab-editor-container" flex="1" align="start" pack="center"></vbox>
|
||||||
|
@ -693,31 +678,22 @@ var gZenVerticalTabsManager = {
|
||||||
input.id = 'tab-label-input';
|
input.id = 'tab-label-input';
|
||||||
input.value = this._tabEdited.label;
|
input.value = this._tabEdited.label;
|
||||||
input.addEventListener('keydown', this.renameTabKeydown.bind(this));
|
input.addEventListener('keydown', this.renameTabKeydown.bind(this));
|
||||||
input.style['white-space'] = 'nowrap';
|
|
||||||
input.style['overflow-x'] = 'scroll';
|
|
||||||
input.style['margin'] = '0';
|
|
||||||
|
|
||||||
containerHtml.appendChild(input);
|
containerHtml.appendChild(input);
|
||||||
input.focus();
|
input.focus();
|
||||||
input.select();
|
input.select();
|
||||||
|
|
||||||
document.addEventListener('click', this.renameTabHalt.bind(this));
|
input.addEventListener('blur', this._renameTabHalt);
|
||||||
},
|
},
|
||||||
|
|
||||||
renameTabHalt(event) {
|
renameTabHalt(event) {
|
||||||
// Ignore click event if it's clicking the input
|
if (document.activeElement === event.target || !this._tabEdited) {
|
||||||
if (event.target.closest('#tab-label-input')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this._tabEdited) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._tabEdited.querySelector('.tab-editor-container').remove();
|
this._tabEdited.querySelector('.tab-editor-container').remove();
|
||||||
const label = this._tabEdited.querySelector('.tab-label-container-editing');
|
const label = this._tabEdited.querySelector('.tab-label-container-editing');
|
||||||
label.style.display = '';
|
label.classList.remove('tab-label-container-editing');
|
||||||
label.className = label.className.replace(' tab-label-container-editing', '');
|
|
||||||
|
|
||||||
document.removeEventListener('click', this.renameTabHalt.bind(this));
|
|
||||||
this._tabEdited = null;
|
this._tabEdited = null;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1139,6 +1139,17 @@
|
||||||
box-shadow: -3px 0 6px -2px var(--toolbarbutton-active-background, rgba(0, 255, 0, 0.2));
|
box-shadow: -3px 0 6px -2px var(--toolbarbutton-active-background, rgba(0, 255, 0, 0.2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Renaming tab */
|
||||||
|
.tab-label-container-editing {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tab-label-input {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow-x: scroll;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Section: tab workspaces stylings */
|
/* Section: tab workspaces stylings */
|
||||||
.zen-workspace-tabs-section {
|
.zen-workspace-tabs-section {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..4faba37097f376b57c7376e320f46e9cd3aacffe 100644
|
index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..c29a3620f85219074b2eeef8d75b4ca7232414e2 100644
|
||||||
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
||||||
@@ -406,11 +406,52 @@
|
@@ -406,11 +406,52 @@
|
||||||
|
@ -102,17 +102,17 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..4faba37097f376b57c7376e320f46e9c
|
||||||
oldTab.updateLastAccessed();
|
oldTab.updateLastAccessed();
|
||||||
// if this is the foreground window, update the last-seen timestamps.
|
// if this is the foreground window, update the last-seen timestamps.
|
||||||
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
|
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
|
||||||
@@ -1462,6 +1509,9 @@
|
@@ -1477,6 +1511,9 @@
|
||||||
}
|
newBrowser &&
|
||||||
|
gURLBar.getBrowserState(newBrowser).urlbarFocused &&
|
||||||
let activeEl = document.activeElement;
|
gURLBar.focused;
|
||||||
+ if (gURLBar._zenHandleUrlbarClose) {
|
+ if (gURLBar._zenHandleUrlbarClose) {
|
||||||
+ gURLBar._zenHandleUrlbarClose(true);
|
+ gURLBar._zenHandleUrlbarClose(true);
|
||||||
+ }
|
+ }
|
||||||
// If focus is on the old tab, move it to the new tab.
|
if (!keepFocusOnUrlBar) {
|
||||||
if (activeEl == oldTab) {
|
// Clear focus so that _adjustFocusAfterTabSwitch can detect if
|
||||||
newTab.focus();
|
// some element has been focused and respect that.
|
||||||
@@ -1785,7 +1835,7 @@
|
@@ -1785,7 +1822,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
|
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
|
||||||
|
@ -121,7 +121,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..4faba37097f376b57c7376e320f46e9c
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2387,7 +2437,7 @@
|
@@ -2387,7 +2424,7 @@
|
||||||
|
|
||||||
let panel = this.getPanel(browser);
|
let panel = this.getPanel(browser);
|
||||||
let uniqueId = this._generateUniquePanelID();
|
let uniqueId = this._generateUniquePanelID();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue