simplification of triggering events from links

This commit is contained in:
zadam
2020-01-21 22:08:41 +01:00
parent 55d1f9e9f0
commit af5c623671
8 changed files with 45 additions and 51 deletions

View File

@@ -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 = `
<div class="dropdown note-actions">
@@ -10,14 +7,14 @@ const TPL = `
<span class="caret"></span>
</button>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item show-note-revisions-button">Revisions</a>
<a class="dropdown-item show-attributes-button"><kbd data-kb-action="ShowAttributes"></kbd> Attributes</a>
<a class="dropdown-item show-link-map-button"><kbd data-kb-action="ShowLinkMap"></kbd> Link map</a>
<a class="dropdown-item show-source-button"><kbd data-kb-action="ShowNoteSource"></kbd> Note source</a>
<a data-trigger-event="showNoteRevisions" class="dropdown-item show-note-revisions-button">Revisions</a>
<a data-trigger-event="showAttributes" class="dropdown-item show-attributes-button"><kbd data-kb-action="ShowAttributes"></kbd> Attributes</a>
<a data-trigger-event="showLinkMap" class="dropdown-item show-link-map-button"><kbd data-kb-action="ShowLinkMap"></kbd> Link map</a>
<a data-trigger-event="showNoteSource" class="dropdown-item show-source-button"><kbd data-kb-action="ShowNoteSource"></kbd> Note source</a>
<a class="dropdown-item import-files-button">Import files</a>
<a class="dropdown-item export-note-button">Export note</a>
<a class="dropdown-item print-note-button"><kbd data-kb-action="PrintActiveNote"></kbd> Print note</a>
<a class="dropdown-item show-note-info-button"><kbd data-kb-action="ShowNoteInfo"></kbd> Note info</a>
<a data-trigger-event="printActiveNote" class="dropdown-item print-note-button"><kbd data-kb-action="PrintActiveNote"></kbd> Print note</a>
<a data-trigger-event="showNoteInfo" class="dropdown-item show-note-info-button"><kbd data-kb-action="ShowNoteInfo"></kbd> Note info</a>
</div>
</div>`;
@@ -25,23 +22,7 @@ export default class NoteActionsWidget extends TabAwareWidget {
doRender() {
this.$widget = $(TPL);
this.$showRevisionsButton = this.$widget.find('.show-note-revisions-button');
this.$showRevisionsButton.on('click', e => this.triggerEvent(e, 'showNoteRevisions'));
this.$showAttributesButton = this.$widget.find('.show-attributes-button');
this.$showAttributesButton.on('click', e => this.triggerEvent(e, 'showAttributes'));
this.$showLinkMapButton = this.$widget.find('.show-link-map-button');
this.$showLinkMapButton.on('click', e => this.triggerEvent(e, 'showLinkMap'));
this.$showSourceButton = this.$widget.find('.show-source-button');
this.$showSourceButton.on('click', e => this.triggerEvent(e, 'showNoteSource'));
this.$showNoteInfoButton = this.$widget.find('.show-note-info-button');
this.$showNoteInfoButton.on('click', e => this.triggerEvent(e, 'showNoteInfo'));
this.$printNoteButton = this.$widget.find('.print-note-button');
this.$printNoteButton.on('click', e => this.triggerEvent(e, 'printActiveNote'));
this.$exportNoteButton = this.$widget.find('.export-note-button');
this.$exportNoteButton.on("click", () => {