ソースを参照

#3002 Menus badges need to be loaded asynchronously via separate AJAX call

Alex Trofimov 6 年 前
親
コミット
82026fbf63

+ 2 - 0
inc/js/classes/BxDolLiveUpdates.js

@@ -30,6 +30,8 @@ BxDolLiveUpdates.prototype.init = function() {
 		this.destroy();
 
     $(document).ready(function() {
+        $this.perform(); // make first call straight away to load addons for menus
+
     	$this._iHandler = setInterval(function() {
     		$this.perform();
     	}, $this._iInterval);

+ 2 - 2
template/scripts/BxBaseLiveUpdates.php

@@ -32,13 +32,13 @@ class BxBaseLiveUpdates extends BxDolLiveUpdates
          * Load and cache(if it's needed) default(system) 
          * live updates for current user.
          */ 
-        $aCached = $this->_getCachedData();
+        //$aCached = $this->_getCachedData();
 
         $aParams = array_merge(array(
             'sActionsUrl' => BX_DOL_URL_ROOT . 'live_updates.php',
             'sObjName' => $this->_sJsObject,
             'iInterval' => $this->_iInterval,
-            'aSystemsActive' => array_intersect_key($aCached, array_flip($this->_aSystemsActive)),
+            'aSystemsActive' => /*array_intersect_key($aCached, */array_flip($this->_aSystemsActive)/*)*/,
             'aSystemsTransient' => array_flip($this->_aSystemsTransient),
             'bServerRequesting' => !empty($this->_aSystems),
             'sHash' => base64_encode($this->_sCacheKey),

+ 11 - 8
template/scripts/BxBaseMenu.php

@@ -17,6 +17,7 @@ class BxBaseMenu extends BxDolMenu
 {
     protected $_oTemplate;
     protected $_aOptionalParams = array('target' => '', 'onclick' => '');
+    protected $_bDisplayAddons = false;
 
     public function __construct ($aObject, $oTemplate)
     {
@@ -153,13 +154,15 @@ class BxBaseMenu extends BxDolMenu
 
         $a = $this->_replaceMarkers($a);
 
-        $mixedAddon = $this->_getMenuAddon($a);
-        if(!is_array($mixedAddon))
-            $this->addMarkers(array('addon' => $mixedAddon));
-        else
-            $this->addMarkers($mixedAddon);
+        if ($this->_bDisplayAddons) {
+            $mixedAddon = $this->_getMenuAddon($a);
+            if(!is_array($mixedAddon))
+                $this->addMarkers(array('addon' => $mixedAddon));
+            else
+                $this->addMarkers($mixedAddon);
 
-        $a = $this->_replaceMarkers($a);
+            $a = $this->_replaceMarkers($a);
+        }
 
         list ($sIcon, $sIconUrl, $sIconA) = $this->_getMenuIcon($a);
 
@@ -197,9 +200,9 @@ class BxBaseMenu extends BxDolMenu
             ),
         );
 
-        $aTmplVarsAddon = $this->_getTmplVarsAddon($mixedAddon, $a);
+        $aTmplVarsAddon = $this->_bDisplayAddons ? $this->_getTmplVarsAddon($mixedAddon, $a) : array();
         $a['bx_if:addon'] = array (
-            'condition' => !empty($aTmplVarsAddon['addon']),
+            'condition' => $this->_bDisplayAddons && !empty($aTmplVarsAddon['addon']),
             'content' => $aTmplVarsAddon
         );