From f852e1de81c25662e2ff2527627cae4e3218338d Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 14 Jan 2020 21:48:19 +0100 Subject: [PATCH] removed sidebar code --- src/public/javascripts/desktop.js | 37 ++++- src/public/javascripts/services/sidebar.js | 172 --------------------- src/public/stylesheets/desktop.css | 2 +- src/views/desktop.ejs | 4 +- 4 files changed, 39 insertions(+), 176 deletions(-) delete mode 100644 src/public/javascripts/services/sidebar.js diff --git a/src/public/javascripts/desktop.js b/src/public/javascripts/desktop.js index b93de56a6..5191209e6 100644 --- a/src/public/javascripts/desktop.js +++ b/src/public/javascripts/desktop.js @@ -27,7 +27,6 @@ import noteAutocompleteService from './services/note_autocomplete.js'; import macInit from './services/mac_init.js'; import cssLoader from './services/css_loader.js'; import dateNoteService from './services/date_notes.js'; -import sidebarService from './services/sidebar.js'; import importService from './services/import.js'; import keyboardActionService from "./services/keyboard_actions.js"; import splitService from "./services/split.js"; @@ -222,4 +221,40 @@ optionService.waitForOptions().then(options => { remote.BrowserWindow.getFocusedWindow().close(); }); } +}); + +const rightPane = $("#right-pane"); + +const $showRightPaneButton = $("#show-right-pane-button"); +const $hideRightPaneButton = $("#hide-right-pane-button"); + +optionService.waitForOptions().then(options => toggleSidebar(options.is('rightPaneVisible'))); + +function toggleSidebar(show) { + rightPane.toggle(show); + $showRightPaneButton.toggle(!show); + $hideRightPaneButton.toggle(show); + + if (show) { + splitService.setupSplitWithSidebar(); + } + else { + splitService.setupSplitWithoutSidebar(); + } +} + +$hideRightPaneButton.on('click', () => { + toggleSidebar(false); + + server.put('options/rightPaneVisible/false'); +}); + +$showRightPaneButton.on('click', async () => { + toggleSidebar(true); + + await server.put('options/rightPaneVisible/true'); + + const {sidebar} = appContext.getActiveTabContext(); + await sidebar.noteLoaded(); + sidebar.show(); }); \ No newline at end of file diff --git a/src/public/javascripts/services/sidebar.js b/src/public/javascripts/services/sidebar.js deleted file mode 100644 index d2639d7f7..000000000 --- a/src/public/javascripts/services/sidebar.js +++ /dev/null @@ -1,172 +0,0 @@ -import bundleService from "./bundle.js"; -import ws from "./ws.js"; -import optionsService from "./options.js"; -import splitService from "./split.js"; -import optionService from "./options.js"; -import server from "./server.js"; -import noteDetailService from "./note_detail.js"; - -const $sidebar = $("#right-pane"); -const $sidebarContainer = $('#sidebar-container'); - -const $showSidebarButton = $("#show-sidebar-button"); -const $hideSidebarButton = $("#hide-sidebar-button"); - -optionService.waitForOptions().then(options => toggleSidebar(options.is('rightPaneVisible'))); - -function toggleSidebar(show) { - $sidebar.toggle(show); - $showSidebarButton.toggle(!show); - $hideSidebarButton.toggle(show); - - if (show) { - splitService.setupSplitWithSidebar(); - } - else { - splitService.setupSplitWithoutSidebar(); - } -} - -$hideSidebarButton.on('click', () => { - toggleSidebar(false); - - server.put('options/rightPaneVisible/false'); -}); - -$showSidebarButton.on('click', async () => { - toggleSidebar(true); - - await server.put('options/rightPaneVisible/true'); - - const {sidebar} = appContext.getActiveTabContext(); - await sidebar.noteLoaded(); - sidebar.show(); -}); - -class Sidebar { - /** - * @param {TabContext} ctx - * @param {object} state - */ - constructor(ctx, state = {}) { - /** @property {TabContext} */ - this.ctx = ctx; - this.state = Object.assign({ - widgets: [] - }, state); - this.widgets = []; - - this.$widgetContainer = $sidebar.find(`.sidebar-widget-container[data-tab-id=${this.ctx.tabId}]`); - - if (this.$widgetContainer.length === 0) { - this.$widgetContainer = $(`