merge parts of #236 (by ShawnTuatara)

This commit is contained in:
Stefan Breunig 2013-02-23 14:02:19 +01:00
parent 71d769c3ec
commit 0ada93ea75
2 changed files with 20 additions and 2 deletions

View File

@ -11,7 +11,7 @@
//
// Boot hook: booting is handled differently because IITC may not yet
// be available. Have a look at the plugins in plugins/. All
// code before “// PLUGIN START” and after “// PLUGIN END” os
// code before “// PLUGIN START” and after “// PLUGIN END” is
// required to successfully boot the plugin.
//
// Heres more specific information about each event:
@ -36,6 +36,16 @@
// array [GUID, time, details]. Plugin can manipulate the
// array to change order or add additional values to the
// details of a portal.
// beforePortalReRender: the callback argument is
// {portal: ent[2], oldPortal : d, reRender : false}.
// The callback needs to update the value of reRender to
// true if the plugin has a reason to have the portal
// redrawn. It is called early on in the
// code/map_data.js#renderPortal as long as there was an
// old portal for the guid.
window._hooks = {}
window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated',

View File

@ -127,7 +127,7 @@ 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); });
@ -231,8 +231,16 @@ window.renderPortal = function(ent) {
var old = findEntityInLeaflet(layerGroup, window.portals, ent[0]);
if(old) {
var oo = old.options;
// Default checks to see if a portal needs to be re-rendered
var u = oo.team !== team;
u = u || oo.level !== portalLevel;
// Allow plugins to add additional conditions as to when a portal gets re-rendered
var hookData = {portal: ent[2], oldPortal: oo.details, reRender: false};
runHooks('beforePortalReRender', hookData);
u = u || hookData.reRender;
// nothing changed that requires re-rendering the portal.
if(!u) {
// let resos handle themselves if they need to be redrawn