AntonLV 5 سال پیش
والد
کامیت
40a925fc44

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

@@ -309,6 +309,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     function actionGetView()
     {
         $aParams = $this->_prepareParamsGet();
+        $aParams['js_init_view'] = false;
 
         $sConten = $this->_oTemplate->getViewBlock($aParams);
         if(empty($sConten))

+ 14 - 8
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -112,17 +112,16 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             return $mixedResult; 
     }
 
-    public function getJsCode($sType, $aParams = array(), $bWrap = true, $bDynamic = false)
+    public function getJsCodeView($aParams = array(), $bWrap = true, $bDynamic = false)
     {
-        $oModule = $this->getModule();
-
         $aParams = array_merge(array(
+            'bInit' => true,
             'bInfScroll' => $this->_oConfig->isInfiniteScroll(),
             'iInfScrollAutoPreloads' => $this->_oConfig->getAutoPreloads(),
             'bDynamicCards' => $this->_oConfig->isDynamicCards(),
         ), $aParams);
 
-        return parent::getJsCode($sType, $aParams, $bWrap, $bDynamic);
+        return parent::getJsCode('view', $aParams, $bWrap, $bDynamic);
     }
 
     public function getJsCodePost($iOwnerId, $aParams = array(), $bWrap = true, $bDynamic = false)
