diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js index c7aa12839..97d8d328a 100644 --- a/src/public/javascripts/services/frontend_script_api.js +++ b/src/public/javascripts/services/frontend_script_api.js @@ -50,7 +50,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte */ this.activateNote = async (notePath, noteLoadedListener) => { await treeService.activateNote(notePath, async () => { - await appContext.getMainNoteTree().scrollToActiveNote(); + await appContext.getMainNoteTree().scrollToActiveNoteListener(); if (noteLoadedListener) { noteLoadedListener(); diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 931a38892..22f430623 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -556,8 +556,6 @@ keyboardActionService.setGlobalActionHandler('CutIntoNote', () => createNoteInto keyboardActionService.setGlobalActionHandler('CreateNoteInto', createNoteInto); -keyboardActionService.setGlobalActionHandler('ScrollToActiveNote', () => appContext.getMainNoteTree().scrollToActiveNote()); - $(window).bind('hashchange', async function() { if (isNotePathInAddress()) { const [notePath, tabId] = getHashValueFromAddress(); diff --git a/src/public/javascripts/widgets/basic_widget.js b/src/public/javascripts/widgets/basic_widget.js index 2105aac8d..c60fac88b 100644 --- a/src/public/javascripts/widgets/basic_widget.js +++ b/src/public/javascripts/widgets/basic_widget.js @@ -7,6 +7,12 @@ class BasicWidget extends Component { keyboardActionsService.updateDisplayedShortcuts($widget); + $widget.find("[data-trigger-event]").on('click', e => { + const eventName = $(e.target).attr('data-trigger-event'); + + this.appContext.trigger(eventName); + }); + return $widget; } diff --git a/src/public/javascripts/widgets/global_buttons.js b/src/public/javascripts/widgets/global_buttons.js index a9f8fc475..c10d6bf39 100644 --- a/src/public/javascripts/widgets/global_buttons.js +++ b/src/public/javascripts/widgets/global_buttons.js @@ -14,31 +14,30 @@ const WIDGET_TPL = `
`; class GlobalButtonsWidget extends BasicWidget { doRender($widget) { - $widget = $(WIDGET_TPL); - - const $createTopLevelNoteButton = $widget.find(".create-top-level-note-button"); - const $collapseTreeButton = $widget.find(".collapse-tree-button"); - const $scrollToActiveNoteButton = $widget.find(".scroll-to-active-note-button"); - const $toggleSearchButton = $widget.find(".toggle-search-button"); - - $createTopLevelNoteButton.on('click', () => this.trigger('createTopLevelNote')); - $collapseTreeButton.on('click', () => this.trigger('collapseTree')); - $scrollToActiveNoteButton.on('click', () => appContext.getMainNoteTree().scrollToActiveNote()); - $toggleSearchButton.on('click', () => this.trigger('toggleSearch')); - - return $widget; + return $(WIDGET_TPL); } } diff --git a/src/public/javascripts/widgets/note_actions.js b/src/public/javascripts/widgets/note_actions.js index 4676da2a7..ff053b9d3 100644 --- a/src/public/javascripts/widgets/note_actions.js +++ b/src/public/javascripts/widgets/note_actions.js @@ -1,7 +1,4 @@ import TabAwareWidget from "./tab_aware_widget.js"; -import appContext from "../services/app_context.js"; -import libraryLoader from "../services/library_loader.js"; -import keyboardActionService from "../services/keyboard_actions.js"; const TPL = `Note ID: | diff --git a/src/public/javascripts/widgets/note_tree.js b/src/public/javascripts/widgets/note_tree.js index 5740cd804..383d39ce0 100644 --- a/src/public/javascripts/widgets/note_tree.js +++ b/src/public/javascripts/widgets/note_tree.js @@ -251,7 +251,7 @@ export default class NoteTreeWidget extends TabAwareWidget { if (!node) { const hoistedNoteId = await hoistedNoteService.getHoistedNoteId(); - node = getNodesByNoteId(hoistedNoteId)[0]; + node = this.getNodesByNoteId(hoistedNoteId)[0]; } node.setExpanded(false); @@ -281,8 +281,7 @@ export default class NoteTreeWidget extends TabAwareWidget { } } - // FIXME since this operates on note details tab context it seems it does not really belong here - async scrollToActiveNote() { + async scrollToActiveNoteListener() { const activeContext = appContext.getActiveTabContext(); if (activeContext && activeContext.notePath) { diff --git a/src/public/stylesheets/desktop.css b/src/public/stylesheets/desktop.css index f2fc34cd5..a3102b7aa 100644 --- a/src/public/stylesheets/desktop.css +++ b/src/public/stylesheets/desktop.css @@ -124,8 +124,8 @@ body { background-color: inherit; } -.widget .note-info-table td, .widget .note-info-table th { - padding: 5px; +#note-info-table td, #note-info-table th { + padding: 15px; } [data-toggle="tooltip"] span { |
---|