add linkAdded and fieldAdded hooks, to mirror the portalAdded hook

This commit is contained in:
Jon Atkins 2013-09-17 07:33:14 +01:00
parent d07164685a
commit aad3c77ff9
2 changed files with 8 additions and 1 deletions

View File

@ -26,6 +26,8 @@
// shown at all. Injection point is in
// code/map_data.js#renderPortal near the end. Will hand
// the Leaflet CircleMarker for the portal in "portal" var.
// linkAdded: called when a link is about to be added to the map
// fieldAdded: called when a field is about to be added to the map
// portalDetailsUpdated: fired after the details in the sidebar have
// been (re-)rendered Provides data about the portal that
// has been selected.
@ -49,7 +51,8 @@ window._hooks = {}
window.VALID_HOOKS = [
'portalSelected',
'mapDataRefreshStart', 'mapDataRefreshEnd',
'portalAdded', 'portalDetailsUpdated',
'portalAdded', 'linkAdded', 'fieldAdded',
'portalDetailsUpdated',
'publicChatDataAvailable', 'factionChatDataAvailable',
'requestFinished', 'nicknameClicked',
'geoSearch', 'iitcLoaded'];

View File

@ -397,6 +397,8 @@ window.Render.prototype.createFieldEntity = function(ent) {
addPortalLinkedField(ent[2].capturedRegion.vertexB.guid);
addPortalLinkedField(ent[2].capturedRegion.vertexC.guid);
runHooks('fieldAdded',{field: poly});
window.fields[ent[0]] = poly;
// TODO? postpone adding to the layer??
@ -440,6 +442,8 @@ window.Render.prototype.createLinkEntity = function(ent,faked) {
data: ent[2]
});
runHooks('linkAdded', {link: poly});
window.links[ent[0]] = poly;
// only add the link to the layer if it's long enough to be seen