1
0
Fork 0

chore(cleaning): upgrade all deps, prepare renovate (#206)

This commit is contained in:
Vincent Voyer 2017-10-18 00:43:51 +02:00 committed by GitHub
parent 607567508b
commit 5afc05ecd2
21 changed files with 19134 additions and 11740 deletions

View file

@ -1,3 +1,3 @@
module.exports = {
extends: ['algolia'],
extends: ['algolia/jest'],
};

2
.gitignore vendored
View file

@ -4,6 +4,8 @@ node_modules/
dist/
.idea/
npm-debug.log*
yarn-error.log
docs/_site
docs/.sass-cache/
dist-es5-module/
yarn.lock

1
.nvmrc Normal file
View file

@ -0,0 +1 @@
8.7.0

View file

@ -1,21 +1,22 @@
language: node_js
node_js: stable
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.2.1
- export PATH=$HOME/.yarn/bin:$PATH
- git config --global user.email "algobot@users.noreply.github.com"
- git config --global user.name "algobot"
- rvm install 2.2.0
- rvm use 2.2.0
- rvm install 2.4.0
- rvm use 2.4.0
script: "./scripts/test-ci"
sudo: false
branches:
only:
- master
sudo: false
cache:
bundler: true
yarn: true
directories:
- node_modules
before_cache:
- rm -f ./node_modules/.bin/which
env:
global:
- secure: WyC8pO+X2CYnHaL9w7bq+94w5JHhn2B1lIIcXdsB7h21uhV4flqepjuOURNEfppJWi83Tq02tvmOKs6xgaZ49hjStat6hB+CDX6V2++C+On4mneMVIQ7AOER2aA5H6xmVK73ifhUxGLYRty5qSY3SwJ6em3Nb9iBIyJ0x4QrOpiY9BqzJ7neQ8olG1EWfLCtUZi5bUvhKXX4Dwko+wVwPhez203poclX0E5njVAYsF6V8/ybvaAc0MC5snivBLwgWgCPQ6j1Owz9Xs689xovlMOtHOzjmFyQ7pk46kd3B34ghapBM/M2mtxY+GoBFrMC2qhmhqbuS9zzknk8otby/4M6Ae1631Hw86EeIP2uHvze3V3Ipq2bJuglceZB35BwnCvIOHDw8GJ0b8KG01vS6LfuOAthAUbKp/dJ89kseNZziNGPfh3eyu7yJ4B7A2D3YJXI8/3iEHPZYMBXRgb6iHYHv+75Cquipb0e0KGQOEhnCGCLqzrzOA2FtuOhjRse+oga7uOzjFXZTPornYJoHy2BkUudELbjtIrHDM4A36rYMv20Si7IoQdQxeRWA58JG3icAgpRHhnOcwImVj7YzPwCUeUNBPwMO/L+99khVYrD5CjfGqxYx99W5mHruSneXdx8o2idijsSx0nUQ3vhNyjJRx1KjNiyxcEZ48FS33c=
- secure: fPkWaIIAJCzARj0TYEwslyZ8Nrr8WbgH/951Uk4LLwnXVBVUgEQNfVCFIyKOu8vYezgVzdfoZq59YWzBbhUC4+2Cx66SlucE7I420SMKon2Ajsfmj4llAlmWnkaPUIhafT5JZICragH8rUPCq8NURiuWiCnhLBHzFU8suxf7CoSb2dmmSdeNwgGPtJQLKdihxaAWvu4+jOhRV8+OjeGhEEvnAo60HuCyFgShVZFP487LfDlHPxc6XPeX27yq34A2Txr9KoM8ab/6md1EcUegr7V0+NGcZ/tDeRXqJJS2gGillKjvn4gihwCn7EgGhnDhKm4lng+fifg6FBwsy6rFUIfyqWTkyWNc3NVhGUh9t6e6h7+qfWxlejJbFRKCorVfG7+P73dGQ/kNnHS6clkLsS7JnE9cB0KdcFBzgDk6j69rKsEe7WH7edn9wKotgV6GDzaLpoTQnfuWmG+iO6tWAewxC8gPa/ifRXwbL2GVqKV1HWeKIHLTUiteTOe8qhcjD+WgubU6emEiY44JDzd2Yjo5szMsOBSAogDTdblGkBiY2aqIii8sBS5WDWLykq1QTebWjHgolwVcLbw0vn18NdGq+1Wtfqr6OukIYi0SXbjf/6FAa6VQeElpt9ZADlw54Z4uR7izCjVNoJX0pRvDhQHuTWNcQx2GiFEow8mZLH0=
secure: TDLpvycpMbbXpwSKLLeDBZdpi05rbZEbPcII9LSglUG9teF/zrqxRMl+Eivvho8IkeJRDQVwdc8EbYCzZ9cAwRHOyqzDNwRFhlpKVwz+fl5uHfxDo5DANsut6F+l/RrBf4n2MWKkJlbo4kq8mUqL89vcPqfRTLpx62FawywDgiJc2s+ixR1lkm5GNlF74ovoUkeOXiLi605LE0sN7H/1TRdD6WOJTBT2yoiuDU3U/RUKJxka6Sz4u9kqUQpn+kJUIPiBiasbz65qglnrxpBL/mYgAEZfRcbVyC5zd+CeFSIlIiGdhMFoVInNMqshq7gl/UWcJyxdnGIIfhO3l/Y/lyEXQQknEZS4M2h7UKeCuu0E1hh7eT7kVVyXDW+nCUNVYPTuupvLwcpnXw02Flef72OpDy6bl19NEdH79lNK4l440GJb+Lhda2M2mMZJmRkg31j9HFjl0wCYqRopzNTKNBFJAPTB4rG6H/y7NgPFjrATphEDLZgq73eNDxtRNBQHtLqGl8IsaFHU4+8vAQ2iEbi5+R/D5Rua2BXSbYAdQjxnvmPojQ7voZgj+w5GHx2573plCvqO4pZvV/u5/Z18tEYIV+4LFC7KR+30Snbk0JAbRogQr6P4mkVrKG/7pAcGS5tpxhMY3OUNaJWdDP8NE1c3/0Q2pKqdB0RauGoUO2w=

View file

@ -31,15 +31,14 @@ Have a fix or a new feature? [Search for corresponding issues](https://github.co
To run this project, you will need:
- Node.js >= v8.7.0, use nvm - [install instructions](https://github.com/creationix/nvm#install-script)
- Yarn >= v1.2.0 - [install instructions](https://yarnpkg.com/en/docs/install#alternatives-tab)
- [Ruby](https://www.ruby-lang.org/en/)
- [Bundler](http://bundler.io/)
## Launch
```sh
yarn
yarn run dev:docs
npm install
npm run dev:docs
```
Then go to:

View file

@ -1,4 +1,5 @@
var docsearch = require('../index.js');
// eslint-disable-next-line import/no-commonjs
const docsearch = require('../index.js');
docsearch({
apiKey: 'e3d767b736584dbe6d4c35f7cf7d4633',

View file

@ -38,3 +38,5 @@ kramdown:
# Assets
sass:
sass_dir: css
exclude: [node_modules]

View file

@ -1,45 +1,17 @@
'use strict';
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 _toConsumableArray(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}
return arr2;
} else {
return Array.from(arr);
}
}
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Main header function with docsearch
* @param {Object} docSearch config
*/
var communityHeader = (function() {
var communityHeader = function () {
function communityHeader(docSearchCredentials, docSearch) {
var _this = this;
@ -50,12 +22,12 @@ var communityHeader = (function() {
this.menuState = {
isOpen: false,
isOpenMobile: false,
isOpenMobile: false
};
this.INIT_VAL = {
WIDTH: 490,
HEIGHT: 360,
HEIGHT: 360
};
this.disableTransitionTimeout;
@ -63,52 +35,35 @@ var communityHeader = (function() {
this.searchIcon = document.querySelector('#search');
this.cancelIcon = document.querySelector('#cancel');
this.searchInputContainer = document.querySelector('.algc-search__input');
this.searchContainer = this.searchInputContainer
? this.searchInputContainer.parentNode
: null;
this.searchContainer = this.searchInputContainer ? this.searchInputContainer.parentNode : null;
this.navRoot = document.querySelector('.algc-dropdownroot');
this.dropdownRoot = document.querySelector(
'.algc-navigation__dropdown-holder'
);
this.dropdownRoot = document.querySelector('.algc-navigation__dropdown-holder');
this.navItems = document.querySelectorAll('a[data-enabledropdown="true"]');
this.navContainer = document.querySelector(
'.algc-dropdownroot__dropdowncontainer'
);
this.navContainer = document.querySelector('.algc-dropdownroot__dropdowncontainer');
this.menuContainer = document.querySelector('.algc-navigation__container');
this.navBg = document.querySelector('.algc-dropdownroot__dropdownbg');
this.navArrow = document.querySelector('.algc-dropdownroot__dropdownarrow');
this.dropDownContainer = document.querySelector(
'.algc-dropdownroot__dropdowncontainer'
);
this.menuTriggers = document.querySelectorAll(
'[data-enabledropdown="true"]'
);
this.dropDownContainer = document.querySelector('.algc-dropdownroot__dropdowncontainer');
this.menuTriggers = document.querySelectorAll('[data-enabledropdown="true"]');
this.mobileMenuButton = document.querySelector('.algc-openmobile ');
this.mobileMenu = document.querySelector('.algc-mobilemenu');
this.subList = document.querySelectorAll('.algc-menu--sublistlink');
this.subListHolders = []
.concat(_toConsumableArray(this.subList))
.map(function(node) {
return node.parentNode;
});
this.subListHolders = [].concat(_toConsumableArray(this.subList)).map(function (node) {
return node.parentNode;
});
this.menuDropdowns = {};
[].forEach.call(
document.querySelectorAll('[data-dropdown-content]'),
function(item) {
_this.menuDropdowns[item.dataset.dropdownContent] = {
parent: item.parentNode,
content: item,
};
}
);
[].forEach.call(document.querySelectorAll('[data-dropdown-content]'), function (item) {
_this.menuDropdowns[item.dataset.dropdownContent] = {
parent: item.parentNode,
content: item
};
});
this.shouldInitDocSearch = this.shouldInitDocSearch.bind(this);
this.docSearchInit = this.checkDocSearch(docSearch);
this.enableDocSearch = this.verifyDocSearchParams(docSearchCredentials);
this.hasDocSearchRendered = document.querySelector(
'.algc-navigation .algc-search__input--docsearch'
);
this.hasDocSearchRendered = document.querySelector('.algc-navigation .algc-search__input--docsearch');
this.triggerMenu = this.triggerMenu.bind(this);
this.shouldTriggerMenu = this.shouldTriggerMenu.bind(this);
this.closeMenu = this.closeMenu.bind(this);
@ -127,288 +82,236 @@ var communityHeader = (function() {
this.bindListeners();
}
_createClass(communityHeader, [
{
key: 'calculatePosition',
value: function calculatePosition(sourceNode) {
var box = sourceNode.getBoundingClientRect();
var realWidth = sourceNode.offsetWidth;
var realHeight = sourceNode.offsetHeight;
_createClass(communityHeader, [{
key: 'calculatePosition',
value: function calculatePosition(sourceNode) {
var box = sourceNode.getBoundingClientRect();
var realWidth = sourceNode.offsetWidth;
var realHeight = sourceNode.offsetHeight;
return {
left: box.left,
top: box.top,
width: box.width,
height: box.height,
realWidth: realWidth,
realHeight: realHeight,
center: box.left + box.width / 2,
};
},
},
{
key: 'shouldInitDocSearch',
value: function shouldInitDocSearch() {
if (!this.enableDocSearch && this.hasDocSearchRendered) {
throw new Error(
'You need to pass docSearch: { apiKey, indexName, inputSelector } to communityHeader function in order to initialise docSearch'
);
}
},
},
{
key: 'checkDocSearch',
value: function checkDocSearch() {
var docSearch = arguments.length > 0 && arguments[0] !== undefined
? arguments[0]
: false;
return {
left: box.left,
top: box.top,
width: box.width,
height: box.height,
realWidth: realWidth,
realHeight: realHeight,
center: box.left + box.width / 2
};
}
}, {
key: 'shouldInitDocSearch',
value: function shouldInitDocSearch() {
if (!this.enableDocSearch && this.hasDocSearchRendered) {
throw new Error('You need to pass docSearch: { apiKey, indexName, inputSelector } to communityHeader function in order to initialise docSearch');
}
}
}, {
key: 'checkDocSearch',
value: function checkDocSearch() {
var docSearch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if (docSearch) return docSearch;
if (docSearch) return docSearch;
if (
typeof window.docsearch === 'function' ||
typeof docsearch === 'function'
) {
return docsearch;
}
},
},
{
key: 'verifyDocSearchParams',
value: function verifyDocSearchParams(docSearchCredentials) {
return docSearchCredentials &&
docSearchCredentials.apiKey &&
docSearchCredentials.indexName &&
docSearchCredentials.inputSelector
? true
: false;
},
},
{
key: 'triggerMenu',
value: function triggerMenu(event) {
var _this2 = this;
if (typeof window.docsearch === "function" || typeof docsearch === "function") {
return docsearch;
}
}
}, {
key: 'verifyDocSearchParams',
value: function verifyDocSearchParams(docSearchCredentials) {
return docSearchCredentials && docSearchCredentials.apiKey && docSearchCredentials.indexName && docSearchCredentials.inputSelector ? true : false;
}
}, {
key: 'triggerMenu',
value: function triggerMenu(event) {
var _this2 = this;
var dropdown = event.target.dataset.dropdown;
var newTarget = this.menuDropdowns[dropdown].content;
var newContent = this.menuDropdowns[dropdown].parent;
var dropdown = event.target.dataset.dropdown;
var newTarget = this.menuDropdowns[dropdown].content;
var newContent = this.menuDropdowns[dropdown].parent;
var navItem = this.calculatePosition(event.target);
var newTargetCoordinates = this.calculatePosition(newTarget);
var menuContainerOffset = this.calculatePosition(this.menuContainer);
var leftDistance = void 0;
var navItem = this.calculatePosition(event.target);
var newTargetCoordinates = this.calculatePosition(newTarget);
var menuContainerOffset = this.calculatePosition(this.menuContainer);
var leftDistance = void 0;
var scaleFactors = {
X: newTargetCoordinates.realWidth / this.INIT_VAL.WIDTH,
Y: newTargetCoordinates.realHeight / this.INIT_VAL.HEIGHT,
};
var scaleFactors = {
X: newTargetCoordinates.realWidth / this.INIT_VAL.WIDTH,
Y: newTargetCoordinates.realHeight / this.INIT_VAL.HEIGHT
};
leftDistance = navItem.center - menuContainerOffset.left + 'px';
leftDistance = navItem.center - menuContainerOffset.left + "px";
if (menuContainerOffset.left < 20) {
leftDistance = 'calc(50% - 36px)';
}
if (menuContainerOffset.left < 20) {
leftDistance = "calc(50% - 36px)";
}
this.navBg.style.cssText = '\n transform: translateX(' +
leftDistance +
') scale(' +
scaleFactors.X +
', ' +
scaleFactors.Y +
')';
this.navBg.style.cssText = '\n transform: translateX(' + leftDistance + ') scale(' + scaleFactors.X + ', ' + scaleFactors.Y + ')';
this.navArrow.style.cssText = '\n transform: translateX(' +
leftDistance +
') rotate(45deg)';
this.navArrow.style.cssText = '\n transform: translateX(' + leftDistance + ') rotate(45deg)';
this.dropDownContainer.style.cssText = '\n transform: translateX(' +
leftDistance +
');\n width: ' +
newTargetCoordinates.realWidth +
'px;\n height: ' +
(newTargetCoordinates.realHeight + 10) +
'px;';
this.dropDownContainer.style.cssText = '\n transform: translateX(' + leftDistance + ');\n width: ' + newTargetCoordinates.realWidth + 'px;\n height: ' + (newTargetCoordinates.realHeight + 10) + 'px;';
this.dropdownRoot.style.pointerEvents = 'auto';
this.dropdownRoot.style.pointerEvents = "auto";
Object.keys(this.menuDropdowns).forEach(function(key) {
if (key === dropdown) {
_this2.menuDropdowns[key].parent.classList.add('active');
} else {
_this2.menuDropdowns[key].parent.classList.remove('active');
}
});
if (!this.menuState.isOpen) {
setTimeout(
function() {
_this2.navRoot.className = 'algc-dropdownroot activeDropdown';
},
50
);
}
window.clearTimeout(this.disableTransitionTimeout);
this.menuState.isOpen = true;
},
},
{
key: 'shouldTriggerMenu',
value: function shouldTriggerMenu(event) {
var _this3 = this;
if (this.menuState.isOpen) {
this.triggerMenu(event);
Object.keys(this.menuDropdowns).forEach(function (key) {
if (key === dropdown) {
_this2.menuDropdowns[key].parent.classList.add('active');
} else {
this.triggerMenuTimeout = setTimeout(
function() {
_this3.triggerMenu(event);
},
200
);
_this2.menuDropdowns[key].parent.classList.remove('active');
}
},
},
{
key: 'closeMenu',
value: function closeMenu(event) {
var _this4 = this;
});
window.clearTimeout(this.triggerMenuTimeout);
this.menuState.isOpen = false;
this.disableTransitionTimeout = setTimeout(
function() {
_this4.dropdownRoot.style.pointerEvents = 'none';
_this4.navRoot.className = 'algc-dropdownroot notransition';
},
50
);
},
},
{
key: 'toggleMobileMenu',
value: function toggleMobileMenu(event) {
this.mobileMenuButton.classList.toggle('algc-openmobile--open');
this.mobileMenu.classList.toggle('algc-mobilemenu--open');
},
if (!this.menuState.isOpen) {
setTimeout(function () {
_this2.navRoot.className = "algc-dropdownroot activeDropdown";
}, 50);
}
// Search
},
{
key: 'docSearchToggling',
value: function docSearchToggling() {
var _this5 = this;
window.clearTimeout(this.disableTransitionTimeout);
this.menuState.isOpen = true;
}
}, {
key: 'shouldTriggerMenu',
value: function shouldTriggerMenu(event) {
var _this3 = this;
this.searchInput = document.querySelector(
this.docSearchCredentials.inputSelector
);
var openSearchInput = function openSearchInput() {
_this5.searchContainer.classList.add('open');
_this5.searchInput.focus();
};
if (this.menuState.isOpen) {
this.triggerMenu(event);
} else {
this.triggerMenuTimeout = setTimeout(function () {
_this3.triggerMenu(event);
}, 200);
}
}
}, {
key: 'closeMenu',
value: function closeMenu(event) {
var _this4 = this;
var closeSearchInput = function closeSearchInput() {
_this5.searchInput.blur();
_this5.searchContainer.classList.remove('open');
};
window.clearTimeout(this.triggerMenuTimeout);
this.menuState.isOpen = false;
this.disableTransitionTimeout = setTimeout(function () {
_this4.dropdownRoot.style.pointerEvents = "none";
_this4.navRoot.className = "algc-dropdownroot notransition";
}, 50);
}
}, {
key: 'toggleMobileMenu',
value: function toggleMobileMenu(event) {
this.mobileMenuButton.classList.toggle('algc-openmobile--open');
this.mobileMenu.classList.toggle('algc-mobilemenu--open');
}
var emptySearchInput = function emptySearchInput() {
if (_this5.searchInput.value !== '') {
_this5.searchInput.value = '';
} else {
closeSearchInput();
}
};
this.searchInput.setAttribute('value', '');
this.searchIcon.addEventListener('click', openSearchInput);
this.cancelIcon.addEventListener('click', emptySearchInput);
},
},
{
key: 'initDocSearch',
value: function initDocSearch() {
this.docSearchToggling();
this.docSearchInit(this.docSearchCredentials);
},
},
{
key: 'initDocSearchStrategy',
value: function initDocSearchStrategy() {
var _this6 = this;
// Search
if (this.enableDocSearch && typeof this.docSearchInit === 'function') {
this.initDocSearch();
} else if (this.docSearch === 'lazy') {
var docSearchScript = document.createElement('script');
docSearchScript.type = 'text/javascript';
docSearchScript.async = true;
document.body.appendChild(docSearchScript);
}, {
key: 'docSearchToggling',
value: function docSearchToggling() {
var _this5 = this;
docSearchScript.onload = function() {
_this6.docSearchInit = docsearch;
_this6.initDocSearch();
};
this.searchInput = document.querySelector(this.docSearchCredentials.inputSelector);
var openSearchInput = function openSearchInput() {
_this5.searchContainer.classList.add('open');
_this5.searchInput.focus();
};
docSearchScript.src = 'https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js';
var closeSearchInput = function closeSearchInput() {
_this5.searchInput.blur();
_this5.searchContainer.classList.remove('open');
};
var emptySearchInput = function emptySearchInput() {
if (_this5.searchInput.value !== '') {
_this5.searchInput.value = '';
} else {
closeSearchInput();
}
},
},
{
key: 'openSublist',
value: function openSublist(node) {
var parent = node.parentNode;
this.subListHolders.forEach(function(holder) {
if (holder === parent && !parent.classList.contains('open')) {
holder.classList.add('open');
} else {
holder.classList.remove('open');
}
});
},
},
{
key: 'closeSubLists',
value: function closeSubLists(event) {
this.subListHolders.forEach(function(holder) {
return holder.classList.remove('open');
});
},
},
{
key: 'bindListeners',
value: function bindListeners() {
var _this7 = this;
};
this.searchInput.setAttribute('value', '');
this.searchIcon.addEventListener('click', openSearchInput);
this.cancelIcon.addEventListener('click', emptySearchInput);
}
}, {
key: 'initDocSearch',
value: function initDocSearch() {
this.docSearchToggling();
this.docSearchInit(this.docSearchCredentials);
}
}, {
key: 'initDocSearchStrategy',
value: function initDocSearchStrategy() {
var _this6 = this;
var that = this;
this.subList.forEach(function(link) {
link.addEventListener('click', function(event) {
event.preventDefault();
event.stopPropagation();
that.openSublist(this);
});
});
if (this.enableDocSearch && typeof this.docSearchInit === "function") {
this.initDocSearch();
} else if (this.docSearch === "lazy") {
this.menuTriggers.forEach(function(item) {
item.addEventListener('mouseenter', _this7.shouldTriggerMenu);
item.addEventListener('focus', _this7.triggerMenu);
});
var docSearchScript = document.createElement('script');
docSearchScript.type = 'text/javascript';
docSearchScript.async = true;
document.body.appendChild(docSearchScript);
this.navItems.forEach(function(item) {
item.addEventListener('mouseleave', _this7.closeMenu);
});
docSearchScript.onload = function () {
_this6.docSearchInit = docsearch;
_this6.initDocSearch();
};
this.navContainer.addEventListener('mouseenter', function() {
clearTimeout(_this7.disableTransitionTimeout);
});
docSearchScript.src = "https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js";
}
}
}, {
key: 'openSublist',
value: function openSublist(node) {
var parent = node.parentNode;
this.subListHolders.forEach(function (holder) {
if (holder === parent && !parent.classList.contains('open')) {
holder.classList.add('open');
} else {
holder.classList.remove('open');
}
});
}
}, {
key: 'closeSubLists',
value: function closeSubLists(event) {
this.subListHolders.forEach(function (holder) {
return holder.classList.remove('open');
});
}
}, {
key: 'bindListeners',
value: function bindListeners() {
var _this7 = this;
this.mobileMenuButton.addEventListener('click', this.toggleMobileMenu);
document.addEventListener('click', this.closeSubLists);
document
.querySelector('.algc-dropdownroot__dropdowncontainer')
.addEventListener('mouseleave', this.closeMenu);
},
},
]);
var that = this;
this.subList.forEach(function (link) {
link.addEventListener('click', function (event) {
event.preventDefault();
event.stopPropagation();
that.openSublist(this);
});
});
this.menuTriggers.forEach(function (item) {
item.addEventListener('mouseenter', _this7.shouldTriggerMenu);
item.addEventListener('focus', _this7.triggerMenu);
});
this.navItems.forEach(function (item) {
item.addEventListener('mouseleave', _this7.closeMenu);
});
this.navContainer.addEventListener('mouseenter', function () {
clearTimeout(_this7.disableTransitionTimeout);
});
this.mobileMenuButton.addEventListener('click', this.toggleMobileMenu);
document.addEventListener('click', this.closeSubLists);
document.querySelector('.algc-dropdownroot__dropdowncontainer').addEventListener('mouseleave', this.closeMenu);
}
}]);
return communityHeader;
})();
}();

5491
docs/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"dependencies": {
"algolia-aerial": "^1.1.5",
"algolia-aerial": "1.1.6",
"algolia-frontend-components": "^0.0.34"
}
}

File diff suppressed because it is too large Load diff

13305
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -15,15 +15,9 @@
"release": "./scripts/release",
"release:beta": "./scripts/release-beta",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"test": "jest --coverage && npm run lint",
"test:watch": "jest --watch",
"precommit": "lint-staged"
},
"lint-staged": {
"*.js": [
"prettier --write --single-quote --trailing-comma es5",
"git add"
]
"test:watch": "jest --watch"
},
"files": [
"dist/"
@ -32,47 +26,45 @@
"license": "MIT",
"repository": "algolia/docsearch",
"devDependencies": {
"autoprefixer": "^6.7.7",
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-eslint": "^7.2.1",
"autoprefixer": "7.1.5",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-eslint": "8.0.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",
"babel-jest": "21.2.0",
"babel-loader": "7.1.2",
"babel-plugin-rewire": "1.1.0",
"babel-preset-env": "1.6.1",
"babel-preset-stage-3": "6.24.1",
"conventional-changelog-cli": "1.3.4",
"cssnano": "^3.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-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",
"eslint": "4.9.0",
"eslint-config-algolia": "12.0.0",
"eslint-config-prettier": "2.6.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jest": "21.2.0",
"eslint-plugin-prettier": "2.3.1",
"gh-pages": "1.0.0",
"jest": "21.2.1",
"jsdom": "11.3.0",
"json": "^9.0.6",
"lint-staged": "^3.4.0",
"mversion": "^1.10.1",
"node-sass": "^4.5.1",
"node-sass": "4.5.3",
"onchange": "^3.2.1",
"postcss-cli": "^3.0.0",
"prettier": "^0.22.0",
"postcss-cli": "4.1.1",
"prettier": "1.7.4",
"pretty-bytes-cli": "^2.0.0",
"semver": "^5.1.0",
"sinon": "^2.1.0",
"uglify-js": "^2.8.16",
"webpack": "^2.3.2",
"webpack-dev-server": "^2.4.2"
"semver": "5.4.1",
"sinon": "4.0.1",
"uglify-js": "3.1.4",
"webpack": "3.8.1",
"webpack-dev-server": "2.9.2"
},
"peerDependencies": {},
"dependencies": {
"algoliasearch": "^3.22.1",
"autocomplete.js": "^0.28.0",
"algoliasearch": "3.24.5",
"autocomplete.js": "0.29.0",
"hogan.js": "^3.0.2",
"to-factory": "^1.0.0"
}

View file

@ -18,12 +18,9 @@ webpack --config webpack.config.jsdelivr.babel.js
echo "$LICENSE" | cat - "${DIST_FILE}" > /tmp/out && mv /tmp/out "${DIST_FILE}"
uglifyjs "${DIST_FILE}" \
--in-source-map "${DIST_FILE_SOURCEMAP}" \
--source-map "${DIST_FILE_SOURCEMAP_MIN}" \
--preamble "$LICENSE" \
-c warnings=false \
-m \
-o "${DIST_FILE_MIN}"
--source-map "content='${DIST_FILE_SOURCEMAP}',filename='${DIST_FILE_SOURCEMAP_MIN}'" \
--beautify "preamble='$LICENSE'" \
--output "${DIST_FILE_MIN}"
# docsearch as several ES5 files, to be `require`d
babel -q index.js -o "$DIST_DIR_NPM/index.js"

View file

@ -4,7 +4,7 @@ set -ev # exit when error
cd docs && \
bundle install && \
yarn && \
npm intall && \
node communityHeader.js && \
bundle exec guard -i & \
npm run dev & \

View file

@ -8,11 +8,10 @@ ghpages.clean();
if (process.env.CI === 'true') {
ghpages.publish(basePath, {
repo: 'https://' + process.env.GH_TOKEN + '@github.com/algolia/docsearch.git',
logger: log
repo: 'https://' + process.env.GH_TOKEN + '@github.com/algolia/docsearch.git'
}, end);
} else {
ghpages.publish(basePath, {logger: log}, end);
ghpages.publish(basePath, end);
}
function end(err) {
@ -21,8 +20,4 @@ function end(err) {
} else {
console.log('published gh-pages');
}
}
function log(msg) {
console.log(msg);
}
}

View file

@ -22,5 +22,4 @@ while true; do
sleep 30
done
curl --silent -L $CACHE_URL > /dev/null
./scripts/docs/update-website

View file

@ -29,26 +29,24 @@ const usage = `Usage:
[ autocompleteOptions.{hint,debug} ]
})`;
class DocSearch {
constructor(
{
apiKey,
indexName,
inputSelector,
appId = 'BH4D9OD16A',
debug = false,
algoliaOptions = {},
autocompleteOptions = {
debug: false,
hint: false,
autoselect: true,
},
transformData = false,
queryHook = false,
handleSelected = false,
enhancedSearchInput = false,
layout = 'collumns',
}
) {
constructor({
apiKey,
indexName,
inputSelector,
appId = 'BH4D9OD16A',
debug = false,
algoliaOptions = {},
autocompleteOptions = {
debug: false,
hint: false,
autoselect: true,
},
transformData = false,
queryHook = false,
handleSelected = false,
enhancedSearchInput = false,
layout = 'collumns',
}) {
DocSearch.checkArguments({
apiKey,
indexName,
@ -68,16 +66,18 @@ class DocSearch {
this.indexName = indexName;
this.input = DocSearch.getInputFromSelector(inputSelector);
this.algoliaOptions = { hitsPerPage: 5, ...algoliaOptions };
const autocompleteOptionsDebug = autocompleteOptions &&
autocompleteOptions.debug
? autocompleteOptions.debug
: false;
const autocompleteOptionsDebug =
autocompleteOptions && autocompleteOptions.debug
? autocompleteOptions.debug
: false;
// eslint-disable-next-line no-param-reassign
autocompleteOptions.debug = debug || autocompleteOptionsDebug;
this.autocompleteOptions = autocompleteOptions;
this.autocompleteOptions.cssClasses = {
prefix: 'ds',
};
// eslint-disable-next-line no-param-reassign
handleSelected = handleSelected || this.handleSelected;
this.isSimpleLayout = layout === 'simple';
@ -133,7 +133,10 @@ class DocSearch {
static injectSearchBox(input) {
input.before(templates.searchBox);
const newInput = input.prev().prev().find('input');
const newInput = input
.prev()
.prev()
.find('input');
input.remove();
return newInput;
}
@ -179,6 +182,7 @@ class DocSearch {
getAutocompleteSource(transformData, queryHook) {
return (query, callback) => {
if (queryHook) {
// eslint-disable-next-line no-param-reassign
query = queryHook(query) || query;
}
@ -206,6 +210,7 @@ class DocSearch {
const clonedHits = utils.deepClone(receivedHits);
const hits = clonedHits.map(hit => {
if (hit._highlightResult) {
// eslint-disable-next-line no-param-reassign
hit._highlightResult = utils.mergeKeyWithParent(
hit._highlightResult,
'hierarchy'
@ -243,15 +248,15 @@ class DocSearch {
'<span class="aa-suggestion-title-separator" aria-hidden="true"> </span>'
);
const text = utils.getSnippetedValue(hit, 'content');
const isTextOrSubcatoryNonEmpty = (subcategory && subcategory !== '') ||
const isTextOrSubcatoryNonEmpty =
(subcategory && subcategory !== '') ||
(displayTitle && displayTitle !== '');
const isLvl1EmptyOrDuplicate = !subcategory ||
subcategory === '' ||
subcategory === category;
const isLvl2 = displayTitle &&
displayTitle !== '' &&
displayTitle !== subcategory;
const isLvl1 = !isLvl2 &&
const isLvl1EmptyOrDuplicate =
!subcategory || subcategory === '' || subcategory === category;
const isLvl2 =
displayTitle && displayTitle !== '' && displayTitle !== subcategory;
const isLvl1 =
!isLvl2 &&
(subcategory && subcategory !== '' && subcategory !== category);
const isLvl0 = !isLvl1 && !isLvl2;
@ -311,12 +316,14 @@ class DocSearch {
middleOfWindow = 900;
}
const alignClass = middleOfInput - middleOfWindow >= 0
? 'algolia-autocomplete-right'
: 'algolia-autocomplete-left';
const otherAlignClass = middleOfInput - middleOfWindow < 0
? 'algolia-autocomplete-right'
: 'algolia-autocomplete-left';
const alignClass =
middleOfInput - middleOfWindow >= 0
? 'algolia-autocomplete-right'
: 'algolia-autocomplete-left';
const otherAlignClass =
middleOfInput - middleOfWindow < 0
? 'algolia-autocomplete-right'
: 'algolia-autocomplete-left';
const autocompleteWrapper = $('.algolia-autocomplete');
if (!autocompleteWrapper.hasClass(alignClass)) {

View file

@ -371,9 +371,10 @@ describe('DocSearch', () => {
describe('when queryHook is used', () => {
it('calls the Agolia client with the correct parameters', () => {
// Given
const actual = docsearch.getAutocompleteSource(false, function(query) {
return query + ' modified';
});
const actual = docsearch.getAutocompleteSource(
false,
query => `${query} modified`
);
// When
actual('query');
@ -681,8 +682,8 @@ describe('DocSearch', () => {
lvl5: null,
},
_highlightResult: {
// eslint-disable-next-line camelcase
hierarchy_camel: {
// eslint-disable-line camelcase
lvl0: {
value: '<mark>Python</mark>',
matchLevel: 'full',
@ -792,7 +793,8 @@ describe('DocSearch', () => {
// When
const actual = DocSearch.formatHits(input);
const separator = '<span class="aa-suggestion-title-separator" aria-hidden="true"> </span>';
const separator =
'<span class="aa-suggestion-title-separator" aria-hidden="true"> </span>';
// Then
expect(actual[0].title).toEqual(
`Geo-search${separator}Foo${separator}Bar${separator}Baz`
@ -838,7 +840,8 @@ describe('DocSearch', () => {
// When
const actual = DocSearch.formatHits(input);
const separator = '<span class="aa-suggestion-title-separator" aria-hidden="true"> </span>';
const separator =
'<span class="aa-suggestion-title-separator" aria-hidden="true"> </span>';
// Then
const expected = `<mark>Geo-search</mark>${separator}<mark>Foo</mark>${separator}<mark>Bar</mark>${separator}<mark>Baz</mark>`;
expect(actual[0].title).toEqual(expected);

View file

@ -153,9 +153,11 @@ const utils = {
flattenAndFlagFirst(object, flag) {
const values = this.values(object).map(collection =>
collection.map((item, index) => {
// eslint-disable-next-line no-param-reassign
item[flag] = index === 0;
return item;
}));
})
);
return this.flatten(values);
},
/*

6941
yarn.lock

File diff suppressed because it is too large Load diff