From 26621c0318ecad940ff5269d27ed80ac5f48ddfa Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 31 Mar 2019 21:19:10 +0200 Subject: [PATCH] short search help in the tooltip --- .../services/note_detail_search.js | 3 ++ .../javascripts/services/search_notes.js | 38 ++++++++++++++----- src/public/stylesheets/style.css | 17 +++++---- src/views/details/search.ejs | 29 +------------- 4 files changed, 42 insertions(+), 45 deletions(-) diff --git a/src/public/javascripts/services/note_detail_search.js b/src/public/javascripts/services/note_detail_search.js index 2cd9dd9d2..7f40095c5 100644 --- a/src/public/javascripts/services/note_detail_search.js +++ b/src/public/javascripts/services/note_detail_search.js @@ -4,8 +4,11 @@ import searchNotesService from "./search_notes.js"; const $searchString = $("#search-string"); const $component = $('#note-detail-search'); const $refreshButton = $('#note-detail-search-refresh-results-button'); +const $help = $("#note-detail-search-help"); function show() { + $help.html(searchNotesService.getHelpText()); + $component.show(); try { diff --git a/src/public/javascripts/services/search_notes.js b/src/public/javascripts/services/search_notes.js index 725a9278f..ab28ba00f 100644 --- a/src/public/javascripts/services/search_notes.js +++ b/src/public/javascripts/services/search_notes.js @@ -3,7 +3,6 @@ import treeCache from "./tree_cache.js"; import server from './server.js'; import infoService from "./info.js"; -const $tree = $("#tree"); const $searchInput = $("input[name='search-text']"); const $resetSearchButton = $("#reset-search-button"); const $doSearchButton = $("#do-search-button"); @@ -13,20 +12,36 @@ const $searchResults = $("#search-results"); const $searchResultsInner = $("#search-results-inner"); const $closeSearchButton = $("#close-search-button"); +const helpText = ` +Search tips - also see +

+

+

`; + function showSearch() { $searchBox.slideDown(); - $searchInput.focus(); $searchBox.tooltip({ trigger: 'focus', html: true, - title: 'Hello! google', + title: helpText, placement: 'right', delay: { show: 500, // necessary because sliding out may cause wrong position - hide: 500 + hide: 200 } }); + + $searchInput.focus(); } function hideSearch() { @@ -49,10 +64,6 @@ function resetSearch() { $searchInput.val(""); } -function getTree() { - return $tree.fancytree('getTree'); -} - async function doSearch(searchText) { if (searchText) { $searchInput.val(searchText); @@ -61,6 +72,14 @@ async function doSearch(searchText) { searchText = $searchInput.val(); } + if (searchText.trim().length === 0) { + infoService.showMessage("Please enter search criteria first."); + + $searchInput.focus(); + + return; + } + const results = await server.get('search/' + encodeURIComponent(searchText)); $searchResultsInner.empty(); @@ -151,5 +170,6 @@ export default { showSearch, refreshSearch, doSearch, - init + init, + getHelpText: () => helpText }; \ No newline at end of file diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 2ceb8bc4b..b34242235 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -28,6 +28,7 @@ --active-item-background-color: #ccc; --menu-text-color: black; --menu-background-color: white; + --tooltip-background-color: #f8f8f8; } body.theme-black { @@ -51,6 +52,7 @@ body.theme-black { --active-item-background-color: #ccc; --menu-text-color: white; --menu-background-color: #222; + --tooltip-background-color: black; } body.theme-black a, body.theme-black a:visited { @@ -82,6 +84,7 @@ body.theme-dark { --active-item-background-color: #ccc; --menu-text-color: white; --menu-background-color: #222; + --tooltip-background-color: #333; } body.theme-dark a, body.theme-dark a:visited { @@ -684,22 +687,20 @@ table.promoted-attributes-in-tooltip td, table.promoted-attributes-in-tooltip th padding: 20px; } -/* this should help with tooltip flickering */ -/*.tooltip {*/ -/* pointer-events: none;*/ -/*}*/ +.tooltip { + font-size: var(--main-font-size) !important; +} .tooltip-inner { - background-color: var(--accented-background-color) !important; - max-width: 400px; + background-color: var(--tooltip-background-color) !important; + max-width: 500px; /* height needs to stay small because tooltip has problem when it can't fit to either top or bottom of the cursor */ max-height: 300px; overflow: hidden; - font-size: var(--main-font-size); - color: var(--main-text-color); border: 1px solid var(--main-border-color); border-radius: 5px; text-align: left; + color: var(--main-text-color) !important; } .tooltip-inner img { diff --git a/src/views/details/search.ejs b/src/views/details/search.ejs index 70d938ea1..a180f2958 100644 --- a/src/views/details/search.ejs +++ b/src/views/details/search.ejs @@ -11,32 +11,5 @@
-

Help

-

-

- - -

+
\ No newline at end of file