diff --git a/.eslintrc b/.eslintrc index 7a40575865..7e33486757 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,39 +1,6 @@ { - "env" : { - "node": true, - "browser": true - }, - "rules" : { - "brace-style": [2, "stroustrup", { "allowSingleLine": true }], - "camelcase" : 1, - "comma-spacing": [2, {"before": false, "after": true}], - "comma-style": [2, "last"], - "consistent-return" : 2, - "consistent-this": [1, "self"], - "curly" : [2,"multi-line"], - "default-case": 1, - "eqeqeq": [2, "smart"], - "global-strict" : 0, - "indent": [2, 2], - "key-spacing" : [1, { "beforeColon" : true, "afterColon" : true }], - "new-cap" : 2, - "no-extra-bind" : 1, - "no-multiple-empty-lines" : 1, - "no-multi-spaces": 1, - "no-spaced-func": 1, - "no-trailing-spaces" : 2, - "no-underscore-dangle": 0, - "quotes" : [1, "double"], - "semi": 2, - "space-before-blocks": 1, - "space-before-function-parentheses": [1, "never"], - "space-infix-ops": 1, - "space-in-parens": [1, "always"], - "strict" : [2, "global"], - "valid-jsdoc": [2, { "requireReturnDescription": false }] - }, - "globals" : { - "module" : true, - "require" : true - } + "extends": [ + "eslint-config-airbnb", + "eslint-config-algolia" + ] } diff --git a/.jsdoc b/.jsdoc index 043010dd62..f93eb8890b 100644 --- a/.jsdoc +++ b/.jsdoc @@ -1,9 +1,9 @@ { "plugins": ["plugins/markdown"], - "opts" : { - "template" : "node_modules/minami" + "opts": { + "template": "node_modules/minami" }, - "markdown" : { - "anchorInHeadings" : true + "markdown": { + "anchorInHeadings": true } } diff --git a/CHANGELOG b/CHANGELOG index bf992e29be..3c5e133ee5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,85 +4,85 @@ UNRELEASED * test: add CI testing (browsers, phantom, node, io) 2.1.2 - 2015-06-26 - * FIX : #113 support for attributes hightlightPreTag and hightlighPostTag - * FIX : #112 distinct = undefined sent to the server - * FIX : #110 helper.hasRefinements() now checks for numerics - * FIX : #106 convert refinements to string - * DOC : Update theme + fix (github.com/algolia/minami) - * DOC : Fix misc links and descrition and added samples of objects - * DOC : Added a cheat sheet in the generated documentation + * FIX: #113 support for attributes hightlightPreTag and hightlighPostTag + * FIX: #112 distinct = undefined sent to the server + * FIX: #110 helper.hasRefinements() now checks for numerics + * FIX: #106 convert refinements to string + * DOC: Update theme + fix (github.com/algolia/minami) + * DOC: Fix misc links and descrition and added samples of objects + * DOC: Added a cheat sheet in the generated documentation 2.1.1 - 2015-06-19 - * FIX : #107 Apply rules to distinct to prevent the API to return an error - * FIX : make algoliasearch-helper requireable + browserifyable by removing the global envify transform + * FIX: #107 Apply rules to distinct to prevent the API to return an error + * FIX: make algoliasearch-helper requireable + browserifyable by removing the global envify transform 2.1.0 - 2015-06-15 - * FIX : #29 Avoid callback for outdated queries - * FIX : #64 Sum up the processing time of all queries - * FIX : #92 Parameters that can be set in the dashboard shouldn't have + * FIX: #29 Avoid callback for outdated queries + * FIX: #64 Sum up the processing time of all queries + * FIX: #92 Parameters that can be set in the dashboard shouldn't have defaults - * FIX : #62 Make sure disctinct is set to false when it's not possible to + * FIX: #62 Make sure disctinct is set to false when it's not possible to use distinct in Algolia - * FEATURE : #91 Support for tags (with support for the raw format #98) - * FEATURE : #70 Ability to get all refined values : helper.getRefinements( + * FEATURE: #91 Support for tags (with support for the raw format #98) + * FEATURE: #70 Ability to get all refined values: helper.getRefinements( facetname ) - * FEATURE : #51 multiple filters for a single conjunctive facet (tests) - * FEATURE : Ability to modify any parameter of the state easily (#76 #84 #12) - * FEATURE : #69 Ability to know if a facet is refined, whatever the value - * FEATURE : #86 Expose SearchParameters, AlgoliaSearchHelper, SearchResults to + * FEATURE: #51 multiple filters for a single conjunctive facet (tests) + * FEATURE: Ability to modify any parameter of the state easily (#76 #84 #12) + * FEATURE: #69 Ability to know if a facet is refined, whatever the value + * FEATURE: #86 Expose SearchParameters, AlgoliaSearchHelper, SearchResults to users directly in the builds - * FEATURE : #25 let the user do a clearRefinement with a function as a filter - * REFACTORING : SearchParameters is immutable (#14) - * REFACTORING : Ensure SearchParameters is totally frozen (#14) - * LIB : Update lodash version to 3.9.x + * FEATURE: #25 let the user do a clearRefinement with a function as a filter + * REFACTORING: SearchParameters is immutable (#14) + * REFACTORING: Ensure SearchParameters is totally frozen (#14) + * LIB: Update lodash version to 3.9.x 2.0.4 - * FIX : #82 Fix facet count on records with multiple values for a single + * FIX: #82 Fix facet count on records with multiple values for a single facet * FEATURE: Add exhaustive attribute to a facet and removed useless timeout (#80) 2.0.3 - 2015-05-13 - * FIX : #72 add back the ability to do multiple disjunctive facetting on a + * FIX: #72 add back the ability to do multiple disjunctive facetting on a single attribute - * FEATURE : #73 method to replace the state, without triggering a change - event : overrideStateWithoutTriggeringChangeEvent (use wisely) - * FEATURE : #66 add setTypoTolerance to SearchParameters + * FEATURE: #73 method to replace the state, without triggering a change + event: overrideStateWithoutTriggeringChangeEvent (use wisely) + * FEATURE: #66 add setTypoTolerance to SearchParameters 2.0.2 - 2015-05-06 - * FIX : setHitsPerPage was creating a new property HitsPerPage instead of + * FIX: setHitsPerPage was creating a new property HitsPerPage instead of updating the currently available hitsPerPage 2.0.1 - * MEH : because of jsDelivr + * MEH: because of jsDelivr 2.0.0 - * FIX : set page to 0 if it might change the number of pages returned - * FIX : handle distinct parameter automatically - * FIX : batch response handler gets the proper search state - * FEATURE : (breaking) Now peer depend on algoliasearch v3.1 - * FEATURE : (breaking) Facets stats and timeout infos are consistently + * FIX: set page to 0 if it might change the number of pages returned + * FIX: handle distinct parameter automatically + * FIX: batch response handler gets the proper search state + * FEATURE: (breaking) Now peer depend on algoliasearch v3.1 + * FEATURE: (breaking) Facets stats and timeout infos are consistently grouped in the facet object in the SearchResults - * FEATURE : (breaking) no more extra queries - * FEATURE : (breaking) Facets results are stored in an array with an order + * FEATURE: (breaking) no more extra queries + * FEATURE: (breaking) Facets results are stored in an array with an order that reflects their definition. - * FEATURE : Search results explicit definition - * FEATURE : (breaking) Search parameters as a separate object - * FEATURE : (breaking) Move callback style to a event based API - * FEATURE : change and results events return the state and the results (if any) - * FEATURE : SearchRefults.getFacetByName to retrieve a facet object from its + * FEATURE: Search results explicit definition + * FEATURE: (breaking) Search parameters as a separate object + * FEATURE: (breaking) Move callback style to a event based API + * FEATURE: change and results events return the state and the results (if any) + * FEATURE: SearchRefults.getFacetByName to retrieve a facet object from its name - * FEATURE : SearchParameters.getNumericRefinement : get back the value of a specific numeric + * FEATURE: SearchParameters.getNumericRefinement: get back the value of a specific numeric refinement - * FEATURE : clear refinements by name - * FEATURE : isDisjunctiveRefined to check if a disjunctive facet is refined - * FEATURE : basic support for numeric filters - * FEATURE : version number on the main helper factory - * TESTS : defaults test + * FEATURE: clear refinements by name + * FEATURE: isDisjunctiveRefined to check if a disjunctive facet is refined + * FEATURE: basic support for numeric filters + * FEATURE: version number on the main helper factory + * TESTS: defaults test 1.1.0 - * REFACTORING : constructor, now expose the defaults - * TESTS : defaults test + * REFACTORING: constructor, now expose the defaults + * TESTS: defaults test * FEATURE: Allow .search(q, params, cb) "callback always last" convention introduced by JavaScript client, also on the helper diff --git a/README.md b/README.md index 6669355855..eb75861757 100644 --- a/README.md +++ b/README.md @@ -33,24 +33,24 @@ This is the library you will need to easily build a good search UX like our [ins A small example that uses Browserify to manage modules. ```javascript -var algoliasearch = require( "algoliasearch" ); -var algoliasearchHelper = require( "algoliasearch-helper" ); +var algoliasearch = require('algoliasearch'); +var algoliasearchHelper = require('algoliasearch-helper'); -var client = algoliasearch( "app_id", "secret" ); +var client = algoliasearch('app_id', 'secret'); -var helper = algoliasearchHelper( client, "myMainIndex", { - facets : [ "mainCharacterFirstName", "year" ], - disjunctiveFacets : [ "director" ] +var helper = algoliasearchHelper(client, 'myMainIndex', { + facets: ['mainCharacterFirstName', 'year'], + disjunctiveFacets: ['director'] }); -helper.on( "result", function( data ){ - console.log( data.hits ); -} ); +helper.on('result', function(data){ + console.log(data.hits); +}); -helper.addDisjunctiveRefine( "director", "Clint Eastword" ); -helper.addDisjunctiveRefine( "director", "Sofia Coppola" ); +helper.addDisjunctiveRefine('director', 'Clint Eastword'); +helper.addDisjunctiveRefine('director', 'Sofia Coppola'); -helper.addNumericRefinement( "year", "=", 2003 ); +helper.addNumericRefinement('year', '=', 2003); // Search for any movie filmed in 2003 and directed by either C. Eastwood or S. Coppola helper.search(); @@ -62,19 +62,19 @@ helper.search(); [See the examples in action](http://algolia.github.io/algoliasearch-helper-js/) -### Use with NPM +### With NPM `npm install algoliasearch-helper` -### Use with bower +### With bower `bower install algoliasearch-helper` -### Use the CDN +### Regular `` +`` ## How to contribute? diff --git a/examples/instantsearch+helper+angular.html b/examples/instantsearch+helper+angular.html index 1afaa6e553..a5b9453b3c 100644 --- a/examples/instantsearch+helper+angular.html +++ b/examples/instantsearch+helper+angular.html @@ -1,3 +1,4 @@ + @@ -64,7 +65,7 @@

Results

disjunctiveFacets: ['category', 'manufacturer'], hitsPerPage: 5, maxValuesPerFacet: 5, - getRankingInfo : true + getRankingInfo: true }); $scope.helper.on('result', function(content) { diff --git a/examples/instantsearch+helper+excludes.html b/examples/instantsearch+helper+excludes.html index 96856ac300..92cf025d6f 100644 --- a/examples/instantsearch+helper+excludes.html +++ b/examples/instantsearch+helper+excludes.html @@ -1,3 +1,4 @@ + @@ -52,8 +53,8 @@

Results

maxValuesPerFacet: 5 }); - helper.on( "result", searchCallback ); - $inputfield.keyup( search ); + helper.on("result", searchCallback); + $inputfield.keyup(search); window.toggleRefine = function(facet, value) { helper.toggleRefine(facet, value).search(); @@ -68,11 +69,11 @@

Results

//Functions function search() { - helper.setQuery( $inputfield.val() ).search(); + helper.setQuery($inputfield.val()).search(); } - function searchCallback( content ) { - console.log( content ); + function searchCallback(content) { + console.log(content); if (content.query != $inputfield.val()) { // do not consider out-dated queries return; @@ -103,8 +104,8 @@

Results

// Scan all disjunctive facets and display them var facets = ''; - for ( var i = 0; i < content.disjunctiveFacets.length; i++ ){ - var facet = content.disjunctiveFacets[ i ]; + for (var i = 0; i < content.disjunctiveFacets.length; i++){ + var facet = content.disjunctiveFacets[i]; facets += '

' + facet.name + '

'; var values = facet.data; for (var value in values) { @@ -118,8 +119,8 @@

Results

// Scan all facets and display them facets = ''; - for( var i = 0; i < content.facets.length; i++ ){ - var facet = content.facets[ i ]; + for(var i = 0; i < content.facets.length; i++){ + var facet = content.facets[i]; facets += '

' + facet.name + '

'; facets += '