mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
first POC of ES6 module
This commit is contained in:
parent
1612e9093d
commit
e3e2dc9fff
14
src/public/javascripts/bootstrap.js
vendored
Normal file
14
src/public/javascripts/bootstrap.js
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import searchTree from './search_tree.js';
|
||||
|
||||
const $toggleSearchButton = $("#toggle-search-button");
|
||||
|
||||
$toggleSearchButton.click(searchTree.toggleSearch);
|
||||
bindShortcut('ctrl+s', searchTree.toggleSearch);
|
||||
|
||||
function bindShortcut(keyboardShortcut, handler) {
|
||||
$(document).bind('keydown', keyboardShortcut, e => {
|
||||
handler();
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
@ -1,15 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const searchTree = (function() {
|
||||
const $tree = $("#tree");
|
||||
const $searchInput = $("input[name='search-text']");
|
||||
const $resetSearchButton = $("#reset-search-button");
|
||||
const $doSearchButton = $("#do-search-button");
|
||||
const $saveSearchButton = $("#save-search-button");
|
||||
const $searchBox = $("#search-box");
|
||||
const $toggleSearchButton = $("#toggle-search-button");
|
||||
|
||||
$resetSearchButton.click(resetSearch);
|
||||
|
||||
function toggleSearch() {
|
||||
if ($searchBox.is(":hidden")) {
|
||||
@ -46,6 +42,14 @@ const searchTree = (function() {
|
||||
getTree().filterBranches(node => noteIds.includes(node.data.noteId));
|
||||
}
|
||||
|
||||
async function saveSearch() {
|
||||
const {noteId} = await server.post('search/' + encodeURIComponent($searchInput.val()));
|
||||
|
||||
await noteTree.reload();
|
||||
|
||||
await noteTree.activateNode(noteId);
|
||||
}
|
||||
|
||||
$searchInput.keyup(e => {
|
||||
const searchText = $searchInput.val();
|
||||
|
||||
@ -60,24 +64,10 @@ const searchTree = (function() {
|
||||
}).focus();
|
||||
|
||||
$doSearchButton.click(doSearch);
|
||||
$resetSearchButton.click(resetSearch);
|
||||
|
||||
$saveSearchButton.click(async () => {
|
||||
const {noteId} = await server.post('search/' + encodeURIComponent($searchInput.val()));
|
||||
$saveSearchButton.click(saveSearch);
|
||||
|
||||
await noteTree.reload();
|
||||
|
||||
await noteTree.activateNode(noteId);
|
||||
});
|
||||
|
||||
$(document).bind('keydown', 'ctrl+s', e => {
|
||||
toggleSearch();
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$toggleSearchButton.click(toggleSearch);
|
||||
|
||||
return {
|
||||
export default {
|
||||
toggleSearch
|
||||
};
|
||||
})();
|
@ -519,6 +519,8 @@
|
||||
|
||||
<link href="stylesheets/style.css" rel="stylesheet">
|
||||
|
||||
<script src="javascripts/bootstrap.js" type="module"></script>
|
||||
|
||||
<script src="javascripts/utils.js"></script>
|
||||
<script src="javascripts/init.js"></script>
|
||||
<script src="javascripts/server.js"></script>
|
||||
@ -530,7 +532,6 @@
|
||||
<script src="javascripts/tree_utils.js"></script>
|
||||
<script src="javascripts/drag_and_drop.js"></script>
|
||||
<script src="javascripts/context_menu.js"></script>
|
||||
<script src="javascripts/search_tree.js"></script>
|
||||
<script src="javascripts/export.js"></script>
|
||||
|
||||
<!-- Note detail -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user