$owl.on('mouseenter mouseleave', function(e) {
$(this).data('owl.carousel').options.autoplay = e.type === 'mouseenter';
$(this).trigger('refresh.owl.carousel');
});
$owl.on('mouseenter mouseleave', function(e) {
$(this).trigger(({
mouseenter: 'play',
mouseleave: 'stop',
})[e.type] + '.owl.autoplay');
});
Uncaught TypeError: number[i].parents is not a function
number[i]
должно было быть $(number[i])
или number.eq(i)
. Но вообще, организовывать цикл вручную нет необходимости:$('.person-wr a.desc')
.filter((i, n) => !n.innerText.trim())
.closest('.add-info')
.hide();
document.addEventListener('click', e => {
const item = e.target.closest('.preliminary-item');
if (item) {
[ 'name', 'quantity', 'proximity' ].forEach(n => {
const html = `<p>${item.querySelector(`.request-${n}`).textContent}</p>`;
document.querySelector(`.result-${n}`).insertAdjacentHTML('beforeend', html);
});
}
});
$(document).on('click', '.preliminary-item', function() {
$.each([ 'name', 'quantity', 'proximity' ], (i, n) => {
$(`.result-${n}`).append(`<p>${$(`.request-${n}`, this).text()}</p>`);
});
});
case 'TURN_DONE_POST':
return {
...state,
data: state.data.map(n => n.id === action.payload
? { ...n, done: !n.done }
: n
),
};
phonesProcessed() {
const classes = Object.fromEntries(this.classes.map(({ classinfoName: c, items }) => [
c,
Object.fromEntries(items.map(n => [
n[`id${c[0].toUpperCase()}${c.slice(1)}`],
n.name,
])),
]));
return this.phones.map(n =>
Object.fromEntries(Object.entries(n).map(([ k, v ]) => [
k,
classes.hasOwnProperty(k) ? classes[k][v] : v,
]))
);
},
created() {
[
[ '5ad979f4-7393-11ea-b9b1-d7fe1923484d', 'classinfo', 'classes' ],
[ '46bf408d-739d-11ea-b9b1-5301e3b2b9ba', 'phones', 'phones' ],
].forEach(([ key, apiPropName, componentPropName ]) => {
axios
.get(`https://jsonblob.com/api/${key}`)
.then(({ data: { [apiPropName]: d } }) => this[componentPropName] = d)
.catch(e => this.errors.push(e));
});
},
computed: {
groupedItems() {
const { items } = this;
const statuses = [...new Set(items.map(n => n.status))];
const positions = [...new Set(items.map(n => n.position))];
return items.reduce(
(acc, n) => (acc[n.status][n.position].push(n), acc),
Object.fromEntries(statuses.map(status => [
status,
Object.fromEntries(positions.map(position => [
position,
[]
]))
]))
);
},
},
<ul>
<li v-for="(statusGroup, status) in groupedItems">
<h2>{{ status }}</h2>
<ul>
<li v-for="(positionGroup, position) in statusGroup">
<h3>{{ position }}</h3>
<ul>
<li v-for="n in positionGroup">{{ n.name }}</li>
</ul>
</li>
</ul>
</li>
</ul>
name: 'v-tree',
props: [ 'items' ],
<ul v-if="items instanceof Object">
<li v-for="n in items">
<b>{{ n.name }}</b>
<v-tree :items="n.children" />
</li>
</ul>
const group = (arr, keys) =>
arr.reduce((acc, n) => {
keys.reduce((g, k, i, a) => {
const name = n[k];
return (g[name] = g[name] || {
name,
children: i === a.length - 1 ? [] : {},
}).children;
}, acc).push(n);
return acc;
}, keys.length ? {} : []);
computed: {
groupedItems() {
return group(this.items, [ 'status', 'position' ]);
},
},
<v-tree :items="groupedItems" />
function getGridSize() {
const w = window.innerWidth;
return [ 500, 700, 1225, Infinity ].findIndex(n => n > w) + 1;
}
function getGridSize() {
const w = window.innerWidth;
return [
{ size: 1, maxWidth: 500 },
{ size: 2, maxWidth: 700 },
{ size: 3, maxWidth: 1225 },
{ size: 4, maxWidth: Infinity },
].find(n => n.maxWidth > w).size;
}
const isEqual = (a, b) =>
a.length === b.length && a.every((n, i) => Object.is(n, b[i]));
const includes = (arrs, search) =>
arrs.some(n => isEqual(n, search));
console.log(includes(array, [ 21, 81 ]));
. el.dispatchEvent(new Event('click'));
// или, если обработчик клика висит не на самом svg, а выше
el.dispatchEvent(new Event('click', { bubbles: true }));
const colors = [
{ color: '...', image: '...' },
{ color: '...', image: '...' },
...
];
background-color
на background-image
:const colorsItems = colors
.map(n => `
<button
style="background-image: url(${n.image})"
class="palette-button"
data-color="${n.color}"
></button>`)
.join('');
.palette-button
- приводите в порядок background:background-position: center;
background-size: contain;
background-repeat: no-repeat;
const markerData = [
{ coord: [ ... ], content: '...' },
{ coord: [ ... ], content: '...' },
...
];
markerData.forEach(function(n) {
const marker = new google.maps.Marker({
position: new google.maps.LatLng(...n.coord),
map,
});
marker.addListener('click', function() {
infowindow.setContent(n.content);
infowindow.open(map, marker);
});
});
const filterByProps = Object.entries(this.state.filters).filter(n => n[1]).map(n => n[0]);
const filteredItems = this.state.items.filter(n => filterByProps.every(m => n[m]));