Преглед изворни кода

Ticket #3226 - Alert to override onGetPost response.

AntonLV пре 5 година
родитељ
комит
93e290032e
2 измењених фајлова са 55 додато и 44 уклоњено
  1. 8 1
      modules/boonex/timeline/classes/BxTimelineModule.php
  2. 47 43
      modules/boonex/timeline/js/post.js

+ 8 - 1
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -350,14 +350,21 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             return echoJson(array('message' => _t('_bx_timeline_txt_msg_posted')));
         */
 
-        echoJson(array(
+        $aResult = array(
             'id' => $aEvent['id'],
             'name' => $aParams['name'],
             'view' => $aParams['view'],
             'type' => $aParams['type'],
             'item' => $this->_oTemplate->getPost($aEvent, $aParams),
             'eval' => $sJsObject . "._onGetPost(oData)"
+        );
+
+        bx_alert($this->getName(), 'on_get_post', 0, 0, array(
+            'params' => $aParams,
+            'override_result' => &$aResult,
         ));
+
+        echoJson($aResult);
     }
 
     function actionGetPosts()

+ 47 - 43
modules/boonex/timeline/js/post.js

@@ -327,61 +327,65 @@ BxTimelinePost.prototype._onGetPost = function(oData)
         if(!$.trim(oData.item).length) 
             return;
 
-        $this.oView = $($this._getHtmlId('main', oData));
-
-        /*
-         * For backward compatibility.
-         * Current UPF: 'Post to Feed' and Timeline: 'Post to Feed' forms 
-         * should work with an old Account Feed ('Owner and Connections') block.
-         */
-        if(!$this.oView.length && oData['type'] == 'feed') {
-            oData['type'] = 'owner_and_connections';
+        var aTypes = Array.isArray(oData.type) ? oData.type : new Array(oData.type);
+        aTypes.forEach(function(sType) {
+            oData['type'] = sType;
             $this.oView = $($this._getHtmlId('main', oData));
-        }
 
-        var oLoadMore = $this.oView.find('.' + $this.sSP + '-load-more');
-        if(!oLoadMore.is(':visible'))
-            oLoadMore.show();
+            /*
+             * For backward compatibility.
+             * Current UPF: 'Post to Feed' and Timeline: 'Post to Feed' forms 
+             * should work with an old Account Feed ('Owner and Connections') block.
+             */
+            if(!$this.oView.length && oData['type'] == 'feed') {
+                oData['type'] = 'owner_and_connections';
+                $this.oView = $($this._getHtmlId('main', oData));
+            }
+
+            var oLoadMore = $this.oView.find('.' + $this.sSP + '-load-more');
+            if(!oLoadMore.is(':visible'))
+                oLoadMore.show();
 
-        var oEmpty = $this.oView.find('.' + $this.sSP + '-empty');
-        if(oEmpty.is(':visible'))
-            oEmpty.hide();
+            var oEmpty = $this.oView.find('.' + $this.sSP + '-empty');
+            if(oEmpty.is(':visible'))
+                oEmpty.hide();
 
-        var oContent = $(oData.item).bxProcessHtml();
-        switch(oData.view) {
-            case 'timeline':
-                var oItems = $this.oView.find('.' + $this.sClassItems);
-                var oDivider  = oItems.find('.' + $this.sClassDividerToday);
-                var bDivider = oDivider.length > 0;
+            var oContent = $(oData.item).bxProcessHtml();
+            switch(oData.view) {
+                case 'timeline':
+                    var oItems = $this.oView.find('.' + $this.sClassItems);
+                    var oDivider  = oItems.find('.' + $this.sClassDividerToday);
+                    var bDivider = oDivider.length > 0;
 
-                if(bDivider && !oDivider.is(':visible'))
-                    oDivider.show();
+                    if(bDivider && !oDivider.is(':visible'))
+                        oDivider.show();
 
-                oContent.hide();
+                    oContent.hide();
 
-                var oItem = bDivider ? oDivider.after(oContent).next('.' + $this.sClassItem + ':hidden') : oContent.prependTo(oItems);
-                oItem.bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-                    $(this).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
-                        $this.onFindOverflow(oElement);
+                    var oItem = bDivider ? oDivider.after(oContent).next('.' + $this.sClassItem + ':hidden') : oContent.prependTo(oItems);
+                    oItem.bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+                        $(this).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
+                            $this.onFindOverflow(oElement);
+                        });
+
+                        $this.initFlickity();
                     });
 
-                    $this.initFlickity();
-                });
+                    if($this._sVideosAutoplay != 'off')
+                        $this.initVideos($this.oView);
+                    break;
 
-                if($this._sVideosAutoplay != 'off')
-                    $this.initVideos($this.oView);
-                break;
+                case 'outline':
+                    $this.prependMasonry(oContent, function(oItems) {
+                        $(oItems).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
+                            $this.onFindOverflow(oElement);
+                        });
 
-            case 'outline':
-                $this.prependMasonry(oContent, function(oItems) {
-                    $(oItems).find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
-                        $this.onFindOverflow(oElement);
+                        $this.initFlickity();
                     });
-
-                    $this.initFlickity();
-                });
-                break;
-        }
+                    break;
+            }
+        });
     };
 
     if(oData && oData.message != undefined && oData.message.length != 0)