FBAC

FBAC

  • Docs
  • Help
  • Changelog

›Getting Started

Getting Started

  • Basic Concepts
  • Installation
  • Tutorial

Configuration

  • Overview
  • Configuration

Basic Concepts

What is FBAC?

FBAC is an acronym for Funnelback Autocomplete/Concierge.

FBAC is a standalone, vanilla JS library for Funnelback's autocomplete and concierge, making it a competition for Funnelback Auto-completion and Typeahead/ Bloodhound.

FBAC in numbers

Typeahead/ BloodhoundFunnelback Auto-completionFunnelback Autocomplete/Concierge
Dependencies (other libraries)jQuery, Typeahead, Bloodhound, (Handlebars)jQuery, Funnelback Auto-completion, Typeahead Bloodhound, (Handlebars)None
SupportIE11+ (or earlier)IE11+ (or earlier)IE11+ (or earlier)
DocumentationGoodPoorGood
What is the size of the bundle?41KB (T&B) + 249KB (jQuery)41KB (T&B) + 249KB (jQuery) + ~50KB (FA)79KB
Easy in useYesYesYes
Can use different endpoints?YesYesYes
Can use the same endpoint many times?Yes, but is fetched many timesYes, but is fetched many timesYes, and is fetched once
Can display one global header?NoNoYes
Can display one header per endpoint?YesYesYes
Can display one global footer?NoNoYes
Can display footer on each endpoint?YesYesYes
Can wrap results in another template?Yes, on the client HTML sideYes, on the client HTML sideYes
Can display both autocomplete and concierge?YesYesYes
Is for Funnelback only?NoYes (well, it’s in the name)Yes (well, it’s in the name)
Can set amount of signs to trigger autocomplete?YesYesYes
Can set amount of results to render?YesYesYes
Can set amount of results to fetch?No, it fetches amount to renderNo, it fetches amount to renderYes
Can define events, eg. afterFetch or beforeRender?YesYesYes
How many events can you define?12125
Can use events outside of the scope?YesNoNo
Can manipulate fetched data before displaying?NoYes, in one place (callback dataset function)Yes
Can highlight data?Yes, uses <strong> element with classYes, uses <strong> element with classYes, uses a template for highlighting
How many fixed classNames does it have?996
Can I use loader?YesYesYes
Can I set a threshold between fetching and typing?NoYesYes
What is the behaviour for autocomplete result click?Sends form with chosen querySends form with chosen querySends the form with chosen query OR fills the input with the chosen query
What is the behaviour for autocomplete enter?Sends form with chosen querySends form with chosen querySends the form with chosen query OR fills the input with the chosen query
What is the behaviour for concierge result click?Goes to a pageGoes to a pageGoes to a page
What is the behaviour for concierge enter?Goes to a pageGoes to a pageGoes to a page
What is the tab behaviour?Fills the input with the first suggestionFills the input with the first suggestionIterates through results (WCAG compatible)
What is the behaviour of arrow-down?Iterates through resultsIterates through resultsIterates through results (rows)
What is the behaviour of side-arrows?NoneNoneIterates through results (columns)
Can hide if no results are fetched?Yes, via “ifology” in the templateYes, via “ifology” in the templateYes, via one variable
Can hide global header and footer on no results?NoNoYes, via one variable
Can hide individual headers and footers on no results?Yes, via “ifology” in the templateYes, via “ifology” in the templateYes, via one variable
Can display hints in the input?YesYesNo
Can destroy events and relations which were defined?YesYesYes
Can add an URL parameter which has not been defined by creators?NoYesYes
Can define default results to show when nothing is typed?NoYesYes, via “No results” template
Can group items by some category?Yes, via “ifology” in the templateYesYes, via “ifology” in the template
Can control data source which comes from Funnelback (JSON/JSONP)?NoYesNo
Can transform data which comes from the endpoint?NoYes, via special templateYes, via events
Does it add functional accessibility attributes (eg. wai-aria attributes)?NoNoYes
Positive1922🏆   36
Neutral1011🏆   4
Negative1310🏆   3

Basic concepts

There are two basic concepts related with FBAC that help you to create your own Funnelback autocomplete/concierge.

In order to make FBAC work you need to install FBAC, create HTML markup for an input bar and FBAC container, and create a configuration JavaScript with settings and templates.

Configuration

Configuration is an object that has properties with their default values in FBAC. You need to provide some of them as required fields - rest is filled automatically by the library.

Example of a simple FBAC configuration

The presented configuration has two different endpoints and three outputs. FBAC fetches the suggest.json only once per collection - in this case two times.

const concierge = new FBAC.default({
  input: "#search",
  inject: "#fbac",
  highlight: true,
  bindEvents: true,
  events: {
      beforeFetch(query) {
          this.query = query.replace(/-/g, ' ');
      }
  },
  scaffold(templates) {
      return `
          ${templates.noResults}

          ${templates.header}

          <div class="fbac__headers">
              ${templates.mercator_1.header}
              ${templates.mercator_2.header}
              ${templates.mercator_3.header}
          </div>

          <div class="fbac__all-results">

              ${templates.mercator_1.results}

              <div class="fbac__concierge fbac__concierge--no-border">
              ${templates.mercator_2.results}
              ${templates.mercator_2.noResults}
              </div>
          
              <div class="fbac__divider"></div>

              <div class="fbac__concierge">
                  ${templates.mercator_3.results}
                  ${templates.mercator_3.noResults}
              </div>

          </div>

          <div class="fbac__footers">
              ${templates.mercator_1.footer}
              ${templates.mercator_2.footer}
              ${templates.mercator_3.footer}
          </div>

          ${templates.footer}
      `;
  },
  url: "https://mercator3-search01.squiz.co.uk/s/suggest.json",
  urlParts: {
      collection: "push-global-port-strategy"
  },
  fb: [
      {
          id: "mercator_1",
          urlParts: {
              collection: "push-meta-port-strategy"
          },
          display: {
              headerOnNoResults: false,
              footerOnNoResults: false
          },
          templates: {
              results(iteratedResults, resultsClass) {
                  return `
                  <div class="fbac__autocomplete">
                      <div class="${resultsClass}">
                          ${iteratedResults}
                      </div>
                  </div>
                  <div class="fbac__divider"></div>
                `;
              }
          }
      },
      {
          id: "mercator_2"
      },
      {
          id: "mercator_3",
          templates: {
              result(data, eventClass) {
                  return `
                  <a href="${data.action}" class="fbac__result ${eventClass}" target="_blank">
                      ${data.disp.name}
                  </a>
                `;
              }
          }
      }
  ]
});

concierge.init();

You will learn more about configuration in dedicated chapter.

Last updated on 11/9/2020 by Jacek Sawczyszyn (Squiz)
Installation →
  • What is FBAC?
  • FBAC in numbers
  • Basic concepts
  • Configuration
  • Example of a simple FBAC configuration
FBAC
Docs
Getting StartedConfiguration
More
ChangelogContact
Copyright © 2021 Squiz