From a922bd36bf85fbd4360a654e0570299acb15b05a Mon Sep 17 00:00:00 2001 From: Shawn Clark Date: Tue, 19 Feb 2013 22:35:32 -0800 Subject: [PATCH] Adding hook portalDataLoaded - portalDataLoaded is called during the code/map_data.js#handleDataResponse to allow plugins to manipulate the portals prior to rendering. --- code/hooks.js | 9 +++++++-- code/map_data.js | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/code/hooks.js b/code/hooks.js index 1aff0010..43f4cc35 100644 --- a/code/hooks.js +++ b/code/hooks.js @@ -30,11 +30,16 @@ // yet been displayed. The data hash contains both the un- // processed raw ajax response as well as the processed // chat data that is going to be used for display. - +// portalDataLoaded: callback is passed the argument of +// {portals : [portal, portal, ...]} where "portal" is the +// data element and not the leaflet object. "portal" is an +// array [GUID, time, details]. Plugin can manipulate the +// array to change order or add additional values to the +// details of a portal. window._hooks = {} window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated', - 'publicChatDataAvailable']; + 'publicChatDataAvailable', 'portalDataLoaded']; window.runHooks = function(event, data) { if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event); diff --git a/code/map_data.js b/code/map_data.js index dc370cd6..6729c0f0 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -127,6 +127,8 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { // Preserve and restore "selectedPortal" between portal re-render if(portalUpdateAvailable) var oldSelectedPortal = selectedPortal; + + runHooks('portalDataLoaded', {portals : ppp}); $.each(ppp, function(ind, portal) { renderPortal(portal); }); var selectedPortalLayer = portals[oldSelectedPortal];