abmp-npm 2.0.74 → 2.0.75
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/Home.js +50 -16
- package/pages/contactForLocation.js +28 -0
- package/pages/index.js +1 -0
- package/public/consts.js +1 -0
package/package.json
CHANGED
package/pages/Home.js
CHANGED
|
@@ -3,12 +3,17 @@ const { location: wixLocation } = require('@wix/site-location');
|
|
|
3
3
|
const { window: wixWindow, rendering } = require('@wix/site-window');
|
|
4
4
|
const { withWarmUpData } = require('psdev-utils/frontend');
|
|
5
5
|
|
|
6
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
ADDRESS_STATUS_TYPES,
|
|
8
|
+
DEFAULT_FILTER,
|
|
9
|
+
DROPDOWN_OPTIONS,
|
|
10
|
+
LIGHTBOX_NAMES,
|
|
11
|
+
} = require('../public/consts.js');
|
|
7
12
|
const { createHomepageUtils } = require('../public/Utils/homePage.js');
|
|
8
13
|
const {
|
|
9
14
|
getMainAddress,
|
|
15
|
+
findMainAddress,
|
|
10
16
|
formatPracticeAreasForDisplay,
|
|
11
|
-
checkAddressIsVisible,
|
|
12
17
|
isWixHostedImage,
|
|
13
18
|
normalizeExternalUrl,
|
|
14
19
|
} = require('../public/Utils/sharedUtils.js');
|
|
@@ -30,6 +35,24 @@ const pagination = {
|
|
|
30
35
|
let searchResults = [];
|
|
31
36
|
let isMobile = false;
|
|
32
37
|
|
|
38
|
+
const getDirectionsTarget = itemData => {
|
|
39
|
+
const addresses = Array.isArray(itemData?.addresses) ? itemData.addresses : [];
|
|
40
|
+
const mainAddr = findMainAddress(itemData?.addressDisplayOption, addresses);
|
|
41
|
+
if (!mainAddr) {
|
|
42
|
+
return { mainAddr: null, mapsLink: null };
|
|
43
|
+
}
|
|
44
|
+
const canShowDirections =
|
|
45
|
+
mainAddr.addressStatus === ADDRESS_STATUS_TYPES.FULL_ADDRESS &&
|
|
46
|
+
mainAddr.latitude &&
|
|
47
|
+
mainAddr.longitude;
|
|
48
|
+
return {
|
|
49
|
+
mainAddr,
|
|
50
|
+
mapsLink: canShowDirections
|
|
51
|
+
? `https://maps.google.com/?q=${mainAddr.latitude},${mainAddr.longitude}`
|
|
52
|
+
: null,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
33
56
|
const homePageOnReady = async ({
|
|
34
57
|
_$w,
|
|
35
58
|
getCompiledFiltersOptions,
|
|
@@ -181,6 +204,16 @@ const homePageOnReady = async ({
|
|
|
181
204
|
await updateResults('zeroTimeout');
|
|
182
205
|
});
|
|
183
206
|
const baseUrl = await wixLocation.baseUrl();
|
|
207
|
+
_$w('#showMaps').onClick(event => {
|
|
208
|
+
const member = searchResults.find(result => result._id === event.context.itemId);
|
|
209
|
+
if (!member) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const { mapsLink } = getDirectionsTarget(member);
|
|
213
|
+
if (!mapsLink) {
|
|
214
|
+
wixWindow.openLightbox(LIGHTBOX_NAMES.CONTACT_FOR_LOCATION, member);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
184
217
|
_$w('#profileRepeater').onItemReady(($item, itemData) => {
|
|
185
218
|
// 1) safely default to arrays
|
|
186
219
|
const addresses = Array.isArray(itemData.addresses) ? itemData.addresses : [];
|
|
@@ -225,23 +258,24 @@ const homePageOnReady = async ({
|
|
|
225
258
|
$item('#milesAwayText').text = '';
|
|
226
259
|
}
|
|
227
260
|
|
|
228
|
-
// 7) "Show maps" button
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
addr =>
|
|
232
|
-
addr.addressStatus === ADDRESS_STATUS_TYPES.FULL_ADDRESS &&
|
|
233
|
-
addr.latitude &&
|
|
234
|
-
addr.longitude
|
|
235
|
-
);
|
|
261
|
+
// 7) "Show maps" button. Links to the primary address when it is a full address;
|
|
262
|
+
// otherwise it stays visible and the page-level onClick opens a lightbox.
|
|
263
|
+
const { mainAddr, mapsLink } = getDirectionsTarget(itemData);
|
|
236
264
|
|
|
237
|
-
if (
|
|
265
|
+
if (!mainAddr) {
|
|
266
|
+
$item('#showMaps').hide();
|
|
267
|
+
} else {
|
|
238
268
|
$item('#showMaps').enable();
|
|
239
269
|
$item('#showMaps').show();
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
270
|
+
|
|
271
|
+
if (mapsLink) {
|
|
272
|
+
$item('#showMaps').link = mapsLink;
|
|
273
|
+
$item('#showMaps').target = '_blank';
|
|
274
|
+
} else {
|
|
275
|
+
// Clear any link left over from a recycled repeater item, otherwise the
|
|
276
|
+
// button would still navigate to the previous member's address.
|
|
277
|
+
$item('#showMaps').link = undefined;
|
|
278
|
+
}
|
|
245
279
|
}
|
|
246
280
|
|
|
247
281
|
// 8) Phone / contact form
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { location: wixLocation } = require('@wix/site-location');
|
|
2
|
+
const { lightbox } = require('@wix/site-window');
|
|
3
|
+
|
|
4
|
+
const { PAGES_PATHS } = require('../public/consts.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Shown from the directory when a member's primary address is not a full address,
|
|
8
|
+
* so "Directions" cannot be offered. Sends the visitor to the member's profile
|
|
9
|
+
* page rather than opening the contact form.
|
|
10
|
+
*/
|
|
11
|
+
async function contactForLocationOnReady({ $w: _$w }) {
|
|
12
|
+
const member = await lightbox.getContext();
|
|
13
|
+
const profilePath = member?.url;
|
|
14
|
+
|
|
15
|
+
if (!profilePath) {
|
|
16
|
+
_$w('#contact').hide();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_$w('#contact').onClick(async () => {
|
|
21
|
+
await lightbox.close();
|
|
22
|
+
wixLocation.to(`/${PAGES_PATHS.PROFILE}/${profilePath}`);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
contactForLocationOnReady,
|
|
28
|
+
};
|
package/pages/index.js
CHANGED
package/public/consts.js
CHANGED