converted jump to note to module

This commit is contained in:
azivner 2017-11-04 13:59:43 -04:00
parent 394fd6f527
commit 1d0e96a314
2 changed files with 34 additions and 24 deletions

View file

@ -1,28 +1,38 @@
function showJumpToNote() {
$("#jump-to-note-autocomplete").val('');
const jumpToNote = (function() {
const dialogEl = $("#jump-to-note-dialog");
const autoCompleteEl = $("#jump-to-note-autocomplete");
const formEl = $("#jump-to-note-form");
$("#jump-to-note-dialog").dialog({
modal: true,
width: 800
});
function showDialog() {
autoCompleteEl.val('');
$("#jump-to-note-autocomplete").autocomplete({
source: getAutocompleteItems(glob.allNoteIds),
minLength: 0
});
}
dialogEl.dialog({
modal: true,
width: 800
});
$(document).bind('keydown', 'alt+j', showJumpToNote);
$("#jump-to-note-form").submit(() => {
const val = $("#jump-to-note-autocomplete").val();
const noteId = getNodeIdFromLabel(val);
if (noteId) {
getNodeByKey(noteId).setActive();
$("#jump-to-note-dialog").dialog('close');
autoCompleteEl.autocomplete({
source: getAutocompleteItems(glob.allNoteIds),
minLength: 0
});
}
return false;
});
$(document).bind('keydown', 'alt+j', showDialog);
formEl.submit(() => {
const val = autoCompleteEl.val();
const noteId = getNodeIdFromLabel(val);
if (noteId) {
getNodeByKey(noteId).setActive();
dialogEl.dialog('close');
}
return false;
});
return {
showDialog
};
})();

View file

@ -14,7 +14,7 @@
<div style="flex-grow: 100;">
<button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button>
<button class="btn btn-xs" onclick="recentNotes.showDialog();">Recent notes</button>
<button class="btn btn-xs" onclick="showJumpToNote();">Jump to note</button>
<button class="btn btn-xs" onclick="jumpToNote.showDialog();">Jump to note</button>
<button class="btn btn-xs" onclick="showEventLog();">Event log</button>
</div>