Просмотр исходного кода

Ticket #507 - Separate events browsing when both Timeline and Outline are on the same page.

AntonLV 10 лет назад
Родитель
Сommit
14e1835e32

+ 1 - 0
modules/boonex/russian/data/langs/bx_timeline/ru.xml

@@ -59,6 +59,7 @@
 	<string name="_bx_timeline_page_title_account"><![CDATA[Лента]]></string>
 	<string name="_bx_timeline_page_block_title_post"><![CDATA[Разместить в Ленте]]></string>
 	<string name="_bx_timeline_page_block_title_view"><![CDATA[Лента]]></string>
+	<string name="_bx_timeline_page_block_title_view_outline"><![CDATA[Сводка]]></string>
 	<string name="_bx_timeline_page_block_title_post_profile"><![CDATA[Разместить в Ленте]]></string>
 	<string name="_bx_timeline_page_block_title_view_profile"><![CDATA[Лента]]></string>
 	<string name="_bx_timeline_page_block_title_view_profile_outline"><![CDATA[Сводка]]></string>

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

@@ -201,13 +201,14 @@ class BxTimelineModule extends BxBaseModNotificationsModule
     function actionGetPosts()
     {
         $aParams = $this->_prepareParamsGet();
-        list($sItems, $sLoadMore, $sBack) = $this->_oTemplate->getPosts($aParams);
+        list($sItems, $sLoadMore, $sBack, $sEmpty) = $this->_oTemplate->getPosts($aParams);
 
         echoJson(array(
         	'view' => $aParams['view'],
         	'items' => $sItems, 
         	'load_more' => $sLoadMore, 
-        	'back' => $sBack, 
+        	'back' => $sBack,
+            'empty' => $sEmpty,
         	'eval' => $this->_oConfig->getJsObject('view') . "._onGetPosts(oData)"
         ));
     }
