Kaynağa Gözat

Ticket #2059 - Usage in comments.

AntonLV 7 yıl önce
ebeveyn
işleme
884a6bdd3a

+ 34 - 0
inc/js/classes/BxDolCmts.js

@@ -417,6 +417,40 @@ BxDolCmts.prototype.goToAndReply = function(oLink, sGoToId, sBlinkIds)
 /*--- Live Updates methods ---*/
 /*----------------------------*/
 BxDolCmts.prototype.showLiveUpdate = function(oData)
+{
+    /*
+     * Note. oData.count_old and oData.count_new are also available and can be checked or used in notification popup.  
+     */
+    if(!oData.code)
+        return;
+
+    var $this = this;
+
+    var oNotifs = $(oData.code);
+    var sId = oNotifs.attr('id');
+    $('#' + sId).remove();
+
+    oNotifs.prependTo('body').dolPopup({
+        position: 'fixed',
+        top: '5rem',
+        left: 'center',
+        fog: false,
+        onBeforeShow: function() {
+        },
+        onBeforeHide: function() {
+        },
+        onShow: function() {
+            setTimeout(function() {
+                $('.bx-popup-chain.bx-popup-applied:visible:first').dolPopupHide();
+            }, 5000);
+        },
+        onHide: function() {
+            $this.resumeLiveUpdates();
+        }
+    });
+};
+
+BxDolCmts.prototype.showLiveUpdates = function(oData)
 {
 	/*
 	 * Note. oData.count_old and oData.count_new are also available and can be checked or used in notification popup.  

+ 1 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1555,6 +1555,7 @@
 	<string name="_cmt_load_more_replies_head"><![CDATA[See newer replies...]]></string>
 	<string name="_cmt_load_more_replies_tail"><![CDATA[See older replies...]]></string>
 	<string name="_cmt_load_more_replies_popular"><![CDATA[See more replies...]]></string>
+        <string name="_cmt_txt_new_content"><![CDATA[New content]]></string>
 	<string name="_cmt_txt_link_show"><![CDATA[Show]]></string>
 	<string name="_cmt_txt_link_reply"><![CDATA[Reply]]></string>
         <string name="_cmt_txt_added_sample"><![CDATA[added a new comment]]></string>

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

@@ -1553,6 +1553,7 @@
 	<string name="_cmt_load_more_replies_head"><![CDATA[Увидеть новые ответы...]]></string>
 	<string name="_cmt_load_more_replies_tail"><![CDATA[Увидеть старые ответы...]]></string>
 	<string name="_cmt_load_more_replies_popular"><![CDATA[Увидеть ещё ответы...]]></string>
+        <string name="_cmt_txt_new_content"><![CDATA[Новый контент]]></string>
 	<string name="_cmt_txt_link_show"><![CDATA[Прочитать]]></string>
 	<string name="_cmt_txt_link_reply"><![CDATA[Ответить]]></string>
         <string name="_cmt_txt_added_sample"><![CDATA[добавил новый комментарий]]></string>

+ 3 - 2
modules/boonex/timeline/template/css/view.css

@@ -506,8 +506,9 @@ div.bx-tl-item-comments-holder .cmts.cmts-margin {
 .bx-tl-live-update-alert {
     position: relative;
     display: block;
-
-    background-color: rgba(0, 0, 255, 0.2);
+}
+div.bx-tl-live-update-alert {
+    background-color: rgba(0, 0, 255, 0.4);
     text-align: center;
 }
 div.bx-tl-lua-cnt {

+ 4 - 7
template/comments_notification.html

@@ -1,10 +1,7 @@
-<div class="__style_prefix__-notif-comment">
-    <a class="__style_prefix__-notif-comment bx-def-padding" href="javascript:void(0)" onclick="__onclick_show__" title="<bx_text_attribute:_cmt_txt_link_show />">
-        <div class="__style_prefix__-notif-cnt">
-            <div class="__style_prefix__-notif-avatar bx-def-thumb-size">__author_unit__</div>
-            <div class="__style_prefix__-notif-info bx-def-thumb-size-min-height bx-def-thumb-size-left-indent bx-def-font-small">
-                <div class="__style_prefix__-notifi-username"><b class="__style_prefix__-notifi-username bx-def-font-color">__author_name__</b>: <span class="bx-def-font-small bx-def-font-grayed">__text__</span></div>
-            </div>
+<div id="__html_id__" class="__style_prefix__-alert-comment bx-def-round-corners" style="display:none;">
+    <a class="__style_prefix__-alert-comment bx-def-padding" href="javascript:void(0)" onclick="__onclick_show__" title="<bx_text_attribute:_cmt_txt_link_show />">
+        <div class="__style_prefix__-ac-cnt bx-def-font-contrasted bx-popup-width">
+            <i class="sys-icon sync-alt bx-def-font-contrasted"></i> <bx_text:_cmt_txt_new_content />
         </div>
     </a>
 </div>

+ 10 - 0
template/comments_notifications.html

@@ -0,0 +1,10 @@
+<div class="__style_prefix__-notif-comment">
+    <a class="__style_prefix__-notif-comment bx-def-padding" href="javascript:void(0)" onclick="__onclick_show__" title="<bx_text_attribute:_cmt_txt_link_show />">
+        <div class="__style_prefix__-notif-cnt">
+            <div class="__style_prefix__-notif-avatar bx-def-thumb-size">__author_unit__</div>
+            <div class="__style_prefix__-notif-info bx-def-thumb-size-min-height bx-def-thumb-size-left-indent bx-def-font-small">
+                <div class="__style_prefix__-notifi-username"><b class="__style_prefix__-notifi-username bx-def-font-color">__author_name__</b>: <span class="bx-def-font-small bx-def-font-grayed">__text__</span></div>
+            </div>
+        </div>
+    </a>
+</div>

+ 14 - 1
template/css/cmts.css

@@ -271,7 +271,20 @@
         width: 100%;
     }
 
-    /*--- Comment Styles in Live Update Notification ---*/
+    /*--- Live Update Alert Styles ---*/
+    .cmt-alert-comment {
+        position: relative;
+        display: block;
+    }
+    div.cmt-alert-comment {
+        background-color: rgba(0, 0, 255, 0.4);
+        text-align: center;
+    }
+    div.cmt-ac-cnt {
+        position: relative;
+    }
+
+    /*--- Live Update Notifications Styles ---*/
     .cmt-notif-comment {
         position: relative;
         display: block;

+ 25 - 3
template/scripts/BxBaseCmts.php

@@ -119,7 +119,7 @@ class BxBaseCmts extends BxDolCmts
         //add live update
         $this->actionResumeLiveUpdate();
 
-        $sServiceCall = BxDolService::getSerializedService('system', 'get_live_updates_comments', array($this->_sSystem, $this->_iId, $this->_getAuthorId(), '{count}'), 'TemplCmtsServices');
+        $sServiceCall = BxDolService::getSerializedService('system', 'get_live_update', array($this->_sSystem, $this->_iId, $this->_getAuthorId(), '{count}'), 'TemplCmtsServices');
         BxDolLiveUpdates::getInstance()->add($this->_sSystem . '_live_updates_cmts_' . $this->_iId, 1, $sServiceCall);
         //add live update
 
@@ -378,7 +378,29 @@ class BxBaseCmts extends BxDolCmts
         return $this->_getFormEdit($iCmtId, $aDp);
     }
 
-    function getNotification($iCountOld = 0, $iCountNew = 0)
+    function getLiveUpdate($iCountOld = 0, $iCountNew = 0)
+    {
+        $iCount = (int)$iCountNew - (int)$iCountOld;
+        if($iCount < 0)
+            return '';
+
+        $aComments = $this->_oQuery->getCommentsBy(array('type' => 'latest', 'object_id' => $this->_iId, 'author' => $this->_getAuthorId(), 'others' => 1, 'start' => '0', 'per_page' => $iCount));
+        if(empty($aComments) || !is_array($aComments))
+            return '';
+
+        $aComment = array_shift($aComments);
+        if(empty($aComment) || !is_array($aComment))
+            return '';
+
+        $sJsObject = $this->getJsObjectName();
+        return $this->_oTemplate->parseHtmlByName('comments_notification.html', array(
+            'style_prefix' => $this->_sStylePrefix,
+            'html_id' => $this->getNotificationId(),
+            'onclick_show' => "javascript:" . $sJsObject . ".goTo(this, '" . $this->getItemAnchor($aComment['cmt_id']) . "', '" . $aComment['cmt_id'] . "');",
+        ));
+    }
+
+    function getLiveUpdates($iCountOld = 0, $iCountNew = 0)
     {
         $bShowAll = true;
         $bShowActions = false;
@@ -422,7 +444,7 @@ class BxBaseCmts extends BxDolCmts
                     'condition' => !$bShowAll && $iIndex < ($iComments - 1),
                     'content' => array(),
                 ),
-                'item' => $this->_oTemplate->parseHtmlByName('comments_notification.html', array(
+                'item' => $this->_oTemplate->parseHtmlByName('comments_notifications.html', array(
                     'style_prefix' => $this->_sStylePrefix,
                     'onclick_show' => $sShowOnClick,
                     'onclick_reply' => $sReplyOnClick,

+ 40 - 15
template/scripts/BxBaseCmtsServices.php

@@ -28,29 +28,54 @@ class BxBaseCmtsServices extends BxDol
         return '';
     }
 
-    public function serviceGetLiveUpdatesComments($sSystem, $iContentId, $iProfileId, $iCount = 0)
+    public function serviceGetLiveUpdate($sSystem, $iContentId, $iProfileId, $iCount = 0)
     {
         $oCmts = BxDolCmts::getObjectInstance($sSystem, $iContentId);
         if(!$oCmts || !$oCmts->isEnabled())
             return false;
 
-		$sKey = $oCmts->getNotificationId();
+        $sKey = $oCmts->getNotificationId();
 
-		bx_import('BxDolSession');
-    	if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
-    		return false;
+        bx_import('BxDolSession');
+        if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
+            return false;
+
+        $iCountNew = $oCmts->getCommentsCount($iContentId, -1, BX_CMT_FILTER_OTHERS);
+        if($iCountNew == $iCount)
+            return false;
+
+        return array(
+            'count' => $iCountNew, // required
+            'method' => $oCmts->getJsObjectName() . '.showLiveUpdate(oData)', // required
+            'data' => array(
+                'code' => $oCmts->getLiveUpdate($iCount, $iCountNew)
+            ),  // optional, may have some additional data to be passed in JS method provided using 'method' param above.
+        );
+    }
+
+    public function serviceGetLiveUpdates($sSystem, $iContentId, $iProfileId, $iCount = 0)
+    {
+        $oCmts = BxDolCmts::getObjectInstance($sSystem, $iContentId);
+        if(!$oCmts || !$oCmts->isEnabled())
+            return false;
 
-		$iCountNew = $oCmts->getCommentsCount($iContentId, -1, BX_CMT_FILTER_OTHERS);
-		if($iCountNew == $iCount)
-			return false;
+        $sKey = $oCmts->getNotificationId();
+
+        bx_import('BxDolSession');
+        if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
+            return false;
 
-    	return array(
-    		'count' => $iCountNew, // required
-    		'method' => $oCmts->getJsObjectName() . '.showLiveUpdate(oData)', // required
-    		'data' => array(
-    			'code' => $oCmts->getNotification($iCount, $iCountNew)
-    		),  // optional, may have some additional data to be passed in JS method provided using 'method' param above.
-    	);
+        $iCountNew = $oCmts->getCommentsCount($iContentId, -1, BX_CMT_FILTER_OTHERS);
+        if($iCountNew == $iCount)
+            return false;
+
+        return array(
+            'count' => $iCountNew, // required
+            'method' => $oCmts->getJsObjectName() . '.showLiveUpdates(oData)', // required
+            'data' => array(
+                'code' => $oCmts->getLiveUpdates($iCount, $iCountNew)
+            ),  // optional, may have some additional data to be passed in JS method provided using 'method' param above.
+        );
     }
     
     public function serviceManageTools($sType = 'common')