Skip to content

Commit

Permalink
Merge pull request #492 from bmlt-enabled/Add-map-menu-to-associated-…
Browse files Browse the repository at this point in the history
…maps

Add-map-menu-to-associated-maps
  • Loading branch information
otrok7 authored Sep 15, 2024
2 parents e0dc4ec + 6bd696c commit 48e87c9
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 34 deletions.
2 changes: 1 addition & 1 deletion crouton.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Description: A tabbed based display for showing meeting information.
Author: bmlt-enabled
Author URI: https://bmlt.app
Version: 3.19.5
Version: 3.20.0
*/
/* Disallow direct access to the plugin file */
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
Expand Down
24 changes: 12 additions & 12 deletions croutonjs/meetingMap/css/meeting_map.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
div.bmlt_map_container_div
div.bmlt_map_container_div
{
width: 100%;
margin:auto;
Expand All @@ -12,7 +12,7 @@ div.bmlt_search_map_div {
margin:auto;
left:0;
top:0;
height:100%;
height:100%;
z-index: 10;
}
div.bmlt_map_container_div .bmlt_map_throbber_div
Expand Down Expand Up @@ -86,7 +86,7 @@ div.bmlt_map_container_div div.bmlt_search_map_div
.accordion h4 {
padding-top: .25em;
font-size: 16px;
font-weight: bold;
font-weight: bold;
margin-top: 8px;
margin-bottom: 8px;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ div.bmlt_map_container_div div.bmlt_search_map_div
padding-bottom: 2px;
font-size:12px;
border:0;
}
}
input[name='panel']:checked ~ .marker_div_meeting {
height:auto;
overflow: auto !important;
Expand All @@ -178,7 +178,7 @@ input[name='panel']:checked ~ .marker_div_meeting {
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #2d5c88 !important; border-radius: 20px !important;
box-shadow: 0 1px 4px rgba(0,0,0,0.3);

}
.onoffswitch-inner {
display: block !important; width: 200% !important; margin-left: -100% !important;
Expand All @@ -196,13 +196,13 @@ input[name='panel']:checked ~ .marker_div_meeting {
position: absolute; top: 0; bottom: 0;
right: 136px !important;
border: 2px solid #2d5c88 !important; border-radius: 20px;
transition: all 0.3s ease-in 0s;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0 !important;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px !important;
right: 0px !important;
}
.mapSearchText {
background-color: #fff !important;
Expand Down Expand Up @@ -234,7 +234,7 @@ div.bmlt_map_container_div button {
}
/* The Modal (background) */
.modal {
font-size: 14px !important; color: black; font-family: Roboto, Arial, sans-serif !important;
font-size: 14px !important; color: black; font-family: Roboto, Arial, sans-serif !important;
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1000; /* Sit on top */
Expand Down Expand Up @@ -367,12 +367,12 @@ div.bmlt_map_container_div button {
font-size: 14px;
font-weight: bold;
margin-top: 0;
line-height: 1.2;
line-height: 1.2;
}
.modal_times {
font-size: 14px;
font-weight: bold;
color: #DB4865;
color: #DB4865;
}
#table_content .meeting-header{
background-color: #93c3cd !important;
Expand Down Expand Up @@ -510,7 +510,7 @@ background-color: #EEEEEE;
.gm-style .gm-style-iw-c {
padding: 0px;
}
#bmlt-map button.gm-ui-hover-effect {
#bmlt-map button.gm-ui-hover-effect, #byfield_embeddedMapPage .gm-ui-hover-effect {
right: 0px;
z-index: 999;
width: 20px !important;
Expand All @@ -521,6 +521,6 @@ background-color: #EEEEEE;
bottom: 13px;
right: 13px;
}
#bmlt-map .gm-style-iw-chr {
#bmlt-map .gm-style-iw-chr, #byfield_embeddedMapPage .gm-style-iw-chr {
height: 0 !important;
}
46 changes: 33 additions & 13 deletions croutonjs/meetingMap/js/meeting_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ function MeetingMap(inConfig) {
}
if (config.map_search.zoom) {
config.zoom = config.map_search.zoom;
}
}
}
let loc = {latitude: config.lat, longitude: config.lng, zoom: config.zoom};
if (handlebarMapOptions) loc = {latitude: handlebarMapOptions.lat, longitude: handlebarMapOptions.lng};
if (handlebarMapOptions) loc = {latitude: handlebarMapOptions.lat, longitude: handlebarMapOptions.lng};
if (gDelegate.createMap(inDiv, loc)) {
gDelegate.addListener('zoomend', function (ev) {
if (shouldRedrawMarkers() && gAllMeetings) {
Expand All @@ -79,7 +79,10 @@ function MeetingMap(inConfig) {
menuContext.imageDir = config.BMLTPlugin_images;
gDelegate.addControl(createNext24Toggle(), 'topleft');
gDelegate.addControl(createMenuButton(menuContext), 'topright', cb);
};
}else {
menuContext = {imageDir: config.BMLTPlugin_images, config: config, dropdownData:false};
gDelegate.addControl(createMenuButton(menuContext), 'topright', cb);
}
}
};
};
Expand Down Expand Up @@ -148,6 +151,7 @@ function MeetingMap(inConfig) {
controlDiv.innerHTML = template(menuContext);
controlDiv.querySelector("#nearbyMeetings").addEventListener('click', function (e) {
retrieveGeolocation().then(position => {
filterVisible(false);
gDelegate.setViewToPosition(position, filterMeetingsAndBounds);
}).catch(error => {
console.error(error.message);
Expand All @@ -157,14 +161,19 @@ function MeetingMap(inConfig) {
});

controlDiv.querySelector("#lookupLocation").addEventListener('click', showGeocodingDialog);
controlDiv.querySelector("#filterMeetings").addEventListener('click', showFilterDialog);
controlDiv.querySelector("#showAsTable").addEventListener('click', showListView);
if (menuContext && menuContext.dropdownData) {
controlDiv.querySelector("#filterMeetings").addEventListener('click', showFilterDialog);
controlDiv.querySelector("#showAsTable").addEventListener('click', showListView);
} else {
controlDiv.querySelector("#filterTable").addEventListener('click', toggleVisible);
}
controlDiv.querySelector("#fullscreenMode").addEventListener('click', toggleFullscreen);
controlDiv.querySelector("#map-menu-button").addEventListener('click', function (e) {
let dropdownContent = document.getElementById("map-menu-dropdown");
if (dropdownContent.style.display == "inline-block")
if (dropdownContent.style.display == "inline-block") {
dropdownContent.style.display = "none";
else
filterVisible(false);
} else
dropdownContent.style.display = "inline-block";
});
[...controlDiv.getElementsByClassName('modal-close')].forEach((elem)=>elem.addEventListener('click', (e)=>closeModalWindow(e.target)));
Expand Down Expand Up @@ -395,14 +404,18 @@ function MeetingMap(inConfig) {
jQuery("#table_page").addClass("hide");
jQuery("#bmlt-map").css("display", "block");
}
function resetVisibleThenFilterMeetingsAndBounds(bounds) {
filterVisible(false);
filterMeetingsAndBounds(bounds);
}
function lookupLocation(fullscreen) {
if (document.getElementById('goto-text').value != '') {
if (fullscreen) {
gDelegate.addListener('idle', function () {
gDelegate.callGeocoder(document.getElementById('goto-text').value, filterMeetingsAndBounds);
gDelegate.callGeocoder(document.getElementById('goto-text').value, resetVisibleThenFilterMeetingsAndBounds);
}, true);
} else {
gDelegate.callGeocoder(document.getElementById('goto-text').value, filterMeetingsAndBounds);
gDelegate.callGeocoder(document.getElementById('goto-text').value, resetVisibleThenFilterMeetingsAndBounds);
}
} else {
alert("");
Expand Down Expand Up @@ -454,12 +467,12 @@ function MeetingMap(inConfig) {
? filtered.map((m)=>[m])
: mapOverlappingMarkersInCity(filtered);

if (useMarkerCluster()) gDelegate.createClusterLayer();
if (useMarkerCluster()) gDelegate.createClusterLayer();
// Draw the meeting markers.
overlap_map.forEach(function (marker) {
createMapMarker(marker);
});
gDelegate.addClusterLayer();
gDelegate.addClusterLayer();
if (expand) {
const lat_lngs = filtered.reduce(function(a,m) {a.push([m.latitude, m.longitude]); return a;},[]);
gDelegate.fitBounds(lat_lngs);
Expand Down Expand Up @@ -564,20 +577,27 @@ function MeetingMap(inConfig) {
(meetings.length > 1),
marker_html, null ,meetings.map((m)=>parseInt(m.id_bigint)));
};
var listOnlyVisible = false;
function filterBounds(bounds) {
return gAllMeetings.filter((meeting) => gDelegate.contains(bounds, meeting.latitude, meeting.longitude));
}
function filterVisible(on=true) {
if (on===listOnlyVisible) return;
let mtgs = on ? filterBounds(gDelegate.getBounds()) : gAllMeetings;
let visible = mtgs.map((m)=>m.id_bigint);
jQuery(".bmlt-data-row").each(function(index,row) {
row.dataset.visible = (visible.includes(row.id.split('-').pop())) ? '1' : '0';
});
jQuery("#byday").removeClass('hide');
jQuery("#filter-dropdown-visibile").val('a-1');
jQuery("#filter-dropdown-visibile").val(on?'a-1':'');
fitDuringFilter = false;
crouton.doFilters();
crouton.simulateFilterDropdown();
fitDuringFilter = true;
jQuery("#filteringByVisibility").html(on?'✔':'');
listOnlyVisible = on;
}
function toggleVisible() {
filterVisible(!listOnlyVisible);
}
function filterBounds(bounds) {
var ret = gAllMeetings.filter((meeting) =>
Expand Down
13 changes: 11 additions & 2 deletions croutonjs/src/js/crouton-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ Crouton.prototype.render = function(doMeetingMap = false) {
{placeholder: self.localization.getWord('common_needs'), pointer: 'Formats', elementId: "filter-dropdown-commonneeds",
uniqueData: (meetings) => getUniqueFormatsOfType(meetings, 'FC3'),
objectPointer: (f) => convertToPunyCode(f.name), optionName: (f)=>f.name});
if (doMeetingMap) self.dropdownData.push(
if (doMeetingMap || self.config.show_map || self.config.map_page) self.dropdownData.push(
{placeholder: '', pointer: 'visible', elementId: "filter-dropdown-visibile",
uniqueData: (meetings) => self.getUsedVisibility(meetings),
objectPointer: (s)=>s.value, optionName: (s)=>s.name});
Expand Down Expand Up @@ -1675,7 +1675,7 @@ crouton_Handlebars.registerHelper('hasBMLT2ics', function() {
return crouton.config['bmlt2ics'].length>0;});
crouton_Handlebars.registerHelper('BMLT2ics', function() {return crouton.config['bmlt2ics'];});
crouton_Handlebars.registerPartial('icsButton',
'<a href="{{BMLT2ics}}?meeting-id={{id_bigint}}" download="{{meeting_name}}.ics" class="bootstrap-bmlt" ><div class="btn btn-primary bmlt-sharebutton"><span class="glyphicon glyphicon-download-alt"></span> {{getWord "bmlt2ics"}}</div></a>');
'<a href="{{BMLT2ics}}?meeting-id={{id_bigint}}" download="{{meeting_name}}.ics" id="share-button" class="btn btn-primary btn-xs" ><span class="glyphicon glyphicon-download-alt"></span> {{getWord "bmlt2ics"}}</a>');
crouton_Handlebars.registerPartial('offerIcsButton',
"{{#if (hasBMLT2ics)}}{{> icsButton}}<br/>{{/if}}");
function convertToPunyCode(str) {
Expand Down Expand Up @@ -1730,6 +1730,15 @@ Crouton.prototype.renderMeetingCount = function() {
self.updateMeetingCount()
});
}
Crouton.prototype.simulateFilterDropdown = function() {
self = this;
jQuery('.bmlt-page:not(#byfield_embeddedMapPage)').each(function () {
self.hidePage(this);
});
self.filteredPage();
if (!self.filtering && !self.config.map_page)
self.showView(self.config['view_by'] === 'byday' ? 'byday' : 'day');
}
Crouton.prototype.getAdjustedDateTime = function(meeting_day, meeting_time, meeting_time_zone) {
var timeZoneAware = this.config['auto_tz_adjust'] === true || this.config['auto_tz_adjust'] === "true";
var meeting_date_time_obj;
Expand Down
Loading

0 comments on commit 48e87c9

Please sign in to comment.