@@ -190,6 +189,12 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
     {
         $oModule = $this->getModule();
 
+        $bJsInitView = true;
+        if(isset($aParams['js_init_view'])) {
+            $bJsInitView = (bool)$aParams['js_init_view'];
+            unset($aParams['js_init_view']);
+        }
+
         list($sContent, $sLoadMore, $sBack, $sEmpty, $iEvent, $bEventsToLoad) = $this->getPosts($aParams);
 
         //--- Add live update
@@ -217,11 +222,12 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'load_more' =>  $sLoadMore,
             'show_more' => $this->_getShowMore($aParams),
             'view_image_popup' => $this->_getImagePopup($aParams),
-            'js_content' => $this->getJsCode('view', array(
+            'js_content' => $this->getJsCodeView(array(
                 'sObjName' => $sJsObject,
                 'sVideosAutoplay' => $this->_oConfig->getVideosAutoplay(),
                 'bEventsToLoad' => $bEventsToLoad,
-            	'oRequestParams' => $aParams
+            	'oRequestParams' => $aParams,
+                'bInit' => $bJsInitView
             ), array(
                 'wrap' => true,
                 'mask_markers' => array('object' => $sJsObject)
@@ -240,7 +246,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'view' => $aParams['view'],
             'content' => $sContent,
             'view_image_popup' => $this->_getImagePopup($aParams),
-            'js_content' => $this->getJsCode('view', array(
+            'js_content' => $this->getJsCodeView(array(
             	'oRequestParams' => $aParams
             ))
         ));
@@ -299,7 +305,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'content' => $sContent,
             'show_more' => $this->_getShowMore($aBrowseParams),
             'view_image_popup' => $this->_getImagePopup($aBrowseParams),
-            'js_content' => $this->getJsCode('view', array(
+            'js_content' => $this->getJsCodeView(array(
                 'sObjName' => $sJsObject,
                 'sVideosAutoplay' => $this->_oConfig->getVideosAutoplay(),
                 'sReferrer' => $sReferrer,

+ 43 - 24
modules/boonex/timeline/js/view.js

@@ -23,6 +23,7 @@ function BxTimelineView(oOptions) {
     this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
     this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams;
 
+    this._bInit = oOptions.bInit == undefined ? true : oOptions.bInit;
     this._bInfScroll = oOptions.bInfScroll == undefined ? false : oOptions.bInfScroll;
     this._iInfScrollAutoPreloads = oOptions.iInfScrollAutoPreloads == undefined ? 10 : oOptions.iInfScrollAutoPreloads;
     this._sInfScrollAfter = 'item';
@@ -48,30 +49,30 @@ function BxTimelineView(oOptions) {
     if(this._bDynamicCards) 
         this.loadCards();
 
-    var $this = this;
-    $(document).ready(function() {
-    	$this.init();
-    });
+    if(this._bInit) {
+        var $this = this;
+        $(document).ready(function() {
+            $this.init();
+        });
+    }
 }
 
 BxTimelineView.prototype = Object.create(BxTimelineMain.prototype);
 BxTimelineView.prototype.constructor = BxTimelineView;
 
-BxTimelineView.prototype.init = function()
+BxTimelineView.prototype.init = function(bForceInit)
 {
     var $this = this;
 
-    if(!this.oView)
+    if(!this.oView || bForceInit)
         this.initView();
 
     if(this.bViewTimeline) {
-        var oItems = this.oView.find('.' + this.sClassItem);
-        oItems.find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight(this.sSP + '-overflow', function(oElement) {
-            $this.onFindOverflow(oElement);
-        });
+        //-- Check content to show 'See More'
+        this.initSeeMore(this.oView, true);
 
         //--- Hide timeline Events which are outside the viewport
-        this.hideEvents(oItems, this._fOutsideOffset);
+        this.hideEvents(this.oView.find('.' + this.sClassItem), this._fOutsideOffset);
 
         //--- Init Video Autoplay
         if(this._sVideosAutoplay != 'off') {
@@ -129,6 +130,9 @@ BxTimelineView.prototype.init = function()
     }
 
     if(this.bViewItem) {
+        //-- Check content to show 'See More'
+        this.initSeeMore(this.oView, false);
+        
         this.oView.find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight(this.sSP + '-overflow', function(oElement) {
             $this.onFindOverflow(oElement);
         });
@@ -158,6 +162,19 @@ BxTimelineView.prototype.initView = function()
         this.bViewItem = true;
 };
 
+BxTimelineView.prototype.initSeeMore = function(oParent, bInItems)
+{
+    var $this = this;
+
+    var oSubParent = oParent;
+    if(bInItems)
+        oSubParent = oParent.find('.' + this.sClassItem);
+
+    oSubParent.find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight(this.sSP + '-overflow', function(oElement) {
+        $this.onFindOverflow(oElement);
+    });
+};
+
 BxTimelineView.prototype.initJumpTo = function(oParent)
 {
     var oJumpTo = $(oParent).find('.' + this.sClassJumpTo);
@@ -279,9 +296,8 @@ BxTimelineView.prototype.loadCards = function()
                 oItem = $this.oView.find('#' + sItemId);
 
                 if($this.bViewTimeline) {
-                    oItem.find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
-                        $this.onFindOverflow(oElement);
-                    });
+                    //-- Check content to show 'See More'
+                    $this.initSeeMore(oItem, false);
 
                     //--- Hide timeline Events which are outside the viewport
                     $this.hideEvent(oItem, $this._fOutsideOffset, iIndex, true);
@@ -296,9 +312,8 @@ BxTimelineView.prototype.loadCards = function()
 
                 if($this.bViewOutline)
                     $this.appendMasonry(oItem, function(oItem) {
-                        oItem.find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
-                            $this.onFindOverflow(oElement);
-                        });
+                        //-- Check content to show 'See More'
+                        $this.initSeeMore(oItem, false);
 
                         //--- Init Flickity
                         $this.initFlickityByItem(oItem);
@@ -478,7 +493,9 @@ BxTimelineView.prototype.changeView = function(oLink, sType, oRequestParams)
             oContent.filter(sView).hide();
 
             oViewBefore.hide();
-            oViews.append(oContent).find(sView).bxProcessHtml().show();
+            oViews.append(oContent).find(sView).bxProcessHtml().show(function() {
+                $this.init(true);
+            });
         },
         'json'
     );
@@ -1070,10 +1087,12 @@ BxTimelineView.prototype._getPage = function(oElement, iStart, iPerPage, onLoad)
 
         if($this.bViewTimeline)
             $this.oView.find('.' + $this.sClassItems).append($(sItems).hide()).find('.' + $this.sClassItem + ':hidden').bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-                $(this).bxProcessHtml().find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
-                    $this.onFindOverflow(oElement);
-                });
+                $(this).bxProcessHtml();
 
+                //-- Check content to show 'See More'
+                $this.initSeeMore($(this), false);
+
+                //-- Init Flickity
                 $this.initFlickity();
 
                 //--- Init Video Autoplay
@@ -1082,10 +1101,10 @@ BxTimelineView.prototype._getPage = function(oElement, iStart, iPerPage, onLoad)
 
         if($this.bViewOutline)
             $this.appendMasonry($(sItems).bxProcessHtml(), function(oItems) {
-                oItems.find('.bx-tl-item-text .bx-tl-content').checkOverflowHeight($this.sSP + '-overflow', function(oElement) {
-                    $this.onFindOverflow(oElement);
-                });
+                //-- Check content to show 'See More'
+                $this.initSeeMore(oItems, false);
 
+                //-- Init Flickity
                 $this.initFlickity();
 
                 //--- Init Video Layout