mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-01-30 09:08:35 -06:00
configurable hiding of tab row for one tab
This commit is contained in:
@@ -6,6 +6,7 @@ import infoService from "../services/info.js";
|
||||
import zoomService from "../services/zoom.js";
|
||||
import utils from "../services/utils.js";
|
||||
import cssLoader from "../services/css_loader.js";
|
||||
import optionsInit from "../services/options_init.js";
|
||||
|
||||
const $dialog = $("#options-dialog");
|
||||
|
||||
@@ -43,6 +44,7 @@ export default {
|
||||
addTabHandler((function() {
|
||||
const $themeSelect = $("#theme-select");
|
||||
const $zoomFactorSelect = $("#zoom-factor-select");
|
||||
const $oneTabDisplaySelect = $("#one-tab-display-select");
|
||||
const $leftPaneMinWidth = $("#left-pane-min-width");
|
||||
const $leftPaneWidthPercent = $("#left-pane-width-percent");
|
||||
const $mainFontSize = $("#main-font-size");
|
||||
@@ -76,6 +78,8 @@ addTabHandler((function() {
|
||||
$zoomFactorSelect.prop('disabled', true);
|
||||
}
|
||||
|
||||
$oneTabDisplaySelect.val(options.hideTabRowForOneTab === 'true' ? 'hide' : 'show');
|
||||
|
||||
$leftPaneMinWidth.val(options.leftPaneMinWidth);
|
||||
$leftPaneWidthPercent.val(options.leftPaneWidthPercent);
|
||||
|
||||
@@ -116,6 +120,13 @@ addTabHandler((function() {
|
||||
$container.css("grid-template-columns", `minmax(${leftPaneMinWidth}px, ${leftPanePercent}fr) ${rightPanePercent}fr`);
|
||||
}
|
||||
|
||||
$oneTabDisplaySelect.change(function() {
|
||||
const hideTabRowForOneTab = $(this).val() === 'hide' ? 'true' : 'false';
|
||||
|
||||
server.put('options/hideTabRowForOneTab/' + hideTabRowForOneTab)
|
||||
.then(optionsInit.loadOptions);
|
||||
});
|
||||
|
||||
$leftPaneMinWidth.change(async function() {
|
||||
await server.put('options/leftPaneMinWidth/' + $(this).val());
|
||||
|
||||
@@ -217,7 +228,7 @@ addTabHandler((function() {
|
||||
const protectedSessionTimeout = $protectedSessionTimeout.val();
|
||||
|
||||
saveOptions({ 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
|
||||
protectedSessionHolder.setProtectedSessionTimeout(protectedSessionTimeout);
|
||||
optionsInit.loadOptions();
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
@@ -310,7 +310,7 @@ $tabContentsContainer.on("drop", e => {
|
||||
});
|
||||
});
|
||||
|
||||
async function createEmptyTab() {
|
||||
async function openEmptyTab() {
|
||||
const ctx = new TabContext(tabRow);
|
||||
tabContexts.push(ctx);
|
||||
|
||||
@@ -319,7 +319,7 @@ async function createEmptyTab() {
|
||||
await tabRow.setCurrentTab(ctx.tab);
|
||||
}
|
||||
|
||||
tabRow.addListener('newTab', createEmptyTab);
|
||||
tabRow.addListener('newTab', openEmptyTab);
|
||||
|
||||
tabRow.addListener('activeTabChange', async ({ detail }) => {
|
||||
const tabId = detail.tabEl.getAttribute('data-tab-id');
|
||||
@@ -342,6 +342,10 @@ tabRow.addListener('tabRemove', async ({ detail }) => {
|
||||
tabContexts = tabContexts.filter(nc => nc.tabId !== tabId);
|
||||
|
||||
console.log(`Removed tab ${tabId}`);
|
||||
|
||||
if (tabContexts.length === 0) {
|
||||
openEmptyTab();
|
||||
}
|
||||
});
|
||||
|
||||
$(tabRow.el).on('contextmenu', '.note-tab', e => {
|
||||
@@ -363,7 +367,7 @@ $(tabRow.el).on('contextmenu', '.note-tab', e => {
|
||||
|
||||
if (utils.isElectron()) {
|
||||
utils.bindShortcut('ctrl+t', () => {
|
||||
createEmptyTab();
|
||||
openEmptyTab();
|
||||
});
|
||||
|
||||
utils.bindShortcut('ctrl+w', () => {
|
||||
|
||||
@@ -1,9 +1,34 @@
|
||||
import server from "./server.js";
|
||||
|
||||
const optionsReady = new Promise((resolve, reject) => {
|
||||
$(document).ready(() => server.get('options').then(resolve));
|
||||
});
|
||||
let optionsReady;
|
||||
|
||||
const loadListeners = [];
|
||||
|
||||
function loadOptions() {
|
||||
optionsReady = new Promise((resolve, reject) => {
|
||||
server.get('options').then(options => {
|
||||
resolve(options);
|
||||
|
||||
for (const listener of loadListeners) {
|
||||
listener(options);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
loadOptions(); // initial load
|
||||
|
||||
function addLoadListener(listener) {
|
||||
loadListeners.push(listener);
|
||||
|
||||
// useful when listener has been added after the promise resolved, but can cause double emit if not yet
|
||||
// that should not be an issue though
|
||||
optionsReady.then(listener);
|
||||
}
|
||||
|
||||
export default {
|
||||
optionsReady
|
||||
// use addLoadListener() which will be called also on refreshes
|
||||
optionsReady,
|
||||
addLoadListener,
|
||||
loadOptions
|
||||
}
|
||||
@@ -6,7 +6,7 @@ const PROTECTED_SESSION_ID_KEY = 'protectedSessionId';
|
||||
let lastProtectedSessionOperationDate = null;
|
||||
let protectedSessionTimeout = null;
|
||||
|
||||
optionsInitService.optionsReady.then(options => protectedSessionTimeout = options.protectedSessionTimeout);
|
||||
optionsInitService.addLoadListener(options => setProtectedSessionTimeout(options.protectedSessionTimeout));
|
||||
|
||||
setInterval(() => {
|
||||
if (lastProtectedSessionOperationDate !== null && Date.now() - lastProtectedSessionOperationDate.getTime() > protectedSessionTimeout * 1000) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -40,7 +40,7 @@ function getCurrentZoom() {
|
||||
}
|
||||
|
||||
if (utils.isElectron()) {
|
||||
optionsInitService.optionsReady.then(options => setZoomFactor(options.zoomFactor))
|
||||
optionsInitService.addLoadListener(options => setZoomFactor(options.zoomFactor))
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user