2017-11-05 07:38:50 +08:00
|
|
|
"use strict";
|
|
|
|
|
2017-11-05 01:59:43 +08:00
|
|
|
const jumpToNote = (function() {
|
|
|
|
const dialogEl = $("#jump-to-note-dialog");
|
|
|
|
const autoCompleteEl = $("#jump-to-note-autocomplete");
|
|
|
|
const formEl = $("#jump-to-note-form");
|
2017-09-10 00:06:15 +08:00
|
|
|
|
2017-11-05 01:59:43 +08:00
|
|
|
function showDialog() {
|
2017-11-05 05:03:15 +08:00
|
|
|
glob.activeDialog = dialogEl;
|
|
|
|
|
2017-11-05 01:59:43 +08:00
|
|
|
autoCompleteEl.val('');
|
2017-09-10 00:06:15 +08:00
|
|
|
|
2017-11-05 01:59:43 +08:00
|
|
|
dialogEl.dialog({
|
|
|
|
modal: true,
|
|
|
|
width: 800
|
|
|
|
});
|
2017-10-11 08:37:45 +08:00
|
|
|
|
2017-11-05 01:59:43 +08:00
|
|
|
autoCompleteEl.autocomplete({
|
2017-11-20 08:39:39 +08:00
|
|
|
source: noteTree.getAutocompleteItems(),
|
2017-11-05 01:59:43 +08:00
|
|
|
minLength: 0
|
|
|
|
});
|
|
|
|
}
|
2017-09-10 00:06:15 +08:00
|
|
|
|
2017-11-05 01:59:43 +08:00
|
|
|
$(document).bind('keydown', 'alt+j', showDialog);
|
2017-09-10 00:06:15 +08:00
|
|
|
|
2017-11-05 01:59:43 +08:00
|
|
|
formEl.submit(() => {
|
|
|
|
const val = autoCompleteEl.val();
|
2017-11-05 05:07:03 +08:00
|
|
|
const noteId = link.getNodeIdFromLabel(val);
|
2017-09-10 00:06:15 +08:00
|
|
|
|
2017-11-05 01:59:43 +08:00
|
|
|
if (noteId) {
|
2017-11-19 21:47:22 +08:00
|
|
|
noteTree.activateNode(noteId);
|
2017-11-05 01:59:43 +08:00
|
|
|
|
|
|
|
dialogEl.dialog('close');
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2017-09-10 00:06:15 +08:00
|
|
|
|
2017-11-05 01:59:43 +08:00
|
|
|
return {
|
|
|
|
showDialog
|
|
|
|
};
|
|
|
|
})();
|