Skip to content

Commit

Permalink
Merge pull request #586 from algolia/fix/504
Browse files Browse the repository at this point in the history
docs(priceRangeSlider): Fixes live-doc + warning message
  • Loading branch information
Vincent Voyer committed Nov 13, 2015
2 parents a047077 + ea691aa commit 7defdbc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/js/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
indexName: 'instant_search'
};
var codeSnippets = q('.code-sample-snippet:not(.start):not(.config):not(.ignore)');
var configSnippet = q('.code-sample-snippet.config')[0];
var configSnippet = "var search = instantsearch({appId: '$appId', apiKey: '$apiKey'," +
"indexName: '$indexName', searchParameters: {hitsPerPage: 6}});\n"
var startSnippet = q('.code-sample-snippet.start')[0];

var source = codeSnippets.map(function(snippet) {
var functionBody = [configSnippet, snippet, startSnippet]
.map(function(e) { return e.textContent; })
.map(function(e) { return e.textContent ? e.textContent : e; })
.join(';');
return '(function() {' + functionBody + '})();';
});
Expand Down
16 changes: 13 additions & 3 deletions widgets/hits-per-page-selector/hits-per-page-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@ function hitsPerPageSelector({
});

if (!isCurrentInOptions) {
options = [{value: undefined, label: ''}].concat(options);
if (window.console) {
window.console.log('[Warning][hitsPerPageSelector] No option in `options` with `value: hitsPerPage` (hitsPerPage: ' + state.hitsPerPage + ')');
if (state.hitsPerPage === undefined) {
if (window.console) {
window.console.log(
'[Warning][hitsPerPageSelector] hitsPerPage not defined.' +
'You should probably used a `hits` widget or set the value `hitsPerPage` ' +
'using the searchParameters attribute of the instantSearch constructor.');
}
} else if (window.console) {
window.console.log(
'[Warning][hitsPerPageSelector] No option in `options` ' +
'with `value: hitsPerPage` (hitsPerPage: ' + state.hitsPerPage + ')');
}

options = [{value: undefined, label: ''}].concat(options);
}
},

Expand Down

0 comments on commit 7defdbc

Please sign in to comment.