@@ -4,7 +4,7 @@ var utils = require('../../lib/utils.js');
44var autoHide = require ( '../../decorators/autoHide' ) ;
55var headerFooter = require ( '../../decorators/headerFooter' ) ;
66var bindProps = require ( '../../decorators/bindProps' ) ;
7- var Stats = autoHide ( headerFooter ( require ( '../../components/Stats' ) ) ) ;
7+ var Stats = autoHide ( headerFooter ( require ( '../../components/Stats/Stats.js ' ) ) ) ;
88
99var Template = require ( '../../components/Template' ) ;
1010
@@ -17,33 +17,32 @@ var defaultTemplates = {
1717/**
1818 * Display various stats about the current search state
1919 * @param {String|DOMElement } options.container CSS Selector or DOMElement to insert the widget
20- * @param {Object } [options.cssClasses] CSS classes to add to the wrapping elements: root
21- * @param {String|String[] } [options.cssClasses.root] CSS class to add to the root element
20+ * @param {Object } [options.cssClasses] CSS classes to add to the default template
21+ * @param {String } [options.cssClasses.root] CSS class to add to the root element
22+ * @param {String } [options.cssClasses.time] CSS class to add to the element wrapping the time processingTimeMs
2223 * @param {Object } [options.templates] Templates to use for the widget
2324 * @param {String|Function } [options.templates.header=''] Header template
24- * @param {String|Function } [options.templates.body='<div>
25+ * @param {String|Function } [options.templates.body='<div class="{{cssClasses.root}}" >
2526 {{#hasNoResults}}No results{{/hasNoResults}}
2627 {{#hasOneResult}}1 result{{/hasOneResult}}
2728 {{#hasManyResults}}{{#helpers.formatNumber}}{{nbHits}}{{/helpers.formatNumber}} results{{/hasManyResults}}
28- <small >found in {{processingTimeMS}}ms</small >
29+ <span class="{{cssClasses.time}}" >found in {{processingTimeMS}}ms</span >
2930</div>'] Body template
3031 * @param {String|Function } [options.templates.footer=''] Footer template
3132 * @param {Function } [options.transformData] Function to change the object passed to the `body` template
3233 * @param {boolean } [hideWhenNoResults=true] Hide the container when there's no results
3334 * @return {Object }
3435 */
3536function stats ( {
36- container = null ,
37- templates = defaultTemplates ,
38- transformData,
37+ container,
38+ cssClasses = { } ,
3939 hideWhenNoResults = true ,
40- cssClasses = {
41- root : null
42- }
40+ templates = defaultTemplates ,
41+ transformData
4342 } ) {
4443 var containerNode = utils . getContainerNode ( container ) ;
4544
46- if ( container === null ) {
45+ if ( ! containerNode ) {
4746 throw new Error ( 'Usage: stats({container[, template, transformData]})' ) ;
4847 }
4948
0 commit comments