From 36dbcfcce0cc636e615cd5aaae2c70db16a4f708 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 28 Aug 2017 23:10:04 -0400 Subject: [PATCH] search notes input box --- TODO | 3 ++- src/templates/app.html | 8 +++++++- static/js/init.js | 7 +++++++ static/js/tree.js | 34 +++++++++++++++++++++++++++++++++- 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 36459696f..443a2808a 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,8 @@ -- when jumping to notes, tree does not scroll - logout detection - conflict detection Later: +- collapse all button +- context menu on items (add subnote etc.) - drag and drop for notes (currently only keyboard) - sync with sync server \ No newline at end of file diff --git a/src/templates/app.html b/src/templates/app.html index 426c95298..518a9cc24 100644 --- a/src/templates/app.html +++ b/src/templates/app.html @@ -13,8 +13,14 @@
- + +

+ + + + +

diff --git a/static/js/init.js b/static/js/init.js index a0b905a33..bc41a3217 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -97,6 +97,9 @@ $(document).on('click', 'div.popover-content a', function(e) { let linkInfo; $(document).bind('keydown', 'alt+l', function() { + var range = $('#noteDetail').summernote('createRange'); + console.log("range:", range); + $("#noteAutocomplete").val(''); $("#linkTitle").val(''); @@ -153,4 +156,8 @@ $("#addLinkButton").click(function() { isNewWindow: true }); } +}); + +$(document).bind('keydown', 'alt+s', function() { + $("input[name=search]").focus(); }); \ No newline at end of file diff --git a/static/js/tree.js b/static/js/tree.js index ef3239594..35b1e8464 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -147,7 +147,7 @@ $(function(){ $("#tree").fancytree({ autoScroll: true, - extensions: ["hotkeys"], + extensions: ["hotkeys", "filter"], source: notes, activate: function(event, data){ const node = data.node.data; @@ -167,7 +167,39 @@ $(function(){ }, hotkeys: { keydown: keybindings + }, + filter: { + autoApply: true, // Re-apply last filter if lazy data is loaded + autoExpand: true, // Expand all branches that contain matches while filtered + counter: false, // Show a badge with number of matching child nodes near parent icons + fuzzy: false, // Match single characters in order, e.g. 'fb' will match 'FooBar' + hideExpandedCounter: true, // Hide counter badge if parent is expanded + hideExpanders: false, // Hide expanders if all child nodes are hidden by filter + highlight: true, // Highlight matches by wrapping inside tags + leavesOnly: false, // Match end nodes only + nodata: true, // Display a 'no data' status node if result is empty + mode: "hide" // Grayout unmatched nodes (pass "hide" to remove unmatched node instead) } }); }); +}); + +$("input[name=search]").keyup(function (e) { + let match = $(this).val(); + + if (e && e.which === $.ui.keyCode.ESCAPE || $.trim(match) === "") { + $("button#btnResetSearch").click(); + return; + } + + // Pass a string to perform case insensitive matching + let tree = $("#tree").fancytree("getTree"); + tree.filterBranches(match); +}).focus(); + +$("button#btnResetSearch").click(function () { + $("input[name=search]").val(""); + + let tree = $("#tree").fancytree("getTree"); + tree.clearFilter(); }); \ No newline at end of file