mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	hiding the search resets filtering, showing gives focus to input box
This commit is contained in:
		
							
								
								
									
										1
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								TODO
									
									
									
									
									
								
							@@ -21,6 +21,7 @@ Encryption:
 | 
			
		||||
 | 
			
		||||
Bugs:
 | 
			
		||||
- deleting cloned nodes ends with 500 (probably only on folders)
 | 
			
		||||
- Uncaught Error: cannot call methods on fancytree prior to initialization; attempted to call method 'getTree'
 | 
			
		||||
 | 
			
		||||
Others:
 | 
			
		||||
- dates should be stored in UTC to work correctly with time zones
 | 
			
		||||
 
 | 
			
		||||
@@ -171,6 +171,52 @@ $(function(){
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function collapseTree() {
 | 
			
		||||
    globalTree.fancytree("getRootNode").visit(function(node){
 | 
			
		||||
        node.setExpanded(false);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(document).bind('keydown', 'alt+c', collapseTree);
 | 
			
		||||
 | 
			
		||||
function scrollToCurrentNote() {
 | 
			
		||||
    const node = getNodeByKey(globalCurrentNote.detail.note_id);
 | 
			
		||||
 | 
			
		||||
    if (node) {
 | 
			
		||||
        node.makeVisible({scrollIntoView: true});
 | 
			
		||||
 | 
			
		||||
        node.setFocus();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function showSearch() {
 | 
			
		||||
    $("#search-box").show();
 | 
			
		||||
 | 
			
		||||
    $("input[name=search]").focus();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(document).bind('keydown', 'alt+s', showSearch);
 | 
			
		||||
 | 
			
		||||
function toggleSearch() {
 | 
			
		||||
    if ($("#search-box:hidden").length) {
 | 
			
		||||
        showSearch();
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        resetSearch();
 | 
			
		||||
 | 
			
		||||
        $("#search-box").hide();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function resetSearch() {
 | 
			
		||||
    $("input[name=search]").val("");
 | 
			
		||||
 | 
			
		||||
    const tree = globalTree.fancytree("getTree");
 | 
			
		||||
    tree.clearFilter();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$("button#btnResetSearch").click(resetSearch);
 | 
			
		||||
 | 
			
		||||
$("input[name=search]").keyup(function (e) {
 | 
			
		||||
    const searchString = $(this).val();
 | 
			
		||||
 | 
			
		||||
@@ -191,38 +237,3 @@ $("input[name=search]").keyup(function (e) {
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}).focus();
 | 
			
		||||
 | 
			
		||||
$("button#btnResetSearch").click(function () {
 | 
			
		||||
    $("input[name=search]").val("");
 | 
			
		||||
 | 
			
		||||
    const tree = globalTree.fancytree("getTree");
 | 
			
		||||
    tree.clearFilter();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function collapseTree() {
 | 
			
		||||
    globalTree.fancytree("getRootNode").visit(function(node){
 | 
			
		||||
        node.setExpanded(false);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function scrollToCurrentNote() {
 | 
			
		||||
    const node = getNodeByKey(globalCurrentNote.detail.note_id);
 | 
			
		||||
 | 
			
		||||
    if (node) {
 | 
			
		||||
        node.makeVisible({scrollIntoView: true});
 | 
			
		||||
 | 
			
		||||
        node.setFocus();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(document).bind('keydown', 'alt+s', function() {
 | 
			
		||||
    $("#search-box").show();
 | 
			
		||||
 | 
			
		||||
    $("input[name=search]").focus();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function toggleSearch() {
 | 
			
		||||
    $("#search-box").toggle();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(document).bind('keydown', 'alt+c', collapseTree);
 | 
			
		||||
		Reference in New Issue
	
	Block a user