{"version":3,"file":"index-D5By-ida.js","sources":["../../../app/assets/javascripts/apps/spacious_website/pages/overseas_properties/shared/components/project_entry_carousel/index.ts","../../../app/assets/javascripts/apps/spacious_website/pages/overseas_properties/shared/components/project_entry_pictures_and_map_browser/with_toggle/google_street_view.ts","../../../app/assets/javascripts/apps/spacious_website/pages/overseas_properties/shared/components/project_entry_pictures_and_map_browser/with_toggle/static_map/index.ts","../../../app/assets/javascripts/apps/spacious_website/pages/overseas_properties/shared/components/project_entry_pictures_and_map_browser/with_toggle/index.ts","../../../app/assets/javascripts/apps/spacious_website/pages/overseas_properties/shared/components/project_entry_row/wide/index.ts"],"sourcesContent":["\n// region JS Imports\n\n// region External Modules\n// endregion External Modules\n\n// Private Modules\nimport ImageLazyLoading from \"widgets/image_lazyloading\"\n// Private Modules\n\n// region Public Components\n// endregion Public Components\n\n// region Private Components\n// endregion Private Components\n\n// endregion JS Imports\n\nfunction init() {\n ImageLazyLoading.default_lazyload_instance().update()\n}\n\nexport default {\n init,\n}\n","\nimport $ from \"jquery\"\nimport Promise from \"plugins/bluebird\"\nimport isBlankStr from \"underscore.string/isBlank\"\n\nimport DomIdGenerator from \"app/utils/dom_id_generator\"\n\nimport GoogleMaps_asyncLoad from \"app/google-maps/index\"\n\nimport SwitchMode from \"components/widgets/switch_mode\"\nimport DataRetriever from \"app/data_retriever\"\n\nimport Notifier from \"app/notifier\"\nimport {\n captureException,\n} from \"app/error_reporting\"\n\nimport I18n from \"plugins/i18n-js\"\n\n\nconst RejectionReasons = {\n FAILURE_CASE_HANDLED: \"FAILURE_CASE_HANDLED\",\n}\n\n\nlet _retained_panoramas_per_dom_id = {} as {\n [key: string]: google.maps.StreetViewPanorama\n}\n\n\ninterface Selector {\n main: string | JQuery\n switch: string\n street_view: string\n}\n\ninterface InputSelector {\n main?: string | JQuery\n switch?: string\n street_view?: string\n}\n\nconst default_selector = {\n main: \".cell--overseas_properties-shared--project_entry_pictures_and_map_browser--with-toggle\",\n switch: \".cell--overseas_properties-shared--project_entry_pictures_and_map_browser--with-toggle__switch--street-view\",\n street_view: \".cell--overseas_properties-shared--project_entry_pictures_and_map_browser--with-toggle__content-for-mode-street .js-google-street-view\",\n}\n\n\nconst init = (selector?: InputSelector) => {\n const sele: Selector = Object.assign({}, default_selector, selector)\n if (DataRetriever.get(\"current-location-country-code-is-china\")) { return }\n\n const $el = $(sele.main)\n\n $el.each((_idx, el_in_each) => {\n const $el_in_each = $(el_in_each)\n const $switch = $el_in_each.find(sele.switch)\n const $street_view_box = $el_in_each.find(sele.street_view)\n const street_view_box = $street_view_box[0]\n\n let dom_id = street_view_box.id\n if (isBlankStr(street_view_box.id)) {\n dom_id = DomIdGenerator.generateNewId()\n street_view_box.setAttribute(\"id\", dom_id)\n }\n\n $switch\n .on(\"click\", () => {\n // The mode switching won't be done immediately\n // So we subscribe to the event instead\n //\n // Don't use `setTimeout`\n SwitchMode.once(\"switch_mode:mode_switched\", () => {\n // Only create street view object when visible\n if (! $street_view_box.is(\":visible\")) { return }\n\n const existing_panorama = _retained_panoramas_per_dom_id[dom_id]\n\n const panorama_promise: Promise = Promise.resolve()\n .then(() => {\n if (existing_panorama != null) {\n return existing_panorama\n }\n\n return GoogleMaps_asyncLoad()\n .then((google_maps) => {\n // # `getAttribute` is used instead of `dataset` for better compatibility\n // # Both return string\n const lat_str = street_view_box.getAttribute(\"data-lat\")\n const lng_str = street_view_box.getAttribute(\"data-lng\")\n if (lat_str == null || lng_str == null) {\n Notifier.showError(I18n.t(\"js.app.street_view.errors.street_view_unavailable_at_this_location\"))\n throw RejectionReasons.FAILURE_CASE_HANDLED\n }\n\n const lat = parseFloat(lat_str)\n const lng = parseFloat(lng_str)\n const latlng_obj = new google_maps.LatLng(lat, lng)\n\n const sv = new google_maps.StreetViewService()\n\n return new Promise((resolve, reject) => {\n // Default is 50m\n sv.getPanorama({location: latlng_obj, radius: 50}, (data, status) => {\n const location_pano = (data == null || data.location == null) ? null : data.location.pano\n if (location_pano == null) {\n Notifier.showError(I18n.t(\"js.app.street_view.errors.street_view_unavailable_at_this_location\"))\n reject(RejectionReasons.FAILURE_CASE_HANDLED)\n return\n }\n\n if (status === google_maps.StreetViewStatus.OK) {\n const new_panorama = new google_maps.StreetViewPanorama(\n street_view_box,\n )\n new_panorama.setPano(location_pano)\n new_panorama.setPov({\n heading: 0,\n pitch: 0,\n })\n\n _retained_panoramas_per_dom_id[dom_id] = new_panorama\n\n // return new_panorama\n return new_panorama\n }\n else {\n Notifier.showError(I18n.t(\"js.app.street_view.errors.street_view_unavailable_at_this_location\"))\n reject(RejectionReasons.FAILURE_CASE_HANDLED)\n }\n })\n })\n })\n })\n\n panorama_promise.then((panorama) => {\n panorama.setVisible(true)\n })\n .catch((reason_or_error) => {\n if (reason_or_error === RejectionReasons.FAILURE_CASE_HANDLED) {\n return\n }\n\n captureException(reason_or_error)\n })\n .done()\n })\n })\n })\n}\n\n// # Call this function to avoid memory leak\n// # panorama objects are kept on initialization on purpose\n// # We need to remove those objects manually\n// # You have to call this function, otherwise there will be memory leak.\nconst removeAllPanoramas = () => {\n _retained_panoramas_per_dom_id = {}\n}\n\nconst _setAllPanoramaVisible = () => {\n Object.values(_retained_panoramas_per_dom_id).forEach((panorama) => {\n panorama.setVisible(true)\n })\n}\n\nconst onLoad = () => {\n SwitchMode.on(\"switch_mode:mode_switched\", () => {\n _setAllPanoramaVisible()\n })\n}\n\nexport default {\n init,\n removeAllPanoramas,\n onLoad,\n}\n","\nimport $ from \"jquery\"\nimport _once from \"lodash/once\"\nimport L from \"plugins/leaflet\"\nimport Promise from \"plugins/bluebird\"\n\nimport AssetsInfoStore from \"app/assets_info_store\"\n\nimport DomIdGenerator from \"app/utils/dom_id_generator\"\n\nimport LeafletMapTileLayer from \"app/map/leaflet/map_tile_layer\"\nimport LeafletSettings from \"app/map/leaflet/settings\"\n\nimport SwitchMode from \"components/widgets/switch_mode\"\n\n\ninterface Selector {\n main: string | JQuery\n switch: string\n map_container: string\n}\n\ninterface InputSelector {\n main?: string | JQuery\n switch?: string\n map_container?: string\n}\n\nconst default_selector = {\n main: \".cell--overseas_properties-shared--project_entry_pictures_and_map_browser--with-toggle\",\n switch: \".cell--overseas_properties-shared--project_entry_pictures_and_map_browser--with-toggle__switch--map\",\n map_container: \".cell--overseas_properties-shared--project_entry_pictures_and_map_browser--with-toggle__static-map-box\",\n}\n\n\nconst init = (selector?: InputSelector) => {\n const sele: Selector = Object.assign({}, default_selector, selector)\n\n\n const $el = $(sele.main)\n\n $el.find(sele.switch)\n .on(\"click\", _once(() => {\n const $map_container = $el.find(sele.map_container)\n const map_el = $map_container[0]\n\n const dom_id = DomIdGenerator.generateNewId()\n // Set new ID if applicable\n if (dom_id !== map_el.id) { map_el.setAttribute(\"id\", dom_id) }\n\n const lat = parseFloat($map_container.data(\"lat\"))\n const lng = parseFloat($map_container.data(\"lng\"))\n const center = L.latLng(lat, lng)\n\n // Generate ID for Leaflet map, if absent\n const map_canvas_dom_id = dom_id\n\n // If we add map tile layer AFTER creating map object\n // The location of tile layer is drifted on load\n // To workaround this we create tile layer first and\n // pass it on map object creation\n Promise.all([\n LeafletMapTileLayer.getNewTileLayerPromise(),\n AssetsInfoStore.fetch(\"map/markers/s-spacious.png\"),\n ])\n .spread((map_tile_layer, icon_image_data) => {\n const leaflet_map =\n LeafletSettings.get_use_baidu_maps() ?\n L.map(map_canvas_dom_id, {\n center: center,\n\n zoom: 17,\n minZoom: 17,\n maxZoom: 17,\n\n // Interaction Options\n dragging: false,\n touchZoom: false,\n scrollWheelZoom: false,\n doubleClickZoom: false,\n boxZoom: false,\n tap: false,\n\n // Control options\n zoomControl: false,\n attributionControl: false,\n\n layers: [\n map_tile_layer,\n ],\n })\n :\n L.map(map_canvas_dom_id, {\n center: center,\n\n zoom: 17,\n minZoom: 17,\n maxZoom: 17,\n\n // Interaction Options\n dragging: false,\n touchZoom: false,\n scrollWheelZoom: false,\n doubleClickZoom: false,\n boxZoom: false,\n tap: false,\n\n // Control options\n zoomControl: false,\n attributionControl: false,\n\n layers: [\n map_tile_layer,\n ],\n })\n\n const marker_icon = L.icon({\n iconUrl: icon_image_data.url,\n iconSize: [25, 29],\n })\n L.marker(center, {\n icon: marker_icon,\n }).addTo(leaflet_map)\n\n SwitchMode.on(\"switch_mode:mode_switched\", () => {\n if (! $map_container.is(\":visible\")) { return }\n\n leaflet_map.invalidateSize()\n leaflet_map.panTo(center, {\n animate: false,\n })\n })\n })\n .done()\n }))\n}\n\n\nexport default {\n init,\n}\n","\n// region JS Imports\n\n// region External Modules\nimport $ from \"jquery\"\nimport u from \"umbrellajs\"\n// endregion External Modules\n\n// Private Modules\n// Private Modules\n\n// region Public Components\nimport Carousel from \"apps/spacious_website/pages/overseas_properties/shared/components/project_entry_carousel\"\n// endregion Public Components\n\n// region Private Components\nimport GoogleStreetView from \"./google_street_view\"\nimport StaticMap from \"./static_map\"\n// endregion Private Components\n\n// endregion JS Imports\n\n\nconst CELL_CLASS_NAME = \"cell--overseas_properties-shared--project_entry_pictures_and_map_browser--with-toggle\"\nconst CELL_INITIALIZED_CLASS_NAME = `${CELL_CLASS_NAME}--js-spacious-initialized`\n\nconst init = () => {\n u(`.${CELL_CLASS_NAME}`).each((el) => {\n const $el = $(el)\n if (el.classList.contains(CELL_INITIALIZED_CLASS_NAME)) { return }\n el.classList.add(CELL_INITIALIZED_CLASS_NAME)\n\n StaticMap.init({\n main: $el,\n })\n\n GoogleStreetView.init({\n main: $el,\n })\n })\n\n Carousel.init()\n}\n\n\nexport default {\n init,\n}\n","\n// region JS Imports\n\n// region External Modules\nimport u from \"umbrellajs\"\n// endregion External Modules\n\n// region Public Components\nimport WithToggle from \"apps/spacious_website/pages/overseas_properties/shared/components/project_entry_pictures_and_map_browser/with_toggle/index\"\n\nimport {\n initAllMatchingElements as BuildingsShortlistButton_init,\n} from \"apps/spacious_website/components/buildings/shortlist_button/icon_only\"\n// endregion Public Components\n\n// endregion JS Imports\n\nconst CELL_CLASS_NAME = \"cell--overseas_properties_shared__project_entry_row--wide\"\nconst CELL_INITIALIZED_CLASS_NAME = `${CELL_CLASS_NAME}--js-spacious-initialized`\n\nconst IMAGE_CELL_CLASS_NAME = \"cell--overseas_properties_shared__project_entry_row--wide--listing-image\"\n\n\nconst init = () => {\n u(`.${CELL_CLASS_NAME}`).each((el) => {\n const $el = u(el)\n\n if (el.classList.contains(CELL_INITIALIZED_CLASS_NAME)) { return }\n el.classList.add(CELL_INITIALIZED_CLASS_NAME)\n\n $el.on(\"click\", (e) => {\n const $this = u(e.target as HTMLElement)\n\n // If user clicks on a non-link, go to full listing page\n if ($this.closest(`.${IMAGE_CELL_CLASS_NAME}`).length === 0 && $this.closest(\"a\").length === 0){\n window.open($el.data(\"overseas-properties-project-page-path\"), \"_blank\")\n }\n })\n })\n\n WithToggle.init()\n BuildingsShortlistButton_init().done()\n}\n\n\nexport default {init}\n"],"names":["init","ImageLazyLoading","Carousel","RejectionReasons","_retained_panoramas_per_dom_id","default_selector","selector","sele","DataRetriever","$","_idx","el_in_each","$el_in_each","$switch","$street_view_box","street_view_box","dom_id","isBlankStr","DomIdGenerator","SwitchMode","existing_panorama","Promise","GoogleMaps_asyncLoad","google_maps","lat_str","lng_str","Notifier","I18n","lat","lng","latlng_obj","sv","resolve","reject","data","status","location_pano","new_panorama","panorama","reason_or_error","captureException","removeAllPanoramas","_setAllPanoramaVisible","onLoad","GoogleStreetView","$el","_once","$map_container","map_el","center","L","map_canvas_dom_id","LeafletMapTileLayer","AssetsInfoStore","map_tile_layer","icon_image_data","leaflet_map","LeafletSettings","marker_icon","StaticMap","CELL_CLASS_NAME","CELL_INITIALIZED_CLASS_NAME","u","el","WithToggle","IMAGE_CELL_CLASS_NAME","e","$this","BuildingsShortlistButton_init","NewDevelopmentBuildingsRow"],"mappings":"gqBAkBA,SAASA,GAAO,CACGC,EAAA,4BAA4B,OAAO,CACtD,CAEA,MAAeC,EAAA,CACbF,KAAAA,CACF,ECJMG,EAAmB,CACvB,qBAAsB,sBACxB,EAGA,IAAIC,EAAiC,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