Skip to content

Commit

Permalink
chore: Remove unused Google API integrations (#1852)
Browse files Browse the repository at this point in the history
* feat(Test.Support.EnvHelpers): change log level

* chore: remove unused variable

* remove unused requires_location_service? variable

* chore(LocationService): remove Google-related code

* chore(TripPlan.Geocode): rename modules for clarity

* fix(DotcomWeb.PlacesController): add more relevant error

* chore: remove unused footer template

* chore: remove other unused/unneeded variables

* chore: remove old stop page backend template

* chore: remove unused GLX-related feature

* chore: remove other unused files from old stop page

* rename stop page files
  • Loading branch information
thecristen authored Jan 18, 2024
1 parent be60ade commit 25e9107
Show file tree
Hide file tree
Showing 185 changed files with 1,155 additions and 19,384 deletions.
84 changes: 0 additions & 84 deletions assets/css/_glx-open.scss

This file was deleted.

5 changes: 0 additions & 5 deletions assets/css/_google-maps.scss

This file was deleted.

4 changes: 1 addition & 3 deletions assets/css/_map.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// # Map module

// Used for rendering a static/dynamic Google Map. The dynamic map will be used
// if JavaScript is available. Otherwise, the static map will be displayed.
// When printing, the static map will always be displayed.
// Used for rendering a static/dynamic Map, depending on route mode.

// ## Flags

Expand Down
6 changes: 0 additions & 6 deletions assets/css/_schedule-line.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
margin-left: calc(#{$base-spacing} / 2);
}

.m-schedule-line__map-static {
@include media-breakpoint-up(lg) {
height: 600px;
}
}

.m-schedule-line__teaser {
@include media-breakpoint-up(md) {
margin-top: $base-spacing * 2;
Expand Down
30 changes: 0 additions & 30 deletions assets/css/_schedule.scss
Original file line number Diff line number Diff line change
Expand Up @@ -161,36 +161,6 @@
margin-bottom: $base-spacing;
}

.line-map {
width: 100%;

// the size of the map varies at different breakpoints, these heights make is a square
@include media-breakpoint-only(xxl) {
height: 356px;
}

@include media-breakpoint-only(lg) {
height: 284px;
}

@include media-breakpoint-only(md) {
height: 222px;
}

@include media-breakpoint-only(sm) {
height: 300px;
}

@include media-breakpoint-only(xs) {
height: 256px;
}

// this hides the close "x" from the info window. This is because we use it like a tooltip (it closes on mouseout)
.gm-style-iw + div {
display: none;
}
}

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
///// DATE AND DIRECTION FILTER BUTTONS
Expand Down
6 changes: 0 additions & 6 deletions assets/css/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,6 @@
color: $gray-lighter;
}

.c-search-result__google {
display: flex;
justify-content: flex-end;
padding: calc(#{$base-spacing} / 2);
}

.c-search__error {
background: $form-error-message;
border-radius: $border-radius;
Expand Down
2 changes: 0 additions & 2 deletions assets/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
@import 'photo-gallery';
@import 'layout-cms';
@import 'embedded-media';
@import 'google-maps';
@import 'checkbox';
@import 'radio';
@import 'grid-button';
Expand Down Expand Up @@ -142,7 +141,6 @@
@import 'event-overlay';
@import 'event-details';
@import 'global-navigation';
@import 'glx-open';

////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
Expand Down
18 changes: 0 additions & 18 deletions assets/js/address-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,13 @@ export function constructUrl(place, input) {
return location_url + query_str;
}

export function addLocationChangedEventListener(autocomplete, input) {
function onPlaceChanged() {
const locationUrl = constructUrl(autocomplete.getPlace(), input);
window.location.href = encodeURI(locationUrl);
}
google.maps.event.addListener(autocomplete, "place_changed", onPlaceChanged);
}

function geolocationCallback(ev, location) {
const path = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
const qs = `?latitude=${location.coords.latitude}&longitude=${location.coords.longitude}`;
window.location.href = encodeURI(path + qs + "#address-search-input");
}

export default function() {
function addLocationChangeCallback(ev, autocomplete) {
addLocationChangedEventListener(autocomplete, ev.target);
}

function setupLocationInput() {
const transitNearMeInput = document.getElementById("address-search-input");

Expand All @@ -83,12 +71,6 @@ export default function() {
document.addEventListener("turbolinks:load", setupLocationInput, {
passive: true
});
$(document).on(
"autocomplete:added",
"#address-search-input",
// eslint-disable-next-line no-use-before-define
addLocationChangeCallback
);
$(document).on(
"geolocation:complete",
"#address-search-input",
Expand Down
8 changes: 4 additions & 4 deletions assets/js/algolia-autocomplete-with-geo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AlgoliaAutocomplete from "./algolia-autocomplete";
import { TEMPLATES } from "./algolia-result";
import * as GoogleMapsHelpers from "./google-maps-helpers";
import { autocomplete, lookupPlace, reverseGeocode } from "./maps-helpers";
// eslint-disable-next-line
import * as QueryHelpers from "../ts/helpers/query";
import geolocationPromise from "./geolocation-promise";
Expand Down Expand Up @@ -83,7 +83,7 @@ class AlgoliaAutocompleteWithGeo extends AlgoliaAutocomplete {

_locationSource(index) {
return (input, callback) =>
GoogleMapsHelpers.autocomplete({
autocomplete({
input,
hitLimit: this._locationParams.hitLimit
}).then(results => this._onResults(callback, index, results));
Expand Down Expand Up @@ -162,7 +162,7 @@ class AlgoliaAutocompleteWithGeo extends AlgoliaAutocomplete {
}

_doLocationSearch(address) {
return GoogleMapsHelpers.lookupPlace(address).then(result =>
return lookupPlace(address).then(result =>
this._onLocationSearchResult(result)
);
}
Expand All @@ -172,7 +172,7 @@ class AlgoliaAutocompleteWithGeo extends AlgoliaAutocomplete {
}

onUseMyLocationResults({ coords: { latitude, longitude } }) {
return GoogleMapsHelpers.reverseGeocode(
return reverseGeocode(
parseFloat(latitude),
parseFloat(longitude)
).then(result => this.onReverseGeocodeResults(result, latitude, longitude));
Expand Down
64 changes: 17 additions & 47 deletions assets/js/algolia-embedded-search.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { doWhenGoogleMapsIsReady } from "./google-maps-loaded";
import Algolia from "./algolia-search";
import * as AlgoliaResult from "./algolia-result";
import AlgoliaAutocompleteWithGeo from "./algolia-autocomplete-with-geo";
import AlgoliaAutocomplete from "./algolia-autocomplete";
// eslint-disable-next-line import/no-unresolved
import * as QueryHelpers from "../ts/helpers/query";

Expand All @@ -18,14 +16,12 @@ export class AlgoliaEmbeddedSearch {

constructor({
pageId,
withGoogle,
selectors,
params,
indices,
locationParams,
templates = AlgoliaResult.TEMPLATES
}) {
this.withGoogle = withGoogle;
this.pageId = pageId;
this.selectors = selectors;
this.params = params;
Expand Down Expand Up @@ -53,27 +49,15 @@ export class AlgoliaEmbeddedSearch {
init() {
this.input.value = "";
this.controller = new Algolia(this.indices, this.params);
this.autocomplete = this.withGoogle
? new AlgoliaAutocompleteWithGeo({
id: this.pageId,
selectors: this.selectors,
indices: Object.keys(this.indices),
locationParams: this.locationParams,
popular: [],
templates: this.#templates,
parent: this
})
: new AlgoliaAutocomplete({
id: this.pageId,
selectors: this.selectors,
indices: Object.keys(this.indices),
locationParams: this.locationParams,
popular: [],
templates: this.#templates,
parent: this
});
this.autocomplete.renderFooterTemplate =
AlgoliaEmbeddedSearch.renderFooterTemplate;
this.autocomplete = new AlgoliaAutocompleteWithGeo({
id: this.pageId,
selectors: this.selectors,
indices: Object.keys(this.indices),
locationParams: this.locationParams,
popular: [],
templates: this.#templates,
parent: this
});
this.addEventListeners();
this.controller.addWidget(this.autocomplete);
}
Expand Down Expand Up @@ -112,15 +96,6 @@ export class AlgoliaEmbeddedSearch {
query: this.input.value
};
}

static renderFooterTemplate(indexName) {
if (indexName === "locations" && AlgoliaResult.autocompleteByGoogle()) {
return AlgoliaResult.TEMPLATES.poweredByGoogleLogo.render({
logo: document.getElementById("powered-by-google-logo").innerHTML
});
}
return null;
}
}

export const initWithoutGoogle = () => {
Expand All @@ -132,8 +107,7 @@ export const initWithoutGoogle = () => {
pageId,
selectors,
params,
indices,
withGoogle: false
indices
});
});
};
Expand All @@ -142,17 +116,13 @@ export const init = () => {
PAGE_IDS.forEach(pageId => {
const { selectors, params, indices } = buildOptions(pageId);
document.addEventListener("turbolinks:load", () => {
doWhenGoogleMapsIsReady(
() =>
new AlgoliaEmbeddedSearch({
pageId,
selectors,
params,
indices,
templates: AlgoliaResult.TEMPLATES_ALT_USE_MY_LOCATION,
withGoogle: true
})
);
new AlgoliaEmbeddedSearch({
pageId,
selectors,
params,
indices,
templates: AlgoliaResult.TEMPLATES_ALT_USE_MY_LOCATION
});
});
});
};
Loading

0 comments on commit 25e9107

Please sign in to comment.