Welcome to mirror list, hosted at ThFree Co, Russian Federation.

instantsearch.js « javascripts « assets « content - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 547fc72efdfe4776e4af6309bb8cc59c015abb40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const search = instantsearch({
  appId: 'BH4D9OD16A',
  apiKey: 'ce1690e1421303458a1fcbea0cc4a927',
  indexName: 'gitlab',
  algoliaOptions: {
    // Filter by tags as described in https://github.com/algolia/docsearch-configs/blob/master/configs/gitlab.json
    'filters': "tags:gitlab<score=3> OR tags:omnibus<score=2> OR tags:runner<score=1>",
    // Number of results shown in the search dropdown
    'hitsPerPage': 10,
  },
  loadingIndicator: true,
  urlSync: true,
  searchFunction: function(helper) {
    var searchResults = $('.search-results');
    if (helper.state.query === '') {
      searchResults.hide();
      return;
    }
    helper.search();
    searchResults.show();
  }
});

search.addWidget(
  instantsearch.widgets.searchBox({
    container: '#search-input',
    reset: true,
    poweredBy: true
  })
);

search.addWidget(
    instantsearch.widgets.refinementList({
      container: '#refinement-list',
      attributeName: 'tags',
      sortBy: ["name:asc","isRefined"],
      templates: {
        header: 'Refine your search:'
      }
    })
  );

search.addWidget(
  instantsearch.widgets.infiniteHits({
    container: '#hits',
    templates: {
      item: document.getElementById('hit-template').innerHTML,
      empty: "We didn't find any results for the search <em>\"{{query}}\"</em>"
    },
    escapeHits: true,
    showMoreLabel: "Load more results..."
  })
);

search.addWidget(
  instantsearch.widgets.stats({
    container: '#stats',
    templates: {
      body: '<div class="stats">We found {{nbHits}} results, fetched in {{processingTimeMS}}ms.</div>'
    }
  })
);

search.start();