Commit 58ea8b78 authored by Simon's avatar Simon

in progress

parent 3d3a6daa
<?php
// debug( getOptions('field', 'Vilnius') );
// debug( getOptions('type', 'Vilnius') );
debug( getOptions('city', '', 'Maitinimas') );
?>
<footer class="l-footer"> <footer class="l-footer">
<div class="l-inner"> <div class="l-inner">
......
...@@ -537,6 +537,25 @@ function start_session() { ...@@ -537,6 +537,25 @@ function start_session() {
} }
} }
function getAvailableOptions ( $request ) {
$res = array();
$params = $request->get_params();
// if ( !$params ) {
// exit;
// }
// $langID = (int) $params['langID'];
// $divisions = getDivisions($langID);
// $res = getOptions('city', '', 'Maitinimas'); // debug( getOptions('city', '', 'Maitinimas') );
$res = getOptions('field', 'Vilnius'); // debug( getOptions('city', '', 'Maitinimas') );
$res = array_merge(getOptions('field', 'Vilnius'), getOptions('type', 'Vilnius')); // debug( getOptions('city', '', 'Maitinimas') );
return new WP_REST_Response( $res, 200 );
}
function getBiuroDivisions ( $request ) { function getBiuroDivisions ( $request ) {
$res = array(); $res = array();
$params = $request->get_params(); $params = $request->get_params();
...@@ -597,6 +616,19 @@ add_action( 'rest_api_init', function () { ...@@ -597,6 +616,19 @@ add_action( 'rest_api_init', function () {
] ]
] ]
)); ));
register_rest_route( 'api/v1', '/options', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'getAvailableOptions',
// 'args' => array(
// 'langID' => array(
// 'validate_callback' => function($param, $request, $key) {
// return is_string( $param );
// }
// )
// )
));
}); });
...@@ -807,8 +839,15 @@ function getOptions($taxonomy, $location = '', $str = '') { ...@@ -807,8 +839,15 @@ function getOptions($taxonomy, $location = '', $str = '') {
endif; endif;
endif; endif;
$location = $location || isset($searchQuery['city']) ? preg_replace('/[\+]/', ' ', $searchQuery['city']) : ''; if ($location == ''):
$search = $str || isset($searchQuery['s']) ? preg_replace('/[\+]/', ' ', $searchQuery['s']) : ''; $location = isset($searchQuery['city']) ? preg_replace('/[\+]/', ' ', $searchQuery['city']) : '';
endif;
if ($str == ''):
$search = isset($searchQuery['s']) ? preg_replace('/[\+]/', ' ', $searchQuery['s']) : '';
else:
$search = $str;
endif;
if ( $location !== '' && $taxonomy !== 'city') : if ( $location !== '' && $taxonomy !== 'city') :
$city = get_term_by( 'name', $location, 'city' ); $city = get_term_by( 'name', $location, 'city' );
...@@ -833,7 +872,7 @@ function getOptions($taxonomy, $location = '', $str = '') { ...@@ -833,7 +872,7 @@ function getOptions($taxonomy, $location = '', $str = '') {
return getResults($taxonomy, $term, $termID); return getResults($taxonomy, $term, $termID);
} }
function getResults($taxonomy, $term, $termID) { function getResults($taxonomy, $term = '', $termID = '') {
global $wpdb; global $wpdb;
$langs = pll_the_languages(array('raw'=>1)); $langs = pll_the_languages(array('raw'=>1));
...@@ -842,6 +881,8 @@ function getResults($taxonomy, $term, $termID) { ...@@ -842,6 +881,8 @@ function getResults($taxonomy, $term, $termID) {
$today = date('Y-m-d'); $today = date('Y-m-d');
$order = ($taxonomy == 'city') ? 'no DESC' : 'total DESC'; $order = ($taxonomy == 'city') ? 'no DESC' : 'total DESC';
$langID = 2;
$condition = ($term && $termID) ? " AND `" . $term . "`.`term_id` = " . $termID : ''; $condition = ($term && $termID) ? " AND `" . $term . "`.`term_id` = " . $termID : '';
$structure = ($term && $termID) ? " LEFT JOIN `{$prefix}term_relationships` AS `rel_term2` ON `rel_term2`.`object_id` = `t`.`ID` $structure = ($term && $termID) ? " LEFT JOIN `{$prefix}term_relationships` AS `rel_term2` ON `rel_term2`.`object_id` = `t`.`ID`
INNER JOIN `{$prefix}term_taxonomy` AS `rel_tt_term2` ON `rel_tt_term2`.`taxonomy` = '" . $term . "' AND `rel_tt_term2`.`term_taxonomy_id` = `rel_term2`.`term_taxonomy_id` INNER JOIN `{$prefix}term_taxonomy` AS `rel_tt_term2` ON `rel_tt_term2`.`taxonomy` = '" . $term . "' AND `rel_tt_term2`.`term_taxonomy_id` = `rel_term2`.`term_taxonomy_id`
...@@ -909,8 +950,8 @@ function getCities() { ...@@ -909,8 +950,8 @@ function getCities() {
delog($wpdb->last_query); delog($wpdb->last_query);
delog('$terms'); delog('$cities');
debug($terms); debug($cities);
return []; return [];
......
...@@ -66,6 +66,21 @@ const autocomplete = (str) => { ...@@ -66,6 +66,21 @@ const autocomplete = (str) => {
let isOpen = false; let isOpen = false;
const updateOptions = (node) => {
console.error(node.id);
console.log(node.value);
fetch('/wp-json/api/v1/options?langID=' + node.dataset.id)
.then((t) => t.json())
.then((data) => {
console.error('data');
console.dir(data);
// initDivisionsMap(node, data);
});
};
const toggle = (status, delay = 0) => { const toggle = (status, delay = 0) => {
setTimeout(() => { setTimeout(() => {
isOpen = status; isOpen = status;
...@@ -121,7 +136,11 @@ const autocomplete = (str) => { ...@@ -121,7 +136,11 @@ const autocomplete = (str) => {
}); });
node.addEventListener('awesomplete-selectcomplete', () => { node.addEventListener('awesomplete-selectcomplete', () => {
node.blur(); node.blur();
updateOptions(node);
if (clear) { if (clear) {
clear.classList.remove('u-hidden'); clear.classList.remove('u-hidden');
} }
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
/******/ /******/
/******/ var hotApplyOnUpdate = true; /******/ var hotApplyOnUpdate = true;
/******/ // eslint-disable-next-line no-unused-vars /******/ // eslint-disable-next-line no-unused-vars
/******/ var hotCurrentHash = "d96ae202b0659d07c501"; /******/ var hotCurrentHash = "0b3c6224e252f550a50f";
/******/ var hotRequestTimeout = 10000; /******/ var hotRequestTimeout = 10000;
/******/ var hotCurrentModuleData = {}; /******/ var hotCurrentModuleData = {};
/******/ var hotCurrentChildModule; /******/ var hotCurrentChildModule;
...@@ -995,7 +995,7 @@ eval("var logLevel = \"info\";\n\nfunction dummy() {}\n\nfunction shouldLog(leve ...@@ -995,7 +995,7 @@ eval("var logLevel = \"info\";\n\nfunction dummy() {}\n\nfunction shouldLog(leve
/***/ (function(module, __webpack_exports__, __webpack_require__) { /***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict"; "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/vendor/awesomplete.js\");\n/* harmony import */ var _vendor_swiper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vendor/swiper */ \"./wp-content/themes/biuro/js/vendor/swiper.js\");\n/* harmony import */ var _vendor_swiper__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_vendor_swiper__WEBPACK_IMPORTED_MODULE_1__);\n// https://github.com/webpack/webpack/issues/8656#issuecomment-456001556\n// import \"core-js/es\";\n// import(/* webpackChunkName: \"autocomplete\" */ './components/autocomplete');\n// import(/* webpackChunkName: \"feedbacks\" */ './components/feedbacks');\n\n\nvar swiper = new _vendor_swiper__WEBPACK_IMPORTED_MODULE_1___default.a('.c-feedbacks--inner', {\n speed: 900,\n autoplay: {\n delay: 6000,\n disableOnInteraction: false\n },\n grabCursor: true,\n loop: true,\n pagination: {\n el: '.swiper-pagination',\n clickable: true\n }\n});\n\nvar lisp = function 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, function (s) {\n return symbols[s];\n });\n return str;\n};\n\nvar autocomplete = function autocomplete(str) {\n var node = document.getElementById(str);\n var arrow = document.querySelector('.js-toggle--' + str);\n var clear = document.querySelector('.js-clear--' + str);\n var isOpen = false;\n\n var toggle = function toggle(status) {\n var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n setTimeout(function () {\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 var box = new _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__[\"default\"](node, {\n minChars: 0,\n maxItems: 1000,\n sort: false,\n filter: function filter(text, input) {\n return lisp(text).indexOf(lisp(input)) !== -1;\n }\n });\n node.addEventListener('input', function () {\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', function () {\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', function () {\n var 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', function () {\n node.blur();\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', function () {\n toggle(false, 150);\n });\n\n if (arrow) {\n arrow.addEventListener('click', function () {\n if (!isOpen) {\n node.focus();\n } else {\n box.close();\n }\n });\n }\n\n if (clear) {\n clear.addEventListener('click', function () {\n node.value = '';\n node.focus();\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\nautocomplete('search-city');\nautocomplete('search-query');\nvar search = document.getElementById('search');\nvar city = document.getElementById('search-city');\nvar query = document.getElementById('search-query');\n\nif (search) {\n search.addEventListener('submit', function (e) {\n if (city && !city.value && query && !query.value) {\n city.focus();\n e.preventDefault();\n }\n }, false);\n}\n\nvar node = document.getElementById('form-city');\nvar cityID = document.getElementById('form-city-id');\n\nif (node) {\n var nodeBox = new _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__[\"default\"](node, {\n minChars: 0,\n maxItems: 1000,\n sort: false,\n filter: function filter(text, input) {\n return lisp(text).indexOf(lisp(input)) !== -1;\n },\n replace: function replace(suggestion) {\n this.input.value = suggestion.label;\n\n if (cityID) {\n cityID.value = suggestion.value;\n }\n }\n });\n node.addEventListener('focus', function () {\n nodeBox.evaluate();\n });\n node.addEventListener('blur', function () {\n var 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\nif (window.NodeList && !NodeList.prototype.forEach) {\n NodeList.prototype.forEach = Array.prototype.forEach;\n}\n\n(function (arr) {\n arr.forEach(function (item) {\n if (item.hasOwnProperty('remove')) {\n return;\n }\n\n Object.defineProperty(item, 'remove', {\n configurable: true,\n enumerable: true,\n writable: true,\n value: function remove() {\n if (this.parentNode === null) {\n return;\n }\n\n this.parentNode.removeChild(this);\n }\n });\n });\n})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);\n\n(function (global) {\n var container = document.getElementById('cookie-warning');\n var btnAgree = document.getElementById('cookie-agree');\n var btnClose = document.getElementById('cookie-close');\n var agreed = useLS() ? localStorage.getItem('biuro-agree') : false;\n\n function useLS() {\n var mod = 'a';\n\n try {\n localStorage.setItem(mod, mod);\n localStorage.removeItem(mod);\n return true;\n } catch (e) {\n return false;\n }\n }\n\n if (!container || !btnAgree || !btnClose || agreed) {\n return;\n }\n\n container.style.display = 'block';\n btnAgree.addEventListener('click', function () {\n if (useLS()) {\n localStorage.setItem('biuro-agree', 'true');\n }\n\n container.style.display = 'none';\n });\n btnClose.addEventListener('click', function () {\n container.style.display = 'none';\n });\n})(window);\n\nif (true) {\n module.hot.accept();\n}\n\n(function (global) {\n var node = document.getElementById('js-map--divisions');\n\n if (!node) {\n return;\n }\n\n fetch('/wp-json/api/v1/divisions?langID=' + node.dataset.id).then(function (t) {\n return t.json();\n }).then(function (data) {\n initDivisionsMap(node, data);\n });\n})(window);\n\n(function (global) {\n var node = document.querySelector('.c-nav--lang');\n\n if (!node) {\n return;\n }\n\n node.addEventListener('click', function (e) {\n e.currentTarget.classList.toggle('c-nav--lang--is-open');\n });\n})(window);\n\n(function (global) {\n var node = document.getElementById('js-map--regions');\n\n if (!node) {\n return;\n }\n\n initRegionsMap(node);\n})(window);\n\n(function (global) {\n document.querySelectorAll('.js-toggle--nav').forEach(function (node) {\n node.addEventListener('click', function (e) {\n e.preventDefault();\n document.body.classList.toggle('is-nav--open');\n });\n });\n document.querySelectorAll('.js-toggle--aside').forEach(function (node) {\n node.addEventListener('click', function (e) {\n e.preventDefault();\n document.body.classList.toggle('is-aside--open');\n });\n });\n})(window);\n\nvar info;\n\nfunction setMarkers(map, positions, focus) {\n var bounds = new window.google.maps.LatLngBounds();\n\n for (var i = 0; i < positions.length; i++) {\n var position = positions[i];\n var pos = new window.google.maps.LatLng(position.lat, position.lng);\n var marker = new window.google.maps.Marker({\n position: pos,\n map: map,\n icon: '/wp-content/themes/biuro/i/ico--map-pin.svg',\n title: position.title || ''\n });\n\n if (info) {\n info.close();\n }\n\n bounds.extend(pos);\n\n if (position.content) {\n marker['content'] = position.content;\n window.google.maps.event.addListener(marker, 'click', function () {\n info = new window.google.maps.InfoWindow({\n content: this.content\n });\n info.open(map, this);\n });\n }\n\n if (focus) {\n if (window.innerWidth < 960) {\n window.scrollTo(0, 0);\n }\n\n new google.maps.event.trigger(marker, 'click');\n }\n }\n\n map.fitBounds(bounds);\n\n if (window.innerWidth > 1020) {\n map.panBy(250, 0);\n } else if (window.innerWidth > 959) {\n map.panBy(180, 0);\n }\n}\n\nfunction setGoogleMap(node) {\n var mapStyles = [{\n featureType: 'all',\n elementType: 'all',\n stylers: [{\n saturation: -92\n }, {\n lightness: -8\n }, {\n hue: '#004ed4'\n }]\n }, {\n featureType: 'water',\n elementType: 'all',\n stylers: [{\n saturation: -95\n }, {\n lightness: -25\n }, {\n hue: '#004ed4'\n }]\n }];\n var map = new window.google.maps.Map(node, {});\n var biuroMap = new window.google.maps.StyledMapType(mapStyles, {\n name: 'Biuro'\n });\n map.mapTypes.set('biuro', biuroMap);\n map.setMapTypeId('biuro');\n window.google.maps.event.addListenerOnce(map, 'bounds_changed', function () {\n if (this.getZoom() > 15) {\n this.setZoom(14);\n }\n });\n return map;\n}\n\nfunction initRegionsMap(node) {\n if (!window.google) {\n setTimeout(function () {\n initRegionsMap(node);\n }, 250);\n return;\n }\n\n var map = setGoogleMap(node);\n var regions = [{\n title: 'Vilnius',\n lat: 54.687157,\n lng: 25.279652\n }, {\n title: 'Rīga',\n lat: 56.946285,\n lng: 24.105078\n }, {\n title: 'Tallinn',\n lat: 59.436962,\n lng: 24.753574\n }];\n setMarkers(map, regions);\n}\n\nfunction initDivisionsMap(node, data) {\n if (!window.google) {\n setTimeout(function () {\n initDivisionsMap(node, data);\n }, 250);\n return;\n }\n\n var map = setGoogleMap(node);\n var divisions = [];\n Object.keys(data).forEach(function (key) {\n var division = data[key];\n\n if (key.substr(0, 4) === 'city') {\n divisions = divisions.concat(division);\n }\n });\n document.querySelectorAll('.js-division').forEach(function (node) {\n node.addEventListener('click', function () {\n var ID = node && node.dataset.id ? node.dataset.id : '';\n\n if (data[ID]) {\n setMarkers(map, data[ID].filter(function (d) {\n return d.lat && d.lng;\n }), true);\n } else {\n setMarkers(map, divisions.filter(function (d) {\n return d.lat && d.lng;\n }));\n }\n });\n });\n setMarkers(map, divisions.filter(function (d) {\n return d.lat && d.lng;\n }));\n}\n\ndocument.querySelectorAll('.js-form--input-file').forEach(function (node) {\n node.addEventListener('change', function () {\n var parent = node.parentNode;\n var name = node.value.split(/\\\\|\\//).pop();\n var text = parent.querySelector('.js-form--input-file-text');\n\n if (text && name) {\n text.innerHTML = name;\n }\n });\n});\ndocument.querySelectorAll('.js-toggle--services').forEach(function (node) {\n node.addEventListener('click', function () {\n node.parentNode.classList.toggle('c-services--is-open');\n });\n});\ndocument.querySelectorAll('.js-toggle--sections').forEach(function (node) {\n node.addEventListener('click', function () {\n var parent = node.parentNode;\n\n if (parent.classList.contains('c-sections--is-open')) {\n parent.classList.toggle('c-sections--is-open');\n } else {\n document.querySelectorAll('.c-sections--is-open').forEach(function (node) {\n node.classList.remove('c-sections--is-open');\n });\n parent.classList.toggle('c-sections--is-open');\n }\n });\n});\ndocument.querySelectorAll('.js-expand-jobs-section').forEach(function (node) {\n node.addEventListener('click', function (e) {\n e.preventDefault();\n node.parentNode.classList.remove('c-jobs-section--is-closed');\n node.remove();\n });\n});\n\nvar initiatePositionForm = function initiatePositionForm() {\n var button = document.querySelector('[name=\"s\"][value=\"1\"]');\n\n if (button) {\n button.click();\n return;\n }\n\n var input = document.querySelector('[name=\"name\"]');\n\n if (input) {\n input.focus();\n }\n};\n\nif (document.querySelector('.js-inititate-position-form')) {\n document.querySelector('.js-inititate-position-form').addEventListener('click', initiatePositionForm);\n}\n\nif (document.querySelector('.js-focus-form')) {\n document.querySelector('.js-focus-form').addEventListener('click', function () {\n var input = document.querySelector('.c-form input:first-of-type');\n\n if (input) {\n input.focus();\n }\n });\n}\n\nif (document.querySelector('.js-modal--close')) {\n document.querySelector('.js-modal--close').addEventListener('click', function () {\n var modal = document.querySelector('.c-modal');\n\n if (modal) {\n modal.remove();\n }\n\n var node = document.querySelector('.c-form [autofocus]');\n\n if (node) {\n node.focus();\n }\n });\n}\n\nfunction fallbackCopyTextToClipboard(text) {\n var textArea = document.createElement('textarea');\n textArea.value = text;\n document.body.appendChild(textArea);\n textArea.focus();\n textArea.select();\n\n try {\n var successful = document.execCommand('copy');\n var msg = successful ? 'successful' : 'unsuccessful';\n console.log('Fallback: Copying text command was ' + msg);\n } catch (err) {\n console.error('Fallback: Oops, unable to copy', err);\n }\n\n document.body.removeChild(textArea);\n}\n\nfunction showCopyTooltip() {\n var tooltip = document.querySelector('#copy-tooltip');\n\n if (tooltip) {\n tooltip.style.opacity = 1;\n setTimeout(function () {\n tooltip.style.opacity = 0;\n }, 3000);\n }\n}\n\nfunction copyTextToClipboard(text) {\n if (!navigator.clipboard) {\n fallbackCopyTextToClipboard(text);\n showCopyTooltip();\n return;\n }\n\n navigator.clipboard.writeText(text).then(function () {\n showCopyTooltip();\n }, function (err) {\n console.error('Async: Could not copy text: ', err);\n });\n}\n\nif (document.querySelector('.js-copy-to-clipboard')) {\n document.querySelector('.js-copy-to-clipboard').addEventListener('click', function (e) {\n e.preventDefault();\n var sep = window.location.href.indexOf('?') === -1 ? '?' : '&';\n copyTextToClipboard(window.location.href + sep + 'utm_source=biuro&utm_medium=Share&utm_campaign=Copy');\n });\n}\n\n(function (global) {\n var node = document.querySelector('.c-form [autofocus]');\n\n if (node) {\n node.focus();\n }\n\n if (location.hash) {\n var error = document.querySelector('.c-form--input-wrap--error input') || document.querySelector('.c-form--checkbox--error');\n\n if (error) {\n error.focus();\n return;\n }\n\n var input = document.querySelector('.c-form [name=\"name\"]');\n\n if (input) {\n input.focus();\n }\n }\n})(window);\n\n(function (global) {\n document.querySelectorAll('.gtm-share-click').forEach(function (node) {\n node.addEventListener('click', function (e) {\n window.dataLayer = window.dataLayer || [];\n window.dataLayer.push({\n 'event': 'shareClick',\n 'shareLabel': node.dataset.label || ''\n });\n });\n });\n})(window); // async function autocomplete() {\n// // await import(/* webpackChunkName: \"autocomplete\" */ './components/autocomplete');\n// const aaaa = require('./components/autocomplete').default;\n// }\n// if (document.getElementById('search-city') || document.getElementById('search-query') || document.getElementById('form-city')) {\n// autocomplete();\n// }\n// async function feedbacks() {\n// await import(/* webpackChunkName: \"feedbacks\" */ './components/feedbacks');\n// };\n// if (document.querySelectorAll('.c-feedbacks--inner').length) {\n// feedbacks();\n// }\n\n\nvar submitContactsFrom = function submitContactsFrom(form) {\n if (form.querySelector('[type=\"submit\"]')) {\n form.querySelector('[type=\"submit\"]').classList.add('c-btn--disabled');\n }\n};\n\ndocument.querySelectorAll('[name=\"form-position\"], [name=\"form-employees\"], [name=\"form-employers\"]').forEach(function (form) {\n form.addEventListener('submit', function () {\n submitContactsFrom(form);\n });\n});\n\nvar collapseContent = function collapseContent(n) {\n var h = n.scrollHeight;\n var t = n.style.transition;\n n.style.transition = '';\n requestAnimationFrame(function () {\n n.style.height = h + 'px';\n n.style.transition = t;\n requestAnimationFrame(function () {\n n.style.height = 0 + 'px';\n });\n });\n};\n\nvar expandContent = function expandContent(n) {\n var h = n.scrollHeight;\n\n var done = function done(e) {\n n.removeEventListener('transitionend', done); // n.style.height = null;\n };\n\n n.style.height = h + 'px';\n n.addEventListener('transitionend', done);\n};\n\ndocument.querySelectorAll('.js-accordion--header').forEach(function (header) {\n header.addEventListener('click', function () {\n var node = header.nextElementSibling;\n\n if (!node || !node.classList.contains('c-accordion--content')) {\n return;\n }\n\n var isOpen = header.classList.contains('c-accordion--header--is-expanded');\n\n if (isOpen) {\n collapseContent(node);\n } else {\n expandContent(node);\n }\n\n header.classList.toggle('c-accordion--header--is-expanded', !isOpen);\n });\n});\ndocument.querySelectorAll('.c-accordion--content').forEach(function (content) {\n content.classList.add('c-accordion--content--is-collapsed');\n});\nvar isPageActive = true;\n\nwindow.onfocus = function () {\n isPageActive = true;\n};\n\nwindow.onblur = function () {\n isPageActive = false;\n};\n\nvar messenger = document.querySelector('.js-share-messenger');\n\nif (messenger) {\n messenger.addEventListener('click', function (e) {\n e.preventDefault();\n var sep = window.location.href.indexOf('?') === -1 ? '?' : '&';\n var target = e.currentTarget;\n window.location.href = 'fb-messenger://share/?link=' + encodeURIComponent(window.location.href + sep + 'utm_source=biuro&utm_medium=Share&utm_campaign=Messenger&app_id=' + target.dataset.id);\n setTimeout(function () {\n if (document.hidden || !isPageActive) {\n return;\n }\n\n window.location.href = target.href;\n }, 100);\n });\n}\n\nvar whatsapp = document.querySelector('.js-share-whatsapp');\n\nif (whatsapp) {\n whatsapp.addEventListener('click', function (e) {\n e.preventDefault();\n var target = e.currentTarget;\n window.location.href = 'whatsapp://send?text=' + encodeURIComponent(target.dataset.text);\n setTimeout(function () {\n if (document.hidden || !isPageActive) {\n return;\n }\n\n window.open(target.href, '_blank');\n }, 100);\n });\n}\n\n//# sourceURL=webpack:///./wp-content/themes/biuro/js/main.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/vendor/awesomplete.js\");\n/* harmony import */ var _vendor_swiper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vendor/swiper */ \"./wp-content/themes/biuro/js/vendor/swiper.js\");\n/* harmony import */ var _vendor_swiper__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_vendor_swiper__WEBPACK_IMPORTED_MODULE_1__);\n// https://github.com/webpack/webpack/issues/8656#issuecomment-456001556\n// import \"core-js/es\";\n// import(/* webpackChunkName: \"autocomplete\" */ './components/autocomplete');\n// import(/* webpackChunkName: \"feedbacks\" */ './components/feedbacks');\n\n\nvar swiper = new _vendor_swiper__WEBPACK_IMPORTED_MODULE_1___default.a('.c-feedbacks--inner', {\n speed: 900,\n autoplay: {\n delay: 6000,\n disableOnInteraction: false\n },\n grabCursor: true,\n loop: true,\n pagination: {\n el: '.swiper-pagination',\n clickable: true\n }\n});\n\nvar lisp = function 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, function (s) {\n return symbols[s];\n });\n return str;\n};\n\nvar autocomplete = function autocomplete(str) {\n var node = document.getElementById(str);\n var arrow = document.querySelector('.js-toggle--' + str);\n var clear = document.querySelector('.js-clear--' + str);\n var isOpen = false;\n\n var updateOptions = function updateOptions(node) {\n console.error(node.id);\n console.log(node.value);\n fetch('/wp-json/api/v1/options?langID=' + node.dataset.id).then(function (t) {\n return t.json();\n }).then(function (data) {\n console.error('data');\n console.dir(data); // initDivisionsMap(node, data);\n });\n };\n\n var toggle = function toggle(status) {\n var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n setTimeout(function () {\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 var box = new _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__[\"default\"](node, {\n minChars: 0,\n maxItems: 1000,\n sort: false,\n filter: function filter(text, input) {\n return lisp(text).indexOf(lisp(input)) !== -1;\n }\n });\n node.addEventListener('input', function () {\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', function () {\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', function () {\n var 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', function () {\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', function () {\n toggle(false, 150);\n });\n\n if (arrow) {\n arrow.addEventListener('click', function () {\n if (!isOpen) {\n node.focus();\n } else {\n box.close();\n }\n });\n }\n\n if (clear) {\n clear.addEventListener('click', function () {\n node.value = '';\n node.focus();\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\nautocomplete('search-city');\nautocomplete('search-query');\nvar search = document.getElementById('search');\nvar city = document.getElementById('search-city');\nvar query = document.getElementById('search-query');\n\nif (search) {\n search.addEventListener('submit', function (e) {\n if (city && !city.value && query && !query.value) {\n city.focus();\n e.preventDefault();\n }\n }, false);\n}\n\nvar node = document.getElementById('form-city');\nvar cityID = document.getElementById('form-city-id');\n\nif (node) {\n var nodeBox = new _vendor_awesomplete__WEBPACK_IMPORTED_MODULE_0__[\"default\"](node, {\n minChars: 0,\n maxItems: 1000,\n sort: false,\n filter: function filter(text, input) {\n return lisp(text).indexOf(lisp(input)) !== -1;\n },\n replace: function replace(suggestion) {\n this.input.value = suggestion.label;\n\n if (cityID) {\n cityID.value = suggestion.value;\n }\n }\n });\n node.addEventListener('focus', function () {\n nodeBox.evaluate();\n });\n node.addEventListener('blur', function () {\n var 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\nif (window.NodeList && !NodeList.prototype.forEach) {\n NodeList.prototype.forEach = Array.prototype.forEach;\n}\n\n(function (arr) {\n arr.forEach(function (item) {\n if (item.hasOwnProperty('remove')) {\n return;\n }\n\n Object.defineProperty(item, 'remove', {\n configurable: true,\n enumerable: true,\n writable: true,\n value: function remove() {\n if (this.parentNode === null) {\n return;\n }\n\n this.parentNode.removeChild(this);\n }\n });\n });\n})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);\n\n(function (global) {\n var container = document.getElementById('cookie-warning');\n var btnAgree = document.getElementById('cookie-agree');\n var btnClose = document.getElementById('cookie-close');\n var agreed = useLS() ? localStorage.getItem('biuro-agree') : false;\n\n function useLS() {\n var mod = 'a';\n\n try {\n localStorage.setItem(mod, mod);\n localStorage.removeItem(mod);\n return true;\n } catch (e) {\n return false;\n }\n }\n\n if (!container || !btnAgree || !btnClose || agreed) {\n return;\n }\n\n container.style.display = 'block';\n btnAgree.addEventListener('click', function () {\n if (useLS()) {\n localStorage.setItem('biuro-agree', 'true');\n }\n\n container.style.display = 'none';\n });\n btnClose.addEventListener('click', function () {\n container.style.display = 'none';\n });\n})(window);\n\nif (true) {\n module.hot.accept();\n}\n\n(function (global) {\n var node = document.getElementById('js-map--divisions');\n\n if (!node) {\n return;\n }\n\n fetch('/wp-json/api/v1/divisions?langID=' + node.dataset.id).then(function (t) {\n return t.json();\n }).then(function (data) {\n initDivisionsMap(node, data);\n });\n})(window);\n\n(function (global) {\n var node = document.querySelector('.c-nav--lang');\n\n if (!node) {\n return;\n }\n\n node.addEventListener('click', function (e) {\n e.currentTarget.classList.toggle('c-nav--lang--is-open');\n });\n})(window);\n\n(function (global) {\n var node = document.getElementById('js-map--regions');\n\n if (!node) {\n return;\n }\n\n initRegionsMap(node);\n})(window);\n\n(function (global) {\n document.querySelectorAll('.js-toggle--nav').forEach(function (node) {\n node.addEventListener('click', function (e) {\n e.preventDefault();\n document.body.classList.toggle('is-nav--open');\n });\n });\n document.querySelectorAll('.js-toggle--aside').forEach(function (node) {\n node.addEventListener('click', function (e) {\n e.preventDefault();\n document.body.classList.toggle('is-aside--open');\n });\n });\n})(window);\n\nvar info;\n\nfunction setMarkers(map, positions, focus) {\n var bounds = new window.google.maps.LatLngBounds();\n\n for (var i = 0; i < positions.length; i++) {\n var position = positions[i];\n var pos = new window.google.maps.LatLng(position.lat, position.lng);\n var marker = new window.google.maps.Marker({\n position: pos,\n map: map,\n icon: '/wp-content/themes/biuro/i/ico--map-pin.svg',\n title: position.title || ''\n });\n\n if (info) {\n info.close();\n }\n\n bounds.extend(pos);\n\n if (position.content) {\n marker['content'] = position.content;\n window.google.maps.event.addListener(marker, 'click', function () {\n info = new window.google.maps.InfoWindow({\n content: this.content\n });\n info.open(map, this);\n });\n }\n\n if (focus) {\n if (window.innerWidth < 960) {\n window.scrollTo(0, 0);\n }\n\n new google.maps.event.trigger(marker, 'click');\n }\n }\n\n map.fitBounds(bounds);\n\n if (window.innerWidth > 1020) {\n map.panBy(250, 0);\n } else if (window.innerWidth > 959) {\n map.panBy(180, 0);\n }\n}\n\nfunction setGoogleMap(node) {\n var mapStyles = [{\n featureType: 'all',\n elementType: 'all',\n stylers: [{\n saturation: -92\n }, {\n lightness: -8\n }, {\n hue: '#004ed4'\n }]\n }, {\n featureType: 'water',\n elementType: 'all',\n stylers: [{\n saturation: -95\n }, {\n lightness: -25\n }, {\n hue: '#004ed4'\n }]\n }];\n var map = new window.google.maps.Map(node, {});\n var biuroMap = new window.google.maps.StyledMapType(mapStyles, {\n name: 'Biuro'\n });\n map.mapTypes.set('biuro', biuroMap);\n map.setMapTypeId('biuro');\n window.google.maps.event.addListenerOnce(map, 'bounds_changed', function () {\n if (this.getZoom() > 15) {\n this.setZoom(14);\n }\n });\n return map;\n}\n\nfunction initRegionsMap(node) {\n if (!window.google) {\n setTimeout(function () {\n initRegionsMap(node);\n }, 250);\n return;\n }\n\n var map = setGoogleMap(node);\n var regions = [{\n title: 'Vilnius',\n lat: 54.687157,\n lng: 25.279652\n }, {\n title: 'Rīga',\n lat: 56.946285,\n lng: 24.105078\n }, {\n title: 'Tallinn',\n lat: 59.436962,\n lng: 24.753574\n }];\n setMarkers(map, regions);\n}\n\nfunction initDivisionsMap(node, data) {\n if (!window.google) {\n setTimeout(function () {\n initDivisionsMap(node, data);\n }, 250);\n return;\n }\n\n var map = setGoogleMap(node);\n var divisions = [];\n Object.keys(data).forEach(function (key) {\n var division = data[key];\n\n if (key.substr(0, 4) === 'city') {\n divisions = divisions.concat(division);\n }\n });\n document.querySelectorAll('.js-division').forEach(function (node) {\n node.addEventListener('click', function () {\n var ID = node && node.dataset.id ? node.dataset.id : '';\n\n if (data[ID]) {\n setMarkers(map, data[ID].filter(function (d) {\n return d.lat && d.lng;\n }), true);\n } else {\n setMarkers(map, divisions.filter(function (d) {\n return d.lat && d.lng;\n }));\n }\n });\n });\n setMarkers(map, divisions.filter(function (d) {\n return d.lat && d.lng;\n }));\n}\n\ndocument.querySelectorAll('.js-form--input-file').forEach(function (node) {\n node.addEventListener('change', function () {\n var parent = node.parentNode;\n var name = node.value.split(/\\\\|\\//).pop();\n var text = parent.querySelector('.js-form--input-file-text');\n\n if (text && name) {\n text.innerHTML = name;\n }\n });\n});\ndocument.querySelectorAll('.js-toggle--services').forEach(function (node) {\n node.addEventListener('click', function () {\n node.parentNode.classList.toggle('c-services--is-open');\n });\n});\ndocument.querySelectorAll('.js-toggle--sections').forEach(function (node) {\n node.addEventListener('click', function () {\n var parent = node.parentNode;\n\n if (parent.classList.contains('c-sections--is-open')) {\n parent.classList.toggle('c-sections--is-open');\n } else {\n document.querySelectorAll('.c-sections--is-open').forEach(function (node) {\n node.classList.remove('c-sections--is-open');\n });\n parent.classList.toggle('c-sections--is-open');\n }\n });\n});\ndocument.querySelectorAll('.js-expand-jobs-section').forEach(function (node) {\n node.addEventListener('click', function (e) {\n e.preventDefault();\n node.parentNode.classList.remove('c-jobs-section--is-closed');\n node.remove();\n });\n});\n\nvar initiatePositionForm = function initiatePositionForm() {\n var button = document.querySelector('[name=\"s\"][value=\"1\"]');\n\n if (button) {\n button.click();\n return;\n }\n\n var input = document.querySelector('[name=\"name\"]');\n\n if (input) {\n input.focus();\n }\n};\n\nif (document.querySelector('.js-inititate-position-form')) {\n document.querySelector('.js-inititate-position-form').addEventListener('click', initiatePositionForm);\n}\n\nif (document.querySelector('.js-focus-form')) {\n document.querySelector('.js-focus-form').addEventListener('click', function () {\n var input = document.querySelector('.c-form input:first-of-type');\n\n if (input) {\n input.focus();\n }\n });\n}\n\nif (document.querySelector('.js-modal--close')) {\n document.querySelector('.js-modal--close').addEventListener('click', function () {\n var modal = document.querySelector('.c-modal');\n\n if (modal) {\n modal.remove();\n }\n\n var node = document.querySelector('.c-form [autofocus]');\n\n if (node) {\n node.focus();\n }\n });\n}\n\nfunction fallbackCopyTextToClipboard(text) {\n var textArea = document.createElement('textarea');\n textArea.value = text;\n document.body.appendChild(textArea);\n textArea.focus();\n textArea.select();\n\n try {\n var successful = document.execCommand('copy');\n var msg = successful ? 'successful' : 'unsuccessful';\n console.log('Fallback: Copying text command was ' + msg);\n } catch (err) {\n console.error('Fallback: Oops, unable to copy', err);\n }\n\n document.body.removeChild(textArea);\n}\n\nfunction showCopyTooltip() {\n var tooltip = document.querySelector('#copy-tooltip');\n\n if (tooltip) {\n tooltip.style.opacity = 1;\n setTimeout(function () {\n tooltip.style.opacity = 0;\n }, 3000);\n }\n}\n\nfunction copyTextToClipboard(text) {\n if (!navigator.clipboard) {\n fallbackCopyTextToClipboard(text);\n showCopyTooltip();\n return;\n }\n\n navigator.clipboard.writeText(text).then(function () {\n showCopyTooltip();\n }, function (err) {\n console.error('Async: Could not copy text: ', err);\n });\n}\n\nif (document.querySelector('.js-copy-to-clipboard')) {\n document.querySelector('.js-copy-to-clipboard').addEventListener('click', function (e) {\n e.preventDefault();\n var sep = window.location.href.indexOf('?') === -1 ? '?' : '&';\n copyTextToClipboard(window.location.href + sep + 'utm_source=biuro&utm_medium=Share&utm_campaign=Copy');\n });\n}\n\n(function (global) {\n var node = document.querySelector('.c-form [autofocus]');\n\n if (node) {\n node.focus();\n }\n\n if (location.hash) {\n var error = document.querySelector('.c-form--input-wrap--error input') || document.querySelector('.c-form--checkbox--error');\n\n if (error) {\n error.focus();\n return;\n }\n\n var input = document.querySelector('.c-form [name=\"name\"]');\n\n if (input) {\n input.focus();\n }\n }\n})(window);\n\n(function (global) {\n document.querySelectorAll('.gtm-share-click').forEach(function (node) {\n node.addEventListener('click', function (e) {\n window.dataLayer = window.dataLayer || [];\n window.dataLayer.push({\n 'event': 'shareClick',\n 'shareLabel': node.dataset.label || ''\n });\n });\n });\n})(window); // async function autocomplete() {\n// // await import(/* webpackChunkName: \"autocomplete\" */ './components/autocomplete');\n// const aaaa = require('./components/autocomplete').default;\n// }\n// if (document.getElementById('search-city') || document.getElementById('search-query') || document.getElementById('form-city')) {\n// autocomplete();\n// }\n// async function feedbacks() {\n// await import(/* webpackChunkName: \"feedbacks\" */ './components/feedbacks');\n// };\n// if (document.querySelectorAll('.c-feedbacks--inner').length) {\n// feedbacks();\n// }\n\n\nvar submitContactsFrom = function submitContactsFrom(form) {\n if (form.querySelector('[type=\"submit\"]')) {\n form.querySelector('[type=\"submit\"]').classList.add('c-btn--disabled');\n }\n};\n\ndocument.querySelectorAll('[name=\"form-position\"], [name=\"form-employees\"], [name=\"form-employers\"]').forEach(function (form) {\n form.addEventListener('submit', function () {\n submitContactsFrom(form);\n });\n});\n\nvar collapseContent = function collapseContent(n) {\n var h = n.scrollHeight;\n var t = n.style.transition;\n n.style.transition = '';\n requestAnimationFrame(function () {\n n.style.height = h + 'px';\n n.style.transition = t;\n requestAnimationFrame(function () {\n n.style.height = 0 + 'px';\n });\n });\n};\n\nvar expandContent = function expandContent(n) {\n var h = n.scrollHeight;\n\n var done = function done(e) {\n n.removeEventListener('transitionend', done); // n.style.height = null;\n };\n\n n.style.height = h + 'px';\n n.addEventListener('transitionend', done);\n};\n\ndocument.querySelectorAll('.js-accordion--header').forEach(function (header) {\n header.addEventListener('click', function () {\n var node = header.nextElementSibling;\n\n if (!node || !node.classList.contains('c-accordion--content')) {\n return;\n }\n\n var isOpen = header.classList.contains('c-accordion--header--is-expanded');\n\n if (isOpen) {\n collapseContent(node);\n } else {\n expandContent(node);\n }\n\n header.classList.toggle('c-accordion--header--is-expanded', !isOpen);\n });\n});\ndocument.querySelectorAll('.c-accordion--content').forEach(function (content) {\n content.classList.add('c-accordion--content--is-collapsed');\n});\nvar isPageActive = true;\n\nwindow.onfocus = function () {\n isPageActive = true;\n};\n\nwindow.onblur = function () {\n isPageActive = false;\n};\n\nvar messenger = document.querySelector('.js-share-messenger');\n\nif (messenger) {\n messenger.addEventListener('click', function (e) {\n e.preventDefault();\n var sep = window.location.href.indexOf('?') === -1 ? '?' : '&';\n var target = e.currentTarget;\n window.location.href = 'fb-messenger://share/?link=' + encodeURIComponent(window.location.href + sep + 'utm_source=biuro&utm_medium=Share&utm_campaign=Messenger&app_id=' + target.dataset.id);\n setTimeout(function () {\n if (document.hidden || !isPageActive) {\n return;\n }\n\n window.location.href = target.href;\n }, 100);\n });\n}\n\nvar whatsapp = document.querySelector('.js-share-whatsapp');\n\nif (whatsapp) {\n whatsapp.addEventListener('click', function (e) {\n e.preventDefault();\n var target = e.currentTarget;\n window.location.href = 'whatsapp://send?text=' + encodeURIComponent(target.dataset.text);\n setTimeout(function () {\n if (document.hidden || !isPageActive) {\n return;\n }\n\n window.open(target.href, '_blank');\n }, 100);\n });\n}\n\n//# sourceURL=webpack:///./wp-content/themes/biuro/js/main.js?");
/***/ }), /***/ }),
......
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