docsearch.js
Advanced tools
Comparing version 2.3.1 to 2.3.2
'use strict'; | ||
/* eslint-disable import/no-commonjs */ | ||
module.exports = require('./src/lib/main.js'); |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
@@ -9,35 +9,35 @@ }); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _hogan = require('hogan.js'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _hogan2 = _interopRequireDefault(_hogan); | ||
var _hoganJs = require('hogan.js'); | ||
var _lite = require('algoliasearch/lite'); | ||
var _hoganJs2 = _interopRequireDefault(_hoganJs); | ||
var _lite2 = _interopRequireDefault(_lite); | ||
var _algoliasearchLite = require('algoliasearch/lite'); | ||
var _autocomplete = require('autocomplete.js'); | ||
var _algoliasearchLite2 = _interopRequireDefault(_algoliasearchLite); | ||
var _autocomplete2 = _interopRequireDefault(_autocomplete); | ||
var _autocompleteJs = require('autocomplete.js'); | ||
var _templates = require('./templates.js'); | ||
var _autocompleteJs2 = _interopRequireDefault(_autocompleteJs); | ||
var _templates2 = _interopRequireDefault(_templates); | ||
var _templatesJs = require('./templates.js'); | ||
var _utils = require('./utils.js'); | ||
var _templatesJs2 = _interopRequireDefault(_templatesJs); | ||
var _utils2 = _interopRequireDefault(_utils); | ||
var _utilsJs = require('./utils.js'); | ||
var _version = require('./version.js'); | ||
var _utilsJs2 = _interopRequireDefault(_utilsJs); | ||
var _version2 = _interopRequireDefault(_version); | ||
var _versionJs = require('./version.js'); | ||
var _zepto = require('./zepto.js'); | ||
var _versionJs2 = _interopRequireDefault(_versionJs); | ||
var _zepto2 = _interopRequireDefault(_zepto); | ||
var _zeptoJs = require('./zepto.js'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _zeptoJs2 = _interopRequireDefault(_zeptoJs); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -59,32 +59,42 @@ /** | ||
var DocSearch = (function () { | ||
var DocSearch = function () { | ||
function DocSearch(_ref) { | ||
var apiKey = _ref.apiKey; | ||
var indexName = _ref.indexName; | ||
var inputSelector = _ref.inputSelector; | ||
var _ref$appId = _ref.appId; | ||
var appId = _ref$appId === undefined ? 'BH4D9OD16A' : _ref$appId; | ||
var _ref$debug = _ref.debug; | ||
var debug = _ref$debug === undefined ? false : _ref$debug; | ||
var _ref$algoliaOptions = _ref.algoliaOptions; | ||
var algoliaOptions = _ref$algoliaOptions === undefined ? {} : _ref$algoliaOptions; | ||
var _ref$autocompleteOptions = _ref.autocompleteOptions; | ||
var autocompleteOptions = _ref$autocompleteOptions === undefined ? { | ||
var apiKey = _ref.apiKey, | ||
indexName = _ref.indexName, | ||
inputSelector = _ref.inputSelector, | ||
_ref$appId = _ref.appId, | ||
appId = _ref$appId === undefined ? 'BH4D9OD16A' : _ref$appId, | ||
_ref$debug = _ref.debug, | ||
debug = _ref$debug === undefined ? false : _ref$debug, | ||
_ref$algoliaOptions = _ref.algoliaOptions, | ||
algoliaOptions = _ref$algoliaOptions === undefined ? {} : _ref$algoliaOptions, | ||
_ref$autocompleteOpti = _ref.autocompleteOptions, | ||
autocompleteOptions = _ref$autocompleteOpti === undefined ? { | ||
debug: false, | ||
hint: false, | ||
autoselect: true | ||
} : _ref$autocompleteOptions; | ||
var _ref$transformData = _ref.transformData; | ||
var transformData = _ref$transformData === undefined ? false : _ref$transformData; | ||
var _ref$handleSelected = _ref.handleSelected; | ||
var handleSelected = _ref$handleSelected === undefined ? false : _ref$handleSelected; | ||
var _ref$enhancedSearchInput = _ref.enhancedSearchInput; | ||
var enhancedSearchInput = _ref$enhancedSearchInput === undefined ? false : _ref$enhancedSearchInput; | ||
var _ref$layout = _ref.layout; | ||
var layout = _ref$layout === undefined ? 'collumns' : _ref$layout; | ||
} : _ref$autocompleteOpti, | ||
_ref$transformData = _ref.transformData, | ||
transformData = _ref$transformData === undefined ? false : _ref$transformData, | ||
_ref$handleSelected = _ref.handleSelected, | ||
handleSelected = _ref$handleSelected === undefined ? false : _ref$handleSelected, | ||
_ref$enhancedSearchIn = _ref.enhancedSearchInput, | ||
enhancedSearchInput = _ref$enhancedSearchIn === undefined ? false : _ref$enhancedSearchIn, | ||
_ref$layout = _ref.layout, | ||
layout = _ref$layout === undefined ? 'collumns' : _ref$layout; | ||
_classCallCheck(this, DocSearch); | ||
DocSearch.checkArguments({ apiKey: apiKey, indexName: indexName, inputSelector: inputSelector, debug: debug, algoliaOptions: algoliaOptions, | ||
autocompleteOptions: autocompleteOptions, transformData: transformData, handleSelected: handleSelected, enhancedSearchInput: enhancedSearchInput, layout: layout }); | ||
DocSearch.checkArguments({ | ||
apiKey: apiKey, | ||
indexName: indexName, | ||
inputSelector: inputSelector, | ||
debug: debug, | ||
algoliaOptions: algoliaOptions, | ||
autocompleteOptions: autocompleteOptions, | ||
transformData: transformData, | ||
handleSelected: handleSelected, | ||
enhancedSearchInput: enhancedSearchInput, | ||
layout: layout | ||
}); | ||
@@ -107,4 +117,4 @@ this.apiKey = apiKey; | ||
this.client = (0, _algoliasearchLite2['default'])(this.appId, this.apiKey); | ||
this.client.addAlgoliaAgent('docsearch.js ' + _versionJs2['default']); | ||
this.client = (0, _lite2.default)(this.appId, this.apiKey); | ||
this.client.addAlgoliaAgent('docsearch.js ' + _version2.default); | ||
@@ -115,7 +125,7 @@ if (enhancedSearchInput) { | ||
this.autocomplete = (0, _autocompleteJs2['default'])(this.input, autocompleteOptions, [{ | ||
this.autocomplete = (0, _autocomplete2.default)(this.input, autocompleteOptions, [{ | ||
source: this.getAutocompleteSource(transformData), | ||
templates: { | ||
suggestion: DocSearch.getSuggestionTemplate(this.isSimpleLayout), | ||
footer: _templatesJs2['default'].footer, | ||
footer: _templates2.default.footer, | ||
empty: DocSearch.getEmptyTemplate() | ||
@@ -139,5 +149,7 @@ } | ||
_createClass(DocSearch, [{ | ||
key: 'getAutocompleteSource', | ||
/** | ||
@@ -171,2 +183,3 @@ * Returns the `source` method to be passed to autocomplete.js. It will query | ||
// a Hogan template | ||
}, { | ||
@@ -182,3 +195,3 @@ key: 'handleSelected', | ||
var middleOfInput = input.offset().left + input.width() / 2; | ||
var middleOfWindow = (0, _zeptoJs2['default'])(document).width() / 2; | ||
var middleOfWindow = (0, _zepto2.default)(document).width() / 2; | ||
@@ -192,3 +205,3 @@ if (isNaN(middleOfWindow)) { | ||
var autocompleteWrapper = (0, _zeptoJs2['default'])('.algolia-autocomplete'); | ||
var autocompleteWrapper = (0, _zepto2.default)('.algolia-autocomplete'); | ||
if (!autocompleteWrapper.hasClass(alignClass)) { | ||
@@ -216,7 +229,6 @@ autocompleteWrapper.addClass(alignClass); | ||
value: function injectSearchBox(input) { | ||
input.before(_templatesJs2['default'].searchBox); | ||
var new_input = input.prev().prev().find('input'); | ||
input.before(_templates2.default.searchBox); | ||
var newInput = input.prev().prev().find('input'); | ||
input.remove(); | ||
return new_input; | ||
return newInput; | ||
} | ||
@@ -226,9 +238,9 @@ }, { | ||
value: function bindSearchBoxEvent() { | ||
(0, _zeptoJs2['default'])('.searchbox [type="reset"]').on('click', function () { | ||
(0, _zeptoJs2['default'])('input#docsearch').focus(); | ||
(0, _zeptoJs2['default'])(this).addClass('hide'); | ||
_autocompleteJs2['default'].autocomplete.setVal(''); | ||
(0, _zepto2.default)('.searchbox [type="reset"]').on('click', function () { | ||
(0, _zepto2.default)('input#docsearch').focus(); | ||
(0, _zepto2.default)(this).addClass('hide'); | ||
_autocomplete2.default.autocomplete.setVal(''); | ||
}); | ||
(0, _zeptoJs2['default'])('input#docsearch').on('keyup', function () { | ||
(0, _zepto2.default)('input#docsearch').on('keyup', function () { | ||
var searchbox = document.querySelector('input#docsearch'); | ||
@@ -250,7 +262,8 @@ var reset = document.querySelector('.searchbox [type="reset"]'); | ||
*/ | ||
}, { | ||
key: 'getInputFromSelector', | ||
value: function getInputFromSelector(selector) { | ||
var input = (0, _zeptoJs2['default'])(selector).filter('input'); | ||
return input.length ? (0, _zeptoJs2['default'])(input[0]) : null; | ||
var input = (0, _zepto2.default)(selector).filter('input'); | ||
return input.length ? (0, _zepto2.default)(input[0]) : null; | ||
} | ||
@@ -260,18 +273,18 @@ }, { | ||
value: function formatHits(receivedHits) { | ||
var clonedHits = _utilsJs2['default'].deepClone(receivedHits); | ||
var clonedHits = _utils2.default.deepClone(receivedHits); | ||
var hits = clonedHits.map(function (hit) { | ||
if (hit._highlightResult) { | ||
hit._highlightResult = _utilsJs2['default'].mergeKeyWithParent(hit._highlightResult, 'hierarchy'); | ||
hit._highlightResult = _utils2.default.mergeKeyWithParent(hit._highlightResult, 'hierarchy'); | ||
} | ||
return _utilsJs2['default'].mergeKeyWithParent(hit, 'hierarchy'); | ||
return _utils2.default.mergeKeyWithParent(hit, 'hierarchy'); | ||
}); | ||
// Group hits by category / subcategory | ||
var groupedHits = _utilsJs2['default'].groupBy(hits, 'lvl0'); | ||
_zeptoJs2['default'].each(groupedHits, function (level, collection) { | ||
var groupedHitsByLvl1 = _utilsJs2['default'].groupBy(collection, 'lvl1'); | ||
var flattenedHits = _utilsJs2['default'].flattenAndFlagFirst(groupedHitsByLvl1, 'isSubCategoryHeader'); | ||
var groupedHits = _utils2.default.groupBy(hits, 'lvl0'); | ||
_zepto2.default.each(groupedHits, function (level, collection) { | ||
var groupedHitsByLvl1 = _utils2.default.groupBy(collection, 'lvl1'); | ||
var flattenedHits = _utils2.default.flattenAndFlagFirst(groupedHitsByLvl1, 'isSubCategoryHeader'); | ||
groupedHits[level] = flattenedHits; | ||
}); | ||
groupedHits = _utilsJs2['default'].flattenAndFlagFirst(groupedHits, 'isCategoryHeader'); | ||
groupedHits = _utils2.default.flattenAndFlagFirst(groupedHits, 'isCategoryHeader'); | ||
@@ -281,6 +294,6 @@ // Translate hits into smaller objects to be send to the template | ||
var url = DocSearch.formatURL(hit); | ||
var category = _utilsJs2['default'].getHighlightedValue(hit, 'lvl0'); | ||
var subcategory = _utilsJs2['default'].getHighlightedValue(hit, 'lvl1') || category; | ||
var displayTitle = _utilsJs2['default'].compact([_utilsJs2['default'].getHighlightedValue(hit, 'lvl2') || subcategory, _utilsJs2['default'].getHighlightedValue(hit, 'lvl3'), _utilsJs2['default'].getHighlightedValue(hit, 'lvl4'), _utilsJs2['default'].getHighlightedValue(hit, 'lvl5'), _utilsJs2['default'].getHighlightedValue(hit, 'lvl6')]).join('<span class="aa-suggestion-title-separator" aria-hidden="true"> › </span>'); | ||
var text = _utilsJs2['default'].getSnippetedValue(hit, 'content'); | ||
var category = _utils2.default.getHighlightedValue(hit, 'lvl0'); | ||
var subcategory = _utils2.default.getHighlightedValue(hit, 'lvl1') || category; | ||
var displayTitle = _utils2.default.compact([_utils2.default.getHighlightedValue(hit, 'lvl2') || subcategory, _utils2.default.getHighlightedValue(hit, 'lvl3'), _utils2.default.getHighlightedValue(hit, 'lvl4'), _utils2.default.getHighlightedValue(hit, 'lvl5'), _utils2.default.getHighlightedValue(hit, 'lvl6')]).join('<span class="aa-suggestion-title-separator" aria-hidden="true"> › </span>'); | ||
var text = _utils2.default.getSnippetedValue(hit, 'content'); | ||
var isTextOrSubcatoryNonEmpty = subcategory && subcategory !== '' || displayTitle && displayTitle !== ''; | ||
@@ -311,4 +324,4 @@ var isLvl1EmptyOrDuplicate = !subcategory || subcategory === '' || subcategory === category; | ||
value: function formatURL(hit) { | ||
var url = hit.url; | ||
var anchor = hit.anchor; | ||
var url = hit.url, | ||
anchor = hit.anchor; | ||
@@ -329,3 +342,3 @@ if (url) { | ||
return function (args) { | ||
return _hoganJs2['default'].compile(_templatesJs2['default'].empty).render(args); | ||
return _hogan2.default.compile(_templates2.default.empty).render(args); | ||
}; | ||
@@ -336,4 +349,4 @@ } | ||
value: function getSuggestionTemplate(isSimpleLayout) { | ||
var stringTemplate = isSimpleLayout ? _templatesJs2['default'].suggestionSimple : _templatesJs2['default'].suggestion; | ||
var template = _hoganJs2['default'].compile(stringTemplate); | ||
var stringTemplate = isSimpleLayout ? _templates2.default.suggestionSimple : _templates2.default.suggestion; | ||
var template = _hogan2.default.compile(stringTemplate); | ||
return function (suggestion) { | ||
@@ -346,5 +359,4 @@ return template.render(suggestion); | ||
return DocSearch; | ||
})(); | ||
}(); | ||
exports['default'] = DocSearch; | ||
module.exports = exports['default']; | ||
exports.default = DocSearch; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _toFactory = require('to-factory'); | ||
@@ -17,10 +15,11 @@ | ||
var _versionJs = require('./version.js'); | ||
var _version = require('./version.js'); | ||
var _versionJs2 = _interopRequireDefault(_versionJs); | ||
var _version2 = _interopRequireDefault(_version); | ||
var docsearch = (0, _toFactory2['default'])(_DocSearch2['default']); | ||
docsearch.version = _versionJs2['default']; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports['default'] = docsearch; | ||
module.exports = exports['default']; | ||
var docsearch = (0, _toFactory2.default)(_DocSearch2.default); | ||
docsearch.version = _version2.default; | ||
exports.default = docsearch; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
@@ -17,6 +17,5 @@ }); | ||
empty: '\n <div class="' + suggestionPrefix + '">\n <div class="' + suggestionPrefix + '--wrapper">\n <div class="' + suggestionPrefix + '--content ' + suggestionPrefix + '--no-results">\n <div class="' + suggestionPrefix + '--title">\n <div class="' + suggestionPrefix + '--text">\n No results found for query <b>"{{query}}"</b>\n </div>\n </div>\n </div>\n </div>\n </div>\n ', | ||
searchBox: '\n <form novalidate="novalidate" onsubmit="return false;" class="searchbox">\n\t<div role="search" class="searchbox__wrapper">\n\t\t<input id="docsearch" type="search" name="search" placeholder="Search the docs" autocomplete="off" required="required" class="searchbox__input">\n\t\t<button type="submit" title="Submit your search query." class="searchbox__submit" >\n\t\t<svg width=12 height=12 role="img" aria-label="Search">\n\t\t\t<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-search-13"></use>\n\t\t\t\t</svg>\n\t\t\t</button>\n\t\t<button type="reset" title="Clear the search query." class="searchbox__reset hide">\n\t\t<svg width=12 height=12 role="img" aria-label="Reset">\n\t\t\t<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-clear-3"></use>\n\t\t\t</svg>\n\t\t</button>\n\t</div>\n</form>\n\n<div class="svg-icons" style="height: 0; width: 0; position: absolute; visibility: hidden">\n\t<svg xmlns="http://www.w3.org/2000/svg">\n\t\t<symbol id="sbx-icon-clear-3" viewBox="0 0 40 40"><path d="M16.228 20L1.886 5.657 0 3.772 3.772 0l1.885 1.886L20 16.228 34.343 1.886 36.228 0 40 3.772l-1.886 1.885L23.772 20l14.342 14.343L40 36.228 36.228 40l-1.885-1.886L20 23.772 5.657 38.114 3.772 40 0 36.228l1.886-1.885L16.228 20z" fill-rule="evenodd"/></symbol>\n\t\t<symbol id="sbx-icon-search-13" viewBox="0 0 40 40"><path d="M26.806 29.012a16.312 16.312 0 0 1-10.427 3.746C7.332 32.758 0 25.425 0 16.378 0 7.334 7.333 0 16.38 0c9.045 0 16.378 7.333 16.378 16.38 0 3.96-1.406 7.593-3.746 10.426L39.547 37.34c.607.608.61 1.59-.004 2.203a1.56 1.56 0 0 1-2.202.004L26.807 29.012zm-10.427.627c7.322 0 13.26-5.938 13.26-13.26 0-7.324-5.938-13.26-13.26-13.26-7.324 0-13.26 5.936-13.26 13.26 0 7.322 5.936 13.26 13.26 13.26z" fill-rule="evenodd"/></symbol>\n\t</svg>\n</div>\n ' | ||
searchBox: '\n <form novalidate="novalidate" onsubmit="return false;" class="searchbox">\n <div role="search" class="searchbox__wrapper">\n <input id="docsearch" type="search" name="search" placeholder="Search the docs" autocomplete="off" required="required" class="searchbox__input"/>\n <button type="submit" title="Submit your search query." class="searchbox__submit" >\n <svg width=12 height=12 role="img" aria-label="Search">\n <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-search-13"></use>\n </svg>\n </button>\n <button type="reset" title="Clear the search query." class="searchbox__reset hide">\n <svg width=12 height=12 role="img" aria-label="Reset">\n <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-clear-3"></use>\n </svg>\n </button>\n </div>\n</form>\n\n<div class="svg-icons" style="height: 0; width: 0; position: absolute; visibility: hidden">\n <svg xmlns="http://www.w3.org/2000/svg">\n <symbol id="sbx-icon-clear-3" viewBox="0 0 40 40"><path d="M16.228 20L1.886 5.657 0 3.772 3.772 0l1.885 1.886L20 16.228 34.343 1.886 36.228 0 40 3.772l-1.886 1.885L23.772 20l14.342 14.343L40 36.228 36.228 40l-1.885-1.886L20 23.772 5.657 38.114 3.772 40 0 36.228l1.886-1.885L16.228 20z" fill-rule="evenodd"></symbol>\n <symbol id="sbx-icon-search-13" viewBox="0 0 40 40"><path d="M26.806 29.012a16.312 16.312 0 0 1-10.427 3.746C7.332 32.758 0 25.425 0 16.378 0 7.334 7.333 0 16.38 0c9.045 0 16.378 7.333 16.378 16.38 0 3.96-1.406 7.593-3.746 10.426L39.547 37.34c.607.608.61 1.59-.004 2.203a1.56 1.56 0 0 1-2.202.004L26.807 29.012zm-10.427.627c7.322 0 13.26-5.938 13.26-13.26 0-7.324-5.938-13.26-13.26-13.26-7.324 0-13.26 5.936-13.26 13.26 0 7.322 5.936 13.26 13.26 13.26z" fill-rule="evenodd"></symbol>\n </svg>\n</div>\n ' | ||
}; | ||
exports['default'] = templates; | ||
module.exports = exports['default']; | ||
exports.default = templates; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _zeptoJs = require('./zepto.js'); | ||
var _zepto = require('./zepto.js'); | ||
var _zeptoJs2 = _interopRequireDefault(_zeptoJs); | ||
var _zepto2 = _interopRequireDefault(_zepto); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var utils = { | ||
@@ -39,9 +41,10 @@ /* | ||
} | ||
if (typeof object[property] !== 'object') { | ||
if (_typeof(object[property]) !== 'object') { | ||
return object; | ||
} | ||
var newObject = _zeptoJs2['default'].extend({}, object, object[property]); | ||
var newObject = _zepto2.default.extend({}, object, object[property]); | ||
delete newObject[property]; | ||
return newObject; | ||
}, | ||
/* | ||
@@ -80,3 +83,3 @@ * Group all objects of a collection by the value of the specified attribute | ||
var newCollection = {}; | ||
_zeptoJs2['default'].each(collection, function (index, item) { | ||
_zepto2.default.each(collection, function (index, item) { | ||
if (item[property] === undefined) { | ||
@@ -89,3 +92,5 @@ throw new Error('[groupBy]: Object has no key ' + property); | ||
} | ||
if (!newCollection[key]) { | ||
// fix #171 the given data type of docsearch hits might be conflict with the properties of the native Object, | ||
// such as the constructor, so we need to do this check. | ||
if (!Object.prototype.hasOwnProperty.call(newCollection, key)) { | ||
newCollection[key] = []; | ||
@@ -97,15 +102,16 @@ } | ||
}, | ||
/* | ||
* Return an array of all the values of the specified object | ||
* eg. | ||
* values({ | ||
* foo: 42, | ||
* bar: true, | ||
* baz: 'yep' | ||
* }) | ||
* => | ||
* [42, true, yep] | ||
* @param {object} object Object to extract values from | ||
* @return {array} | ||
*/ | ||
* Return an array of all the values of the specified object | ||
* eg. | ||
* values({ | ||
* foo: 42, | ||
* bar: true, | ||
* baz: 'yep' | ||
* }) | ||
* => | ||
* [42, true, yep] | ||
* @param {object} object Object to extract values from | ||
* @return {array} | ||
*/ | ||
values: function values(object) { | ||
@@ -116,11 +122,12 @@ return Object.keys(object).map(function (key) { | ||
}, | ||
/* | ||
* Flattens an array | ||
* eg. | ||
* flatten([1, 2, [3, 4], [5, 6]]) | ||
* => | ||
* [1, 2, 3, 4, 5, 6] | ||
* @param {array} array Array to flatten | ||
* @return {array} | ||
*/ | ||
* Flattens an array | ||
* eg. | ||
* flatten([1, 2, [3, 4], [5, 6]]) | ||
* => | ||
* [1, 2, 3, 4, 5, 6] | ||
* @param {array} array Array to flatten | ||
* @return {array} | ||
*/ | ||
flatten: function flatten(array) { | ||
@@ -139,31 +146,32 @@ var results = []; | ||
}, | ||
/* | ||
* Flatten all values of an object into an array, marking each first element of | ||
* each group with a specific flag | ||
* eg. | ||
* flattenAndFlagFirst({ | ||
* 'devs': [ | ||
* {name: 'Tim', category: 'dev'}, | ||
* {name: 'Vincent', category: 'dev'}, | ||
* {name: 'AlexS', category: 'dev'} | ||
* ], | ||
* 'sales': [ | ||
* {name: 'Ben', category: 'sales'}, | ||
* {name: 'Jeremy', category: 'sales'}, | ||
* {name: 'AlexK', category: 'sales'} | ||
* ] | ||
* , 'isTop'); | ||
* => | ||
* [ | ||
* {name: 'Tim', category: 'dev', isTop: true}, | ||
* {name: 'Vincent', category: 'dev', isTop: false}, | ||
* {name: 'AlexS', category: 'dev', isTop: false}, | ||
* {name: 'Ben', category: 'sales', isTop: true}, | ||
* {name: 'Jeremy', category: 'sales', isTop: false}, | ||
* {name: 'AlexK', category: 'sales', isTop: false} | ||
* ] | ||
* @param {object} object Object to flatten | ||
* @param {string} flag Flag to set to true on first element of each group | ||
* @return {array} | ||
*/ | ||
* Flatten all values of an object into an array, marking each first element of | ||
* each group with a specific flag | ||
* eg. | ||
* flattenAndFlagFirst({ | ||
* 'devs': [ | ||
* {name: 'Tim', category: 'dev'}, | ||
* {name: 'Vincent', category: 'dev'}, | ||
* {name: 'AlexS', category: 'dev'} | ||
* ], | ||
* 'sales': [ | ||
* {name: 'Ben', category: 'sales'}, | ||
* {name: 'Jeremy', category: 'sales'}, | ||
* {name: 'AlexK', category: 'sales'} | ||
* ] | ||
* , 'isTop'); | ||
* => | ||
* [ | ||
* {name: 'Tim', category: 'dev', isTop: true}, | ||
* {name: 'Vincent', category: 'dev', isTop: false}, | ||
* {name: 'AlexS', category: 'dev', isTop: false}, | ||
* {name: 'Ben', category: 'sales', isTop: true}, | ||
* {name: 'Jeremy', category: 'sales', isTop: false}, | ||
* {name: 'AlexK', category: 'sales', isTop: false} | ||
* ] | ||
* @param {object} object Object to flatten | ||
* @param {string} flag Flag to set to true on first element of each group | ||
* @return {array} | ||
*/ | ||
flattenAndFlagFirst: function flattenAndFlagFirst(object, flag) { | ||
@@ -178,11 +186,12 @@ var values = this.values(object).map(function (collection) { | ||
}, | ||
/* | ||
* Removes all empty strings, null, false and undefined elements array | ||
* eg. | ||
* compact([42, false, null, undefined, '', [], 'foo']); | ||
* => | ||
* [42, [], 'foo'] | ||
* @param {array} array Array to compact | ||
* @return {array} | ||
*/ | ||
* Removes all empty strings, null, false and undefined elements array | ||
* eg. | ||
* compact([42, false, null, undefined, '', [], 'foo']); | ||
* => | ||
* [42, [], 'foo'] | ||
* @param {array} array Array to compact | ||
* @return {array} | ||
*/ | ||
compact: function compact(array) { | ||
@@ -198,2 +207,3 @@ var results = []; | ||
}, | ||
/* | ||
@@ -226,2 +236,3 @@ * Returns the highlighted value of the specified key in the specified object. | ||
}, | ||
/* | ||
@@ -254,15 +265,16 @@ * Returns the snippeted value of the specified key in the specified object. | ||
if (snippet[0] !== snippet[0].toUpperCase()) { | ||
snippet = '…' + snippet; | ||
snippet = '\u2026' + snippet; | ||
} | ||
if (['.', '!', '?'].indexOf(snippet[snippet.length - 1]) === -1) { | ||
snippet = snippet + '…'; | ||
snippet = snippet + '\u2026'; | ||
} | ||
return snippet; | ||
}, | ||
/* | ||
* Deep clone an object. | ||
* Note: This will not clone functions and dates | ||
* @param {object} object Object to clone | ||
* @return {object} | ||
*/ | ||
* Deep clone an object. | ||
* Note: This will not clone functions and dates | ||
* @param {object} object Object to clone | ||
* @return {object} | ||
*/ | ||
deepClone: function deepClone(object) { | ||
@@ -273,3 +285,2 @@ return JSON.parse(JSON.stringify(object)); | ||
exports['default'] = utils; | ||
module.exports = exports['default']; | ||
exports.default = utils; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports['default'] = '2.3.1'; | ||
module.exports = exports['default']; | ||
exports.default = '2.3.2'; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _zepto = require('autocomplete.js/zepto.js'); | ||
var _autocompleteJsZeptoJs = require('autocomplete.js/zepto.js'); | ||
var _zepto2 = _interopRequireDefault(_zepto); | ||
var _autocompleteJsZeptoJs2 = _interopRequireDefault(_autocompleteJsZeptoJs); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports['default'] = _autocompleteJsZeptoJs2['default']; | ||
module.exports = exports['default']; | ||
exports.default = _zepto2.default; |
{ | ||
"name": "docsearch.js", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "Add an autocomplete dropdown to your documentation", | ||
@@ -18,7 +18,16 @@ "main": "dist/npm/index.js", | ||
"lint": "eslint .", | ||
"test": "BABEL_ENV=test mocha --timeout 6000 --reporter dot ./test/helpers.js ./test/*-test.js", | ||
"test:watch": "BABEL_ENV=test mocha --reporter min --watch ./test/helpers.js ./test/*-test.js", | ||
"test:coverage": "./scripts/test-coverage", | ||
"gh-pages": "./scripts/gh-pages" | ||
"test": "jest --coverage && npm run lint", | ||
"test:watch": "jest --watch", | ||
"gh-pages": "./scripts/gh-pages", | ||
"precommit": "lint-staged" | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"prettier --write --single-quote --trailing-comma es5", | ||
"git add" | ||
] | ||
}, | ||
"files": [ | ||
"dist/" | ||
], | ||
"author": "Algolia <support@algolia.com> (https://github.com/algolia/)", | ||
@@ -28,41 +37,44 @@ "license": "MIT", | ||
"devDependencies": { | ||
"autoprefixer": "^6.3.6", | ||
"babel": "^5.8.29", | ||
"babel-core": "^5.8.29", | ||
"babel-eslint": "^4.1.3", | ||
"babel-istanbul": "^0.5.9", | ||
"babel-loader": "^5.3.2", | ||
"babel-plugin-rewire": "^0.1.22", | ||
"conventional-changelog": "^0.5.1", | ||
"coveralls": "^2.11.9", | ||
"autoprefixer": "^6.7.7", | ||
"babel-cli": "^6.24.0", | ||
"babel-core": "^6.24.0", | ||
"babel-eslint": "^7.2.1", | ||
"babel-istanbul": "^0.12.2", | ||
"babel-loader": "^6.4.1", | ||
"babel-plugin-rewire": "^1.0.0", | ||
"babel-preset-env": "^1.2.2", | ||
"babel-preset-stage-3": "^6.22.0", | ||
"conventional-changelog-cli": "^1.3.1", | ||
"cssnano": "^3.7.0", | ||
"doctoc": "^0.15.0", | ||
"eslint": "^1.6.0", | ||
"eslint-config-airbnb": "^0.1.0", | ||
"eslint-config-algolia": "^4.7.0", | ||
"doctoc": "^1.3.0", | ||
"eslint": "^3.18.0", | ||
"eslint-config-algolia": "^7.0.2", | ||
"eslint-config-prettier": "^1.5.0", | ||
"eslint-import-resolver-webpack": "^0.8.1", | ||
"eslint-plugin-algolia": "^1.5.0", | ||
"eslint-plugin-react": "^3.5.1", | ||
"expect": "^1.20.1", | ||
"gh-pages": "^0.8.0", | ||
"jsdom": "^7.1.1", | ||
"json": "^9.0.4", | ||
"mocha": "^2.5.3", | ||
"mocha-jsdom": "^1.1.0", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-jest": "^19.0.1", | ||
"gh-pages": "^0.12.0", | ||
"husky": "^0.13.3", | ||
"jest": "^19.0.2", | ||
"jsdom": "^9.12.0", | ||
"json": "^9.0.6", | ||
"lint-staged": "^3.4.0", | ||
"mversion": "^1.10.1", | ||
"nd": "^1.2.0", | ||
"node-sass": "^3.7.0", | ||
"onchange": "^2.5.0", | ||
"postcss-cli": "^2.5.2", | ||
"pretty-bytes": "^2.0.1", | ||
"node-sass": "^4.5.1", | ||
"onchange": "^3.2.1", | ||
"postcss-cli": "^3.0.0", | ||
"prettier": "^0.22.0", | ||
"pretty-bytes-cli": "^2.0.0", | ||
"semver": "^5.1.0", | ||
"sinon": "^1.17.4", | ||
"uglify-js": "^2.6.2", | ||
"webpack": "^1.13.1", | ||
"webpack-dev-server": "^1.14.1" | ||
"sinon": "^2.1.0", | ||
"uglify-js": "^2.8.16", | ||
"webpack": "^2.3.2", | ||
"webpack-dev-server": "^2.4.2" | ||
}, | ||
"peerDependencies": {}, | ||
"dependencies": { | ||
"algoliasearch": "^3.18.0", | ||
"autocomplete.js": "^0.25.0", | ||
"algoliasearch": "^3.22.1", | ||
"autocomplete.js": "^0.28.0", | ||
"hogan.js": "^3.0.2", | ||
@@ -69,0 +81,0 @@ "to-factory": "^1.0.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
4
1348239
37
20
10964
5
+ Addedautocomplete.js@0.28.3(transitive)
- Removedautocomplete.js@0.25.0(transitive)
Updatedalgoliasearch@^3.22.1
Updatedautocomplete.js@^0.28.0