From 25e68762fec2c461f2c463ff553ea85ad98aa411 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 13 Nov 2018 23:16:26 +0100 Subject: [PATCH] note autocompletes now have clear text button --- .../javascripts/services/note_autocomplete.js | 22 ++++++++++++++----- src/public/stylesheets/style.css | 14 ++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/public/javascripts/services/note_autocomplete.js b/src/public/javascripts/services/note_autocomplete.js index 494ab51de..bc859964a 100644 --- a/src/public/javascripts/services/note_autocomplete.js +++ b/src/public/javascripts/services/note_autocomplete.js @@ -16,6 +16,10 @@ async function autocompleteSource(term, cb) { cb(result); } +function clearText($el) { + $el.val('').change(); +} + function showRecentNotes($el) { $el.autocomplete("val", ""); $el.autocomplete("open"); @@ -23,12 +27,20 @@ function showRecentNotes($el) { function initNoteAutocomplete($el) { if (!$el.hasClass("aa-input")) { - const $showRecentNotesButton = $("
").addClass("input-group-append").append( - $("") - .addClass("input-group-text show-recent-notes-button jam jam-clock") - .prop("title", "Show recent notes")); + const $clearTextButton = $("") + .addClass("input-group-text input-clearer-button jam jam-close") + .prop("title", "Clear text field"); - $el.after($showRecentNotesButton); + const $showRecentNotesButton = $("") + .addClass("input-group-text show-recent-notes-button jam jam-clock") + .prop("title", "Show recent notes"); + + $el.after($("
") + .addClass("input-group-append") + .append($clearTextButton) + .append($showRecentNotesButton)); + + $clearTextButton.click(() => clearText($el)); $showRecentNotesButton.click(() => showRecentNotes($el)); diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 2d56243e0..f105d14bb 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -451,6 +451,20 @@ html.theme-dark body { .show-recent-notes-button { cursor: pointer; font-size: 1.3em; + padding-left: 7px; + padding-right: 7px; +} + +.input-clearer-button { + cursor: pointer; + font-size: 1.3em; + background: inherit !important; + padding-left: 5px; + padding-right: 7px; +} + +.promoted-attribute-input.aa-input { + border-right: 0; } table.promoted-attributes-in-tooltip {