Two variants
Both use the same CSS class names for the rows, but the stylesheets are not interchangeable. The simple layer builds a table, the extended one builds lists in two columns.
The simple suggest layer
ff_suggest.js
The file defines a constructorFFSuggest. You create an instance and call init() with eight parameters.
ff_suggest.js
ff_suggest.js
The module doesn’t query FACT-Finder on every keystroke. It first compares with the last request and skips search terms longer than 50 characters entirely.The response is plain text: one line per suggestion, containing three fields separated by
### in the order suggestion, hit count, type. In the generated HTML they appear in the order suggestion, type, hit count.ff_suggest.css
ff_suggest.css
ff_suggest.css
The values for
top and left on div.suggestLayer are tailored to a specific shop design. Adjust them to your header, or position the layer relative to the search field.The extended suggest layer
The extended layer splits the suggestions into two columns: product suggestions with images on the left, the remaining search terms on the right. It requires jQuery, fetches the suggestions via JSONP, and responds to more keys.Which version you need
The previous documentation provides four files, one for each combination of jQuery version and FACT-Finder version. Together they differ in thirteen lines. This page therefore shows one version and describes the two deviations.
Check with Omikron which FACT-Finder version you use.
The deviation for jQuery 2
jQuery 3 removed.error(). The template therefore uses .fail(). For jQuery 2, change this one line at the end of getSuggestions() back:
The deviation for FACT-Finder 6.10
As of 6.10, FACT-Finder no longer returns the suggestions as a bare array but wraps them in an object with the propertysuggestions. The previous documentation solves this with a separate file in which every use of jsonObj is replaced by pSuggest.
There’s a simpler way. In the response function of getSuggestions(), add one line directly after pCurrentSelection = -1;:
jsonObj is the array of suggestions in both FACT-Finder versions, and the rest of the file remains unchanged.
The parameters of init()
Hereinit() takes fourteen parameters instead of eight. The first eight are the same as for the simple layer.
sid, uid, and site are only appended if they are filled. They end up both in the suggest request and in the target link that a clicked suggestion opens. FACT-Finder evaluates them for its statistics.The translation object
Unlike the simple layer, the extended one contains no hard-coded texts. It expects them in thetranslation parameter:
If a heading is missing, the module uses the technical type name. This was added here; the previous documentation doesn’t describe the parameter.
The callback functions
Three of them are global functions that you simply define. You pass the fourth toinit().
displayElementCallback runs with a delay; the module defers each call by ten milliseconds. So don’t rely on the layer still being visible inside it.With onSubmitSuggest, you attach your own target pages to suggestions, for example to send a category suggestion directly to the category page instead of to the search.The classes the module expects
The module inserts these classes into the generated HTML itself. Your stylesheet must define them.ff_big_suggest.css
ff_big_suggest.css
ff_big_suggest.css
Where to get ff_big_suggest.js
The file itself isn’t printed here. It’s 509 lines long and consists almost entirely of flow logic that you adopt unchanged: keyboard control, building and tearing down the layer, assembling the links. Everything you configure in it is described above on this page.
For the two deviations for jQuery 2 and FACT-Finder 6.10, change one line each, as described above.
If you don’t have the file at hand, ask WEBSALE. Since the direct integration is no longer being developed, it won’t change anymore.
What both variants have in common
Both expect a search form with a name and an emptydiv for the layer. Both attach to the input field, not to a button. And both offer a function you can use to close the layer from outside:
Compared to the previous documentation, five spots in the listings have been corrected: an inverted error check that would have accessed a property of
undefined in case of an error, the selection being preset to 0 instead of -1, the deprecated escape(), a missing semicolon, and “calback” instead of “callback” in two places.