[Libreoffice-commits] help.git: help3xsl/help.js

Gabriel Chiquini gabrielchiquini at hotmail.com
Sat Dec 16 12:20:41 UTC 2017


 help3xsl/help.js |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit fae24d85eb9fb736c9fdab08c78d25cafb213913
Author: Gabriel Chiquini <gabrielchiquini at hotmail.com>
Date:   Fri Dec 8 23:48:39 2017 -0200

    Fixed remaining index search bugs
    
    Show list only after typing 3 or more characters
    Hide labels when module results is empty
    
    Change-Id: Ifb7a255b6ac627a0448878df104e837d96074fce
    Reviewed-on: https://gerrit.libreoffice.org/46134
    Reviewed-by: Olivier Hallot <olivier.hallot at libreoffice.org>
    Tested-by: Olivier Hallot <olivier.hallot at libreoffice.org>

diff --git a/help3xsl/help.js b/help3xsl/help.js
index 2c230e91e..09ebb34b8 100644
--- a/help3xsl/help.js
+++ b/help3xsl/help.js
@@ -97,15 +97,25 @@ $(document).ready(function() {
             clearTimeout(debouncer);
         }
         debouncer = setTimeout(function(){
-            if ($('#search-bar').val()) {
+            if ($('#search-bar').val().length > 2) {
                 var toShow = $('#Index ul a').filter(function(){
                     return $(this).text().toLowerCase().indexOf($('#search-bar').val().toLowerCase()) > -1;
                 });
                 toShow.parent().show();
                 $("#Index ul a").not(toShow).parent().hide();
+                $("#Bookmarks").show();
+
+                var listToShow = $('');
+                $('#Index ul li').filter(':visible').each(function(){
+                    //add all module labels that have results in search
+                    listToShow = listToShow.add($(this).parent().prev());
+                });
+                $(listToShow).show();
+                //hide all labels with 0 results
+                $('#Bookmarks > p').not(listToShow).hide();
             }
             else {
-                $("#Index ul li" ).show();
+                $("#Bookmarks").hide();
             }
         }, 200);
     });
@@ -124,6 +134,8 @@ $(document).ready(function() {
     $('#accordion-3').on('change', function(){
         if($(this).is(':checked')){
             $('#search-bar').focus();
+            //prevent all results to be shown
+            $("#Bookmarks").toggle($('#search-bar').val().length > 2);
         }
     });
 });


More information about the Libreoffice-commits mailing list