abmp-npm 2.0.74 → 2.0.76
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 +55 -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,18 @@ 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,
|
|
10
|
-
|
|
15
|
+
findMainAddress,
|
|
11
16
|
checkAddressIsVisible,
|
|
17
|
+
formatPracticeAreasForDisplay,
|
|
12
18
|
isWixHostedImage,
|
|
13
19
|
normalizeExternalUrl,
|
|
14
20
|
} = require('../public/Utils/sharedUtils.js');
|
|
@@ -30,6 +36,28 @@ const pagination = {
|
|
|
30
36
|
let searchResults = [];
|
|
31
37
|
let isMobile = false;
|
|
32
38
|
|
|
39
|
+
const isMappable = addr =>
|
|
40
|
+
addr?.addressStatus === ADDRESS_STATUS_TYPES.FULL_ADDRESS && addr.latitude && addr.longitude;
|
|
41
|
+
|
|
42
|
+
// The button is only offered when the member has at least one mappable address, which is
|
|
43
|
+
// the same condition as before the lightbox was introduced. When that address is not the
|
|
44
|
+
// primary one we still show the button but withhold the link, so the click opens the
|
|
45
|
+
// lightbox instead of sending the visitor to a secondary address in another city.
|
|
46
|
+
const getDirectionsTarget = itemData => {
|
|
47
|
+
const addresses = Array.isArray(itemData?.addresses) ? itemData.addresses : [];
|
|
48
|
+
const showButton = checkAddressIsVisible(addresses).some(isMappable);
|
|
49
|
+
if (!showButton) {
|
|
50
|
+
return { showButton: false, mapsLink: null };
|
|
51
|
+
}
|
|
52
|
+
const mainAddr = findMainAddress(itemData?.addressDisplayOption, addresses);
|
|
53
|
+
return {
|
|
54
|
+
showButton: true,
|
|
55
|
+
mapsLink: isMappable(mainAddr)
|
|
56
|
+
? `https://maps.google.com/?q=${mainAddr.latitude},${mainAddr.longitude}`
|
|
57
|
+
: null,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
33
61
|
const homePageOnReady = async ({
|
|
34
62
|
_$w,
|
|
35
63
|
getCompiledFiltersOptions,
|
|
@@ -181,6 +209,16 @@ const homePageOnReady = async ({
|
|
|
181
209
|
await updateResults('zeroTimeout');
|
|
182
210
|
});
|
|
183
211
|
const baseUrl = await wixLocation.baseUrl();
|
|
212
|
+
_$w('#showMaps').onClick(event => {
|
|
213
|
+
const member = searchResults.find(result => result._id === event.context.itemId);
|
|
214
|
+
if (!member) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const { showButton, mapsLink } = getDirectionsTarget(member);
|
|
218
|
+
if (showButton && !mapsLink) {
|
|
219
|
+
wixWindow.openLightbox(LIGHTBOX_NAMES.CONTACT_FOR_LOCATION, member);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
184
222
|
_$w('#profileRepeater').onItemReady(($item, itemData) => {
|
|
185
223
|
// 1) safely default to arrays
|
|
186
224
|
const addresses = Array.isArray(itemData.addresses) ? itemData.addresses : [];
|
|
@@ -225,23 +263,24 @@ const homePageOnReady = async ({
|
|
|
225
263
|
$item('#milesAwayText').text = '';
|
|
226
264
|
}
|
|
227
265
|
|
|
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
|
-
);
|
|
266
|
+
// 7) "Show maps" button. Links to the primary address when it is a full address;
|
|
267
|
+
// otherwise it stays visible and the page-level onClick opens a lightbox.
|
|
268
|
+
const { showButton, mapsLink } = getDirectionsTarget(itemData);
|
|
236
269
|
|
|
237
|
-
if (
|
|
270
|
+
if (!showButton) {
|
|
271
|
+
$item('#showMaps').hide();
|
|
272
|
+
} else {
|
|
238
273
|
$item('#showMaps').enable();
|
|
239
274
|
$item('#showMaps').show();
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
275
|
+
|
|
276
|
+
if (mapsLink) {
|
|
277
|
+
$item('#showMaps').link = mapsLink;
|
|
278
|
+
$item('#showMaps').target = '_blank';
|
|
279
|
+
} else {
|
|
280
|
+
// Clear any link left over from a recycled repeater item, otherwise the
|
|
281
|
+
// button would still navigate to the previous member's address.
|
|
282
|
+
$item('#showMaps').link = undefined;
|
|
283
|
+
}
|
|
245
284
|
}
|
|
246
285
|
|
|
247
286
|
// 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