| |
@@ -0,0 +1,64 @@
|
| |
+ $(document).ready(function() {
|
| |
+ var hubs = new Bloodhound({
|
| |
+ datumTokenizer: function (datum) {
|
| |
+ return Bloodhound.tokenizers.whitespace(datum.value);
|
| |
+ },
|
| |
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
|
| |
+ remote: {
|
| |
+ wildcard: '%QUERY',
|
| |
+ url: window.searchAPIurl + '%QUERY',
|
| |
+ transform: function(response) { return response.data; },
|
| |
+ }
|
| |
+ });
|
| |
+
|
| |
+ hubs.initialize();
|
| |
+
|
| |
+ $('#bloodhound .typeahead').typeahead({
|
| |
+ hint: true,
|
| |
+ highlight: true,
|
| |
+ minLength: 2,
|
| |
+ },
|
| |
+ {
|
| |
+ name: 'hubs',
|
| |
+ displayKey: 'name',
|
| |
+ source: hubs.ttAdapter(),
|
| |
+ templates: {
|
| |
+ pending: [
|
| |
+ '<div class="py-1 text-center">',
|
| |
+ '<i class="fa fa-circle-o-notch fa-spin fa-fw"></i>',
|
| |
+ '</div>'
|
| |
+ ].join('\n'),
|
| |
+ empty: [
|
| |
+ '<div class="empty-message text-muted py-1 text-center">',
|
| |
+ 'no matching hubs',
|
| |
+ '</div>'
|
| |
+ ].join('\n'),
|
| |
+ suggestion: function(datum) {
|
| |
+ output = '<div class="py-1 media">'
|
| |
+ if (datum.user_hub){
|
| |
+ output = output+'<img width="64px" height="64px" src="'+datum.config.avatar+'"/>'
|
| |
+ } else {
|
| |
+ output = output+'<div class="monogram-avatar bg-fedora-'+datum.monogram_colour+' text-fedora-'+datum.monogram_colour+'-dark">'+datum.name.charAt(0).toUpperCase()+'</div>'
|
| |
+ }
|
| |
+ output = output +'<div class="media-body pl-3">'
|
| |
+ output = output +'<div><strong>'+datum.name+'</strong></div>'
|
| |
+ output = output +'<div>'+datum.config.summary+'</div>'
|
| |
+ output = output +'<div>'
|
| |
+ if (datum.user_hub){
|
| |
+ output = output +'<span class="badge badge-primary">User</span>'
|
| |
+ } else {
|
| |
+ output = output +'<span class="badge badge-info">Group</span>'
|
| |
+ }
|
| |
+ output = output +'</div>'
|
| |
+ output = output +'</div>'
|
| |
+ output = output +'</div>'
|
| |
+ return output;
|
| |
+ },
|
| |
+ },
|
| |
+ },
|
| |
+ );
|
| |
+
|
| |
+ $('#bloodhound input.typeahead').on('typeahead:selected', function (e, datum) {
|
| |
+ window.location.href = datum.hub_url;
|
| |
+ });
|
| |
+ });
|
| |
\ No newline at end of file
|
| |
This implements a basic search of hubs, and puts the search
in the search box at the top of the page
Fixes #461
Signed-off-by: Ryan Lerch rlerch@redhat.com