Skip to content

Commit

Permalink
move renderPortalDetails call to marker mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
le-jeu committed Feb 14, 2021
1 parent 57d05c3 commit 4a5b70b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
14 changes: 7 additions & 7 deletions core/code/map_data_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ window.Render.prototype.endRenderPass = function() {
this.isRendering = false;

// re-select the selected portal, to re-render the side-bar. ensures that any data calculated from the map data is up to date
if (selectedPortal) {
renderPortalDetails (selectedPortal);
}
// if (selectedPortal) {
// renderPortalDetails (selectedPortal);
// }
}

window.Render.prototype.bringPortalsToFront = function() {
Expand Down Expand Up @@ -364,10 +364,10 @@ window.Render.prototype.createPortalEntity = function(ent, details) {
}

// (re-)select the portal, to refresh the sidebar on any changes
if (data.guid == selectedPortal) {
log.log('portal guid '+data.guid+' is the selected portal - re-rendering portal details');
renderPortalDetails (selectedPortal);
}
// if (data.guid == selectedPortal) {
// log.log('portal guid '+data.guid+' is the selected portal - re-rendering portal details');
// renderPortalDetails (selectedPortal);
// }

window.ornaments.addPortal(marker);

Expand Down
6 changes: 3 additions & 3 deletions core/code/portal_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ var handleResponse = function(deferred, guid, data, success) {

//FIXME..? better way of handling sidebar refreshing...

if (guid == selectedPortal) {
renderPortalDetails(guid);
}
// if (guid == selectedPortal) {
// renderPortalDetails(guid);
// }

deferred.resolve(portal.options.data);
window.runHooks ('portalDetailLoaded', {guid:guid, success:success, details:portal.options.data, ent:ent});
Expand Down
4 changes: 2 additions & 2 deletions core/code/portal_detail_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ window.renderPortalDetails = function(guid) {

var portal = window.portals[guid];
var data = portal.options.data;
var details = portalDetail.get(guid);
var details = portal.hasFullDetails() ? portal.getDetails() : null;
var historyDetails = getPortalHistoryDetails(data);

// details and data can get out of sync. if we have details, construct a matching 'data'
Expand Down Expand Up @@ -224,7 +224,7 @@ window.getPortalMiscDetails = function(guid,d) {

if (d.artifactBrief && d.artifactBrief.target && Object.keys(d.artifactBrief.target).length > 0) {
var targets = Object.keys(d.artifactBrief.target);
//currently (2015-07-10) we no longer know the team each target portal is for - so we'll just show the artifact type(s)
//currently (2015-07-10) we no longer know the team each target portal is for - so we'll just show the artifact type(s)
randDetails += '<div id="artifact_target">Target portal: '+targets.map(function(x) { return x.capitalize(); }).join(', ')+'</div>';
}

Expand Down
30 changes: 24 additions & 6 deletions core/code/portal_marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ var portalBaseStyle = {

// portal hooks
function handler_portal_click (e) {
window.renderPortalDetails(e.target.options.guid);
e.target.select(true);
}
function handler_portal_dblclick (e) {
window.renderPortalDetails(e.target.options.guid);
e.target.select(true);
window.map.setView(e.target.getLatLng(), DEFAULT_ZOOM);
}
function handler_portal_contextmenu (e) {
window.renderPortalDetails(e.target.options.guid);
e.target.select(true);
if (window.isSmartphone()) {
window.show('info');
} else if (!$('#scrollwrapper').is(':visible')) {
Expand All @@ -38,8 +38,9 @@ var PortalMarker = L.CircleMarker.extend({
},
updateDetails: function(details) {
// portal has been moved
if (this._details.latE6 !== details.latE6 || this._details.lngE6 !== details.lngE6)
this.setLatLng(L.latLng(details.latE6/1E6, details.lngE6/1E6));
if (this.details)
if (this._details.latE6 !== details.latE6 || this._details.lngE6 !== details.lngE6)
this.setLatLng(L.latLng(details.latE6/1E6, details.lngE6/1E6));

// xxx: handle permanent data
this._details = details;
Expand All @@ -61,14 +62,31 @@ var PortalMarker = L.CircleMarker.extend({
};
L.setOptions(this, dataOptions);

if (this._selected) {
this.renderDetails();
}

this.reset();
},
renderDetails() {
if (!this._rendering) {
this._rendering = true;
renderPortalDetails(this._details.guid);
this._rendering = false;
}
},
getDetails: function () {
return this._details;
},
hasFullDetails: function () {
return !!this._details.mods
},
select: function (selected) {
if (selected) {
this.renderDetails();
}
return this.reset(selected);
},
reset: function (selected) {
var styleOptions = this._style();
this.setStyle(styleOptions);
Expand Down Expand Up @@ -136,7 +154,7 @@ window.createMarker = function(latlng, data) {


window.setMarkerStyle = function(marker, selected) {
marker.reset(selected);
marker.select(selected);
}


Expand Down

0 comments on commit 4a5b70b

Please sign in to comment.