/* global instantsearch: true */ /*jshint camelcase: false */ $(document).ready(function () { var algoliaSettings = CONFIG.algolia; var isAlgoliaSettingsValid = algoliaSettings.applicationID && algoliaSettings.apiKey && algoliaSettings.indexName; if (!isAlgoliaSettingsValid) { window.console.error('Algolia Settings are invalid.'); return; } var search = instantsearch({ appId: algoliaSettings.applicationID, apiKey: algoliaSettings.apiKey, indexName: algoliaSettings.indexName, searchFunction: function (helper) { var searchInput = $('#algolia-search-input').find('input'); if (searchInput.val()) { helper.search(); } } }); // Registering Widgets [ instantsearch.widgets.searchBox({ container: '#algolia-search-input', placeholder: algoliaSettings.labels.input_placeholder }), instantsearch.widgets.hits({ container: '#algolia-hits', hitsPerPage: algoliaSettings.hits.per_page || 10, templates: { item: function (data) { var link = data.permalink ? data.permalink : (CONFIG.root + data.path); return ( '' + data._highlightResult.title.value + '' ); }, empty: function (data) { return ( '