Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map size is saved between page changes #792

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/assets/javascripts/result/result-map.js
Expand Up @@ -13,6 +13,9 @@ function (markerDataLoader, googleMaps, plugins, mapRenderer, MapSizeControl) {
// Whether the Google Map APIs and plugins have successfully loaded.
var _mapStackReady = false;

//Whether the map is at its max size or not
var _atMaxSize;

function init() {
// Load map marker data from DOM.
var markerData = markerDataLoader.loadData('#map-locations-data');
Expand All @@ -33,6 +36,16 @@ function (markerDataLoader, googleMaps, plugins, mapRenderer, MapSizeControl) {
mapRenderer.renderMapStack();
var mapSizeControl = MapSizeControl.create('#map-size-control');
mapSizeControl.addEventListener('click', _mapSizeControlClicked);
_setMapSize();
}

function _setMapSize() {
if (typeof(sessionStorage) !== 'undefined' && sessionStorage.atMaxSize !== undefined) {
_atMaxSize = JSON.parse(sessionStorage.atMaxSize) || false;
if (_atMaxSize !== false) {
document.getElementById('map-size-control').click();
}
}
}

function _mapSizeControlClicked() {
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/util/map/MapSizeControl.js
Expand Up @@ -39,6 +39,9 @@ function (eventObserver) {
// Map size control was clicked. This control toggles the large & small map.
function _buttonElmClicked(evt) {
_atMaxSize = !_atMaxSize;
if (typeof(sessionStorage) !== 'undefined') {
sessionStorage.atMaxSize = JSON.stringify(_atMaxSize) || false;
}
_buttonElm.innerHTML = _atMaxSize ? LARGER_MAP_TEXT : SMALLER_MAP_TEXT;
_instance.dispatchEvent(_events.CLICK, {target:_instance});
evt.preventDefault();
Expand Down