@@ -1092,18 +1093,18 @@ class BxTimelineModule extends BxBaseModNotificationsModule
 
         $sJsObject = $this->_oConfig->getJsObject('view');
         $aMenu = array(
-            array('id' => 'timeline-view-all', 'name' => 'timeline-view-all', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_all'), 'active' => 1),
-            array('id' => 'timeline-view-owner', 'name' => 'timeline-view-owner', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_owner', $sUserName)),
-            array('id' => 'timeline-view-other', 'name' => 'timeline-view-other', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_other')),
-            array('id' => 'timeline-get-rss', 'name' => 'timeline-get-rss', 'class' => '', 'link' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . $iProfileId . '/', 'target' => '_blank', 'title' => _t('_bx_timeline_menu_item_get_rss')),
+            array('id' => $sView . '-view-all', 'name' => $sView . '-view-all', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_all'), 'active' => 1),
+            array('id' => $sView . '-view-owner', 'name' => $sView . '-view-owner', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_owner', $sUserName)),
+            array('id' => $sView . '-view-other', 'name' => $sView . '-view-other', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeFilter(this)', 'target' => '_self', 'title' => _t('_bx_timeline_menu_item_view_other')),
+            array('id' => $sView . '-get-rss', 'name' => $sView . '-get-rss', 'class' => '', 'link' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'rss/' . $iProfileId . '/', 'target' => '_blank', 'title' => _t('_bx_timeline_menu_item_get_rss')),
         );
 
         $sContent = '';
         $oProfileOwner = BxDolProfile::getInstance($this->_iOwnerId);
         bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view', $this->_iOwnerId, $this->getUserId(), array('override_content' => &$sContent, 'params' => &$aParams, 'menu' => &$aMenu));
 
-        $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> 'timeline-view-all', 'menu_items' => $aMenu));
-        $oMenu->setSelected('', 'timeline-view-all');
+        $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $sView . '-view-all', 'menu_items' => $aMenu));
+        $oMenu->setSelected('', $sView . '-view-all');
 
         if (!$sContent)
             $sContent = $this->_oTemplate->getViewBlock($aParams);

+ 5 - 3
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -59,13 +59,14 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
     public function getViewBlock($aParams)
     {
-        list($sContent, $sLoadMore, $sBack) = $this->getPosts($aParams);
+        list($sContent, $sLoadMore, $sBack, $sEmpty) = $this->getPosts($aParams);
 
         return $this->parseHtmlByName('block_view.html', array(
             'style_prefix' => $this->_oConfig->getPrefix('style'),
         	'html_id' => $this->_oConfig->getHtmlIds('view', 'main_' . $aParams['view']),
             'view' => $aParams['view'],
             'back' => $sBack,
+            'empty' => $sEmpty, 
             'content' => $sContent,
             'load_more' =>  $sLoadMore,
         	'view_image_popup' => $this->_getImagePopup($aParams),
@@ -172,7 +173,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         }
 
         $iEvents = count($aEvents);
-        $sContent = $this->getEmpty($iEvents <= 0);
+        $sContent = '';
         if($bViewTimeline && $iEvents <= 0)
         	$sContent .= $this->getDividerToday();
 
@@ -194,7 +195,8 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
         $sBack = $this->getBack($aParams);
         $sLoadMore = $this->getLoadMore($aParams, $bNext, $iEvents > 0);
-        return array($sContent, $sLoadMore, $sBack);
+        $sEmpty = $this->getEmpty($iEvents <= 0);
+        return array($sContent, $sLoadMore, $sBack, $sEmpty);
     }
 
     public function getEmpty($bVisible)

+ 1 - 0
modules/boonex/timeline/install/langs/en.xml

@@ -59,6 +59,7 @@
 	<string name="_bx_timeline_page_title_account"><![CDATA[Timeline]]></string>
 	<string name="_bx_timeline_page_block_title_post"><![CDATA[Post to Timeline]]></string>
 	<string name="_bx_timeline_page_block_title_view"><![CDATA[Timeline]]></string>
+	<string name="_bx_timeline_page_block_title_view_outline"><![CDATA[Outline]]></string>
 	<string name="_bx_timeline_page_block_title_post_profile"><![CDATA[Post to Timeline]]></string>
 	<string name="_bx_timeline_page_block_title_view_profile"><![CDATA[Timeline]]></string>	
 	<string name="_bx_timeline_page_block_title_view_profile_outline"><![CDATA[Outline]]></string>

+ 1 - 1
modules/boonex/timeline/install/sql/enable.sql

@@ -6,7 +6,7 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay
 INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES
 ('bx_timeline_view', 1, 'bx_timeline', '_bx_timeline_page_block_title_post', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:14:"get_block_post";}', 0, 0, 1),
 ('bx_timeline_view', 1, 'bx_timeline', '_bx_timeline_page_block_title_view', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:14:"get_block_view";}', 0, 0, 2),
-('bx_timeline_view', 1, 'bx_timeline', '_bx_timeline_page_block_title_view', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:22:"get_block_view_outline";}', 0, 0, 3),
+('bx_timeline_view', 1, 'bx_timeline', '_bx_timeline_page_block_title_view_outline', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:22:"get_block_view_outline";}', 0, 0, 3),
 
 ('bx_timeline_item', 1, 'bx_timeline', '_bx_timeline_page_block_title_item', 0, 2147483647, 'service', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:14:"get_block_item";}', 0, 0, 1);
 

+ 4 - 2
modules/boonex/timeline/js/main.js

@@ -211,8 +211,10 @@ BxTimelineMain.prototype._getView = function(oView) {
 
 BxTimelineMain.prototype._getDefaultData = function(oElement) {
 	var oDate = new Date();
-    return jQuery.extend({}, this._oRequestParams, {
-    	view: oElement != undefined ? this._getView(oElement) : '',
+	var sView = oElement != undefined ? this._getView(oElement) : '';
+
+    return jQuery.extend({}, this._oRequestParams[sView.length > 0 ? sView : 'general'], {
+    	view: sView,
 		_t:oDate.getTime()
     });
 };

+ 14 - 6
modules/boonex/timeline/js/post.js

@@ -227,17 +227,25 @@ BxTimelinePost.prototype._onGetPost = function(oData) {
 	if(oEmpty.is(':visible'))
 		oEmpty.hide();
 
+	var oContent = $(oData.item).bxTime();
 	switch(oData.view) {
 		case 'timeline':
-			var oViewTimeline = $('#' + this._aHtmlIds['main_timeline']);
-			if(!oViewTimeline.find('.' + this.sClassDividerToday).is(':visible'))
-				oViewTimeline.find('.' + this.sClassDividerToday).show();
-		
-			oViewTimeline.find('.' + this.sClassDividerToday).after($(oData.item).bxTime().hide()).next('.' + this.sClassItem + ':hidden').bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
+			var oItem = null;
+			var oItems = $('#' + this._aHtmlIds['main_timeline'] + ' ' + '.' + this.sClassItems);
+			var oDivider  = oItems.find('.' + this.sClassDividerToday);
+			var bDivider = oDivider.length > 0;
+
+			if(bDivider && !oDivider.is(':visible'))
+				oDivider.show();
+
+			oContent.hide();
+
+			oItem = bDivider ? oDivider.after(oContent).next('.' + this.sClassItem + ':hidden') : oContent.prependTo(oItems);
+			oItem.bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
 			break;
 
 		case 'outline':
-			this.prependMasonry($(oData.item).bxTime());
+			this.prependMasonry(oContent);
 			break;
 	}
 };

+ 47 - 20
modules/boonex/timeline/js/view.js

@@ -16,7 +16,11 @@ function BxTimelineView(oOptions) {
     this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'slide' : oOptions.sAnimationEffect;
     this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
     this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
-    this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams;
+    this._oRequestParams = {
+    	timeline: null,
+    	outline: null,
+    	general: oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams
+    };
 
     this._fOutsideOffset = 0.8;
 
@@ -38,6 +42,8 @@ BxTimelineView.prototype.init = function() {
 	this.bViewOutline = this.oViewOutline.length > 0;	
 
 	if(this.bViewTimeline) {
+		this._oRequestParams['timeline'] = jQuery.extend({}, this._oRequestParams['general']);
+
 		var oItems = this.oViewTimeline.find('.' + this.sClassItem);
 
 		//--- Hide timeline Events which are outside the viewport
@@ -57,6 +63,8 @@ BxTimelineView.prototype.init = function() {
 	}
 
 	if(this.bViewOutline) {
+		this._oRequestParams['outline'] = jQuery.extend({}, this._oRequestParams['general']);
+
     	this.initMasonry();
 
     	this.oViewOutline.find('.' + this.sClassItem).resize(function() {
@@ -88,8 +96,8 @@ BxTimelineView.prototype.changePage = function(oLink, iStart, iPerPage) {
 
 	this.loadingInButton(oLink, true);
 
-	this._oRequestParams.start = iStart;
-    this._oRequestParams.per_page = iPerPage;
+	this._oRequestParams[sView].start = iStart;
+    this._oRequestParams[sView].per_page = iPerPage;
     this._getPosts(oLink, function(oData) {
     	$this.loadingInButton(oLink, false);
 
@@ -107,7 +115,6 @@ BxTimelineView.prototype.changePage = function(oLink, iStart, iPerPage) {
     			oView = $this.oViewOutline;
     			$this.appendMasonry($(sItems).bxTime());
     			break;
-    	
     	}
 
     	if(oView && oData && oData.load_more != undefined)
@@ -115,26 +122,35 @@ BxTimelineView.prototype.changePage = function(oLink, iStart, iPerPage) {
 
     	if(oView && oData && oData.back != undefined)
     		oView.find('.' + $this.sSP + '-back-holder').html($.trim(oData.back));
+
+    	if(oData && oData.empty != undefined)
+			oView.find('.' + $this.sSP + '-empty-holder').html($.trim(oData.empty));
     });
 };
 
 BxTimelineView.prototype.changeFilter = function(oLink) {
+	var sView = this._getView(oLink);
+
     var sId = $(oLink).attr('id');
     sId = sId.substr(sId.lastIndexOf('-') + 1, sId.length);
 
     this.loadingInBlock(oLink, true);
 
-    this._oRequestParams.start = 0;
-    this._oRequestParams.filter = sId;
+    this._oRequestParams[sView].start = 0;
+    this._oRequestParams[sView].filter = sId;
     this._getPosts(oLink);
 };
 
 BxTimelineView.prototype.changeTimeline = function(oLink, iYear) {
+	var sView = this._getView(oLink);
+
 	this.loadingInBlock(oLink, true);
 
-	this._oRequestParams.start = 0;
-    this._oRequestParams.timeline = iYear;
+	this._oRequestParams[sView].start = 0;
+    this._oRequestParams[sView].timeline = iYear;
 	this._getPosts(oLink);
+	
+	console.log(this._oRequestParams);
 };
 
 BxTimelineView.prototype.showMoreContent = function(oLink) {
@@ -223,7 +239,7 @@ BxTimelineView.prototype.onPinPost = function(oData) {
 	if(this.bViewTimeline) {
 		var sItemTimeline = this.sIdItemTimeline + oData.id;
 
-		this._oRequestParams.start = 0;
+		this._oRequestParams['timeline'].start = 0;
         this._getPosts(this.oViewTimeline, function(oData) {
         	$(sItemTimeline).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
     	        $(this).remove();
@@ -237,7 +253,7 @@ BxTimelineView.prototype.onPinPost = function(oData) {
 	if(this.bViewOutline) {
 		var sItemOutline = this.sIdItemOutline + oData.id;
 
-		this._oRequestParams.start = 0;
+		this._oRequestParams['outline'].start = 0;
         this._getPosts(this.oViewOutline, function(oData) {
         	$this.removeMasonry(sItemOutline, function() {
         		$this.processResult(oData);
@@ -325,6 +341,17 @@ BxTimelineView.prototype._onGetPosts = function(oData) {
 	var $this = this;
 	var oView = $('#' + this._aHtmlIds['main_' + oData.view]);
 
+	var onComplete = function() {
+		if(oData && oData.load_more != undefined)
+			oView.find('.' + $this.sSP + '-load-more-holder').html($.trim(oData.load_more));
+
+		if(oData && oData.back != undefined)
+			oView.find('.' + $this.sSP + '-back-holder').html($.trim(oData.back));
+
+		if(oData && oData.empty != undefined)
+			oView.find('.' + $this.sSP + '-empty-holder').html($.trim(oData.empty));
+	};
+
 	if(oData && oData.items != undefined) {
 		var sItems = $.trim(oData.items);
 
@@ -332,26 +359,26 @@ BxTimelineView.prototype._onGetPosts = function(oData) {
 			case 'timeline':
 				oView.find('.' + this.sClassItems).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
 					$(this).html(sItems).show().bxTime();
+
+					onComplete();
 			    });
 				break;
-	
+
 			case 'outline':
 				oView.find('.' + this.sClassItems).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
 			        $(this).html(sItems).show().bxTime();
 
-			        $this.destroyMasonry();
-			        if($this.isMasonryEmpty())
-			        	return;
+			        if($this.isMasonry())
+			        	$this.destroyMasonry();
+
+			        if(!$this.isMasonryEmpty())
+			        	$this.initMasonry();
 
-			        $this.initMasonry();
+			        onComplete();
 			    });
 				break;
 		}
 	}
 
-	if(oData && oData.load_more != undefined)
-		oView.find('.' + this.sSP + '-load-more-holder').html($.trim(oData.load_more));
-
-	if(oData && oData.back != undefined)
-		oView.find('.' + this.sSP + '-back-holder').html($.trim(oData.back));
+	
 };

+ 1 - 0
modules/boonex/timeline/template/block_view.html

@@ -1,6 +1,7 @@
 <div id="__html_id__" class="__style_prefix__-view __style_prefix__-view-__view__ bx-def-bc-margin">
 	<div class="__style_prefix__-cnt">
         <div class="__style_prefix__-back-holder">__back__</div>
+        <div class="__style_prefix__-empty-holder">__empty__</div>
         <div class="__style_prefix__-items-wrapper">
             <div class="__style_prefix__-items bx-def-margin-sec-leftright-neg">__content__</div>
         </div>

+ 5 - 5
modules/boonex/timeline/template/css/view-media-desktop.css

@@ -45,26 +45,26 @@
 	}
 
 	/*--- Animation ---*/
-	.cssanimations .bx-tl-item-type.is-hidden {
+	.cssanimations div.bx-tl-view-timeline .bx-tl-item-type.is-hidden {
 	    visibility: hidden;
 	}
-	.cssanimations .bx-tl-item-type.bounce-in {
+	.cssanimations div.bx-tl-view-timeline .bx-tl-item-type.bounce-in {
 		visibility: visible;
 		-webkit-animation: cd-bounce-1 0.6s;
 		-moz-animation: cd-bounce-1 0.6s;
 		animation: cd-bounce-1 0.6s;
 	}
-	.cssanimations .bx-tl-item-cnt.is-hidden {
+	.cssanimations div.bx-tl-view-timeline .bx-tl-item-cnt.is-hidden {
 	    visibility: hidden;
 	}
-	.cssanimations .bx-tl-item-cnt.bounce-in {
+	.cssanimations div.bx-tl-view-timeline .bx-tl-item-cnt.bounce-in {
 		visibility: visible;
 		-webkit-animation: cd-bounce-2 0.6s;
 		-moz-animation: cd-bounce-2 0.6s;
 		animation: cd-bounce-2 0.6s;
 	}
 	/* inverse bounce effect on even content blocks */
-	.cssanimations .bx-tl-item:nth-child(even) .bx-tl-item-cnt.bounce-in {
+	.cssanimations .bx-layout-column-fullwidth div.bx-tl-view-timeline .bx-tl-item:nth-child(even) .bx-tl-item-cnt.bounce-in {
 		-webkit-animation: cd-bounce-2-inverse 0.6s;
 		-moz-animation: cd-bounce-2-inverse 0.6s;
 		animation: cd-bounce-2-inverse 0.6s;