homeflowjs 0.13.35 → 0.13.37

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.13.35",
3
+ "version": "0.13.37",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -126,7 +126,7 @@ const PropertiesDisplay = ({
126
126
  {items}
127
127
  </div>
128
128
  {showScrollRef && (
129
- <div ref={infiniteScrollRef} />
129
+ <div ref={infiniteScrollRef} className="hf-property-results__infinite-scroll-trigger" style={{ height: '1px', opacity: 0 }} />
130
130
  )}
131
131
  {showScrollLoader && (
132
132
  <InfiniteScrollLoader />
@@ -0,0 +1,16 @@
1
+ .draggable-map-overlay {
2
+ position: absolute;
3
+ inset: 0;
4
+ display: none;
5
+ justify-content: center;
6
+ align-items: center;
7
+ background-color: rgba(0, 0, 0, 0.5);
8
+ font-size: 4rem;
9
+ color: white;
10
+ cursor: pointer;
11
+ user-select: none;
12
+ }
13
+
14
+ .draggable-map-overlay--show {
15
+ display: flex;
16
+ }
@@ -8,6 +8,8 @@ import { setPlace, setSearchField } from '../../actions/search.actions';
8
8
  import { setProperties, setSelectedMarker, setPagination } from '../../actions/properties.actions';
9
9
  import { setLoading } from '../../actions/app.actions';
10
10
 
11
+ import './draggable-map.css';
12
+
11
13
  const element = function (X, Y) {
12
14
  this.X = X;
13
15
  this.Y = Y;
@@ -23,6 +25,12 @@ export default class DraggableMap {
23
25
  this.render = this.render.bind(this);
24
26
  this.generateMap = this.generateMap.bind(this);
25
27
  this.properties = this.getProperties();
28
+ this.disableHandlers = this.disableHandlers.bind(this);
29
+ this.enableHandlers = this.enableHandlers.bind(this);
30
+ this.addOverlay = this.addOverlay.bind(this);
31
+ this.removeOverlay = this.removeOverlay.bind(this);
32
+ this.showOverlay = this.showOverlay.bind(this);
33
+ this.hideOverlay = this.hideOverlay.bind(this);
26
34
  this.initOnMarkerClick();
27
35
  }
28
36
 
@@ -703,4 +711,47 @@ export default class DraggableMap {
703
711
 
704
712
  return new L.LatLng(y, x);
705
713
  }
714
+
715
+ disableHandlers() {
716
+ this.map._handlers.forEach(function(handler) {
717
+ handler.disable();
718
+ });
719
+ }
720
+
721
+ enableHandlers() {
722
+ this.map._handlers.forEach(function(handler) {
723
+ handler.enable();
724
+ });
725
+ }
726
+
727
+ addOverlay({ text }) {
728
+ const { _container, _overlayElement } = this.map;
729
+ if (_overlayElement) {
730
+ this.removeOverlay();
731
+ }
732
+
733
+ const newDiv = document.createElement("div");
734
+ newDiv.classList.add('draggable-map-overlay');
735
+ this._overlayElement = newDiv;
736
+ if (text) {
737
+ const newContent = document.createTextNode(text);
738
+ newDiv.appendChild(newContent);
739
+ }
740
+ _container.appendChild(newDiv, _container);
741
+ }
742
+
743
+ removeOverlay() {
744
+ if (this._overlayElement) {
745
+ this._overlayElement?.remove();
746
+ this._overlayElement = null;
747
+ }
748
+ }
749
+
750
+ showOverlay() {
751
+ this?._overlayElement?.classList?.add('draggable-map-overlay--show')
752
+ }
753
+
754
+ hideOverlay() {
755
+ this?._overlayElement?.classList?.remove('draggable-map-overlay--show')
756
+ }
706
757
  }
@@ -16,17 +16,32 @@ import './marker_cluster.css';
16
16
  import './marker_cluster.default.css';
17
17
 
18
18
  // global callback to run when maps scripts are loaded
19
- window.initLegacyMap = () => {
19
+ window.initLegacyMap = (options) => {
20
+ let map;
20
21
  if (Homeflow.get('geonames_map')) {
21
- const map = new GeonamesMap();
22
+ map = new GeonamesMap();
22
23
  map.init();
23
24
  } else if (Homeflow.get('enable_draw_a_map') && !!window.CanvasRenderingContext2D && !!history.pushState) {
24
- const map = new DrawableMap();
25
+ map = new DrawableMap();
25
26
  map.init();
26
27
  } else {
27
- const map = new DraggableMap();
28
+ map = new DraggableMap();
28
29
  map.init();
29
30
  }
31
+
32
+ if (map && options) {
33
+ if (options?.disableHandlersOnInit) {
34
+ map.disableHandlers();
35
+ map.addOverlay({ text: options.overlayText || 'Click to interact' });
36
+ map.showOverlay();
37
+
38
+ map.map.on('click', () => {
39
+ map.enableHandlers();
40
+ map.hideOverlay();
41
+ map.removeOverlay();
42
+ })
43
+ }
44
+ }
30
45
  };
31
46
 
32
47
  // have to stub these jQuery methods as they're called in drawamap code
@@ -52,7 +67,7 @@ window.$ = () => ({
52
67
  // )
53
68
  // end
54
69
 
55
- const PropertiesMap = ({ leaflet, gmapKey, googleLayer }) => {
70
+ const PropertiesMap = ({ leaflet, gmapKey, googleLayer, legacyMapOptions }) => {
56
71
  const addLegacyMaps = () => {
57
72
  const needsGoogle = !leaflet || googleLayer;
58
73
 
@@ -67,10 +82,13 @@ const PropertiesMap = ({ leaflet, gmapKey, googleLayer }) => {
67
82
  const script = document.createElement('script');
68
83
  script.setAttribute('src', '/legacy_asset_bundles/legacy_maps.js');
69
84
  script.setAttribute('id', 'hfjs-legacy-maps');
70
- script.setAttribute('onload', 'window.initLegacyMap()');
85
+ script.setAttribute(
86
+ 'onload',
87
+ `window.initLegacyMap(${legacyMapOptions ? JSON.stringify(legacyMapOptions) : ''})`,
88
+ );
71
89
  document.head.appendChild(script);
72
90
  } else {
73
- window.initLegacyMap();
91
+ window.initLegacyMap(legacyMapOptions);
74
92
  }
75
93
  };
76
94
 
@@ -90,12 +108,17 @@ PropertiesMap.propTypes = {
90
108
  gmapKey: PropTypes.string,
91
109
  leaflet: PropTypes.bool,
92
110
  googleLayer: PropTypes.bool,
111
+ legacyMapOptions: PropTypes.shape({
112
+ disableHandlersOnInit: PropTypes.bool,
113
+ overlayText: PropTypes.string,
114
+ })
93
115
  };
94
116
 
95
117
  PropertiesMap.defaultProps = {
96
118
  gmapKey: null,
97
119
  leaflet: false,
98
120
  googleLayer: false,
121
+ legacyMapOptions: null,
99
122
  };
100
123
 
101
124
  const mapStateToProps = (state) => ({