on the portalAdded event, include a previousDetails parameter when we're changing an existing portals data

for #504
This commit is contained in:
Jon Atkins 2013-09-03 04:52:10 +01:00
parent fdf690fd5c
commit d976a8c033

View File

@ -217,6 +217,8 @@ window.Render.prototype.createEntity = function(ent) {
window.Render.prototype.createPortalEntity = function(ent) { window.Render.prototype.createPortalEntity = function(ent) {
this.seenPortalsGuid[ent[0]] = true; // flag we've seen it this.seenPortalsGuid[ent[0]] = true; // flag we've seen it
var previousDetails = undefined;
// check if entity already exists // check if entity already exists
if (ent[0] in window.portals) { if (ent[0] in window.portals) {
// yes. now check to see if the entity data we have is newer than that in place // yes. now check to see if the entity data we have is newer than that in place
@ -228,6 +230,10 @@ window.Render.prototype.createPortalEntity = function(ent) {
// (e.g. level changed, so size is different, or stats changed so highlighter is different) // (e.g. level changed, so size is different, or stats changed so highlighter is different)
// so to keep things simple we'll always re-create the entity in this case // so to keep things simple we'll always re-create the entity in this case
// remember the old details, for the callback
previousDetails = p.options.details;
this.deletePortalEntity(ent[0]); this.deletePortalEntity(ent[0]);
} }
@ -273,7 +279,7 @@ window.Render.prototype.createPortalEntity = function(ent) {
marker.on('dblclick', function() { window.renderPortalDetails(ent[0]); window.map.setView(latlng, 17); }); marker.on('dblclick', function() { window.renderPortalDetails(ent[0]); window.map.setView(latlng, 17); });
window.runHooks('portalAdded', {portal: marker}); window.runHooks('portalAdded', {portal: marker, previousDetails: previousDetails});
window.portals[ent[0]] = marker; window.portals[ent[0]] = marker;