Răsfoiți Sursa

#24 - Share counter and share element settings.

AntonLV 13 ani în urmă
părinte
comite
065b45d4d7

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -110,7 +110,7 @@ class BxTimelineConfig extends BxDolModuleConfig
 			'show_do_share_label' => false,
 			'show_counter' => true
 		);
-        
+
         $this->_sAnimationEffect = 'fade';
         $this->_iAnimationSpeed = 'slow';
         $this->_sStylePrefix = 'bx-tl';

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

@@ -140,7 +140,8 @@ class BxTimelineModule extends BxDolModule
         if(!empty($iId)) {
         	$this->onShare($iId, $aShared);
 
-        	$this->_echoResultJson(array('code' => 0, 'msg' => _t('_bx_timeline_txt_msg_success_share')));
+        	$sCounter = $this->_oTemplate->getShareCounter($aContent['type'], $aContent['action'], $aContent['object_id']);
+        	$this->_echoResultJson(array('code' => 0, 'counter' => $sCounter, 'msg' => _t('_bx_timeline_txt_msg_success_share')));
         	return;
         }
 

+ 18 - 4
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -295,26 +295,40 @@ class BxTimelineTemplate extends BxDolModuleTemplate
 
 	public function getShareElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams = array())
     {
-    	$sStylePrefix = $this->_oConfig->getPrefix('style');
-
     	$aShared = $this->_oDb->getShared($sType, $sAction, $iObjectId);
+    	if(empty($aShared) || !is_array($aShared))
+    		return '';
+
+		$bShowDoShareAsButton = isset($aParams['show_do_share_as_button']) && $aParams['show_do_share_as_button'] == true;
+		$bShowDoShareIcon = isset($aParams['show_do_share_icon']) && $aParams['show_do_share_icon'] == true;
+		$bShowDoShareLabel = isset($aParams['show_do_share_label']) && $aParams['show_do_share_label'] == true;
+		$bShowCounter = isset($aParams['show_counter']) && $aParams['show_counter'] === true;
+
+		$sDoShare = '';
+		if($bShowDoShareIcon)
+			$sDoShare .= $this->parseHtmlByName('bx_icon.html', array('name' => 'share'));
+
+		if($bShowDoShareLabel)
+			$sDoShare .= ($sDoShare != '' ? ' ' : '') . _t('_bx_timeline_txt_do_share');
 
     	$sDoShare = $this->parseHtmlByName('bx_a.html', array(
     		'href' => 'javascript:void(0)',
     		'title' => _t('_bx_timeline_txt_do_share'),
     		'bx_repeat:attrs' => array(
+    			array('key' => 'class', 'value' => ($bShowDoShareAsButton ? 'bx-btn' : '')),
     			array('key' => 'onclick', 'value' => $this->getShareJsClick($iOwnerId, $sType, $sAction, $iObjectId))
     		),
-    		'content' => $this->parseHtmlByName('bx_icon.html', array('name' => 'share'))
+    		'content' => $sDoShare
     	));
 
+    	$sStylePrefix = $this->_oConfig->getPrefix('style');
     	return $this->parseHtmlByName('share_element_block.html', array(
     		'style_prefix' => $sStylePrefix,
     		'html_id' => $this->_oConfig->getHtmlIds('share', 'main') . $aShared['id'],
     		'count' => $aShared['shares'],
     		'do_share' => $sDoShare,
     		'bx_if:show_counter' => array(
-    			'condition' => isset($aParams['show_counter']) && $aParams['show_counter'] === true,
+    			'condition' => $bShowCounter,
     			'content' => array(
     				'style_prefix' => $sStylePrefix,
     				'counter' => $this->getShareCounter($sType, $sAction, $iObjectId)

+ 5 - 0
modules/boonex/timeline/js/share.js

@@ -32,6 +32,11 @@ BxTimelineShare.prototype.shareItem = function(oLink, iOwnerId, sType, sAction,
 
         	if(oData && oData.msg != undefined)
                 alert(oData.msg);
+
+        	if(oData && oData.counter != undefined) {
+        		var sCounterId = $(oData.counter).attr('id');
+        		$('#' + sCounterId).replaceWith(oData.counter);
+        	}
         },
         'json'
     );