Merged in feature/plugins-update (pull request #9)
wp plugin updates from pantheon * wp plugin updates from pantheon
1110
wp/wp-content/plugins/facetwp/assets/css/admin.css
Normal file
327
wp/wp-content/plugins/facetwp/assets/css/front.css
Normal file
@@ -0,0 +1,327 @@
|
||||
.facetwp-facet {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.facetwp-facet.is-loading {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.facetwp-overlay {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.facetwp-pager-label {
|
||||
display: inline-block;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.facetwp-page {
|
||||
display: inline-block;
|
||||
padding: 0px 4px;
|
||||
margin-right: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.facetwp-page.dots {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.facetwp-page.active {
|
||||
font-weight: bold;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* Checkboxes */
|
||||
|
||||
.facetwp-type-checkboxes .facetwp-depth {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.facetwp-type-checkboxes .facetwp-depth.visible {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
.facetwp-checkbox {
|
||||
background: url('../images/checkbox.png') 0 50% no-repeat;
|
||||
background-size: 14px 14px;
|
||||
margin-bottom: 4px;
|
||||
padding-left: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.facetwp-checkbox.checked {
|
||||
background-image: url('../images/checkbox-on.png');
|
||||
}
|
||||
|
||||
.facetwp-checkbox.disabled,
|
||||
.facetwp-radio.disabled {
|
||||
opacity: 0.4;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.facetwp-checkbox .facetwp-expand {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.facetwp-display-value {
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
/* Radio */
|
||||
|
||||
.facetwp-radio {
|
||||
background: url('../images/radio.png') 0 50% no-repeat;
|
||||
background-size: 14px 14px;
|
||||
margin-bottom: 4px;
|
||||
padding-left: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.facetwp-radio.checked {
|
||||
background-image: url('../images/radio-on.png');
|
||||
}
|
||||
|
||||
/* fSelect */
|
||||
|
||||
.facetwp-type-fselect.is-loading {
|
||||
opacity: 1; /* prevent stack order issues */
|
||||
}
|
||||
|
||||
.facetwp-type-fselect.is-loading .fs-label-wrap,
|
||||
.facetwp-type-fselect.is-loading .fs-search,
|
||||
.facetwp-type-fselect.is-loading .fs-no-results,
|
||||
.facetwp-type-fselect.is-loading .fs-options {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.facetwp-type-fselect.is-loading .fs-option {
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.facetwp-type-fselect .fs-wrap.fs-disabled .fs-option {
|
||||
opacity: 0.4;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.facetwp-type-fselect .fs-option .fs-option-label {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.facetwp-type-fselect .fs-option.d1 .fs-option-label {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.facetwp-type-fselect .fs-option.d2 .fs-option-label {
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.facetwp-type-fselect .fs-option.d3 .fs-option-label {
|
||||
padding-left: 60px;
|
||||
}
|
||||
|
||||
/* Hierarchy */
|
||||
|
||||
.facetwp-depth {
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.facetwp-link {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.facetwp-link.checked {
|
||||
font-weight: bold;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.facetwp-toggle {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.facetwp-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Slider */
|
||||
|
||||
.facetwp-slider-wrap {
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.facetwp-slider-reset {
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 3px;
|
||||
background: #fff;
|
||||
box-shadow: inset 0 0 1px #fff, inset 0 1px 7px #ebebeb, 0 3px 6px -3px #bbb;
|
||||
padding: 4px 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.facetwp-slider[data-disabled="true"] {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.facetwp-slider[data-disabled="true"] .noUi-handle {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* Search */
|
||||
|
||||
.facetwp-input-wrap {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.facetwp-facet input.facetwp-search,
|
||||
.facetwp-facet input.facetwp-location {
|
||||
margin: 0;
|
||||
padding-right: 30px;
|
||||
min-width: 240px;
|
||||
}
|
||||
|
||||
.facetwp-icon {
|
||||
right: 0;
|
||||
height: 100%;
|
||||
line-height: 1;
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.facetwp-icon:before {
|
||||
display: inline-block;
|
||||
content: '';
|
||||
width: 30px;
|
||||
height: 100%;
|
||||
background: url('../images/icon-search.png') no-repeat;
|
||||
background-position: 5px 50%;
|
||||
background-size: 20px 20px;
|
||||
}
|
||||
|
||||
/* Proximity */
|
||||
|
||||
.location-results {
|
||||
position: absolute;
|
||||
background: #fff;
|
||||
border-left: 1px solid #ddd;
|
||||
border-right: 1px solid #ddd;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.location-result {
|
||||
font-size: 11px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 5px;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.location-result:hover {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.location-result.active {
|
||||
background-color: #EBF2FE;
|
||||
}
|
||||
|
||||
.location-result .result-main {
|
||||
font-size: 13px;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.facetwp-icon.locate-me:before {
|
||||
background-image: url('../images/icon-locate.png');
|
||||
}
|
||||
|
||||
.facetwp-icon.f-reset:before {
|
||||
background-image: url('../images/icon-close.png');
|
||||
}
|
||||
|
||||
.facetwp-icon.f-loading:before {
|
||||
background-image: url('../images/loading.png');
|
||||
animation: spin 700ms infinite linear;
|
||||
}
|
||||
|
||||
.location-attribution {
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.powered-by-google {
|
||||
height: 15px;
|
||||
background: url('../images/powered-by-google.png') top right no-repeat;
|
||||
background-size: auto 15px;
|
||||
}
|
||||
|
||||
/* Rating */
|
||||
|
||||
.facetwp-stars {
|
||||
display: inline-block;
|
||||
line-height: 1;
|
||||
padding-right: 4px;
|
||||
user-select: none;
|
||||
unicode-bidi: bidi-override;
|
||||
direction: rtl;
|
||||
}
|
||||
|
||||
.facetwp-star {
|
||||
cursor: pointer;
|
||||
font-size: 20px;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.facetwp-star:hover,
|
||||
.facetwp-star:hover ~ .facetwp-star,
|
||||
.facetwp-star.selected,
|
||||
.facetwp-star.selected ~ .facetwp-star {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.facetwp-star.selected:hover,
|
||||
.facetwp-star.selected:hover ~ .facetwp-star {
|
||||
color: red;
|
||||
}
|
||||
|
||||
/* CSS animations */
|
||||
|
||||
@keyframes spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Selections shortcode */
|
||||
|
||||
.facetwp-selections li {
|
||||
display: inline-block;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.facetwp-selections .facetwp-selection-value {
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
cursor: pointer;
|
||||
|
||||
padding-right: 16px;
|
||||
background-image: url('../images/icon-close.png');
|
||||
background-size: 12px 12px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: right center;
|
||||
}
|
||||
|
||||
/* Layout builder */
|
||||
|
||||
@media (max-width: 480px) {
|
||||
body .facetwp-template .fwpl-layout,
|
||||
body .facetwp-template-static .fwpl-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
BIN
wp/wp-content/plugins/facetwp/assets/images/checkbox-on.png
Normal file
|
After Width: | Height: | Size: 128 B |
BIN
wp/wp-content/plugins/facetwp/assets/images/checkbox.png
Normal file
|
After Width: | Height: | Size: 272 B |
BIN
wp/wp-content/plugins/facetwp/assets/images/icon-close.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
wp/wp-content/plugins/facetwp/assets/images/icon-locate.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
wp/wp-content/plugins/facetwp/assets/images/icon-search.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
wp/wp-content/plugins/facetwp/assets/images/loading.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
5
wp/wp-content/plugins/facetwp/assets/images/logo.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg width="100" height="78" xmlns="http://www.w3.org/2000/svg">
|
||||
<g fill="#ffffff">
|
||||
<path d="M99.991,26.908c0.017-0.176,0.009-0.353-0.02-0.527c-0.009-0.06-0.02-0.119-0.033-0.178c-0.05-0.213-0.122-0.422-0.235-0.616L89.269,7.73c-0.011-0.019-0.029-0.032-0.039-0.052c-0.011-0.014-0.014-0.032-0.021-0.047c-0.014-0.021-0.034-0.034-0.051-0.055c-0.033-0.048-0.074-0.092-0.111-0.138c-0.076-0.091-0.153-0.174-0.241-0.252c-0.048-0.042-0.095-0.083-0.145-0.12c-0.034-0.027-0.067-0.055-0.103-0.079c-0.097-0.064-0.2-0.111-0.31-0.159c-0.056-0.027-0.108-0.057-0.167-0.079c-0.041-0.015-0.082-0.031-0.124-0.044c-0.014-0.004-0.022-0.012-0.033-0.017L64.389,0.084C64.189,0.028,63.982,0,63.776,0H34.784c-0.216,0-0.431,0.032-0.638,0.093L11.637,6.698C11.626,6.7,11.617,6.71,11.606,6.713C11.571,6.724,11.535,6.736,11.5,6.75c-0.06,0.021-0.114,0.056-0.172,0.083c-0.111,0.052-0.22,0.104-0.32,0.171c-0.031,0.022-0.059,0.045-0.088,0.068c-0.052,0.038-0.098,0.083-0.146,0.126c-0.089,0.08-0.17,0.166-0.247,0.259c-0.035,0.045-0.074,0.084-0.106,0.132c-0.012,0.02-0.031,0.03-0.045,0.049c-0.012,0.019-0.015,0.04-0.025,0.059c-0.015,0.024-0.037,0.043-0.052,0.069L0.275,25.621c-0.106,0.187-0.171,0.387-0.22,0.593c-0.013,0.056-0.02,0.111-0.029,0.167C0,26.554-0.007,26.728,0.006,26.902c0.004,0.048,0.001,0.095,0.008,0.143c0.027,0.191,0.072,0.38,0.148,0.563c0.008,0.02,0.022,0.035,0.03,0.056c0.019,0.042,0.046,0.079,0.068,0.12c0.086,0.164,0.19,0.312,0.312,0.449c0.022,0.026,0.034,0.058,0.057,0.083l47.748,48.979c0.113,0.114,0.235,0.215,0.365,0.303c0.012,0.008,0.025,0.013,0.038,0.021c0.155,0.1,0.32,0.173,0.49,0.23c0.027,0.01,0.05,0.027,0.078,0.035c0.027,0.007,0.053,0.007,0.08,0.013c0.187,0.05,0.377,0.082,0.57,0.085c0,0,0.001,0,0.002,0l0,0l0,0l0,0l0,0c0,0,0.001,0,0.003,0c0.193-0.003,0.384-0.034,0.57-0.085c0.027-0.006,0.053-0.005,0.081-0.013c0.026-0.008,0.05-0.026,0.076-0.035c0.17-0.058,0.337-0.131,0.49-0.23c0.011-0.006,0.024-0.009,0.032-0.019c0.001,0,0.001,0,0.001,0c0.002,0,0.003-0.002,0.004-0.002c0.13-0.087,0.252-0.188,0.366-0.303l47.747-48.979c0.026-0.026,0.035-0.058,0.058-0.084c0.12-0.135,0.222-0.281,0.308-0.441c0.025-0.045,0.053-0.087,0.074-0.134c0.011-0.022,0.026-0.041,0.035-0.064c0.073-0.179,0.119-0.366,0.143-0.553C99.994,26.995,99.989,26.953,99.991,26.908z M81.532,12.666l-2.729,3.546L66.955,31.606l-12.8-12.06l13.981-3.514L81.532,12.666z M48.795,67.046c-3.293-7.789-8.291-19.604-11.321-26.771c-0.442-1.047-0.837-1.98-1.185-2.801c-0.032-0.079-0.066-0.156-0.097-0.23h27.611L53.173,62.381l-3.175,7.509C49.634,69.029,49.226,68.063,48.795,67.046z M43.744,20.945L32.985,31.577L18.17,12.713l26.968,6.854L43.744,20.945z M73.118,31.036l7.756-10.079l6.179-8.029l7.241,12.387L73.118,31.036z M35.109,4.539h28.354L78.49,8.756l-7.704,1.937l-21.198,5.328l-28.727-7.3L35.109,4.539z M9.674,31.099l21.464,5.834c0.108,0.255,0.24,0.568,0.404,0.958c1.244,2.941,4.275,10.111,11.682,27.625L9.674,31.099z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
BIN
wp/wp-content/plugins/facetwp/assets/images/radio-on.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
wp/wp-content/plugins/facetwp/assets/images/radio.png
Normal file
|
After Width: | Height: | Size: 957 B |
1684
wp/wp-content/plugins/facetwp/assets/js/dist/admin.min.js
vendored
Normal file
1
wp/wp-content/plugins/facetwp/assets/js/dist/front.min.js
vendored
Normal file
104
wp/wp-content/plugins/facetwp/assets/js/src/accessibility.js
Normal file
@@ -0,0 +1,104 @@
|
||||
(function($) {
|
||||
var last_checked = null;
|
||||
|
||||
if ('undefined' !== typeof FWP.hooks) {
|
||||
FWP.hooks.addAction('facetwp/loaded', function() {
|
||||
|
||||
// checkbox, radio, fselect
|
||||
$('.facetwp-checkbox, .facetwp-radio, .fs-option').each(function() {
|
||||
let $el = $(this);
|
||||
if (! $el.hasClass('disabled')) {
|
||||
$el.attr('role', 'checkbox');
|
||||
$el.attr('aria-checked', $el.hasClass('checked') ? 'true' : 'false');
|
||||
$el.attr('aria-label', $el.text());
|
||||
$el.attr('tabindex', 0);
|
||||
}
|
||||
});
|
||||
|
||||
// pager, show more, user selections, hierarchy
|
||||
$('.facetwp-page, .facetwp-toggle, .facetwp-selection-value, .facetwp-link').each(function() {
|
||||
let $el = $(this);
|
||||
let label = $el.text();
|
||||
|
||||
if ($el.hasClass('facetwp-page')) {
|
||||
label = FWP_JSON.a11y.label_page + ' ' + label;
|
||||
|
||||
if ($el.hasClass('next')) {
|
||||
label = FWP_JSON.a11y.label_page_next;
|
||||
}
|
||||
else if ($el.hasClass('prev')) {
|
||||
label = FWP_JSON.a11y.label_page_prev;
|
||||
}
|
||||
}
|
||||
|
||||
$el.attr('role', 'link');
|
||||
$el.attr('aria-label', label);
|
||||
$el.attr('tabindex', 0);
|
||||
});
|
||||
|
||||
// dropdown, sort facet, old sort feature
|
||||
$('.facetwp-type-dropdown select, .facetwp-type-sort select, .facetwp-sort-select select').each(function() {
|
||||
$(this).attr('aria-label', $(this).find('option:selected').text());
|
||||
});
|
||||
|
||||
// search, date
|
||||
$('.facetwp-search, .facetwp-date').each(function() {
|
||||
$(this).attr('aria-label', $(this).attr('placeholder'));
|
||||
});
|
||||
|
||||
// checkbox group
|
||||
$('.facetwp-type-checkboxes').each(function() {
|
||||
let facet_name = $(this).attr('data-name');
|
||||
$(this).attr('aria-label', FWP.settings.labels[facet_name]);
|
||||
$(this).attr('role', 'group');
|
||||
});
|
||||
|
||||
// fselect
|
||||
$('.fs-wrap').each(function() {
|
||||
$(this).attr('role', 'button');
|
||||
$(this).attr('aria-haspopup', 'true');
|
||||
$(this).attr('aria-expanded', $(this).hasClass('fs-open') ? 'true' : 'false');
|
||||
});
|
||||
|
||||
$('.facetwp-type-fselect .facetwp-dropdown').attr('aria-hidden', 'true');
|
||||
|
||||
// pager
|
||||
$('.facetwp-pager').attr('role', 'navigation');
|
||||
$('.facetwp-page.active').attr('aria-current', 'true');
|
||||
|
||||
// focus on selection
|
||||
if (null != last_checked) {
|
||||
var $el = $('.facetwp-facet [data-value="' + last_checked + '"]');
|
||||
if ($el.len()) {
|
||||
$el.nodes[0].focus();
|
||||
}
|
||||
last_checked = null;
|
||||
}
|
||||
}, 999);
|
||||
}
|
||||
|
||||
// keyboard support
|
||||
$().on('keydown', '.facetwp-checkbox, .facetwp-radio, .facetwp-link', function(e) {
|
||||
if (32 == e.keyCode || 13 == e.keyCode) {
|
||||
last_checked = $(this).attr('data-value');
|
||||
e.preventDefault();
|
||||
this.click();
|
||||
}
|
||||
});
|
||||
|
||||
$().on('keydown', '.facetwp-page, .facetwp-toggle, .facetwp-selection-value', function(e) {
|
||||
if (32 == e.keyCode || 13 == e.keyCode) {
|
||||
e.preventDefault();
|
||||
this.click();
|
||||
}
|
||||
});
|
||||
|
||||
// fselect - determine "aria-expanded"
|
||||
function toggleExpanded(e) {
|
||||
var $fs = $(e.detail[0]);
|
||||
$fs.attr('aria-expanded', $fs.hasClass('fs-open') ? 'true' : 'false');
|
||||
}
|
||||
|
||||
$().on('fs:opened', toggleExpanded);
|
||||
$().on('fs:closed', toggleExpanded);
|
||||
})(fUtil);
|
||||
2189
wp/wp-content/plugins/facetwp/assets/js/src/admin.js
Normal file
10
wp/wp-content/plugins/facetwp/assets/js/src/deprecated.js
Normal file
@@ -0,0 +1,10 @@
|
||||
FWP.deprecated = (old_method, new_method, ...args) => {
|
||||
console.warn('FWP.' + old_method + '() has changed to FWP.' + new_method + '()');
|
||||
return FWP[new_method](...args);
|
||||
};
|
||||
FWP.build_post_data = (...args) => FWP.deprecated('build_post_data', 'buildPostData', ...args);
|
||||
FWP.build_query_string = (...args) => FWP.deprecated('build_query_string', 'buildQueryString', ...args);
|
||||
FWP.fetch_data = (...args) => FWP.deprecated('fetch_data', 'fetchData', ...args);
|
||||
FWP.load_from_hash = (...args) => FWP.deprecated('load_from_hash', 'loadFromHash', ...args);
|
||||
FWP.parse_facets = (...args) => FWP.deprecated('parse_facets', 'parseFacets', ...args);
|
||||
FWP.set_hash = (...args) => FWP.deprecated('set_hash', 'setHash', ...args);
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* WP-JS-Hooks
|
||||
* @version 1.0.0
|
||||
* @author Carl Danley & 10up
|
||||
*/
|
||||
!function(t,n){"use strict";t.FWP=t.FWP||{},t.FWP.hooks=t.FWP.hooks||new function(){function t(t,n,r,i){var e,o,c;if(f[t][n])if(r)if(e=f[t][n],i)for(c=e.length;c--;)(o=e[c]).callback===r&&o.context===i&&e.splice(c,1);else for(c=e.length;c--;)e[c].callback===r&&e.splice(c,1);else f[t][n]=[]}function n(t,n,i,e,o){var c={callback:i,priority:e,context:o},l=f[t][n];l?(l.push(c),l=r(l)):l=[c],f[t][n]=l}function r(t){for(var n,r,i,e=1,o=t.length;e<o;e++){for(n=t[e],r=e;(i=t[r-1])&&i.priority>n.priority;)t[r]=t[r-1],--r;t[r]=n}return t}function i(t,n,r){var i,e,o=f[t][n];if(!o)return"filters"===t&&r[0];if(e=o.length,"filters"===t)for(i=0;i<e;i++)r[0]=o[i].callback.apply(o[i].context,r);else for(i=0;i<e;i++)o[i].callback.apply(o[i].context,r);return"filters"!==t||r[0]}var e=Array.prototype.slice,o={removeFilter:function(n,r){return"string"==typeof n&&t("filters",n,r),o},applyFilters:function(){var t=e.call(arguments),n=t.shift();return"string"==typeof n?i("filters",n,t):o},addFilter:function(t,r,i,e){return"string"==typeof t&&"function"==typeof r&&n("filters",t,r,i=parseInt(i||10,10),e),o},removeAction:function(n,r){return"string"==typeof n&&t("actions",n,r),o},doAction:function(){var t=e.call(arguments),n=t.shift();return"string"==typeof n&&i("actions",n,t),o},addAction:function(t,r,i,e){return"string"==typeof t&&"function"==typeof r&&n("actions",t,r,i=parseInt(i||10,10),e),o}},f={actions:{},filters:{}};return o}}(window);
|
||||
1013
wp/wp-content/plugins/facetwp/assets/js/src/front-facets.js
Normal file
659
wp/wp-content/plugins/facetwp/assets/js/src/front.js
Normal file
@@ -0,0 +1,659 @@
|
||||
window.FWP = (($) => {
|
||||
|
||||
class FacetWP {
|
||||
constructor() {
|
||||
this.import();
|
||||
this.bindEvents();
|
||||
}
|
||||
|
||||
import() {
|
||||
if ('undefined' !== typeof FWP) {
|
||||
$.each(FWP, (val, key) => this[key] = val);
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
var FWP = this;
|
||||
|
||||
this.setDefaults();
|
||||
|
||||
if (0 < $('.facetwp-sort').len()) {
|
||||
FWP.extras.sort = 'default';
|
||||
}
|
||||
|
||||
if (0 < $('.facetwp-pager').len()) {
|
||||
FWP.extras.pager = true;
|
||||
}
|
||||
|
||||
if (0 < $('.facetwp-per-page').len()) {
|
||||
FWP.extras.per_page = 'default';
|
||||
}
|
||||
|
||||
if (0 < $('.facetwp-counts').len()) {
|
||||
FWP.extras.counts = true;
|
||||
}
|
||||
|
||||
if (0 < $('.facetwp-selections').len()) {
|
||||
FWP.extras.selections = true;
|
||||
}
|
||||
|
||||
// Make sure there's a template
|
||||
var has_template = $('.facetwp-template').len() > 0;
|
||||
|
||||
if (! has_template) {
|
||||
var has_loop = FWP.helper.detectLoop(document.body);
|
||||
|
||||
if (has_loop) {
|
||||
$(has_loop).addClass('facetwp-template');
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var $div = $('.facetwp-template').first();
|
||||
FWP.template = $div.attr('data-name') ? $div.attr('data-name') : 'wp';
|
||||
|
||||
// Facets inside the template?
|
||||
if ($div.find('.facetwp-facet').len() > 0) {
|
||||
console.error('Facets should not be inside the "facetwp-template" container');
|
||||
}
|
||||
|
||||
FWP.hooks.doAction('facetwp/ready');
|
||||
|
||||
// Generate the user selections
|
||||
if (FWP.extras.selections) {
|
||||
FWP.hooks.addAction('facetwp/loaded', () => {
|
||||
|
||||
var selections = '';
|
||||
var skipped = ['pager', 'reset', 'sort'];
|
||||
|
||||
$.each(FWP.facets, (val, key) => {
|
||||
if (val.length < 1 || ! $.isset(FWP.settings.labels[key]) || skipped.includes(FWP.facet_type[key])) {
|
||||
return true; // skip facet
|
||||
}
|
||||
|
||||
var choices = val;
|
||||
var $el = $('.facetwp-facet-' + key);
|
||||
var facet_type = $el.attr('data-ui') || $el.attr('data-type');
|
||||
choices = FWP.hooks.applyFilters('facetwp/selections/' + facet_type, choices, {
|
||||
'el': $el,
|
||||
'selected_values': choices
|
||||
});
|
||||
|
||||
if (choices.length) {
|
||||
if ('string' === typeof choices) {
|
||||
choices = [{ value: '', label: choices }];
|
||||
}
|
||||
else if (! $.isset(choices[0].label)) {
|
||||
choices = [{ value: '', label: choices[0] }];
|
||||
}
|
||||
}
|
||||
|
||||
var values = '';
|
||||
$.each(choices, (choice) => {
|
||||
values += '<span class="facetwp-selection-value" data-value="' + choice.value + '">' + FWP.helper.escapeHtml(choice.label) + '</span>';
|
||||
});
|
||||
|
||||
selections += '<li data-facet="' + key + '"><span class="facetwp-selection-label">' + FWP.settings.labels[key] + ':</span> ' + values + '</li>';
|
||||
});
|
||||
|
||||
if ('' !== selections) {
|
||||
selections = '<ul>' + selections + '</ul>';
|
||||
}
|
||||
|
||||
$('.facetwp-selections').html(selections);
|
||||
});
|
||||
}
|
||||
|
||||
FWP.refresh();
|
||||
}
|
||||
|
||||
setDefaults() {
|
||||
let defaults = {
|
||||
'facets': {},
|
||||
'template': null,
|
||||
'settings': {},
|
||||
'is_reset': false,
|
||||
'is_refresh': false,
|
||||
'is_bfcache': false,
|
||||
'is_hash_click': false,
|
||||
'is_load_more': false,
|
||||
'auto_refresh': true,
|
||||
'soft_refresh': false,
|
||||
'frozen_facets': {},
|
||||
'active_facet': null,
|
||||
'facet_type': {},
|
||||
'loaded': false,
|
||||
'extras': {},
|
||||
'paged': 1
|
||||
};
|
||||
|
||||
for (var prop in defaults) {
|
||||
if (!$.isset(this[prop])) {
|
||||
this[prop] = defaults[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
refresh() {
|
||||
FWP.is_refresh = true;
|
||||
|
||||
// Add the loading overlay
|
||||
FWP.toggleOverlay('on');
|
||||
|
||||
// Load facet DOM values
|
||||
if (! FWP.is_reset) {
|
||||
FWP.parseFacets();
|
||||
}
|
||||
|
||||
// Check the URL on pageload
|
||||
if (! FWP.loaded) {
|
||||
FWP.loadFromHash();
|
||||
}
|
||||
|
||||
// Fire a notification event
|
||||
$().trigger('facetwp-refresh');
|
||||
|
||||
// Trigger window.onpopstate
|
||||
if (FWP.loaded && ! FWP.is_popstate && ! FWP.is_load_more) {
|
||||
FWP.setHash();
|
||||
}
|
||||
|
||||
// Preload?
|
||||
if (! FWP.loaded && ! FWP.is_bfcache && $.isset(FWP_JSON.preload_data)) {
|
||||
FWP.render(FWP_JSON.preload_data);
|
||||
}
|
||||
else {
|
||||
FWP.fetchData();
|
||||
}
|
||||
|
||||
// Unfreeze any soft-frozen facets
|
||||
$.each(FWP.frozen_facets, (type, name) => {
|
||||
if ('hard' !== type) {
|
||||
delete FWP.frozen_facets[name];
|
||||
}
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
FWP.paged = 1;
|
||||
FWP.soft_refresh = false;
|
||||
FWP.is_refresh = false;
|
||||
FWP.is_reset = false;
|
||||
}
|
||||
|
||||
autoload() {
|
||||
if (FWP.auto_refresh && ! FWP.is_refresh) {
|
||||
FWP.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
parseFacets() {
|
||||
FWP.facets = {};
|
||||
|
||||
$('.facetwp-facet').each(function() {
|
||||
var $this = $(this);
|
||||
var facet_name = $this.attr('data-name');
|
||||
var facet_type = $this.attr('data-type');
|
||||
var is_ignored = $this.hasClass('facetwp-ignore');
|
||||
|
||||
if (null !== $this.attr('data-ui')) {
|
||||
facet_type = $this.attr('data-ui');
|
||||
}
|
||||
|
||||
// Store the facet type
|
||||
FWP.facet_type[facet_name] = facet_type;
|
||||
|
||||
// Plugin hook
|
||||
if (! is_ignored) {
|
||||
FWP.hooks.doAction('facetwp/refresh/' + facet_type, $this, facet_name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
buildQueryString() {
|
||||
var query_string = '';
|
||||
|
||||
// Non-FacetWP URL variables
|
||||
var hash = [];
|
||||
var get_str = window.location.search.replace('?', '').split('&');
|
||||
$.each(get_str, (val) => {
|
||||
var param_name = val.split('=')[0];
|
||||
if (0 !== param_name.indexOf(FWP_JSON.prefix)) {
|
||||
hash.push(val);
|
||||
}
|
||||
});
|
||||
hash = hash.join('&');
|
||||
|
||||
// FacetWP URL variables
|
||||
var fwp_vars = Object.assign({}, FWP.facets);
|
||||
|
||||
// Add pagination to the URL hash
|
||||
if (1 < FWP.paged) {
|
||||
fwp_vars['paged'] = FWP.paged;
|
||||
}
|
||||
|
||||
// Add "per page" to the URL hash
|
||||
if (FWP.extras.per_page && 'default' !== FWP.extras.per_page) {
|
||||
fwp_vars['per_page'] = FWP.extras.per_page;
|
||||
}
|
||||
|
||||
// Add sorting to the URL hash
|
||||
if (FWP.extras.sort && 'default' !== FWP.extras.sort) {
|
||||
fwp_vars['sort'] = FWP.extras.sort;
|
||||
}
|
||||
|
||||
fwp_vars = FWP.helper.serialize(fwp_vars, FWP_JSON.prefix);
|
||||
|
||||
if ('' !== hash) {
|
||||
query_string += hash;
|
||||
}
|
||||
if ('' !== fwp_vars) {
|
||||
query_string += ('' !== hash ? '&' : '') + fwp_vars;
|
||||
}
|
||||
|
||||
return query_string;
|
||||
}
|
||||
|
||||
setHash() {
|
||||
var query_string = FWP.buildQueryString();
|
||||
|
||||
if ('' !== query_string) {
|
||||
query_string = '?' + query_string;
|
||||
}
|
||||
|
||||
if (history.pushState) {
|
||||
history.pushState(null, null, window.location.pathname + query_string);
|
||||
}
|
||||
|
||||
// Update FWP_HTTP.get
|
||||
FWP_HTTP.get = {};
|
||||
window.location.search.replace('?', '').split('&').forEach((el) => {
|
||||
var item = el.split('=');
|
||||
|
||||
if ('' != item[0]) {
|
||||
FWP_HTTP.get[item[0]] = item[1];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadFromHash() {
|
||||
var hash = [];
|
||||
var get_str = window.location.search.replace('?', '').split('&');
|
||||
$.each(get_str, (val) => {
|
||||
var param_name = val.split('=')[0];
|
||||
if (0 === param_name.indexOf(FWP_JSON.prefix)) {
|
||||
hash.push(val.replace(FWP_JSON.prefix, ''));
|
||||
}
|
||||
});
|
||||
hash = hash.join('&');
|
||||
|
||||
// Reset facet values
|
||||
$.each(FWP.facets, (val, key) => {
|
||||
FWP.facets[key] = [];
|
||||
});
|
||||
|
||||
FWP.paged = 1;
|
||||
FWP.extras.sort = 'default';
|
||||
|
||||
if ('' !== hash) {
|
||||
hash = hash.split('&');
|
||||
$.each(hash, (chunk) => {
|
||||
var obj = chunk.split('=')[0];
|
||||
var val = chunk.split('=')[1];
|
||||
|
||||
if ('paged' === obj) {
|
||||
FWP.paged = val;
|
||||
}
|
||||
else if ('per_page' === obj || 'sort' === obj) {
|
||||
FWP.extras[obj] = val;
|
||||
}
|
||||
else if ('' !== val) {
|
||||
var type = $.isset(FWP.facet_type[obj]) ? FWP.facet_type[obj] : '';
|
||||
if ('search' === type || 'autocomplete' === type) {
|
||||
FWP.facets[obj] = decodeURIComponent(val);
|
||||
}
|
||||
else {
|
||||
FWP.facets[obj] = decodeURIComponent(val).split(',');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
buildPostData() {
|
||||
return {
|
||||
'facets': FWP.facets,
|
||||
'frozen_facets': FWP.frozen_facets,
|
||||
'http_params': FWP_HTTP,
|
||||
'template': FWP.template,
|
||||
'extras': FWP.extras,
|
||||
'soft_refresh': FWP.soft_refresh ? 1 : 0,
|
||||
'is_bfcache': FWP.is_bfcache ? 1 : 0,
|
||||
'first_load': FWP.loaded ? 0 : 1,
|
||||
'paged': FWP.paged
|
||||
};
|
||||
}
|
||||
|
||||
fetchData() {
|
||||
var endpoint = ('wp' === FWP.template) ? document.URL : FWP_JSON.ajaxurl;
|
||||
var data = {
|
||||
action: 'facetwp_refresh',
|
||||
data: FWP.buildPostData()
|
||||
};
|
||||
|
||||
var settings = {
|
||||
dataType: 'text', // better JSON error handling
|
||||
done: (resp) => {
|
||||
try {
|
||||
var json = JSON.parse(resp);
|
||||
FWP.render(json);
|
||||
}
|
||||
catch(e) {
|
||||
var pos = resp.indexOf('{"facets');
|
||||
if (-1 < pos) {
|
||||
var json = JSON.parse(resp.substr(pos));
|
||||
FWP.render(json);
|
||||
}
|
||||
else {
|
||||
$('.facetwp-template').text('FacetWP was unable to auto-detect the post listing');
|
||||
console.log(resp);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
|
||||
settings = FWP.hooks.applyFilters('facetwp/ajax_settings', settings);
|
||||
|
||||
$.post(endpoint, data, settings);
|
||||
}
|
||||
|
||||
render(response) {
|
||||
FWP.response = response;
|
||||
|
||||
// Don't render CSS-based (or empty) templates on pageload
|
||||
// The template has already been pre-loaded
|
||||
if (('wp' === FWP.template || '' === response.template) && ! FWP.loaded && ! FWP.is_bfcache) {
|
||||
var inject = false;
|
||||
}
|
||||
else {
|
||||
var inject = response.template;
|
||||
|
||||
if ('wp' === FWP.template) {
|
||||
var obj = $(response.template);
|
||||
var $tpl = obj.find('.facetwp-template');
|
||||
|
||||
if ($tpl.len() < 1) {
|
||||
var loop = FWP.helper.detectLoop(obj.nodes[0]);
|
||||
|
||||
if (loop) {
|
||||
$tpl = $(loop).addClass('facetwp-template');
|
||||
}
|
||||
}
|
||||
|
||||
if ($tpl.len() > 0) {
|
||||
var inject = $tpl.html();
|
||||
}
|
||||
else {
|
||||
// Fallback until "loop_no_results" action is added to WP core
|
||||
var inject = FWP_JSON['no_results_text'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (false !== inject) {
|
||||
if (! FWP.hooks.applyFilters('facetwp/template_html', false, { 'response': response, 'html': inject })) {
|
||||
$('.facetwp-template').html(inject);
|
||||
}
|
||||
}
|
||||
|
||||
// Populate each facet box
|
||||
$.each(response.facets, (val, name) => {
|
||||
$('.facetwp-facet-' + name).html(val);
|
||||
});
|
||||
|
||||
// Populate the counts
|
||||
if ($.isset(response.counts)) {
|
||||
$('.facetwp-counts').html(response.counts);
|
||||
}
|
||||
|
||||
// Populate the pager
|
||||
if ($.isset(response.pager)) {
|
||||
$('.facetwp-pager').html(response.pager);
|
||||
}
|
||||
|
||||
// Populate the "per page" box
|
||||
if ($.isset(response.per_page)) {
|
||||
$('.facetwp-per-page').html(response.per_page);
|
||||
if ('default' !== FWP.extras.per_page) {
|
||||
$('.facetwp-per-page-select').val(FWP.extras.per_page);
|
||||
}
|
||||
}
|
||||
|
||||
// Populate the sort box
|
||||
if ($.isset(response.sort)) {
|
||||
$('.facetwp-sort').html(response.sort);
|
||||
$('.facetwp-sort-select').val(FWP.extras.sort);
|
||||
}
|
||||
|
||||
// Populate the settings object (iterate to preserve static facet settings)
|
||||
$.each(response.settings, (val, key) => {
|
||||
FWP.settings[key] = val;
|
||||
});
|
||||
|
||||
// WP Playlist support
|
||||
if ('function' === typeof WPPlaylistView) {
|
||||
$('.facetwp-template .wp-playlist').each((item) => {
|
||||
return new WPPlaylistView({ el: item });
|
||||
});
|
||||
}
|
||||
|
||||
// Fire a notification event
|
||||
$().trigger('facetwp-loaded');
|
||||
|
||||
// Allow final actions
|
||||
FWP.hooks.doAction('facetwp/loaded');
|
||||
|
||||
// Remove the loading overlay
|
||||
FWP.toggleOverlay('off');
|
||||
|
||||
// Clear the active facet
|
||||
FWP.active_facet = null;
|
||||
|
||||
// Detect "back-forward" cache
|
||||
FWP.is_bfcache = true;
|
||||
|
||||
// Done loading?
|
||||
FWP.loaded = true;
|
||||
}
|
||||
|
||||
reset(facets) {
|
||||
FWP.parseFacets();
|
||||
|
||||
var opts = {};
|
||||
|
||||
if ('string' === typeof facets) {
|
||||
opts[facets] = '';
|
||||
}
|
||||
else if (Array.isArray(facets)) {
|
||||
$.each(facets, (facet_name) => {
|
||||
opts[facet_name] = '';
|
||||
});
|
||||
}
|
||||
else if ('object' === typeof facets && !! facets) {
|
||||
opts = facets;
|
||||
}
|
||||
|
||||
var reset_all = Object.keys(opts).length < 1;
|
||||
|
||||
$.each(FWP.facets, (vals, facet_name) => {
|
||||
var has_reset = $.isset(opts[facet_name]);
|
||||
var selected_vals = Array.isArray(vals) ? vals : [vals];
|
||||
|
||||
if (has_reset && -1 < selected_vals.indexOf(opts[facet_name])) {
|
||||
var pos = selected_vals.indexOf(opts[facet_name]);
|
||||
selected_vals.splice(pos, 1); // splice() is mutable!
|
||||
FWP.facets[facet_name] = selected_vals;
|
||||
}
|
||||
|
||||
if (has_reset && (selected_vals.length < 1 || '' === opts[facet_name])) {
|
||||
delete FWP.frozen_facets[facet_name];
|
||||
}
|
||||
|
||||
if (reset_all || (has_reset && '' === opts[facet_name])) {
|
||||
FWP.facets[facet_name] = [];
|
||||
}
|
||||
});
|
||||
|
||||
if (reset_all) {
|
||||
FWP.extras.per_page = 'default';
|
||||
FWP.extras.sort = 'default';
|
||||
FWP.frozen_facets = {};
|
||||
}
|
||||
|
||||
FWP.hooks.doAction('facetwp/reset');
|
||||
FWP.is_reset = true;
|
||||
FWP.refresh();
|
||||
}
|
||||
|
||||
toggleOverlay(which) {
|
||||
var method = ('on' === which) ? 'addClass' : 'removeClass';
|
||||
$('.facetwp-facet')[method]('is-loading');
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
window.addEventListener('popstate', () => {
|
||||
|
||||
// Detect browser "back-foward" cache
|
||||
if (FWP.is_bfcache) {
|
||||
FWP.loaded = false;
|
||||
}
|
||||
|
||||
if ((FWP.loaded || FWP.is_bfcache) && ! FWP.is_refresh && ! FWP.is_hash_click) {
|
||||
FWP.is_popstate = true;
|
||||
FWP.refresh();
|
||||
FWP.is_popstate = false;
|
||||
}
|
||||
|
||||
FWP.is_hash_click = false;
|
||||
});
|
||||
|
||||
// Prevent hash clicks from triggering a refresh
|
||||
$().on('click', 'a[href^="#"]', () => {
|
||||
FWP.is_hash_click = true;
|
||||
});
|
||||
|
||||
// Click on a user selection
|
||||
$().on('click', '.facetwp-selections .facetwp-selection-value', function() {
|
||||
if (FWP.is_refresh) {
|
||||
return;
|
||||
}
|
||||
|
||||
var facet_name = $(this).closest('li').attr('data-facet');
|
||||
var facet_value = $(this).attr('data-value');
|
||||
|
||||
if ('' != facet_value) {
|
||||
var obj = {};
|
||||
obj[facet_name] = facet_value;
|
||||
FWP.reset(obj);
|
||||
}
|
||||
else {
|
||||
FWP.reset(facet_name);
|
||||
}
|
||||
});
|
||||
|
||||
// Pagination
|
||||
$().on('click', '.facetwp-page[data-page]', function() {
|
||||
$('.facetwp-page').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
|
||||
FWP.paged = $(this).attr('data-page');
|
||||
FWP.soft_refresh = true;
|
||||
FWP.refresh();
|
||||
});
|
||||
|
||||
// Use jQuery if available for select2
|
||||
var $f = ('function' === typeof jQuery) ? jQuery : fUtil;
|
||||
|
||||
// Per page
|
||||
$f(document).on('change', '.facetwp-per-page-select', function() {
|
||||
FWP.extras.per_page = $(this).val();
|
||||
FWP.soft_refresh = true;
|
||||
FWP.autoload();
|
||||
});
|
||||
|
||||
// Sorting
|
||||
$f(document).on('change', '.facetwp-sort-select', function() {
|
||||
FWP.extras.sort = $(this).val();
|
||||
FWP.soft_refresh = true;
|
||||
FWP.autoload();
|
||||
});
|
||||
|
||||
$f(() => {
|
||||
this.init();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
FacetWP.prototype.helper = {
|
||||
getUrlVar: (name) => {
|
||||
var name = FWP_JSON.prefix + name;
|
||||
var url_vars = window.location.search.replace('?', '').split('&');
|
||||
for (var i = 0; i < url_vars.length; i++) {
|
||||
var item = url_vars[i].split('=');
|
||||
if (item[0] === name) {
|
||||
return item[1];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
debounce: (func, wait) => {
|
||||
var timeout;
|
||||
return function(...args) {
|
||||
var boundFunc = func.bind(this, ...args);
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(boundFunc, wait);
|
||||
};
|
||||
},
|
||||
serialize: (obj, prefix) => {
|
||||
var str = [];
|
||||
var prefix = $.isset(prefix) ? prefix : '';
|
||||
for (var p in obj) {
|
||||
if ('' != obj[p]) { // Needs to be "!=" instead of "!=="
|
||||
str.push(prefix + encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
|
||||
}
|
||||
}
|
||||
return str.join('&');
|
||||
},
|
||||
escapeHtml: (text) => {
|
||||
var map = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": '''
|
||||
};
|
||||
return text.replace(/[&<>"']/g,(m) => map[m]).trim();
|
||||
},
|
||||
detectLoop: (node) => {
|
||||
var curNode = null;
|
||||
var iterator = document.createNodeIterator(node, NodeFilter.SHOW_COMMENT, () => {
|
||||
return NodeFilter.FILTER_ACCEPT; /* IE expects a function */
|
||||
}, false);
|
||||
|
||||
while (curNode = iterator.nextNode()) {
|
||||
if (8 === curNode.nodeType && 'fwp-loop' === curNode.nodeValue) {
|
||||
return curNode.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
return new FacetWP();
|
||||
|
||||
})(fUtil);
|
||||
1
wp/wp-content/plugins/facetwp/assets/js/src/sample.json
Normal file
@@ -0,0 +1 @@
|
||||
{"facets":[{"name":"categories","label":"Categories","type":"checkboxes","source":"tax/category","parent_term":"","hierarchical":"no","show_expanded":"no","ghosts":"no","preserve_ghosts":"no","operator":"and","orderby":"count","count":"10","soft_limit":"5"}],"templates":[{"name":"blog_posts","label":"Blog posts","query":"","template":"","layout":{"items":[{"type":"row","items":[{"type":"col","items":[{"type":"item","source":"post_title","settings":{"link":{"type":"post","href":"","target":""},"prefix":"","suffix":"","border":{"style":"none","color":"","width":{"unit":"px","top":0,"right":0,"bottom":0,"left":0}},"background_color":"","padding":{"unit":"px","top":0,"right":0,"bottom":0,"left":0},"text_color":"","text_style":{"align":"","bold":false,"italic":false},"font_size":{"unit":"px","size":0},"name":"el-fz703r","css_class":"","is_hidden":""}}],"settings":{"border":{"style":"none","color":"","width":{"unit":"px","top":0,"right":0,"bottom":0,"left":0}},"background_color":"","padding":{"unit":"px","top":0,"right":0,"bottom":0,"left":0},"text_color":"","text_style":{"align":"","bold":false,"italic":false},"font_size":{"unit":"px","size":0},"name":"el-1tvcxf","css_class":""}}],"settings":{"grid_template_columns":"1fr","border":{"style":"none","color":"","width":{"unit":"px","top":0,"right":0,"bottom":0,"left":0}},"background_color":"","padding":{"unit":"px","top":0,"right":0,"bottom":0,"left":0},"text_color":"","text_style":{"align":"","bold":false,"italic":false},"font_size":{"unit":"px","size":0},"name":"el-8cjrpw","css_class":""}}],"settings":{"num_columns":1,"grid_gap":10,"border":{"style":"none","color":"","width":{"unit":"px","top":0,"right":0,"bottom":0,"left":0}},"background_color":"","padding":{"unit":"px","top":0,"right":0,"bottom":0,"left":0},"text_color":"","text_style":{"align":"","bold":false,"italic":false},"font_size":{"unit":"px","size":0},"name":"el-hkhimk","css_class":"","custom_css":""}},"query_obj":{"post_type":[{"label":"Posts","value":"post"}],"posts_per_page":10,"orderby":[{"key":"date","order":"DESC","type":"CHAR"}],"filters":[]},"modes":{"display":"visual","query":"visual"}}],"settings":{"thousands_separator":",","decimal_separator":".","prefix":"_"}}
|
||||
29
wp/wp-content/plugins/facetwp/assets/vendor/fComplete/fComplete.css
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
.fcomplete-wrap {
|
||||
position: absolute;
|
||||
border: 1px solid #ddd;
|
||||
border-top: none;
|
||||
background-color: #fff;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.fcomplete-result,
|
||||
.fcomplete-status {
|
||||
padding: 6px 8px;
|
||||
}
|
||||
|
||||
.fcomplete-result {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fcomplete-result:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.fcomplete-status {
|
||||
font-size: 13px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.fcomplete-hidden {
|
||||
display: none;
|
||||
}
|
||||
283
wp/wp-content/plugins/facetwp/assets/vendor/fComplete/fComplete.js
vendored
Normal file
@@ -0,0 +1,283 @@
|
||||
window.fComplete = (() => {
|
||||
|
||||
class fComplete {
|
||||
|
||||
constructor(selector, options) {
|
||||
let that = this;
|
||||
|
||||
var defaults = {
|
||||
data: [],
|
||||
minChars: 3,
|
||||
maxResults: 10,
|
||||
searchDelay: 200,
|
||||
loadingText: 'Loading...',
|
||||
minCharsText: 'Enter {n} or more characters',
|
||||
noResultsText: 'No results',
|
||||
beforeRender: null,
|
||||
onSelect: null
|
||||
};
|
||||
|
||||
that.settings = Object.assign({}, defaults, options);
|
||||
that.settings.minChars = Math.max(1, that.settings.minChars);
|
||||
that.settings.maxResults = Math.max(1, that.settings.maxResults);
|
||||
that.settings.searchDelay = Math.max(0, that.settings.searchDelay);
|
||||
|
||||
if ('string' === typeof selector) {
|
||||
var nodes = Array.from(document.querySelectorAll(selector));
|
||||
}
|
||||
else if (selector instanceof Node) {
|
||||
var nodes = [selector];
|
||||
}
|
||||
else if (Array.isArray(selector)) {
|
||||
var nodes = selector;
|
||||
}
|
||||
else {
|
||||
var nodes = [];
|
||||
}
|
||||
|
||||
if ('undefined' === typeof window.fCompleteInit) {
|
||||
window.fCompleteInit = {
|
||||
lastFocus: null,
|
||||
eventsBound: true
|
||||
};
|
||||
that.bindEvents();
|
||||
}
|
||||
|
||||
nodes.forEach((input) => {
|
||||
that.input = input;
|
||||
input.fcomplete = that;
|
||||
input.classList.add('fcomplete-enabled');
|
||||
that.create();
|
||||
});
|
||||
}
|
||||
|
||||
create() {
|
||||
var that = this;
|
||||
|
||||
var html = `
|
||||
<div class="fcomplete-wrap fcomplete-hidden">
|
||||
<div class="fcomplete-status"></div>
|
||||
<div class="fcomplete-results"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
var rect = that.input.getBoundingClientRect();
|
||||
|
||||
var tpl = document.createElement('template');
|
||||
tpl.innerHTML = html;
|
||||
var wrap = tpl.content.querySelector('.fcomplete-wrap');
|
||||
wrap.style.minWidth = rect.width + 'px';
|
||||
that.input.parentNode.insertBefore(wrap, that.input.nextSibling);
|
||||
|
||||
// add a relationship link
|
||||
that.input._rel = wrap;
|
||||
wrap._rel = that.input;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.input._rel.remove();
|
||||
delete this.input._rel;
|
||||
}
|
||||
|
||||
reload() {
|
||||
this.destroy();
|
||||
this.create();
|
||||
}
|
||||
|
||||
open() {
|
||||
this.input._rel.classList.remove('fcomplete-hidden');
|
||||
}
|
||||
|
||||
close() {
|
||||
window.fCompleteInit.lastFocus = null;
|
||||
this.input._rel.classList.add('fcomplete-hidden');
|
||||
}
|
||||
|
||||
setStatus(text) {
|
||||
var text = text.replace('{n}', this.settings.minChars);
|
||||
var node = this.input._rel.querySelector('.fcomplete-status');
|
||||
node.innerHTML = text;
|
||||
|
||||
var method = (text) ? 'remove' : 'add';
|
||||
node.classList[method]('fcomplete-hidden');
|
||||
}
|
||||
|
||||
render(data) {
|
||||
var data = (this.settings.beforeRender) ? this.settings.beforeRender(data) : data;
|
||||
var wrap = this.input._rel;
|
||||
|
||||
if (data.length) {
|
||||
var html = '';
|
||||
var len = Math.min(data.length, this.settings.maxResults);
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
html += `<div class="fcomplete-result" data-value="${data[i].value}" tabindex="-1">${data[i].label}</div>`;
|
||||
}
|
||||
|
||||
wrap.querySelector('.fcomplete-results').innerHTML = html;
|
||||
this.setStatus('');
|
||||
}
|
||||
else {
|
||||
wrap.querySelector('.fcomplete-results').innerHTML = '';
|
||||
this.setStatus(this.settings.noResultsText);
|
||||
}
|
||||
|
||||
this.input.fcomplete.open();
|
||||
}
|
||||
|
||||
getAdjacentSibling(which) {
|
||||
var that = this;
|
||||
var which = which || 'next';
|
||||
var sibling = window.fCompleteInit.lastFocus;
|
||||
var selector = '.fcomplete-result';
|
||||
|
||||
if (sibling) {
|
||||
sibling = sibling[which + 'ElementSibling'];
|
||||
|
||||
while (sibling) {
|
||||
if (sibling.matches(selector)) break;
|
||||
sibling = sibling[which + 'ElementSibling'];
|
||||
}
|
||||
|
||||
return sibling;
|
||||
}
|
||||
else if ('next' == which) {
|
||||
sibling = that.input._rel.querySelector(selector);
|
||||
}
|
||||
|
||||
return sibling;
|
||||
}
|
||||
|
||||
debounce(func, wait) {
|
||||
var timeout;
|
||||
return (...args) => {
|
||||
var boundFunc = func.bind(this, ...args);
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(boundFunc, wait);
|
||||
}
|
||||
}
|
||||
|
||||
trigger(eventName, ...args) {
|
||||
document.dispatchEvent(new CustomEvent(eventName, {detail: [...args]}));
|
||||
}
|
||||
|
||||
on(eventName, elementSelector, handler) {
|
||||
document.addEventListener(eventName, function(e) {
|
||||
// loop parent nodes from the target to the delegation node
|
||||
for (var target = e.target; target && target != this; target = target.parentNode) {
|
||||
if (target.matches(elementSelector)) {
|
||||
handler.call(target, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
let that = this;
|
||||
|
||||
that.on('click', '*', function(e) {
|
||||
var wrap = this.closest('.fcomplete-wrap');
|
||||
var isInput = this.classList.contains('fcomplete-enabled');
|
||||
|
||||
if (isInput) {
|
||||
var input = this;
|
||||
var settings = input.fcomplete.settings;
|
||||
var status = (settings.minChars > input.value.length) ? settings.minCharsText : '';
|
||||
input.fcomplete.setStatus(status);
|
||||
this.fcomplete.open();
|
||||
}
|
||||
else if (!wrap && !isInput) {
|
||||
document.querySelectorAll('.fcomplete-wrap').forEach((node) => node.classList.add('fcomplete-hidden'));
|
||||
}
|
||||
});
|
||||
|
||||
that.on('click', '.fcomplete-result', function(e) {
|
||||
var wrap = e.target.closest('.fcomplete-wrap');
|
||||
var input = wrap._rel;
|
||||
input.value = e.target.getAttribute('data-value');
|
||||
|
||||
if (typeof input.fcomplete.settings.onSelect === 'function') {
|
||||
input.fcomplete.settings.onSelect();
|
||||
}
|
||||
|
||||
input.fcomplete.close();
|
||||
});
|
||||
that.on('keydown', '*', function(e) {
|
||||
var wrap = this.closest('.fcomplete-wrap');
|
||||
var isInput = this.classList.contains('fcomplete-enabled');
|
||||
|
||||
if (!wrap && !isInput) return;
|
||||
|
||||
var input = (wrap) ? wrap._rel : this;
|
||||
wrap = (wrap) ? wrap : input._rel;
|
||||
|
||||
if (-1 < [13, 38, 40, 27].indexOf(e.which)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
if (13 == e.which) { // enter
|
||||
if (this.classList.contains('fcomplete-result')) {
|
||||
this.click();
|
||||
}
|
||||
}
|
||||
else if (38 == e.which) { // up
|
||||
if (this.classList.contains('fcomplete-result')) {
|
||||
var sibling = wrap._rel.fcomplete.getAdjacentSibling('previous');
|
||||
window.fCompleteInit.lastFocus = sibling; // stop at the search box
|
||||
(sibling) ? sibling.focus() : input.focus();
|
||||
}
|
||||
}
|
||||
else if (40 == e.which) { // down
|
||||
if (this === input) {
|
||||
var firstResult = wrap.querySelector('.fcomplete-result');
|
||||
|
||||
if (firstResult) {
|
||||
firstResult.focus();
|
||||
window.fCompleteInit.lastFocus = firstResult;
|
||||
}
|
||||
}
|
||||
else if (this.classList.contains('fcomplete-result')) {
|
||||
var sibling = wrap._rel.fcomplete.getAdjacentSibling('next');
|
||||
|
||||
if (sibling) {
|
||||
sibling.focus();
|
||||
window.fCompleteInit.lastFocus = sibling; // stop at the bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (9 == e.which || 27 == e.which) { // tab, esc
|
||||
wrap._rel.fcomplete.close();
|
||||
}
|
||||
});
|
||||
|
||||
that.on('keyup', '.fcomplete-enabled', that.debounce(function(e) {
|
||||
if (-1 < [13, 38, 40, 27].indexOf(e.which)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var input = e.target;
|
||||
var settings = input.fcomplete.settings;
|
||||
|
||||
if (settings.minChars <= input.value.length) {
|
||||
if (Array.isArray(settings.data)) {
|
||||
input.fcomplete.render(settings.data);
|
||||
}
|
||||
else if (typeof settings.data === 'function') {
|
||||
input.fcomplete.setStatus(settings.loadingText);
|
||||
settings.data();
|
||||
}
|
||||
}
|
||||
else {
|
||||
input.fcomplete.render([]);
|
||||
input.fcomplete.setStatus(settings.minCharsText);
|
||||
}
|
||||
}, that.settings.searchDelay));
|
||||
}
|
||||
}
|
||||
|
||||
var $ = (selector, options) => new fComplete(selector, options);
|
||||
|
||||
return $;
|
||||
|
||||
})();
|
||||
7
wp/wp-content/plugins/facetwp/assets/vendor/fDate/LICENSE.md
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright 2021 FacetWP, LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
87
wp/wp-content/plugins/facetwp/assets/vendor/fDate/fDate.css
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
.fdate-input {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.fdate-wrap {
|
||||
width: 300px;
|
||||
display: none;
|
||||
background: #fff;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #ddd;
|
||||
font-size: 14px;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
.fdate-wrap.opened {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.fdate-wrap .disabled {
|
||||
opacity: 0.1;
|
||||
}
|
||||
|
||||
.fdate-nav {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 5fr 1fr;
|
||||
}
|
||||
|
||||
.fdate-nav > div,
|
||||
.fdate-clear {
|
||||
padding: 10px 0;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fdate-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fdate-grid.grid-day {
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
}
|
||||
|
||||
.fdate-grid > div {
|
||||
padding: 20px 0;
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.fdate-grid > div:hover {
|
||||
background-color: #ddd;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fdate-grid .fdate-day {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.fdate-grid .weekday,
|
||||
.fdate-grid .inner {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.fdate-grid .today {
|
||||
background-color: #F8F8F8;
|
||||
}
|
||||
|
||||
.fdate-grid .selected {
|
||||
background-color: #DDD6FE;
|
||||
}
|
||||
|
||||
.fdate-day.weekday {
|
||||
font-weight: bold;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.fdate-grid .weekday:hover,
|
||||
.fdate-grid .disabled:hover {
|
||||
background-color: transparent;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.fdate-wrap .disabled:hover {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
679
wp/wp-content/plugins/facetwp/assets/vendor/fDate/fDate.js
vendored
Normal file
@@ -0,0 +1,679 @@
|
||||
window.fDate = (() => {
|
||||
|
||||
var qs = (selector) => document.querySelector(selector);
|
||||
var isset = (input) => 'undefined' !== typeof input;
|
||||
var ymd = (...args) => {
|
||||
var d = new Date(...args);
|
||||
var zeroed = (num) => (num > 9) ? num : '0' + num;
|
||||
// toJSON() produces unexpected results due to timezones
|
||||
return d.getFullYear() + '-' + zeroed(d.getMonth() + 1) + '-' + zeroed(d.getDate());
|
||||
};
|
||||
|
||||
class fDate {
|
||||
|
||||
constructor(selector, options) {
|
||||
let that = this;
|
||||
|
||||
var defaults = {
|
||||
i18n: {
|
||||
weekdays_short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
||||
months_short: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
clearText: 'Clear',
|
||||
firstDayOfWeek: 0
|
||||
},
|
||||
minDate: '',
|
||||
maxDate: '',
|
||||
altFormat: '',
|
||||
onChange: null
|
||||
};
|
||||
|
||||
that.settings = Object.assign({}, defaults, options);
|
||||
|
||||
if ('string' === typeof selector) {
|
||||
var inputs = document.querySelectorAll(selector);
|
||||
}
|
||||
else if (selector instanceof Node) {
|
||||
var inputs = [selector];
|
||||
}
|
||||
else {
|
||||
var inputs = selector;
|
||||
}
|
||||
|
||||
if (inputs.length) {
|
||||
inputs.forEach(function(input) {
|
||||
input.setAttribute('readonly', 'readonly');
|
||||
|
||||
if ('' !== that.settings.altFormat) {
|
||||
that.el = input;
|
||||
|
||||
let altInput = input.cloneNode();
|
||||
altInput.classList.add('fdate-alt-input');
|
||||
altInput.value = that.getAltDate();
|
||||
altInput._input = input;
|
||||
|
||||
input._altInput = altInput;
|
||||
input.setAttribute('type', 'hidden');
|
||||
input.parentNode.insertBefore(altInput, input.nextSibling); // append()
|
||||
}
|
||||
|
||||
input.classList.add('fdate-input');
|
||||
input._input = input;
|
||||
input.fdate = {
|
||||
settings: that.settings,
|
||||
refresh() {
|
||||
input.click();
|
||||
},
|
||||
open() {
|
||||
input.click();
|
||||
},
|
||||
close() {
|
||||
that.setCalVisibility('hide');
|
||||
},
|
||||
clear() {
|
||||
input.value = '';
|
||||
|
||||
if (isset(input._altInput)) {
|
||||
input._altInput.value = '';
|
||||
}
|
||||
|
||||
that.triggerEvent('onChange');
|
||||
},
|
||||
destroy() {
|
||||
input.classList.remove('fdate-input');
|
||||
delete input._altInput;
|
||||
delete input._input;
|
||||
delete input.fdate;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (null === qs('.fdate-wrap')) {
|
||||
this.initCalendar();
|
||||
this.bindEvents();
|
||||
}
|
||||
}
|
||||
|
||||
initCalendar() {
|
||||
var html = `
|
||||
<div class="fdate-wrap">
|
||||
<div class="fdate-nav">
|
||||
<div class="fdate-nav-prev"><</div>
|
||||
<div class="fdate-nav-label" tabindex="-1"></div>
|
||||
<div class="fdate-nav-next">></div>
|
||||
</div>
|
||||
<div class="fdate-grid"></div>
|
||||
<div class="fdate-clear" tabindex="-1">${this.settings.i18n.clearText}</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.body.insertAdjacentHTML('beforeend', html);
|
||||
}
|
||||
|
||||
setInput(input) {
|
||||
this.el = input;
|
||||
this.mode = 'day';
|
||||
this.settings = input.fdate.settings;
|
||||
|
||||
this.setDateBounds();
|
||||
|
||||
// valid YYYY-MM-DD?
|
||||
if (null !== input.value.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
||||
var date_str = input.value;
|
||||
}
|
||||
// use the min date or today, whichever is higher
|
||||
else {
|
||||
var today = ymd();
|
||||
var date_str = (this.min.str < today) ? today : this.min.str;
|
||||
}
|
||||
|
||||
// rewind the calendar if beyond the maxDate
|
||||
if (date_str < this.max.str) {
|
||||
var temp_date = new Date(date_str + 'T00:00');
|
||||
this.year = temp_date.getFullYear();
|
||||
this.month = temp_date.getMonth();
|
||||
}
|
||||
else {
|
||||
this.year = this.max.year;
|
||||
this.month = this.max.month;
|
||||
}
|
||||
}
|
||||
|
||||
setDateBounds() {
|
||||
let min = this.settings.minDate || '1000-01-01';
|
||||
let max = this.settings.maxDate || '3000-01-01';
|
||||
let minDate = new Date(min + 'T00:00');
|
||||
let maxDate = new Date(max + 'T00:00');
|
||||
|
||||
this.min = {
|
||||
year: minDate.getFullYear(),
|
||||
month: minDate.getMonth(),
|
||||
str: min
|
||||
};
|
||||
|
||||
this.max = {
|
||||
year: maxDate.getFullYear(),
|
||||
month: maxDate.getMonth(),
|
||||
str: max
|
||||
};
|
||||
}
|
||||
|
||||
isInBounds(val) {
|
||||
if ('year' == this.mode) {
|
||||
let year = parseInt(val);
|
||||
|
||||
if (year < this.min.year || year > this.max.year) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ('month' == this.mode) {
|
||||
let month = parseInt(val);
|
||||
let valStr = ymd(this.year, month).substr(0, 7);
|
||||
let monthMin = this.min.str.substr(0, 7);
|
||||
let monthMax = this.max.str.substr(0, 7);
|
||||
|
||||
if (valStr < monthMin || valStr > monthMax) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ('day' == this.mode) {
|
||||
if (val < this.min.str || val > this.max.str) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
isNavAllowed(type) {
|
||||
if ('year' == this.mode) {
|
||||
let decade = parseInt(this.year.toString().substr(0, 3) + '0');
|
||||
|
||||
return ('next' == type) ?
|
||||
decade < parseInt(this.max.str.substr(0, 4)) :
|
||||
decade > parseInt(this.min.str.substr(0, 4));
|
||||
}
|
||||
else if ('month' == this.mode) {
|
||||
return ('next' == type) ?
|
||||
ymd(this.year + 1, 0, 0) < this.max.str :
|
||||
ymd(this.year, 0) > this.min.str;
|
||||
}
|
||||
else if ('day' == this.mode) {
|
||||
return ('next' == type) ?
|
||||
ymd(this.year, this.month + 1, 0) < this.max.str :
|
||||
ymd(this.year, this.month) > this.min.str;
|
||||
}
|
||||
}
|
||||
|
||||
setDisplay(which) {
|
||||
var that = this;
|
||||
|
||||
this.mode = which;
|
||||
|
||||
qs('.fdate-grid').classList.remove('grid-day');
|
||||
|
||||
// show or hide the nav arrows
|
||||
qs('.fdate-nav-prev').classList.add('disabled');
|
||||
qs('.fdate-nav-next').classList.add('disabled');
|
||||
|
||||
if (that.isNavAllowed('prev')) {
|
||||
qs('.fdate-nav-prev').classList.remove('disabled');
|
||||
}
|
||||
|
||||
if ( that.isNavAllowed('next')) {
|
||||
qs('.fdate-nav-next').classList.remove('disabled');
|
||||
}
|
||||
|
||||
// month
|
||||
if ('month' == which) {
|
||||
var output = '';
|
||||
this.settings.i18n.months_short.forEach(function(item, index) {
|
||||
var css = that.isInBounds(index) ? ' inner' : ' disabled';
|
||||
output += '<div class="fdate-month' + css + '" data-value="' + index + '" tabindex="-1">' + item + '</div>';
|
||||
});
|
||||
|
||||
qs('.fdate-grid').innerHTML = output;
|
||||
qs('.fdate-nav-label').innerHTML = this.year;
|
||||
}
|
||||
// year
|
||||
else if ('year' == which) {
|
||||
var output = '';
|
||||
var decade = parseInt(this.year.toString().substr(0, 3) + '0');
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var css = that.isInBounds(decade + i) ? ' inner' : ' disabled';
|
||||
output += '<div class="fdate-year' + css + '" data-value="' + (decade + i) + '" tabindex="-1">' + (decade + i) + '</div>';
|
||||
}
|
||||
|
||||
qs('.fdate-grid').innerHTML = output;
|
||||
|
||||
var prefix = this.year.toString().substr(0, 3);
|
||||
var decade = prefix + '0 - ' + prefix + '9';
|
||||
qs('.fdate-nav-label').innerHTML = decade;
|
||||
}
|
||||
// day
|
||||
else {
|
||||
qs('.fdate-grid').classList.add('grid-day');
|
||||
|
||||
var output = '';
|
||||
var days = this.generateDays(this.year, this.month);
|
||||
days.forEach(function(item) {
|
||||
output += '<div class="fdate-day' + item.class + '" data-value="' + item.value + '" tabindex="-1">' + item.text + '</div>';
|
||||
});
|
||||
|
||||
qs('.fdate-grid').innerHTML = output;
|
||||
qs('.fdate-nav-label').innerHTML = this.settings.i18n.months[this.month] + ' ' + this.year;
|
||||
}
|
||||
}
|
||||
|
||||
generateDays(year, month) {
|
||||
let that = this;
|
||||
var output = [];
|
||||
let i18n = that.settings.i18n;
|
||||
let weekdays = i18n.weekdays_short;
|
||||
let firstDayOfWeek = i18n.firstDayOfWeek; // 0 = Sunday
|
||||
let firstDayNum = new Date(year, month).getDay(); // between 0 and 6
|
||||
let offset = firstDayNum - firstDayOfWeek;
|
||||
offset = (offset < 0) ? 7 + offset : offset; // negative offset (e.g. August 2021)
|
||||
let num_days = new Date(year, month + 1, 0).getDate();
|
||||
let today = ymd();
|
||||
|
||||
// shift weekdays according to firstDayOfWeek
|
||||
if (0 < firstDayOfWeek) {
|
||||
let temp = JSON.parse(JSON.stringify(weekdays));
|
||||
let append = temp.splice(0, firstDayOfWeek);
|
||||
weekdays = temp.concat(append);
|
||||
}
|
||||
|
||||
// get weekdays
|
||||
weekdays.forEach(function(item) {
|
||||
output.push({
|
||||
text: item,
|
||||
value: '',
|
||||
class: ' weekday'
|
||||
});
|
||||
});
|
||||
|
||||
// get days from the previous month
|
||||
if (0 < offset) {
|
||||
let year_prev = (0 == month) ? year - 1 : year;
|
||||
let month_prev = (0 == month) ? 11 : month - 1;
|
||||
let num_days_prev = new Date(year_prev, month_prev + 1, 0).getDate();
|
||||
|
||||
for (var i = (num_days_prev - offset + 1); i <= num_days_prev; i++) {
|
||||
var val = ymd(year_prev, month_prev, i);
|
||||
var css = that.isInBounds(val) ? '' : ' disabled';
|
||||
output.push({
|
||||
text: i,
|
||||
value: val,
|
||||
class: css
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// get days from the current month
|
||||
for (var i = 1; i <= num_days; i++) {
|
||||
var val = ymd(year, month, i);
|
||||
|
||||
if ( that.isInBounds(val)) {
|
||||
var css = ' inner';
|
||||
css += (val == today) ? ' today' : '';
|
||||
css += (val == this.el.value) ? ' selected' : '';
|
||||
}
|
||||
else {
|
||||
var css = ' disabled';
|
||||
}
|
||||
|
||||
output.push({
|
||||
text: i,
|
||||
value: val,
|
||||
class: css
|
||||
});
|
||||
}
|
||||
|
||||
// get days from the next month
|
||||
let year_next = (11 == month) ? year + 1 : year;
|
||||
let month_next = (11 == month) ? 0 : month + 1;
|
||||
let num_filler = 42 - num_days - offset;
|
||||
|
||||
for (var i = 1; i <= num_filler; i++) {
|
||||
var val = ymd(year_next, month_next, i);
|
||||
var css = that.isInBounds(val) ? '' : ' disabled';
|
||||
output.push({
|
||||
text: i,
|
||||
value: val,
|
||||
class: css
|
||||
});
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
adjustDate(increment, unit) {
|
||||
var temp_year = ('year' == unit) ? this.year + increment : this.year;
|
||||
var temp_month = ('month' == unit) ? this.month + increment : this.month;
|
||||
var temp_date = new Date(temp_year, temp_month);
|
||||
|
||||
this.year = temp_date.getFullYear();
|
||||
this.month = temp_date.getMonth();
|
||||
}
|
||||
|
||||
on(eventName, elementSelector, handler) {
|
||||
document.addEventListener(eventName, function(e) {
|
||||
// loop parent nodes from the target to the delegation node
|
||||
for (var target = e.target; target && target != this; target = target.parentNode) {
|
||||
if (target.matches(elementSelector)) {
|
||||
handler.call(target, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
getAltDate() {
|
||||
let that = this;
|
||||
|
||||
if ('' === that.el.value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let date_array = that.el.value.split('-');
|
||||
let format_array = that.settings.altFormat.split('');
|
||||
let output = '';
|
||||
|
||||
let escaped = false;
|
||||
format_array.forEach(function(token) {
|
||||
if ('\\' === token) {
|
||||
escaped = true;
|
||||
return;
|
||||
}
|
||||
|
||||
output += escaped ? token : that.parseDateToken(token, date_array);
|
||||
escaped = false;
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
parseDateToken(token, date_array) {
|
||||
let i18n = this.settings.i18n;
|
||||
|
||||
let tokens = {
|
||||
'd': () => date_array[2],
|
||||
'j': () => parseInt(date_array[2]),
|
||||
'm': () => date_array[1],
|
||||
'n': () => parseInt(date_array[1]),
|
||||
'F': () => i18n.months[parseInt(date_array[1]) - 1],
|
||||
'M': () => i18n.months_short[parseInt(date_array[1]) - 1],
|
||||
'y': () => date_array[0].substring(2),
|
||||
'Y': () => date_array[0]
|
||||
};
|
||||
|
||||
return isset(tokens[token]) ? tokens[token]() : token;
|
||||
}
|
||||
|
||||
setPosition(input) {
|
||||
let wrap = qs('.fdate-wrap');
|
||||
let inputBounds = input.getBoundingClientRect();
|
||||
let calendarWidth = wrap.getBoundingClientRect().width;
|
||||
let calendarHeight = wrap.getBoundingClientRect().height;
|
||||
let distanceFromRight = document.body.clientWidth - inputBounds.left;
|
||||
let distanceFromBottom = document.body.clientHeight - inputBounds.bottom;
|
||||
let showOnTop = (distanceFromBottom < calendarHeight && inputBounds.top > calendarHeight);
|
||||
let showOnLeft = (distanceFromRight < calendarWidth && inputBounds.left > calendarWidth);
|
||||
|
||||
let top = window.pageYOffset + inputBounds.top + (!showOnTop ? input.offsetHeight + 2 : -calendarHeight - 2);
|
||||
let left = window.pageXOffset + inputBounds.left;
|
||||
let right = window.pageXOffset + inputBounds.right - calendarWidth;
|
||||
let pixels = showOnLeft ? right : left;
|
||||
|
||||
wrap.style.position = 'absolute';
|
||||
wrap.style.top = top + 'px';
|
||||
wrap.style.left = pixels + 'px';
|
||||
}
|
||||
|
||||
setCalVisibility(which) {
|
||||
var wrap = qs('.fdate-wrap');
|
||||
|
||||
if ('hide' === which) {
|
||||
if (wrap.classList.contains('opened')) {
|
||||
wrap.classList.remove('opened');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (! wrap.classList.contains('opened')) {
|
||||
wrap.classList.add('opened');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
triggerEvent(name) {
|
||||
if (typeof this.settings[name] === 'function') {
|
||||
this.settings[name](this);
|
||||
}
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
var that = this;
|
||||
|
||||
that.on('click', '.fdate-day:not(.disabled):not(.weekday)', function(e) {
|
||||
that.el.value = e.target.getAttribute('data-value');
|
||||
|
||||
if (isset(that.el._altInput)) {
|
||||
that.el._altInput.value = that.getAltDate();
|
||||
}
|
||||
|
||||
that.triggerEvent('onChange');
|
||||
that.setCalVisibility('hide');
|
||||
e.stopImmediatePropagation(); // important
|
||||
});
|
||||
|
||||
that.on('click', '.fdate-month:not(.disabled)', function(e) {
|
||||
that.month = parseInt(e.target.getAttribute('data-value'));
|
||||
that.setDisplay('day');
|
||||
e.stopImmediatePropagation(); // important
|
||||
});
|
||||
|
||||
that.on('click', '.fdate-year:not(.disabled)', function(e) {
|
||||
that.year = parseInt(e.target.getAttribute('data-value'));
|
||||
that.setDisplay('month');
|
||||
e.stopImmediatePropagation(); // important
|
||||
});
|
||||
|
||||
that.on('click', '.fdate-nav-prev:not(.disabled)', function() {
|
||||
var incr = ('year' == that.mode) ? -10 : -1;
|
||||
var unit = ('day' == that.mode) ? 'month' : 'year';
|
||||
|
||||
that.adjustDate(incr, unit);
|
||||
that.setDisplay(that.mode);
|
||||
});
|
||||
|
||||
that.on('click', '.fdate-nav-next:not(.disabled)', function() {
|
||||
var incr = ('year' == that.mode) ? 10 : 1;
|
||||
var unit = ('day' == that.mode) ? 'month' : 'year';
|
||||
|
||||
that.adjustDate(incr, unit);
|
||||
that.setDisplay(that.mode);
|
||||
});
|
||||
|
||||
that.on('click', '.fdate-nav-label', function() {
|
||||
if ('day' == that.mode) {
|
||||
that.setDisplay('month');
|
||||
}
|
||||
else if ('month' == that.mode) {
|
||||
that.setDisplay('year');
|
||||
}
|
||||
else if ('year' == that.mode) {
|
||||
that.setDisplay('day');
|
||||
}
|
||||
});
|
||||
|
||||
that.on('click', '.fdate-clear', function() {
|
||||
that.el.fdate.clear();
|
||||
});
|
||||
|
||||
that.on('click', '*', function(e) {
|
||||
var is_input = e.target.classList.contains('fdate-input') || e.target.classList.contains('fdate-alt-input');
|
||||
var is_cal = (null !== e.target.closest('.fdate-wrap'));
|
||||
var is_clear = e.target.classList.contains('fdate-clear');
|
||||
|
||||
if (is_input || (is_cal && ! is_clear)) {
|
||||
that.setCalVisibility('show');
|
||||
|
||||
// set position and render calendar
|
||||
if (is_input) {
|
||||
let visibleInput = e.target._altInput || e.target;
|
||||
that.setInput(e.target._input);
|
||||
that.setDisplay('day');
|
||||
that.setPosition(visibleInput);
|
||||
}
|
||||
}
|
||||
else {
|
||||
that.setCalVisibility('hide');
|
||||
}
|
||||
});
|
||||
|
||||
// a11y support
|
||||
window.addEventListener('keyup', function(e) {
|
||||
if ('Tab' === e.key) {
|
||||
if (e.target.classList.contains('fdate-input') || e.target.classList.contains('fdate-alt-input')) {
|
||||
e.target._input.click();
|
||||
}
|
||||
else {
|
||||
that.setCalVisibility('hide');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('keydown', function(e) {
|
||||
if ('Enter' === e.key) {
|
||||
if (e.target.closest('.fdate-grid')) {
|
||||
qs('.fdate-nav-label').focus();
|
||||
}
|
||||
if (e.target.closest('.fdate-wrap')) {
|
||||
e.target.click();
|
||||
}
|
||||
}
|
||||
else if ('Escape' === e.key) {
|
||||
if (e.target.closest('.fdate-wrap') || e.target.classList.contains('fdate-input') || e.target.classList.contains('fdate-alt-input')) {
|
||||
that.el.fdate.close();
|
||||
}
|
||||
}
|
||||
else if ('ArrowUp' === e.key) {
|
||||
if (e.target.classList.contains('fdate-input') || e.target.classList.contains('fdate-alt-input')) { // from input
|
||||
qs('.fdate-clear').focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
else if (e.target.classList.contains('fdate-nav-label')) {
|
||||
that.el.focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
else if (e.target.classList.contains('fdate-clear')) {
|
||||
let days = document.querySelectorAll('.fdate-day.inner');
|
||||
let item = (days.length) ? days[days.length - 1] : qs('.fdate-nav-label');
|
||||
item.focus();
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
else if (e.target.closest('.fdate-grid')) {
|
||||
let offset = ('day' === that.mode) ? -7 : -4;
|
||||
let el = that.getSibling(e.target, offset);
|
||||
|
||||
if (el) {
|
||||
el.focus();
|
||||
}
|
||||
else {
|
||||
qs('.fdate-nav-label').focus();
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
else if ('ArrowDown' === e.key) {
|
||||
if (e.target.classList.contains('fdate-input') || e.target.classList.contains('fdate-alt-input')) { // from input
|
||||
let selected = qs('.fdate-grid .selected');
|
||||
let today = qs('.fdate-grid .today');
|
||||
|
||||
if (selected) {
|
||||
selected.focus();
|
||||
}
|
||||
else if (today) {
|
||||
today.focus();
|
||||
}
|
||||
else {
|
||||
qs('.fdate-nav-label').focus();
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
else if (e.target.classList.contains('fdate-nav-label')) { // from nav
|
||||
qs('.fdate-grid .inner').focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
else if (e.target.classList.contains('fdate-clear')) {
|
||||
that.el.focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
else if (e.target.closest('.fdate-grid')) { // from grid
|
||||
let offset = ('day' === that.mode) ? 7 : 4;
|
||||
let el = that.getSibling(e.target, offset);
|
||||
|
||||
if (el) {
|
||||
el.focus();
|
||||
}
|
||||
else {
|
||||
qs('.fdate-clear').focus();
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
else if ('ArrowLeft' === e.key) {
|
||||
if (e.target.classList.contains('fdate-nav-label')) { // into the past
|
||||
qs('.fdate-nav-prev').click();
|
||||
e.preventDefault();
|
||||
}
|
||||
if (e.target.closest('.fdate-grid')) { // previous grid item
|
||||
let prev = e.target.previousElementSibling;
|
||||
if (prev && prev.classList.contains('inner')) {
|
||||
prev.focus();
|
||||
}
|
||||
else {
|
||||
let days = document.querySelectorAll('.fdate-day.inner');
|
||||
days[days.length - 1].focus(); // last valid day of month
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
else if ('ArrowRight' === e.key) {
|
||||
if (e.target.classList.contains('fdate-nav-label')) { // into the future
|
||||
qs('.fdate-nav-next').click();
|
||||
e.preventDefault();
|
||||
}
|
||||
if (e.target.closest('.fdate-grid')) { // next grid item
|
||||
let next = e.target.nextElementSibling;
|
||||
if (next && next.classList.contains('inner')) {
|
||||
next.focus();
|
||||
}
|
||||
else {
|
||||
qs('.fdate-day.inner').focus(); // first valid day of month
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getSibling(orig, offset) {
|
||||
let el = orig;
|
||||
for (var i = 0; i < Math.abs(offset); i++) {
|
||||
el = (0 < offset) ? el.nextElementSibling : el.previousElementSibling;
|
||||
if (null === el || !el.classList.contains('inner')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
}
|
||||
|
||||
return fDate;
|
||||
})();
|
||||
1
wp/wp-content/plugins/facetwp/assets/vendor/fDate/fDate.min.js
vendored
Normal file
147
wp/wp-content/plugins/facetwp/assets/vendor/fSelect/fSelect.css
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
.fs-wrap {
|
||||
width: 220px;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.fs-label-wrap {
|
||||
position: relative;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.fs-label-wrap,
|
||||
.fs-dropdown {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.fs-label-wrap .fs-label {
|
||||
padding: 6px 22px 6px 8px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fs-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-top: 5px solid #333;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 5px;
|
||||
bottom: 0;
|
||||
margin: auto;
|
||||
transition: ease-in 0.15s;
|
||||
}
|
||||
|
||||
.fs-open .fs-arrow {
|
||||
transform: rotate(-180deg);
|
||||
}
|
||||
|
||||
.fs-dropdown {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-top: none;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.fs-dropdown .fs-options {
|
||||
max-height: 200px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.fs-search {
|
||||
background-color: #f8f8f8;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.fs-wrap .fs-search input {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
background-color: transparent;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fs-option,
|
||||
.fs-search,
|
||||
.fs-optgroup-label {
|
||||
padding: 6px 8px;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.fs-option:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.fs-no-results {
|
||||
padding: 6px 8px;
|
||||
}
|
||||
|
||||
.fs-option {
|
||||
cursor: pointer;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.fs-option.disabled {
|
||||
opacity: 0.4;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.fs-wrap.single .fs-option.selected {
|
||||
background-color: #dff3ff;
|
||||
}
|
||||
|
||||
.fs-wrap.multiple .fs-option {
|
||||
position: relative;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
.fs-wrap.multiple .fs-checkbox {
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 30px;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.fs-wrap.multiple .fs-option .fs-checkbox i {
|
||||
position: absolute;
|
||||
margin: auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border: 1px solid #aeaeae;
|
||||
border-radius: 2px;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.fs-wrap.multiple .fs-option.selected .fs-checkbox i {
|
||||
background-color: rgb(108, 138, 255);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.fs-optgroup-label {
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.fs-hidden {
|
||||
display: none;
|
||||
}
|
||||
420
wp/wp-content/plugins/facetwp/assets/vendor/fSelect/fSelect.js
vendored
Normal file
@@ -0,0 +1,420 @@
|
||||
window.fSelect = (() => {
|
||||
|
||||
var build = {};
|
||||
|
||||
class fSelect {
|
||||
|
||||
constructor(selector, options) {
|
||||
let that = this;
|
||||
|
||||
var defaults = {
|
||||
placeholder: 'Select some options',
|
||||
numDisplayed: 3,
|
||||
overflowText: '{n} selected',
|
||||
searchText: 'Search',
|
||||
noResultsText: 'No results found',
|
||||
showSearch: true,
|
||||
optionFormatter: false
|
||||
};
|
||||
|
||||
that.settings = Object.assign({}, defaults, options);
|
||||
build = {output: '', optgroup: 0, idx: 0};
|
||||
|
||||
if ('string' === typeof selector) {
|
||||
var nodes = Array.from(document.querySelectorAll(selector));
|
||||
}
|
||||
else if (selector instanceof Node) {
|
||||
var nodes = [selector];
|
||||
}
|
||||
else if (Array.isArray(selector)) {
|
||||
var nodes = selector;
|
||||
}
|
||||
else {
|
||||
var nodes = [];
|
||||
}
|
||||
|
||||
if ('undefined' === typeof window.fSelectInit) {
|
||||
window.fSelectInit = {
|
||||
searchCache: '',
|
||||
lastChoice: null,
|
||||
lastFocus: null,
|
||||
activeEl: null
|
||||
};
|
||||
that.bindEvents();
|
||||
}
|
||||
|
||||
nodes.forEach((input) => {
|
||||
if (typeof input.fselect === 'object') {
|
||||
input.fselect.destroy();
|
||||
}
|
||||
|
||||
that.settings.multiple = input.matches('[multiple]');
|
||||
input.fselect = that;
|
||||
that.input = input;
|
||||
that.create();
|
||||
});
|
||||
}
|
||||
|
||||
create() {
|
||||
var that = this;
|
||||
var options = that.buildOptions();
|
||||
var label = that.getDropdownLabel();
|
||||
var mode = (that.settings.multiple) ? 'multiple' : 'single';
|
||||
var searchClass = (that.settings.showSearch) ? '' : ' fs-hidden';
|
||||
var noResultsClass = (build.idx < 2) ? '' : ' fs-hidden';
|
||||
|
||||
var html = `
|
||||
<div class="fs-wrap ${mode}" tabindex="0">
|
||||
<div class="fs-label-wrap">
|
||||
<div class="fs-label">${label}</div>
|
||||
<span class="fs-arrow"></span>
|
||||
</div>
|
||||
<div class="fs-dropdown fs-hidden">
|
||||
<div class="fs-search${searchClass}">
|
||||
<input type="text" placeholder="${that.settings.searchText}" />
|
||||
</div>
|
||||
<div class="fs-no-results${noResultsClass}">${that.settings.noResultsText}</div>
|
||||
<div class="fs-options">${options}</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
var tpl = document.createElement('template');
|
||||
tpl.innerHTML = html;
|
||||
var wrap = tpl.content.querySelector('.fs-wrap');
|
||||
that.input.parentNode.insertBefore(wrap, that.input.nextSibling);
|
||||
that.input.classList.add('fs-hidden');
|
||||
|
||||
// add a relationship link
|
||||
that.input._rel = wrap;
|
||||
wrap._rel = that.input;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.input._rel.remove();
|
||||
this.input.classList.remove('fs-hidden');
|
||||
delete this.input._rel;
|
||||
}
|
||||
|
||||
reload() {
|
||||
this.destroy();
|
||||
this.create();
|
||||
}
|
||||
|
||||
open() {
|
||||
var wrap = this.input._rel;
|
||||
wrap.classList.add('fs-open');
|
||||
wrap.querySelector('.fs-dropdown').classList.remove('fs-hidden');
|
||||
|
||||
// don't auto-focus for touch devices
|
||||
if (! window.matchMedia("(pointer: coarse)").matches) {
|
||||
wrap.querySelector('.fs-search input').focus();
|
||||
}
|
||||
|
||||
window.fSelectInit.lastChoice = this.getSelectedOptions('value');
|
||||
window.fSelectInit.activeEl = wrap;
|
||||
|
||||
this.trigger('fs:opened', wrap);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.input._rel.classList.remove('fs-open');
|
||||
this.input._rel.querySelector('.fs-dropdown').classList.add('fs-hidden');
|
||||
|
||||
window.fSelectInit.searchCache = '';
|
||||
window.fSelectInit.lastChoice = null;
|
||||
window.fSelectInit.lastFocus = null;
|
||||
window.fSelectInit.activeEl = null;
|
||||
|
||||
this.trigger('fs:closed', this.input._rel);
|
||||
}
|
||||
|
||||
buildOptions(parent) {
|
||||
var that = this;
|
||||
var parent = parent || that.input;
|
||||
|
||||
Array.from(parent.children).forEach((node) => {
|
||||
if ('optgroup' === node.nodeName.toLowerCase()) {
|
||||
var opt = `<div class="fs-optgroup-label" data-group="${build.optgroup}">${node.label}</div>`;
|
||||
build.output += opt;
|
||||
that.buildOptions(node);
|
||||
build.optgroup++;
|
||||
}
|
||||
else {
|
||||
var val = node.value;
|
||||
|
||||
// skip the first choice in multi-select mode
|
||||
if (0 === build.idx && '' === val && that.settings.multiple) {
|
||||
build.idx++;
|
||||
return;
|
||||
}
|
||||
|
||||
var classes = ['fs-option', 'g' + build.optgroup];
|
||||
|
||||
// append existing classes
|
||||
node.className.split(' ').forEach((className) => {
|
||||
if ('' !== className) {
|
||||
classes.push(className);
|
||||
}
|
||||
});
|
||||
|
||||
if (node.matches('[disabled]')) classes.push('disabled');
|
||||
if (node.matches('[selected]')) classes.push('selected');
|
||||
classes = classes.join(' ');
|
||||
|
||||
if ('function' === typeof that.settings.optionFormatter) {
|
||||
node.label = that.settings.optionFormatter(node.label, node);
|
||||
}
|
||||
|
||||
var opt = `<div class="${classes}" data-value="${val}" data-idx="${build.idx}" tabindex="-1"><span class="fs-checkbox"><i></i></span><div class="fs-option-label">${node.label}</div></div>`;
|
||||
|
||||
build.output += opt;
|
||||
build.idx++;
|
||||
}
|
||||
});
|
||||
|
||||
return build.output;
|
||||
}
|
||||
|
||||
getSelectedOptions(field, context) {
|
||||
var context = context || this.input;
|
||||
return Array.from(context.selectedOptions).map((opt) => {
|
||||
return (field) ? opt[field] : opt;
|
||||
});
|
||||
}
|
||||
|
||||
getAdjacentSibling(which) {
|
||||
var that = this;
|
||||
var which = which || 'next';
|
||||
var sibling = window.fSelectInit.lastFocus;
|
||||
var selector = '.fs-option:not(.fs-hidden):not(.disabled)';
|
||||
|
||||
if (sibling) {
|
||||
sibling = sibling[which + 'ElementSibling'];
|
||||
|
||||
while (sibling) {
|
||||
if (sibling.matches(selector)) break;
|
||||
sibling = sibling[which + 'ElementSibling'];
|
||||
}
|
||||
|
||||
return sibling;
|
||||
}
|
||||
else if ('next' == which) {
|
||||
sibling = that.input._rel.querySelector(selector);
|
||||
}
|
||||
|
||||
return sibling;
|
||||
}
|
||||
|
||||
getDropdownLabel() {
|
||||
var that = this;
|
||||
var labelText = that.getSelectedOptions('text');
|
||||
|
||||
if (labelText.length < 1) {
|
||||
labelText = that.settings.placeholder;
|
||||
}
|
||||
else if (labelText.length > that.settings.numDisplayed) {
|
||||
labelText = that.settings.overflowText.replace('{n}', labelText.length);
|
||||
}
|
||||
else {
|
||||
labelText = labelText.join(', ');
|
||||
}
|
||||
|
||||
return labelText;
|
||||
}
|
||||
|
||||
debounce(func, wait) {
|
||||
var timeout;
|
||||
return (...args) => {
|
||||
var boundFunc = func.bind(this, ...args);
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(boundFunc, wait);
|
||||
}
|
||||
}
|
||||
|
||||
trigger(eventName, ...args) {
|
||||
document.dispatchEvent(new CustomEvent(eventName, {detail: [...args]}));
|
||||
}
|
||||
|
||||
on(eventName, elementSelector, handler) {
|
||||
document.addEventListener(eventName, function(e) {
|
||||
// loop parent nodes from the target to the delegation node
|
||||
for (var target = e.target; target && target != this; target = target.parentNode) {
|
||||
if (target.matches(elementSelector)) {
|
||||
handler.call(target, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
var that = this;
|
||||
var optionSelector = '.fs-option:not(.fs-hidden):not(.disabled)';
|
||||
var unaccented = (str) => str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
||||
|
||||
// debounce search for better performance
|
||||
that.on('keyup', '.fs-search input', that.debounce(function(e) {
|
||||
var wrap = e.target.closest('.fs-wrap');
|
||||
var options = wrap._rel.options;
|
||||
|
||||
var matchOperators = /[|\\{}()[\]^$+*?.]/g;
|
||||
var keywords = e.target.value.replace(matchOperators, '\\$&');
|
||||
keywords = unaccented(keywords);
|
||||
|
||||
// if the searchCache already has a prefixed version of this search
|
||||
// then don't un-hide the existing exclusions
|
||||
if (0 !== keywords.indexOf(window.fSelectInit.searchCache)) {
|
||||
wrap.querySelectorAll('.fs-option, .fs-optgroup-label').forEach((node) => node.classList.remove('fs-hidden'));
|
||||
}
|
||||
|
||||
window.fSelectInit.searchCache = keywords;
|
||||
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
if ('' === options[i].value) continue;
|
||||
|
||||
var needle = new RegExp(keywords, 'gi');
|
||||
var haystack = unaccented(options[i].text);
|
||||
|
||||
if (null === haystack.match(needle)) {
|
||||
wrap.querySelector('.fs-option[data-idx="' + i + '"]').classList.add('fs-hidden');
|
||||
}
|
||||
}
|
||||
|
||||
// hide optgroups if no choices
|
||||
wrap.querySelectorAll('.fs-optgroup-label').forEach((node) => {
|
||||
var group = node.getAttribute('data-group');
|
||||
var container = node.closest('.fs-options');
|
||||
var count = container.querySelectorAll('.fs-option.g' + group + ':not(.fs-hidden)').length;
|
||||
|
||||
if (count < 1) {
|
||||
node.classList.add('fs-hidden');
|
||||
}
|
||||
});
|
||||
|
||||
// toggle the noResultsText div
|
||||
if (wrap.querySelectorAll('.fs-option:not(.fs-hidden').length) {
|
||||
wrap.querySelector('.fs-no-results').classList.add('fs-hidden');
|
||||
}
|
||||
else {
|
||||
wrap.querySelector('.fs-no-results').classList.remove('fs-hidden');
|
||||
}
|
||||
|
||||
}, 100));
|
||||
|
||||
that.on('click', optionSelector, function(e) {
|
||||
var wrap = this.closest('.fs-wrap');
|
||||
var value = this.getAttribute('data-value');
|
||||
var input = wrap._rel;
|
||||
var isMultiple = wrap.classList.contains('multiple');
|
||||
|
||||
if (!isMultiple) {
|
||||
input.value = value;
|
||||
wrap.querySelectorAll('.fs-option.selected').forEach((node) => node.classList.remove('selected'));
|
||||
}
|
||||
else {
|
||||
var idx = parseInt(this.getAttribute('data-idx'));
|
||||
input.options[idx].selected = !this.classList.contains('selected');
|
||||
}
|
||||
|
||||
this.classList.toggle('selected');
|
||||
|
||||
var label = input.fselect.getDropdownLabel();
|
||||
wrap.querySelector('.fs-label').innerHTML = label;
|
||||
|
||||
// fire a change event
|
||||
input.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
input.fselect.trigger('fs:changed', wrap);
|
||||
|
||||
if (!isMultiple) {
|
||||
input.fselect.close();
|
||||
}
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
});
|
||||
|
||||
that.on('keydown', '*', function(e) {
|
||||
var wrap = this.closest('.fs-wrap');
|
||||
|
||||
if (!wrap) return;
|
||||
|
||||
if (-1 < [38, 40, 27].indexOf(e.which)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
if (32 == e.which || 13 == e.which) { // space, enter
|
||||
if (e.target.closest('.fs-search')) {
|
||||
// preserve spaces for search
|
||||
}
|
||||
else if (e.target.matches(optionSelector)) {
|
||||
e.target.click();
|
||||
e.preventDefault();
|
||||
}
|
||||
else {
|
||||
wrap.querySelector('.fs-label').click();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
else if (38 == e.which) { // up
|
||||
var sibling = wrap._rel.fselect.getAdjacentSibling('previous');
|
||||
window.fSelectInit.lastFocus = sibling; // stop at the search box
|
||||
|
||||
if (sibling) {
|
||||
sibling.focus();
|
||||
}
|
||||
else {
|
||||
wrap.querySelector('.fs-search input').focus();
|
||||
}
|
||||
}
|
||||
else if (40 == e.which) { // down
|
||||
var sibling = wrap._rel.fselect.getAdjacentSibling('next');
|
||||
|
||||
if (sibling) {
|
||||
sibling.focus();
|
||||
window.fSelectInit.lastFocus = sibling; // stop at the bottom
|
||||
}
|
||||
}
|
||||
else if (9 == e.which || 27 == e.which) { // tab, esc
|
||||
wrap._rel.fselect.close();
|
||||
}
|
||||
});
|
||||
|
||||
that.on('click', '*', function(e) {
|
||||
var wrap = this.closest('.fs-wrap');
|
||||
var lastActive = window.fSelectInit.activeEl;
|
||||
|
||||
if (wrap) {
|
||||
var labelWrap = this.closest('.fs-label-wrap');
|
||||
|
||||
if (labelWrap) {
|
||||
if (lastActive) {
|
||||
lastActive._rel.fselect.close();
|
||||
}
|
||||
if (wrap !== lastActive) {
|
||||
wrap._rel.fselect.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (lastActive) {
|
||||
lastActive._rel.fselect.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var $ = (selector, options) => new fSelect(selector, options);
|
||||
|
||||
return $;
|
||||
|
||||
})();
|
||||
|
||||
if ('undefined' !== typeof fUtil) {
|
||||
fUtil.fn.fSelect = function(opts) {
|
||||
this.each(function() { // no arrow function to preserve "this"
|
||||
fSelect(this, opts);
|
||||
});
|
||||
return this;
|
||||
};
|
||||
}
|
||||
18
wp/wp-content/plugins/facetwp/assets/vendor/fTip/fTip.css
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
.ftip-wrap {
|
||||
position: absolute;
|
||||
display: none;
|
||||
max-width: 400px;
|
||||
padding: 6px 8px;
|
||||
background-color: #222;
|
||||
border-radius: 6px;
|
||||
opacity: 0;
|
||||
color: #fff;
|
||||
cursor: default;
|
||||
transition: height 0s, opacity 1s;
|
||||
}
|
||||
|
||||
.ftip-wrap.active {
|
||||
height: auto;
|
||||
display: inline-block;
|
||||
opacity: 0.9;
|
||||
}
|
||||
100
wp/wp-content/plugins/facetwp/assets/vendor/fTip/fTip.js
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
window.fTip = (() => {
|
||||
|
||||
var qs = (selector) => document.querySelector(selector);
|
||||
|
||||
class fTip {
|
||||
|
||||
constructor(selector, options) {
|
||||
let that = this;
|
||||
|
||||
var defaults = {
|
||||
content: (node) => node.getAttribute('title')
|
||||
};
|
||||
|
||||
that.settings = Object.assign({}, defaults, options);
|
||||
|
||||
var inputs = [];
|
||||
|
||||
if ('string' === typeof selector) {
|
||||
var inputs = Array.from(document.querySelectorAll(selector));
|
||||
}
|
||||
else if (selector instanceof Node) {
|
||||
var inputs = [selector];
|
||||
}
|
||||
else if (Array.isArray(selector)) {
|
||||
var inputs = selector;
|
||||
}
|
||||
|
||||
if (null === qs('.ftip-wrap')) {
|
||||
that.buildHtml();
|
||||
that.bindEvents();
|
||||
}
|
||||
|
||||
inputs.forEach(function(input) {
|
||||
that.input = input;
|
||||
input.ftip = that;
|
||||
input.classList.add('ftip-enabled');
|
||||
});
|
||||
}
|
||||
|
||||
open() {
|
||||
let input = this.input;
|
||||
let wrap = qs('.ftip-wrap');
|
||||
|
||||
wrap.innerHTML = this.settings.content(input);
|
||||
wrap.classList.add('active');
|
||||
|
||||
let wrapBounds = wrap.getBoundingClientRect();
|
||||
let inputBounds = input.getBoundingClientRect();
|
||||
let top = window.pageYOffset + inputBounds.top;
|
||||
let left = window.pageXOffset + inputBounds.right;
|
||||
let centered = ((inputBounds.height - wrapBounds.height) / 2);
|
||||
|
||||
wrap.style.top = (top + centered) + 'px';
|
||||
wrap.style.left = (left + 10) + 'px';
|
||||
}
|
||||
|
||||
buildHtml() {
|
||||
let html = '<div class="ftip-wrap"></div>';
|
||||
document.body.insertAdjacentHTML('beforeend', html);
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
var that = this;
|
||||
let wrap = qs('.ftip-wrap');
|
||||
|
||||
var delayHandler = () => {
|
||||
that.delay = setTimeout(() => {
|
||||
wrap.classList.remove('active');
|
||||
}, 250);
|
||||
};
|
||||
|
||||
that.on('mouseover', '.ftip-enabled', function(e) {
|
||||
clearTimeout(that.delay);
|
||||
this.ftip.open();
|
||||
});
|
||||
|
||||
that.on('mouseout', '.ftip-enabled', delayHandler);
|
||||
that.on('mouseout', '.ftip-wrap', delayHandler);
|
||||
that.on('mouseover', '.ftip-wrap', () => {
|
||||
clearTimeout(that.delay);
|
||||
});
|
||||
}
|
||||
|
||||
on(eventName, elementSelector, handler) {
|
||||
document.addEventListener(eventName, function(e) {
|
||||
// loop parent nodes from the target to the delegation node
|
||||
for (var target = e.target; target && target != this; target = target.parentNode) {
|
||||
if (target.matches(elementSelector)) {
|
||||
handler.call(target, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
|
||||
var $ = (selector, options) => new fTip(selector, options);
|
||||
|
||||
return $;
|
||||
})();
|
||||
7
wp/wp-content/plugins/facetwp/assets/vendor/fUtil/LICENSE.md
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright 2021 FacetWP, LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
451
wp/wp-content/plugins/facetwp/assets/vendor/fUtil/fUtil.js
vendored
Normal file
@@ -0,0 +1,451 @@
|
||||
window.fUtil = (() => {
|
||||
|
||||
class fUtil {
|
||||
|
||||
constructor(selector) {
|
||||
if (typeof selector === 'string' || selector instanceof String) { // string
|
||||
var selector = selector.replace(':selected', ':checked');
|
||||
|
||||
if ('' === selector) {
|
||||
this.nodes = [];
|
||||
}
|
||||
else if (this.isValidSelector(selector)) {
|
||||
this.nodes = Array.from(document.querySelectorAll(selector));
|
||||
}
|
||||
else {
|
||||
var tpl = document.createElement('template');
|
||||
tpl.innerHTML = selector;
|
||||
this.nodes = [tpl.content];
|
||||
}
|
||||
}
|
||||
else if (Array.isArray(selector)) { // array of nodes
|
||||
this.nodes = selector;
|
||||
}
|
||||
else if (typeof selector === 'object' && selector.nodeName) { // node
|
||||
this.nodes = [selector];
|
||||
}
|
||||
else if (typeof selector === 'function') { // function
|
||||
this.ready(selector);
|
||||
}
|
||||
else if (selector === window) { // window
|
||||
this.nodes = [window];
|
||||
}
|
||||
else { // document
|
||||
this.nodes = [document];
|
||||
}
|
||||
|
||||
// custom plugins
|
||||
$.each($.fn, (handler, method) => {
|
||||
this[method] = handler;
|
||||
});
|
||||
}
|
||||
|
||||
static isset(input) {
|
||||
return typeof input !== 'undefined';
|
||||
}
|
||||
|
||||
static post(url, data, settings) {
|
||||
var settings = Object.assign({}, {
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
headers: {},
|
||||
done: () => {},
|
||||
fail: () => {}
|
||||
}, settings);
|
||||
|
||||
settings.headers['Content-Type'] = settings.contentType;
|
||||
|
||||
data = ('application/json' === settings.contentType) ? JSON.stringify(data) : $.toEncoded(data);
|
||||
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
headers: settings.headers,
|
||||
body: data
|
||||
})
|
||||
.then(response => response[settings.dataType]())
|
||||
.then(json => settings.done(json))
|
||||
.catch(err => settings.fail(err));
|
||||
}
|
||||
|
||||
static toEncoded(obj, prefix, out) {
|
||||
var out = out || [];
|
||||
var prefix = prefix || '';
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
if (obj.length) {
|
||||
obj.forEach((val) => {
|
||||
$.toEncoded(val, prefix + '[]', out);
|
||||
});
|
||||
}
|
||||
else {
|
||||
$.toEncoded('', prefix, out);
|
||||
}
|
||||
}
|
||||
else if (typeof obj === 'object' && obj !== null) {
|
||||
Object.keys(obj).forEach((key) => {
|
||||
var new_prefix = prefix ? prefix + '[' + key + ']' : key;
|
||||
$.toEncoded(obj[key], new_prefix, out);
|
||||
});
|
||||
}
|
||||
else {
|
||||
out.push(encodeURIComponent(prefix) + '=' + encodeURIComponent(obj));
|
||||
}
|
||||
|
||||
return out.join('&');
|
||||
}
|
||||
|
||||
static forEach(items, callback) {
|
||||
if (typeof items === 'object' && items !== null) {
|
||||
if (Array.isArray(items)) {
|
||||
items.forEach((val, key) => callback.bind(val)(val, key));
|
||||
}
|
||||
else {
|
||||
Object.keys(items).forEach(key => {
|
||||
var val = items[key];
|
||||
callback.bind(val)(val, key);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
isValidSelector(string) {
|
||||
try {
|
||||
document.createDocumentFragment().querySelector(string);
|
||||
}
|
||||
catch(err) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
clone() {
|
||||
return $(this.nodes);
|
||||
}
|
||||
|
||||
len() {
|
||||
return this.nodes.length;
|
||||
}
|
||||
|
||||
each(callback) {
|
||||
this.nodes.forEach((node, key) => {
|
||||
let func = callback.bind(node); // set "this"
|
||||
func(node, key);
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
ready(callback) {
|
||||
if (typeof callback !== 'function') return;
|
||||
|
||||
if (document.readyState === 'complete') {
|
||||
return callback();
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', callback, false);
|
||||
}
|
||||
|
||||
addClass(className) {
|
||||
this.each(node => node.classList.add(className));
|
||||
return this;
|
||||
}
|
||||
|
||||
removeClass(className) {
|
||||
this.each(node => node.classList.remove(className));
|
||||
return this;
|
||||
}
|
||||
|
||||
hasClass(className) {
|
||||
return $.isset(this.nodes.find(node => node.classList.contains(className)));
|
||||
}
|
||||
|
||||
toggleClass(className) {
|
||||
this.each(node => node.classList.toggle(className));
|
||||
return this;
|
||||
}
|
||||
|
||||
is(selector) {
|
||||
for (let i = 0; i < this.len(); i++) { // forEach prevents loop exiting
|
||||
if (this.nodes[i].matches(selector)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
find(selector) {
|
||||
var selector = selector.replace(':selected', ':checked');
|
||||
let nodes = [];
|
||||
let clone = this.clone();
|
||||
|
||||
clone.each(node => {
|
||||
nodes = nodes.concat(Array.from(node.querySelectorAll(selector)));
|
||||
});
|
||||
|
||||
clone.nodes = nodes;
|
||||
return clone;
|
||||
}
|
||||
|
||||
first() {
|
||||
let clone = this.clone();
|
||||
if (clone.len()) {
|
||||
clone.nodes = this.nodes.slice(0, 1);
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
last() {
|
||||
let clone = this.clone();
|
||||
if (clone.len()) {
|
||||
clone.nodes = this.nodes.slice(-1);
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
prev(selector) {
|
||||
let nodes = [];
|
||||
let clone = this.clone();
|
||||
|
||||
clone.each(node => {
|
||||
let sibling = node.previousElementSibling;
|
||||
|
||||
while (sibling) {
|
||||
if (!$.isset(selector) || sibling.matches(selector)) break;
|
||||
sibling = sibling.previousElementSibling;
|
||||
}
|
||||
|
||||
if (sibling) {
|
||||
nodes.push(sibling);
|
||||
}
|
||||
});
|
||||
|
||||
clone.nodes = nodes;
|
||||
return clone;
|
||||
}
|
||||
|
||||
next(selector) {
|
||||
let nodes = [];
|
||||
let clone = this.clone();
|
||||
|
||||
clone.each(node => {
|
||||
let sibling = node.nextElementSibling;
|
||||
|
||||
while (sibling) {
|
||||
if (!$.isset(selector) || sibling.matches(selector)) break;
|
||||
sibling = sibling.nextElementSibling;
|
||||
}
|
||||
|
||||
if (sibling) {
|
||||
nodes.push(sibling);
|
||||
}
|
||||
});
|
||||
|
||||
clone.nodes = nodes;
|
||||
return clone;
|
||||
}
|
||||
|
||||
prepend(html) {
|
||||
this.each(node => node.insertAdjacentHTML('afterbegin', html));
|
||||
return this;
|
||||
}
|
||||
|
||||
append(html) {
|
||||
this.each(node => node.insertAdjacentHTML('beforeend', html));
|
||||
return this;
|
||||
}
|
||||
|
||||
parents(selector) {
|
||||
let parents = [];
|
||||
let clone = this.clone();
|
||||
|
||||
clone.each(node => {
|
||||
let parent = node.parentNode;
|
||||
while (parent && parent !== document) {
|
||||
if (parent.matches(selector)) parents.push(parent);
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
});
|
||||
|
||||
clone.nodes = [...new Set(parents)]; // remove dupes
|
||||
return clone;
|
||||
}
|
||||
|
||||
closest(selector) {
|
||||
let nodes = [];
|
||||
let clone = this.clone();
|
||||
|
||||
clone.each(node => {
|
||||
let closest = node.closest(selector);
|
||||
|
||||
if (closest) {
|
||||
nodes.push(closest);
|
||||
}
|
||||
});
|
||||
|
||||
clone.nodes = nodes;
|
||||
return clone;
|
||||
}
|
||||
|
||||
remove() {
|
||||
this.each(node => node.remove());
|
||||
return this;
|
||||
}
|
||||
|
||||
on(eventName, selector, callback) {
|
||||
if (!$.isset(selector)) return;
|
||||
if (!$.isset(callback)) {
|
||||
var callback = selector;
|
||||
var selector = null;
|
||||
}
|
||||
|
||||
// Reusable callback
|
||||
var checkForMatch = (e) => {
|
||||
if (null === selector || e.target.matches(selector)) {
|
||||
callback.bind(e.target)(e);
|
||||
}
|
||||
else if (e.target.closest(selector)) {
|
||||
var $this = e.target.closest(selector);
|
||||
callback.bind($this)(e);
|
||||
}
|
||||
};
|
||||
|
||||
this.each(node => {
|
||||
|
||||
// Attach a unique ID to each node
|
||||
if (!$.isset(node._id)) {
|
||||
node._id = $.event.count;
|
||||
$.event.store[$.event.count] = node;
|
||||
$.event.count++;
|
||||
}
|
||||
|
||||
var id = node._id;
|
||||
|
||||
// Store the raw callback, needed for .off()
|
||||
checkForMatch._str = callback.toString();
|
||||
|
||||
if (!$.isset($.event.map[id])) {
|
||||
$.event.map[id] = {};
|
||||
}
|
||||
if (!$.isset($.event.map[id][eventName])) {
|
||||
$.event.map[id][eventName] = {};
|
||||
}
|
||||
if (!$.isset($.event.map[id][eventName][selector])) {
|
||||
$.event.map[id][eventName][selector] = [];
|
||||
}
|
||||
|
||||
// Use $.event.map to store event references
|
||||
// removeEventListener needs named callbacks, so we're creating
|
||||
// one for every handler
|
||||
let length = $.event.map[id][eventName][selector].push(checkForMatch);
|
||||
|
||||
node.addEventListener(eventName, $.event.map[id][eventName][selector][length - 1]);
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
off(eventName, selector, callback) {
|
||||
if (!$.isset(callback)) {
|
||||
var callback = selector;
|
||||
var selector = null;
|
||||
}
|
||||
|
||||
this.each(node => {
|
||||
var id = node._id;
|
||||
|
||||
$.each($.event.map[id], (selectors, theEventName) => {
|
||||
$.each(selectors, (callbacks, theSelector) => {
|
||||
$.each(callbacks, (theCallback, index) => {
|
||||
if (
|
||||
(!eventName || theEventName === eventName) &&
|
||||
(!selector || theSelector === selector) &&
|
||||
(!callback || theCallback._str === callback.toString())
|
||||
) {
|
||||
node.removeEventListener(theEventName, $.event.map[id][theEventName][theSelector][index]);
|
||||
delete $.event.map[id][theEventName][theSelector][index];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
trigger(eventName, extraData) {
|
||||
this.each(node => node.dispatchEvent(new CustomEvent(eventName, {
|
||||
detail: extraData,
|
||||
bubbles: true
|
||||
})));
|
||||
return this;
|
||||
}
|
||||
|
||||
attr(attributeName, value) {
|
||||
if (!$.isset(value)) {
|
||||
return (this.len()) ? this.nodes[0].getAttribute(attributeName) : null;
|
||||
}
|
||||
|
||||
this.each(node => node.setAttribute(attributeName, value));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
data(key, value) {
|
||||
if (!$.isset(value)) {
|
||||
return (this.len()) ? this.nodes[0]._fdata[key] : null;
|
||||
}
|
||||
|
||||
this.each(node => node._fdata[key] = value);
|
||||
return this;
|
||||
}
|
||||
|
||||
html(htmlString) {
|
||||
if (!$.isset(htmlString)) {
|
||||
return (this.len()) ? this.nodes[0].innerHTML : null;
|
||||
}
|
||||
|
||||
this.each(node => node.innerHTML = htmlString);
|
||||
return this;
|
||||
}
|
||||
|
||||
text(textString) {
|
||||
if (!$.isset(textString)) {
|
||||
return (this.len()) ? this.nodes[0].textContent : null;
|
||||
}
|
||||
else {
|
||||
this.each(node => node.textContent = textString);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
val(value) {
|
||||
if (!$.isset(value)) {
|
||||
if (this.len()) {
|
||||
var field = this.nodes[0];
|
||||
if (field.nodeName.toLowerCase() === 'select' && field.multiple) {
|
||||
return [...field.options].filter((x) => x.selected).map((x) => x.value);
|
||||
}
|
||||
return field.value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
this.each(node => node.value = value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var $ = selector => new fUtil(selector);
|
||||
|
||||
// Set object methods
|
||||
$.fn = {};
|
||||
$.post = fUtil.post;
|
||||
$.isset = fUtil.isset;
|
||||
$.each = fUtil.forEach;
|
||||
$.toEncoded = fUtil.toEncoded;
|
||||
$.event = {map: {}, store: [], count: 0};
|
||||
return $;
|
||||
})();
|
||||
150
wp/wp-content/plugins/facetwp/assets/vendor/noUiSlider/nouislider.css
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
.noUi-target,
|
||||
.noUi-target * {
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.noUi-target {
|
||||
position: relative;
|
||||
}
|
||||
.noUi-base,
|
||||
.noUi-connects {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
.noUi-connects {
|
||||
overflow: hidden;
|
||||
z-index: 0;
|
||||
}
|
||||
.noUi-connect,
|
||||
.noUi-origin {
|
||||
will-change: transform;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
top: 0;
|
||||
right: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
transform-origin: 0 0;
|
||||
transform-style: flat;
|
||||
}
|
||||
.noUi-txt-dir-rtl.noUi-horizontal .noUi-origin {
|
||||
left: 0;
|
||||
right: auto;
|
||||
}
|
||||
.noUi-horizontal .noUi-origin {
|
||||
height: 0;
|
||||
}
|
||||
.noUi-handle {
|
||||
backface-visibility: hidden;
|
||||
position: absolute;
|
||||
}
|
||||
.noUi-touch-area {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.noUi-state-tap .noUi-connect,
|
||||
.noUi-state-tap .noUi-origin {
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
.noUi-horizontal {
|
||||
height: 14px;
|
||||
}
|
||||
.noUi-horizontal .noUi-handle {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
right: -10px;
|
||||
top: -4px;
|
||||
}
|
||||
.noUi-target {
|
||||
background: #FAFAFA;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #D3D3D3;
|
||||
padding: 0 8px;
|
||||
}
|
||||
.noUi-connects {
|
||||
border-radius: 3px;
|
||||
}
|
||||
.noUi-connect {
|
||||
background: #ddd;
|
||||
}
|
||||
.noUi-handle {
|
||||
border: 1px solid #D9D9D9;
|
||||
border-radius: 3px;
|
||||
background: #FFF;
|
||||
cursor: default;
|
||||
}
|
||||
.noUi-pips,
|
||||
.noUi-pips * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.noUi-pips {
|
||||
position: absolute;
|
||||
color: #999;
|
||||
}
|
||||
.noUi-value {
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
}
|
||||
.noUi-value-sub {
|
||||
color: #ccc;
|
||||
font-size: 10px;
|
||||
}
|
||||
.noUi-marker {
|
||||
position: absolute;
|
||||
background: #CCC;
|
||||
}
|
||||
.noUi-marker-sub {
|
||||
background: #AAA;
|
||||
}
|
||||
.noUi-marker-large {
|
||||
background: #AAA;
|
||||
}
|
||||
.noUi-pips-horizontal {
|
||||
padding: 10px 0;
|
||||
height: 80px;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.noUi-value-horizontal {
|
||||
transform: translate(-50%, 50%);
|
||||
}
|
||||
.noUi-rtl .noUi-value-horizontal {
|
||||
transform: translate(50%, 50%);
|
||||
}
|
||||
.noUi-marker-horizontal.noUi-marker {
|
||||
margin-left: -1px;
|
||||
width: 2px;
|
||||
height: 5px;
|
||||
}
|
||||
.noUi-marker-horizontal.noUi-marker-sub {
|
||||
height: 10px;
|
||||
}
|
||||
.noUi-marker-horizontal.noUi-marker-large {
|
||||
height: 15px;
|
||||
}
|
||||
.noUi-tooltip {
|
||||
display: block;
|
||||
position: absolute;
|
||||
border: 1px solid #D9D9D9;
|
||||
border-radius: 3px;
|
||||
background: #fff;
|
||||
color: #000;
|
||||
padding: 5px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.noUi-horizontal .noUi-tooltip {
|
||||
transform: translate(-50%, 0);
|
||||
left: 50%;
|
||||
bottom: 120%;
|
||||
}
|
||||
.noUi-horizontal .noUi-origin > .noUi-tooltip {
|
||||
transform: translate(50%, 0);
|
||||
left: auto;
|
||||
bottom: 10px;
|
||||
}
|
||||
2
wp/wp-content/plugins/facetwp/assets/vendor/noUiSlider/nouislider.min.js
vendored
Normal file
87
wp/wp-content/plugins/facetwp/assets/vendor/nummy/nummy.js
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Nummy.js - A (very) lightweight number formatter
|
||||
* @link https://github.com/mgibbs189/nummy
|
||||
*/
|
||||
(function() {
|
||||
function isValid(input) {
|
||||
return !isNaN(parseFloat(input)) && isFinite(input);
|
||||
}
|
||||
|
||||
function toFixed(value, precision) {
|
||||
var pow = Math.pow(10, precision);
|
||||
return (Math.round(value * pow) / pow).toFixed(precision);
|
||||
}
|
||||
|
||||
class Nummy {
|
||||
constructor(value) {
|
||||
this._value = isValid(value) ? value : 0;
|
||||
}
|
||||
|
||||
format(format, opts) {
|
||||
var value = this._value,
|
||||
negative = false,
|
||||
precision = 0,
|
||||
valueStr = '',
|
||||
wholeStr = '',
|
||||
decimalStr = '',
|
||||
abbr = '';
|
||||
|
||||
var opts = Object.assign({}, {
|
||||
'thousands_separator': ',',
|
||||
'decimal_separator': '.'
|
||||
}, opts);
|
||||
|
||||
if (-1 < format.indexOf('a')) {
|
||||
var abbrevs = ['K', 'M', 'B', 't', 'q', 'Q'];
|
||||
var exp = Math.floor(Math.log(Math.abs(value)) * Math.LOG10E); // log10 polyfill
|
||||
var nearest_exp = (exp - (exp % 3)); // nearest exponent divisible by 3
|
||||
|
||||
if (3 <= exp) {
|
||||
value = value / Math.pow(10, nearest_exp);
|
||||
abbr += abbrevs[Math.floor(exp / 3) - 1];
|
||||
}
|
||||
|
||||
format = format.replace('a', '');
|
||||
}
|
||||
|
||||
// Check for decimals format
|
||||
if (-1 < format.indexOf('.')) {
|
||||
precision = format.split('.')[1].length;
|
||||
}
|
||||
|
||||
value = toFixed(value, precision);
|
||||
valueStr = value.toString();
|
||||
|
||||
// Handle negative number
|
||||
if (value < 0) {
|
||||
negative = true;
|
||||
value = Math.abs(value);
|
||||
valueStr = valueStr.slice(1);
|
||||
}
|
||||
|
||||
wholeStr = valueStr.split('.')[0] || '';
|
||||
decimalStr = valueStr.split('.')[1] || '';
|
||||
|
||||
// Handle decimals
|
||||
decimalStr = (0 < precision && '' != decimalStr) ? '.' + decimalStr : '';
|
||||
|
||||
// Use thousands separators
|
||||
if (-1 < format.indexOf(',')) {
|
||||
wholeStr = wholeStr.replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
|
||||
}
|
||||
|
||||
var output = (negative ? '-' : '') + wholeStr + decimalStr + abbr;
|
||||
|
||||
output = output.replace(/\./g, '{d}');
|
||||
output = output.replace(/\,/g, '{t}');
|
||||
output = output.replace(/{d}/g, opts.decimal_separator);
|
||||
output = output.replace(/{t}/g, opts.thousands_separator);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
window.nummy = function(input) {
|
||||
return new Nummy(input);
|
||||
}
|
||||
})();
|
||||
1
wp/wp-content/plugins/facetwp/assets/vendor/nummy/nummy.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var a;(a=function(a){var t;this._value=(t=a,!isNaN(parseFloat(t))&&isFinite(t)?a:0)}).prototype.format=function(a,t){var e=this._value,r=!1,i=0,n="",o="",s="",l="";if(t=Object.assign({},{thousands_separator:",",decimal_separator:"."},t),-1<a.indexOf("a")){var p=Math.floor(Math.log(Math.abs(e))*Math.LOG10E),c=p-p%3;3<=p&&(e/=Math.pow(10,c),l+=["K","M","B","t","q","Q"][Math.floor(p/3)-1]),a=a.replace("a","")}-1<a.indexOf(".")&&(i=a.split(".")[1].length),e=function(a,t){var e=Math.pow(10,t);return(Math.round(a*e)/e).toFixed(t)}(e,i),n=e.toString(),e<0&&(r=!0,e=Math.abs(e),n=n.slice(1)),o=n.split(".")[0]||"",s=n.split(".")[1]||"",s=0<i&&""!=s?"."+s:"",-1<a.indexOf(",")&&(o=o.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"));var d=(r?"-":"")+o+s+l;return d=(d=(d=(d=d.replace(/\./g,"{d}")).replace(/\,/g,"{t}")).replace(/{d}/g,t.decimal_separator)).replace(/{t}/g,t.thousands_separator)},window.nummy=function(t){return new a(t)}}();
|
||||