Merge pull request #235 from ShawnTuatara/hook-portalDataLoaded

Adding hook portalDataLoaded
This commit is contained in:
Stefan Breunig 2013-02-19 22:43:04 -08:00
commit 95e8569e4d
2 changed files with 9 additions and 2 deletions

View File

@ -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);

View File

@ -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];