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() { const jumpToNote = (function() {
$("#jump-to-note-autocomplete").val(''); const dialogEl = $("#jump-to-note-dialog");
const autoCompleteEl = $("#jump-to-note-autocomplete");
const formEl = $("#jump-to-note-form");
$("#jump-to-note-dialog").dialog({ function showDialog() {
modal: true, autoCompleteEl.val('');
width: 800
});
$("#jump-to-note-autocomplete").autocomplete({ dialogEl.dialog({
source: getAutocompleteItems(glob.allNoteIds), modal: true,
minLength: 0 width: 800
}); });
}
$(document).bind('keydown', 'alt+j', showJumpToNote); autoCompleteEl.autocomplete({
source: getAutocompleteItems(glob.allNoteIds),
$("#jump-to-note-form").submit(() => { minLength: 0
const val = $("#jump-to-note-autocomplete").val(); });
const noteId = getNodeIdFromLabel(val);
if (noteId) {
getNodeByKey(noteId).setActive();
$("#jump-to-note-dialog").dialog('close');
} }
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;"> <div style="flex-grow: 100;">
<button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button> <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="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> <button class="btn btn-xs" onclick="showEventLog();">Event log</button>
</div> </div>