diff --git a/src/public/app/layouts/desktop_main_window_layout.js b/src/public/app/layouts/desktop_main_window_layout.js index 7dced63fc..81ed45ab3 100644 --- a/src/public/app/layouts/desktop_main_window_layout.js +++ b/src/public/app/layouts/desktop_main_window_layout.js @@ -4,9 +4,6 @@ import TabRowWidget from "../widgets/tab_row.js"; import TitleBarButtonsWidget from "../widgets/title_bar_buttons.js"; import StandardTopWidget from "../widgets/standard_top_widget.js"; import SidePaneContainer from "../widgets/side_pane_container.js"; -import GlobalButtonsWidget from "../widgets/global_buttons.js"; -import SearchBoxWidget from "../widgets/search_box.js"; -import SearchResultsWidget from "../widgets/search_results.js"; import NoteTreeWidget from "../widgets/note_tree.js"; import TabCachingWidget from "../widgets/tab_caching_widget.js"; import NotePathsWidget from "../widgets/note_paths.js"; @@ -142,9 +139,6 @@ export default class DesktopMainWindowLayout { .filling() .child(new SidePaneContainer('left') .hideInZenMode() - .child(new GlobalButtonsWidget()) - .child(new SearchBoxWidget()) - .child(new SearchResultsWidget()) .child(new TabCachingWidget(() => new NotePathsWidget())) .child(appContext.mainTreeWidget) .child(...this.customWidgets.get('left-pane')) diff --git a/src/public/app/widgets/global_buttons.js b/src/public/app/widgets/global_buttons.js deleted file mode 100644 index b1ae870c2..000000000 --- a/src/public/app/widgets/global_buttons.js +++ /dev/null @@ -1,40 +0,0 @@ -import BasicWidget from "./basic_widget.js"; - -const WIDGET_TPL = ` -
- - - - - - - - - -
-`; - -class GlobalButtonsWidget extends BasicWidget { - doRender() { - this.$widget = $(WIDGET_TPL); - this.overflowing(); - } -} - -export default GlobalButtonsWidget; diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index bd23d4422..79057239e 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -49,10 +49,24 @@ const TPL = ` border-color: var(--button-border-color); } + .collapse-tree-button { + position: absolute; + top: 10px; + right: 70px; + z-index: 100; + } + + .scroll-to-active-note-button { + position: absolute; + top: 10px; + right: 35px; + z-index: 100; + } + .tree-settings-button { position: absolute; top: 10px; - right: 10px; + right: 0px; z-index: 100; } @@ -130,6 +144,10 @@ const TPL = ` } + + + +
@@ -697,6 +715,8 @@ export default class NoteTreeWidget extends TabAwareWidget { await this.setExpandedStatusForSubtree(node, false); } + collapseTreeCommand() { this.collapseTree(); } + /** * @return {FancytreeNode|null} */ @@ -719,7 +739,7 @@ export default class NoteTreeWidget extends TabAwareWidget { } } - async scrollToActiveNoteEvent() { + async scrollToActiveNoteCommand() { const activeContext = appContext.tabManager.getActiveTabContext(); if (activeContext && activeContext.notePath) { @@ -829,9 +849,6 @@ export default class NoteTreeWidget extends TabAwareWidget { return list ? list : []; // if no nodes with this refKey are found, fancy tree returns null } - // must be event since it's triggered from outside the tree - collapseTreeEvent() { this.collapseTree(); } - isEnabled() { return !!this.tabContext; } diff --git a/src/public/app/widgets/search_box.js b/src/public/app/widgets/search_box.js deleted file mode 100644 index 784b58650..000000000 --- a/src/public/app/widgets/search_box.js +++ /dev/null @@ -1,182 +0,0 @@ -import BasicWidget from "./basic_widget.js"; -import toastService from "../services/toast.js"; -import appContext from "../services/app_context.js"; -import noteCreateService from "../services/note_create.js"; -import utils from "../services/utils.js"; -import treeCache from "../services/tree_cache.js"; - -const TPL = ` -`; - -export default class SearchBoxWidget extends BasicWidget { - doRender() { - this.$widget = $(TPL); - this.contentSized(); - - this.$searchBox = this.$widget; - this.$closeSearchButton = this.$widget.find(".close-search-button"); - this.$searchInput = this.$widget.find("input[name='search-text']"); - this.$resetSearchButton = this.$widget.find(".reset-search-button"); - this.$doSearchButton = this.$widget.find(".do-search-button"); - this.$saveSearchButton = this.$widget.find(".save-search-button"); - - this.$searchInput.on('keyup',e => { - const searchText = this.$searchInput.val(); - - if (e && e.which === $.ui.keyCode.ESCAPE || $.trim(searchText) === "") { - this.$resetSearchButton.trigger('click'); - return; - } - - if (e && e.which === $.ui.keyCode.ENTER) { - this.doSearch(); - } - }); - - this.$doSearchButton.on('click', () => this.doSearch()); // keep long form because of argument - this.$resetSearchButton.on('click', () => this.resetSearchEvent()); - - this.$saveSearchButton.on('click', () => this.saveSearch()); - - this.$closeSearchButton.on('click', () => this.hideSearch()); - } - - doSearch(searchText) { - if (searchText) { - this.$searchInput.val(searchText); - } - else { - searchText = this.$searchInput.val(); - } - - if (searchText.trim().length === 0) { - toastService.showMessage("Please enter search criteria first."); - - this.$searchInput.trigger('focus'); - - return; - } - - this.triggerCommand('searchForResults', { - searchText: this.$searchInput.val() - }); - - this.$searchBox.tooltip("hide"); - } - - async saveSearch() { - const searchString = this.$searchInput.val().trim(); - - if (searchString.length === 0) { - alert("Write some search criteria first so there is something to save."); - return; - } - - let parent = appContext.tabManager.getActiveTabNote(); - - if (parent.type === 'search') { - parent = await treeCache.getNote('root'); - } - - await noteCreateService.createNote(parent.noteId, { - type: "search", - mime: "application/json", - title: searchString, - content: JSON.stringify({ searchString: searchString }) - }); - - this.resetSearchEvent(); - } - - showSearchEvent(data = {}) { - const {searchText} = data; - - utils.saveFocusedElement(); - - this.$searchBox.slideDown(); - - this.$searchBox.tooltip({ - trigger: 'focus', - html: true, - title: window.glob.SEARCH_HELP_TEXT, - placement: 'right', - delay: { - show: 500, // necessary because sliding out may cause wrong position - hide: 200 - } - }); - - if (searchText) { - this.$searchInput.val(searchText); - } - - this.$searchInput.trigger('focus'); - } - - hideSearch() { - this.resetSearchEvent(); - - this.$searchBox.slideUp(); - - this.triggerCommand('searchFlowEnded'); - } - - toggleSearchEvent() { - if (this.$searchBox.is(":hidden")) { - this.showSearchEvent(); - } - else { - this.hideSearch(); - } - } - - // searchNotesEvent() { - // this.toggleSearchEvent(); - // } - - resetSearchEvent() { - this.$searchInput.val(""); - } - - searchInSubtreeEvent({node}) { - const noteId = node.data.noteId; - - this.showSearchEvent(); - - this.$searchInput.val(`YOUR_SEARCH_TEXT note.ancestors.noteId=${noteId}`); - } -} diff --git a/src/public/app/widgets/search_results.js b/src/public/app/widgets/search_results.js deleted file mode 100644 index 094fa4444..000000000 --- a/src/public/app/widgets/search_results.js +++ /dev/null @@ -1,61 +0,0 @@ -import BasicWidget from "./basic_widget.js"; - -const TPL = ` -
- - - Search results: - - -
-`; - -export default class SearchResultsWidget extends BasicWidget { - doRender() { - this.$widget = $(TPL); - - this.$searchResults = this.$widget; - this.$searchResultsInner = this.$widget.find(".search-results-list"); - - this.toggleInt(false); - } - - searchResultsEvent({results}) { - this.toggleInt(true); - - this.$searchResultsInner.empty(); - this.$searchResults.show(); - - for (const result of results) { - const link = $('', { - href: 'javascript:', - text: result.notePathTitle, - 'data-action': 'note', - 'data-note-path': result.notePathArray.join('/') - }); - - const $result = $('
  • ').append(link); - - this.$searchResultsInner.append($result); - } - } - - searchFlowEndedEvent() { - this.$searchResults.hide(); - } -} diff --git a/src/public/app/widgets/standard_top_widget.js b/src/public/app/widgets/standard_top_widget.js index 8d16f3a75..366babf51 100644 --- a/src/public/app/widgets/standard_top_widget.js +++ b/src/public/app/widgets/standard_top_widget.js @@ -33,12 +33,17 @@ const TPL = `
    - + + -