Commit 5b3b4f46 authored by Simonas's avatar Simonas

Merge branch 'small-bugs' into dev

parents 777ca6be 7b32190d
......@@ -12,7 +12,7 @@
padding-bottom: 50px;
}
@media (--min--medium) {
flex: 0 0 400px; padding: 70px 40px;
flex: 0 0 400px; padding: 70px 40px; max-width: 400px;
}
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -19,7 +19,7 @@ eval("module.exports = function(originalModule) {\n\tif (!originalModule.webpack
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor/awesomplete */ \"./wp-content/themes/biuro/js/components/autocomplete/vendor/awesomplete.js\");\n\n\nconst lisp = str => {\n var symbols = {\n 'ą': 'a',\n 'č': 'c',\n 'ę': 'e',\n 'ė': 'e',\n 'į': 'i',\n 'š': 's',\n 'ų': 'u',\n 'ū': 'u',\n 'ž': 'z',\n 'ā': 'a',\n 'ē': 'e',\n 'ģ': 'g',\n 'ī': 'i',\n 'ķ': 'k',\n 'ļ': 'l',\n 'ņ': 'n',\n 'õ': 'o',\n 'ä': 'a',\n 'ö': 'o',\n 'ü': 'u'\n };\n str = str.trim();\n str = str.toLowerCase();\n str = str.replace(/[ąčęėįšųūžāēģīķļņõäöü]/g, s => {\n return symbols[s];\n });\n return str;\n};\n\nconst autocomplete = str => {\n const node = document.getElementById(str);\n const arrow = document.querySelector('.js-toggle--' + str);\n const clear = document.querySelector('.js-clear--' + str);\n let isOpen = false;\n\n const update = (langID, target, str, hidden) => {\n const type = target.id === 'search-city' ? 'query' : 'city';\n fetch('/wp-json/api/v1/options?langID=' + langID + '&str=' + str + '&type=' + type).then(t => t.json()).then(data => {\n if (!data || !data.length) {\n return;\n }\n\n const list = data.map(option => {\n return {\n label: option.name + ' (' + option.total + ')',\n value: option.name\n };\n });\n target.box.list = list;\n\n if (hidden) {\n target.box.evaluate();\n target.box.close();\n } else {\n target.focus();\n target.box.evaluate();\n }\n });\n };\n\n const updateOptions = node => {\n const target = node.id === 'search-city' ? document.getElementById('search-query') : document.getElementById('search-city');\n\n if (!target || target.value && node.value) {\n return;\n }\n\n if (!target.value && node.value) {\n update(node.dataset.id, target, node.value, true);\n } else if (!node.value) {\n update(node.dataset.id, node, target.value);\n\n if (!target.value) {\n update(node.dataset.id, target, target.value, true);\n }\n }\n };\n\n const toggle = (status, delay = 0) => {\n setTimeout(() => {\n isOpen = status;\n }, delay);\n\n if (arrow) {\n arrow.classList.toggle('is-open', status);\n }\n };\n\n if (!node) {\n return;\n }\n\n const box = new _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__[\"default\"](node, {\n minChars: 0,\n maxItems: 1000,\n sort: false,\n filter: function (text, input) {\n return lisp(text).indexOf(lisp(input)) !== -1;\n }\n });\n node.addEventListener('input', () => {\n if (clear) {\n clear.classList.toggle('u-hidden', !node.value);\n }\n\n if (arrow) {\n arrow.classList.toggle('u-hidden', !!node.value);\n }\n });\n node.addEventListener('focus', () => {\n if (box.ul.childNodes.length === 0 || box.ul.hasAttribute('hidden')) {\n toggle(true);\n box.evaluate();\n } else {\n toggle(false);\n box.close();\n }\n });\n node.addEventListener('blur', () => {\n const suggestion = Array.isArray(box.suggestions) && box.suggestions.length === 1 ? box.suggestions[0] : null;\n\n if (!suggestion) {\n return;\n }\n\n if (lisp(node.value) === lisp(suggestion.value)) {\n node.value = suggestion.value;\n }\n });\n node.addEventListener('awesomplete-selectcomplete', () => {\n node.blur();\n updateOptions(node);\n\n if (clear) {\n clear.classList.remove('u-hidden');\n }\n\n if (arrow) {\n arrow.classList.add('u-hidden');\n }\n });\n node.addEventListener('awesomplete-close', () => {\n toggle(false, 150);\n });\n\n if (arrow) {\n arrow.addEventListener('click', () => {\n if (!isOpen) {\n node.focus();\n } else {\n box.close();\n }\n });\n }\n\n if (clear) {\n clear.addEventListener('click', () => {\n node.value = '';\n updateOptions(node);\n\n if (clear) {\n clear.classList.add('u-hidden');\n }\n\n if (arrow) {\n arrow.classList.remove('u-hidden');\n }\n });\n }\n\n node.box = box;\n};\n\nconst setCityAwesomplete = (node, cityID) => {\n if (!node || !cityID) {\n return;\n }\n\n const nodeBox = new _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__[\"default\"](node, {\n minChars: 0,\n maxItems: 1000,\n sort: false,\n filter: function (text, input) {\n return lisp(text).indexOf(lisp(input)) !== -1;\n },\n replace: function (suggestion) {\n this.input.value = suggestion.label;\n\n if (cityID) {\n cityID.value = suggestion.value;\n }\n }\n });\n node.addEventListener('focus', () => {\n nodeBox.evaluate();\n });\n node.addEventListener('blur', () => {\n const suggestion = Array.isArray(nodeBox.suggestions) && nodeBox.suggestions.length === 1 ? nodeBox.suggestions[0] : null;\n\n if (!suggestion) {\n return;\n }\n\n if (lisp(node.value) === lisp(suggestion.label)) {\n node.value = suggestion.label;\n\n if (cityID) {\n cityID.value = suggestion.value;\n }\n }\n });\n};\n\nconst setCityAwesompletes = () => {\n setCityAwesomplete(document.getElementById('form-city'), document.getElementById('form-city-id'));\n setCityAwesomplete(document.getElementById('recommend-form-city'), document.getElementById('recommend-form-city-id'));\n};\n\nconst inititateAutocomplete = () => {\n const search = document.getElementById('search');\n const city = document.getElementById('search-city');\n const query = document.getElementById('search-query');\n\n if (city) {\n autocomplete('search-city');\n }\n\n if (query) {\n autocomplete('search-query');\n }\n\n if (search && city && query) {\n search.addEventListener('submit', e => {\n if (!city.value && !query.value) {\n city.focus();\n e.preventDefault();\n }\n }, false);\n }\n\n setCityAwesompletes();\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (inititateAutocomplete);\n\n//# sourceURL=webpack:///./wp-content/themes/biuro/js/components/autocomplete/autocomplete.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor/awesomplete */ \"./wp-content/themes/biuro/js/components/autocomplete/vendor/awesomplete.js\");\n\n\nconst lisp = str => {\n var symbols = {\n 'ą': 'a',\n 'č': 'c',\n 'ę': 'e',\n 'ė': 'e',\n 'į': 'i',\n 'š': 's',\n 'ų': 'u',\n 'ū': 'u',\n 'ž': 'z',\n 'ā': 'a',\n 'ē': 'e',\n 'ģ': 'g',\n 'ī': 'i',\n 'ķ': 'k',\n 'ļ': 'l',\n 'ņ': 'n',\n 'õ': 'o',\n 'ä': 'a',\n 'ö': 'o',\n 'ü': 'u'\n };\n str = str.trim();\n str = str.toLowerCase();\n str = str.replace(/[ąčęėįšųūžāēģīķļņõäöü]/g, s => {\n return symbols[s];\n });\n return str;\n};\n\nconst autocomplete = str => {\n const node = document.getElementById(str);\n const arrow = document.querySelector('.js-toggle--' + str);\n const clear = document.querySelector('.js-clear--' + str);\n let isOpen = false;\n let isClosed = false;\n\n const update = (langID, target, str, hidden) => {\n const type = target.id === 'search-city' ? 'query' : 'city';\n fetch('/wp-json/api/v1/options?langID=' + langID + '&str=' + str + '&type=' + type).then(t => t.json()).then(data => {\n if (!data || !data.length) {\n return;\n }\n\n const list = data.map(option => {\n return {\n label: option.name + ' (' + option.total + ')',\n value: option.name\n };\n });\n target.box.list = list;\n\n if (hidden) {\n target.box.evaluate();\n target.box.close();\n } else {\n target.focus();\n target.box.evaluate();\n }\n });\n };\n\n const updateOptions = node => {\n const target = node.id === 'search-city' ? document.getElementById('search-query') : document.getElementById('search-city');\n\n if (!target || target.value && node.value) {\n return;\n }\n\n if (!target.value && node.value) {\n update(node.dataset.id, target, node.value, true);\n } else if (!node.value) {\n update(node.dataset.id, node, target.value);\n\n if (!target.value) {\n update(node.dataset.id, target, target.value, true);\n }\n }\n };\n\n const toggle = (status, delay = 0) => {\n setTimeout(() => {\n isOpen = status;\n }, delay);\n\n if (arrow) {\n arrow.classList.toggle('is-open', status);\n }\n };\n\n if (!node) {\n return;\n }\n\n const box = new _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__[\"default\"](node, {\n minChars: 0,\n maxItems: 1000,\n sort: false,\n filter: function (text, input) {\n return lisp(text).indexOf(lisp(input)) !== -1;\n }\n });\n node.addEventListener('input', () => {\n if (clear) {\n clear.classList.toggle('u-hidden', !node.value);\n }\n\n if (arrow) {\n arrow.classList.toggle('u-hidden', !!node.value);\n }\n });\n node.addEventListener('focus', () => {\n if (!isOpen && (box.ul.childNodes.length === 0 || box.ul.hasAttribute('hidden'))) {\n toggle(true);\n box.evaluate();\n } else {\n toggle(false);\n box.close();\n node.blur();\n }\n });\n node.addEventListener('blur', () => {\n const suggestion = Array.isArray(box.suggestions) && box.suggestions.length === 1 ? box.suggestions[0] : null;\n\n if (!suggestion) {\n return;\n }\n\n if (lisp(node.value) === lisp(suggestion.value)) {\n node.value = suggestion.value;\n }\n });\n node.addEventListener('awesomplete-selectcomplete', () => {\n node.blur();\n updateOptions(node);\n\n if (clear) {\n clear.classList.remove('u-hidden');\n }\n\n if (arrow) {\n arrow.classList.add('u-hidden');\n }\n });\n node.addEventListener('awesomplete-close', () => {\n toggle(false, 150);\n });\n\n if (arrow) {\n arrow.addEventListener('click', e => {\n if (!isOpen) {\n node.focus();\n } else {\n box.close();\n }\n });\n }\n\n if (clear) {\n clear.addEventListener('click', () => {\n node.value = '';\n updateOptions(node);\n\n if (clear) {\n clear.classList.add('u-hidden');\n }\n\n if (arrow) {\n arrow.classList.remove('u-hidden');\n }\n });\n }\n\n node.box = box;\n};\n\nconst setCityAwesomplete = (node, cityID) => {\n if (!node || !cityID) {\n return;\n }\n\n const nodeBox = new _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__[\"default\"](node, {\n minChars: 0,\n maxItems: 1000,\n sort: false,\n filter: function (text, input) {\n return lisp(text).indexOf(lisp(input)) !== -1;\n },\n replace: function (suggestion) {\n this.input.value = suggestion.label;\n\n if (cityID) {\n cityID.value = suggestion.value;\n }\n }\n });\n node.addEventListener('focus', () => {\n nodeBox.evaluate();\n });\n node.addEventListener('blur', () => {\n const suggestion = Array.isArray(nodeBox.suggestions) && nodeBox.suggestions.length === 1 ? nodeBox.suggestions[0] : null;\n\n if (!suggestion) {\n return;\n }\n\n if (lisp(node.value) === lisp(suggestion.label)) {\n node.value = suggestion.label;\n\n if (cityID) {\n cityID.value = suggestion.value;\n }\n }\n });\n};\n\nconst setCityAwesompletes = () => {\n setCityAwesomplete(document.getElementById('form-city'), document.getElementById('form-city-id'));\n setCityAwesomplete(document.getElementById('recommend-form-city'), document.getElementById('recommend-form-city-id'));\n};\n\nconst inititateAutocomplete = () => {\n const search = document.getElementById('search');\n const city = document.getElementById('search-city');\n const query = document.getElementById('search-query');\n\n if (city) {\n autocomplete('search-city');\n }\n\n if (query) {\n autocomplete('search-query');\n }\n\n if (search && city && query) {\n search.addEventListener('submit', e => {\n if (!city.value && !query.value) {\n city.focus();\n e.preventDefault();\n }\n }, false);\n }\n\n setCityAwesompletes();\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (inititateAutocomplete);\n\n//# sourceURL=webpack:///./wp-content/themes/biuro/js/components/autocomplete/autocomplete.js?");
/***/ }),
......
......@@ -19,6 +19,7 @@ const autocomplete = (str) => {
const clear = document.querySelector('.js-clear--' + str);
let isOpen = false;
let isClosed = false;
const update = (langID, target, str, hidden) => {
const type = (target.id === 'search-city') ? 'query' : 'city';
......@@ -97,12 +98,13 @@ const autocomplete = (str) => {
});
node.addEventListener('focus', () => {
if (box.ul.childNodes.length === 0 || box.ul.hasAttribute('hidden')) {
if (!isOpen && (box.ul.childNodes.length === 0 || box.ul.hasAttribute('hidden'))) {
toggle(true);
box.evaluate();
} else {
toggle(false);
box.close();
node.blur();
}
});
......@@ -136,7 +138,7 @@ const autocomplete = (str) => {
});
if (arrow) {
arrow.addEventListener('click', () => {
arrow.addEventListener('click', (e) => {
if (!isOpen) {
node.focus();
} else {
......
......@@ -92,7 +92,7 @@
/******/
/******/ var hotApplyOnUpdate = true;
/******/ // eslint-disable-next-line no-unused-vars
/******/ var hotCurrentHash = "297196b8612ef6440284";
/******/ var hotCurrentHash = "0115a90eb0eff9676988";
/******/ var hotRequestTimeout = 10000;
/******/ var hotCurrentModuleData = {};
/******/ var hotCurrentChildModule;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment