Skip to content

Commit

Permalink
solve some timing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
otrok7 committed Dec 7, 2023
1 parent 345be39 commit aa0f321
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
15 changes: 14 additions & 1 deletion croutonjs/meetingMap/js/gmapsDelegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function createMarker ( inCoords, ///< The long/lat for the marker.
});
gAllMarkers[gAllMarkers.length] = {ids: inIds, marker: marker};
};
function addControl(div,pos) {
function addControl(div,pos,cb) {
var p = pos;
switch(pos) {
case 'topright':
Expand All @@ -288,6 +288,19 @@ function addControl(div,pos) {
break;
}
div.index = 1;
if (cb) {
const observer = new MutationObserver(function (records) {
records.forEach(record => {
record.addedNodes.forEach(n => {
if (n === div) {
observer.disconnect();
cb();
}
});
})
});
observer.observe(document, {childList: true, subtree: true});
}
gMainMap.controls[p].push(div);
}
/************************************************************************************//**
Expand Down
14 changes: 7 additions & 7 deletions croutonjs/meetingMap/js/meeting_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function MeetingMap(inConfig) {
* \brief Load the map and set it up. *
****************************************************************************************/

function loadMap(inDiv, menuContext, handlebarMapOptions=null) {
function loadMap(inDiv, menuContext, handlebarMapOptions=null,cb=null) {
if (!gDelegate.isApiLoaded()) {
preloadApiLoadedCallback(loadMap, [inDiv, menuContext, handlebarMapOptions]);
preloadApiLoadedCallback(loadMap, [inDiv, menuContext, handlebarMapOptions, cb]);
gDelegate.loadApi();
return;
}
Expand All @@ -54,12 +54,12 @@ function MeetingMap(inConfig) {
}
}, false);
if (config.map_search) {
gDelegate.addControl(createSearchButton(), 'topleft');
gDelegate.addControl(createSearchButton(), 'topleft', cb);
}
else if (menuContext) {
menuContext.imageDir = config.BMLTPlugin_images;
//gDelegate.addControl(createFilterMeetingsToggle(), 'topleft');
gDelegate.addControl(createMenuButton(menuContext), 'topright');
gDelegate.addControl(createMenuButton(menuContext), 'topright', cb);
};
}
};
Expand Down Expand Up @@ -124,14 +124,14 @@ function MeetingMap(inConfig) {
return controlDiv;
}

function loadFromCrouton(inDiv_id, meetings_responseObject, menuContext = null, handlebarMapOptions = null) {
function loadFromCrouton(inDiv_id, meetings_responseObject, menuContext = null, handlebarMapOptions = null, callback) {
if (!gDelegate.isApiLoaded()) {
preloadApiLoadedCallback(loadFromCrouton, [inDiv_id, meetings_responseObject, menuContext, handlebarMapOptions]);
preloadApiLoadedCallback(loadFromCrouton, [inDiv_id, meetings_responseObject, menuContext, handlebarMapOptions, callback]);
gDelegate.loadApi();
return;
}
let inDiv = document.getElementById(inDiv_id);
loadMap(inDiv, menuContext, handlebarMapOptions);
loadMap(inDiv, menuContext, handlebarMapOptions,callback);
loadAllMeetings(meetings_responseObject, true);
};
var fitDuringFilter = true;
Expand Down
15 changes: 14 additions & 1 deletion croutonjs/meetingMap/js/osmDelegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function openMarker(id) {
jQuery(".bmlt-data-row > td").removeClass("rowHighlight");
jQuery("#meeting-data-row-" + id + " > td").addClass("rowHighlight");
}
function addControl(div,pos) {
function addControl(div,pos,cb) {
var ControlClass = L.Control.extend({
onAdd: function (map) {
return div;
Expand All @@ -208,6 +208,19 @@ function addControl(div,pos) {
var controlConstructor = function(opts) {
return new ControlClass(opts);
}
if (cb) {
const observer = new MutationObserver(function (records) {
records.forEach(record => {
record.addedNodes.forEach(n => {
if (n === div) {
observer.disconnect();
cb();
}
});
})
});
observer.observe(document, {childList: true, subtree: true});
}
controlConstructor({ position: pos }).addTo(gMainMap);
}
// Low level GeoCoding
Expand Down
5 changes: 2 additions & 3 deletions croutonjs/src/js/crouton-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ function Crouton(config) {
crouton_Handlebars.registerPartial('meetings', hbs_Crouton.templates['meetings']);
crouton_Handlebars.registerPartial('bydays', hbs_Crouton.templates['byday']);
crouton_Handlebars.registerPartial('formatPopup', hbs_Crouton.templates['formatPopup']);
croutonMap.initialize(self.createBmltMapElement(),self.meetingData,context);
callback && callback();
croutonMap.initialize(self.createBmltMapElement(),self.meetingData,context,null,callback);
}
self.getCurrentLocation = function(callback) {
if (navigator.geolocation) {
Expand Down Expand Up @@ -1120,7 +1119,7 @@ Crouton.prototype.render = function(doMeetingMap = false) {
objectPointer: (a) => convertToPunyCode(a.name), optionName: (a)=>a.name});
if (self.config.has_locations) self.dropdownData.push(
{placeholder: self.localization.getWord('locations'), pointer: 'Locations', elementId: "filter-dropdown-locations",
uniqueData: (meetings) => getUniqueValuesOfKey(meetings, 'location_text').sort(),
uniqueData: (meetings) => getUniqueValuesOfKey(meetings, 'location_text').map((s)=>s.replace(/(<([^>]+)>)/gi, "")).sort(),
objectPointer: convertToPunyCode, optionName: (s)=>s});
if (self.config.has_sub_province) self.dropdownData.push(
{placeholder: self.localization.getWord('counties'), pointer: 'Counties', elementId: "filter-dropdown-sub_province",
Expand Down

0 comments on commit aa0f321

Please sign in to comment.