sr-npm 1.7.67 → 1.7.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pages/homePage.js +2 -1
- package/public/filterUtils.js +2 -2
- package/public/index.js +1 -0
- package/public/mapUtils.js +16 -0
package/package.json
CHANGED
package/pages/homePage.js
CHANGED
|
@@ -2,6 +2,7 @@ const {
|
|
|
2
2
|
debounce,
|
|
3
3
|
getFilter,
|
|
4
4
|
} = require('../public/filterUtils');
|
|
5
|
+
const { handleOnLocationClick } = require('../public/mapUtils');
|
|
5
6
|
const { location } = require('@wix/site-location');
|
|
6
7
|
|
|
7
8
|
async function homePageOnReady(_$w) {
|
|
@@ -64,7 +65,7 @@ function init(_$w) {
|
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
_$w('#locationItem').onClick((event)=>{
|
|
67
|
-
handleOnLocationClick(event, '#locationsRepeater', '#googleMaps');
|
|
68
|
+
handleOnLocationClick(event, '#locationsRepeater', '#googleMaps', _$w);
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
|
package/public/filterUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { items:wixData } = require('@wix/data');
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function getFilter(fieldsToSearch = [], mode = 'or') {
|
|
4
4
|
const baseFilter = wixData.filter();
|
|
5
5
|
// if no fields to search, return empty filter
|
|
6
6
|
if (fieldsToSearch.length === 0) {
|
|
@@ -22,7 +22,7 @@ export function getFilter(fieldsToSearch = [], mode = 'or') {
|
|
|
22
22
|
return filter;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
function debounce(fn, delay = 400) {
|
|
26
26
|
let timeout;
|
|
27
27
|
return function (...args) {
|
|
28
28
|
clearTimeout(timeout);
|
package/public/index.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function handleOnLocationClick(event, repeaterId, mapId, _$w) {
|
|
2
|
+
const FOCUS_ZOOM = 13;
|
|
3
|
+
const { itemId } = event.context;
|
|
4
|
+
const itemData = _$w(repeaterId).data.find(item => item._id === itemId);
|
|
5
|
+
|
|
6
|
+
const location = itemData.locationAddress.location;
|
|
7
|
+
|
|
8
|
+
//@ts-ignore
|
|
9
|
+
_$w(mapId).setCenter(location);
|
|
10
|
+
//@ts-ignore
|
|
11
|
+
_$w(mapId).setZoom(FOCUS_ZOOM);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
handleOnLocationClick
|
|
16
|
+
};
|