]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5052 Rework top search
authorStas Vilchik <vilchiks@gmail.com>
Tue, 11 Feb 2014 14:41:39 +0000 (20:41 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 11 Feb 2014 14:41:39 +0000 (20:41 +0600)
Show "no results" label. Show total count.

sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
sonar-server/src/main/webapp/javascripts/top-search.js

index 4a42d0aee442b05c687832fe66c6be8ad155926e..77ceacd7835115121f9243565e5c0ff0e5f0d1e3 100644 (file)
@@ -42,7 +42,9 @@
         <% end %>
       </ul>
     </div>
-    <div id="searchResourcesResults" class="autocomplete" style="display:none"></div>
+    <div id="searchResourcesResults" class="autocomplete" style="display:none"
+         data-results="<%= message('search.results') -%>"
+         data-no-results="<%= message('no_results') -%>"></div>
   </div>
   <%= render 'layouts/breadcrumb' if @breadcrumbs || selected_section==Navigation::SECTION_RESOURCE -%>
   <div id="body">
index 4b1691a5745a36df1390f9640519749a941d8163..b6bba4a1b6553af13d636839e37fd2b233a6bbcf 100644 (file)
             });
           });
 
+          resultsEl.append('<div class="autocompleteNote">' + r.total + ' ' + resultsEl.data('results') + '</div>');
+
           resultsEl.show();
-          items = resultsEl.find('li');
-          index = -1;
-          total = items.length;
-          selectNext();
-
-          items
-              .on('mouseover', function() {
-                index = items.index($(this));
-                select();
-              })
-              .on('click', function() {
-                index = items.index($(this));
-                select();
-                choose();
-              });
+
+          if (r.total === 0) {
+            ul.append('<li>' + resultsEl.data('no-results') + '</li>');
+          } else {
+            items = resultsEl.find('li');
+            index = -1;
+            total = items.length;
+            selectNext();
+
+            items
+                .on('mouseover', function() {
+                  index = items.index($(this));
+                  select();
+                })
+                .on('click', function() {
+                  index = items.index($(this));
+                  select();
+                  choose();
+                });
+          }
         },
 
         hide = function() {