Skip to content

Commit

Permalink
feat(algolia agent): provide an algolia agent when searching
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Stanislawski committed Feb 7, 2017
1 parent d70ef46 commit 6ca7ac2
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 12 deletions.
35 changes: 33 additions & 2 deletions dist/autocomplete.angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
// #351: preventDefault won't cancel blurs in ie <= 8
$input.on('blur.aa', function($e) {
var active = document.activeElement;
if (_.isMsie() && ($menu.is(active) || $menu.has(active).length > 0)) {
if (_.isMsie() && ($menu[0] === active || $menu[0].contains(active))) {
$e.preventDefault();
// stop immediate in order to prevent Input#_onBlur from
// getting exectued
Expand Down Expand Up @@ -2523,7 +2523,7 @@

module.exports = {
hits: __webpack_require__(21),
popularIn: __webpack_require__(22)
popularIn: __webpack_require__(24)
};


Expand All @@ -2534,8 +2534,14 @@
'use strict';

var _ = __webpack_require__(4);
var version = __webpack_require__(22);
var parseAlgoliaClientVersion = __webpack_require__(23);

module.exports = function search(index, params) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params.additionalUA = 'autocomplete.js ' + version;
}
return sourceFn;

function sourceFn(query, cb) {
Expand All @@ -2552,13 +2558,38 @@

/***/ },
/* 22 */
/***/ function(module, exports) {

module.exports = "3.4.2";


/***/ },
/* 23 */
/***/ function(module, exports) {

'use strict';
module.exports = function parseAlgoliaClientVersion(agent) {
var parsed = agent.match(/Algolia for vanilla JavaScript (\d+\.)(\d+\.)(\d+)/);
if (parsed) return [parsed[1], parsed[2], parsed[3]];
return undefined;
};


/***/ },
/* 24 */
/***/ function(module, exports, __webpack_require__) {

'use strict';

var _ = __webpack_require__(4);
var version = __webpack_require__(22);
var parseAlgoliaClientVersion = __webpack_require__(23);

module.exports = function popularIn(index, params, details, options) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params.additionalUA = 'autocomplete.js ' + version;
}
if (!details.source) {
return _.error("Missing 'source' key");
}
Expand Down
4 changes: 2 additions & 2 deletions dist/autocomplete.angular.min.js

Large diffs are not rendered by default.

35 changes: 33 additions & 2 deletions dist/autocomplete.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
// #351: preventDefault won't cancel blurs in ie <= 8
$input.on('blur.aa', function($e) {
var active = document.activeElement;
if (_.isMsie() && ($menu.is(active) || $menu.has(active).length > 0)) {
if (_.isMsie() && ($menu[0] === active || $menu[0].contains(active))) {
$e.preventDefault();
// stop immediate in order to prevent Input#_onBlur from
// getting exectued
Expand Down Expand Up @@ -2572,7 +2572,7 @@

module.exports = {
hits: __webpack_require__(21),
popularIn: __webpack_require__(22)
popularIn: __webpack_require__(24)
};


Expand All @@ -2583,8 +2583,14 @@
'use strict';

var _ = __webpack_require__(4);
var version = __webpack_require__(22);
var parseAlgoliaClientVersion = __webpack_require__(23);

module.exports = function search(index, params) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params.additionalUA = 'autocomplete.js ' + version;
}
return sourceFn;

function sourceFn(query, cb) {
Expand All @@ -2601,13 +2607,38 @@

/***/ },
/* 22 */
/***/ function(module, exports) {

module.exports = "3.4.2";


/***/ },
/* 23 */
/***/ function(module, exports) {

'use strict';
module.exports = function parseAlgoliaClientVersion(agent) {
var parsed = agent.match(/Algolia for vanilla JavaScript (\d+\.)(\d+\.)(\d+)/);
if (parsed) return [parsed[1], parsed[2], parsed[3]];
return undefined;
};


/***/ },
/* 24 */
/***/ function(module, exports, __webpack_require__) {

'use strict';

var _ = __webpack_require__(4);
var version = __webpack_require__(22);
var parseAlgoliaClientVersion = __webpack_require__(23);

module.exports = function popularIn(index, params, details, options) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params.additionalUA = 'autocomplete.js ' + version;
}
if (!details.source) {
return _.error("Missing 'source' key");
}
Expand Down
3 changes: 2 additions & 1 deletion dist/autocomplete.jquery.min.js

Large diffs are not rendered by default.

35 changes: 33 additions & 2 deletions dist/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ return /******/ (function(modules) { // webpackBootstrap
// #351: preventDefault won't cancel blurs in ie <= 8
$input.on('blur.aa', function($e) {
var active = document.activeElement;
if (_.isMsie() && ($menu.is(active) || $menu.has(active).length > 0)) {
if (_.isMsie() && ($menu[0] === active || $menu[0].contains(active))) {
$e.preventDefault();
// stop immediate in order to prevent Input#_onBlur from
// getting exectued
Expand Down Expand Up @@ -3822,7 +3822,7 @@ return /******/ (function(modules) { // webpackBootstrap

module.exports = {
hits: __webpack_require__(21),
popularIn: __webpack_require__(22)
popularIn: __webpack_require__(24)
};


Expand All @@ -3833,8 +3833,14 @@ return /******/ (function(modules) { // webpackBootstrap
'use strict';

var _ = __webpack_require__(4);
var version = __webpack_require__(22);
var parseAlgoliaClientVersion = __webpack_require__(23);

module.exports = function search(index, params) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params.additionalUA = 'autocomplete.js ' + version;
}
return sourceFn;

function sourceFn(query, cb) {
Expand All @@ -3851,13 +3857,38 @@ return /******/ (function(modules) { // webpackBootstrap

/***/ },
/* 22 */
/***/ function(module, exports) {

module.exports = "3.4.2";


/***/ },
/* 23 */
/***/ function(module, exports) {

'use strict';
module.exports = function parseAlgoliaClientVersion(agent) {
var parsed = agent.match(/Algolia for vanilla JavaScript (\d+\.)(\d+\.)(\d+)/);
if (parsed) return [parsed[1], parsed[2], parsed[3]];
return undefined;
};


/***/ },
/* 24 */
/***/ function(module, exports, __webpack_require__) {

'use strict';

var _ = __webpack_require__(4);
var version = __webpack_require__(22);
var parseAlgoliaClientVersion = __webpack_require__(23);

module.exports = function popularIn(index, params, details, options) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params.additionalUA = 'autocomplete.js ' + version;
}
if (!details.source) {
return _.error("Missing 'source' key");
}
Expand Down
4 changes: 2 additions & 2 deletions dist/autocomplete.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ if [[ -n $(git status --porcelain) ]]; then
error_exit "Release: Working tree is not clean (git status)"
fi

echo "module.exports = \"${nextVersion}\";" > version.js
git add version.js

yarn &&
mversion $nextVersion &&
yarn build &&
Expand Down
6 changes: 6 additions & 0 deletions src/common/parseAlgoliaClientVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';
module.exports = function parseAlgoliaClientVersion(agent) {
var parsed = agent.match(/Algolia for vanilla JavaScript (\d+\.)(\d+\.)(\d+)/);
if (parsed) return [parsed[1], parsed[2], parsed[3]];
return undefined;
};
6 changes: 6 additions & 0 deletions src/sources/hits.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
'use strict';

var _ = require('../common/utils.js');
var version = require('../../version.js');
var parseAlgoliaClientVersion = require('../common/parseAlgoliaClientVersion.js');

module.exports = function search(index, params) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params.additionalUA = 'autocomplete.js ' + version;
}
return sourceFn;

function sourceFn(query, cb) {
Expand Down
6 changes: 6 additions & 0 deletions src/sources/popularIn.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
'use strict';

var _ = require('../common/utils.js');
var version = require('../../version.js');
var parseAlgoliaClientVersion = require('../common/parseAlgoliaClientVersion.js');

module.exports = function popularIn(index, params, details, options) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params.additionalUA = 'autocomplete.js ' + version;
}
if (!details.source) {
return _.error("Missing 'source' key");
}
Expand Down
2 changes: 1 addition & 1 deletion test/playground.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h4>Multi-sections auto-complete</h4>
</div>

<script src="../../dist/autocomplete.js"></script>
<script src="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
<script src="https://cdn.jsdelivr.net/algoliasearch/3.21.0/algoliasearch.js"></script>
<script type="text/template" id="my-custom-menu-template">
<div class="my-custom-menu">
<div class="row">
Expand Down
1 change: 1 addition & 0 deletions version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "3.4.2";

0 comments on commit 6ca7ac2

Please sign in to comment.