AntonLV %!s(int64=8) %!d(string=hai) anos
pai
achega
063fb3cac5

+ 25 - 10
inc/classes/BxDolCmts.php

@@ -131,6 +131,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
     protected $_oQuery = null;
     protected $_oTemplate = null;
 
+    protected $_bMinPostForm;
     protected $_sFormObject;
     protected $_sFormDisplayPost;
     protected $_sFormDisplayEdit;
@@ -222,6 +223,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
 
         $this->_oQuery = new BxDolCmtsQuery($this);
 
+        $this->_bMinPostForm = true;
         $this->_sFormObject = 'sys_comment';
         $this->_sFormDisplayPost = 'sys_comment_post';
         $this->_sFormDisplayEdit = 'sys_comment_edit';
@@ -835,11 +837,19 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         if (!$this->isEnabled())
             return '';
 
-        $iCmtParentId= isset($_REQUEST['CmtParent']) ? bx_process_input($_REQUEST['CmtParent'], BX_DATA_INT) : 0;
-        $sCmtBrowse = isset($_REQUEST['CmtBrowse']) ? bx_process_input($_REQUEST['CmtBrowse'], BX_DATA_TEXT) : '';
-        $sCmtDisplay = isset($_REQUEST['CmtDisplay']) ? bx_process_input($_REQUEST['CmtDisplay'], BX_DATA_TEXT) : '';
+        $iCmtParentId = bx_get('CmtParent');
+        $iCmtParentId = $iCmtParentId !== false ? bx_process_input($iCmtParentId, BX_DATA_INT) : 0;
+        
+        $sCmtBrowse = bx_get('CmtBrowse');
+        $sCmtBrowse = $sCmtBrowse !== false ? bx_process_input($sCmtBrowse, BX_DATA_TEXT) : '';
+
+        $sCmtDisplay = bx_get('CmtDisplay');
+        $sCmtDisplay = $sCmtDisplay !== false ? bx_process_input($sCmtDisplay, BX_DATA_TEXT) : '';
 
-        return $this->getFormBoxPost(array('parent_id' => $iCmtParentId, 'type' => $sCmtBrowse), array('type' => $sCmtDisplay, 'dynamic_mode' => true));
+        $bMinPostForm = bx_get('CmtMinPostForm');
+        $bMinPostForm = $bMinPostForm !== false ? bx_process_input($bMinPostForm, BX_DATA_INT) == 1 : $this->_bMinPostForm;
+
+        return $this->getFormBoxPost(array('parent_id' => $iCmtParentId, 'type' => $sCmtBrowse), array('type' => $sCmtDisplay, 'dynamic_mode' => true, 'min_post_form' => $bMinPostForm));
     }
 
     public function actionGetFormEdit ()
@@ -1344,10 +1354,13 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         if(bx_get('CmtBlink') !== false) 
             $aDp['blink'] = bx_process_input($_REQUEST['CmtBlink'], BX_DATA_TEXT);
 
+        $aDp['min_post_form'] = isset($aDp['min_post_form']) ? (bool)$aDp['min_post_form'] : $this->_bMinPostForm;
+        if(bx_get('CmtMinPostForm') !== false)
+            $aDp['min_post_form'] = bx_process_input(bx_get('CmtMinPostForm'), BX_DATA_INT) == 1;
+
         $aDp['in_designbox'] = isset($aDp['in_designbox']) ? (bool)$aDp['in_designbox'] : true;
         $aDp['dynamic_mode'] = isset($aDp['dynamic_mode']) ? (bool)$aDp['dynamic_mode'] : false;
         $aDp['show_empty'] = isset($aDp['show_empty']) ? (bool)$aDp['show_empty'] : false;
-            
     }
 
     protected function _prepareTextForOutput ($s, $iCmtId = 0)
@@ -1366,18 +1379,20 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
 
     protected function _prepareParams(&$aBp, &$aDp)
     {
-        $aBp['type'] = isset($aBp['type']) && !empty($aBp['type']) ? $aBp['type'] : $this->_sBrowseType;
-        $aBp['filter'] = isset($aBp['filter']) && !empty($aBp['filter']) ? $aBp['filter'] : $this->_sBrowseFilter;
+        $aBp['type'] = !empty($aBp['type']) ? $aBp['type'] : $this->_sBrowseType;
+        $aBp['filter'] = !empty($aBp['filter']) ? $aBp['filter'] : $this->_sBrowseFilter;
         $aBp['parent_id'] = isset($aBp['parent_id']) ? $aBp['parent_id'] : 0;
         $aBp['start'] = isset($aBp['start']) ? $aBp['start'] : -1;
         $aBp['per_view'] = isset($aBp['per_view']) ? $aBp['per_view'] : -1;
         $aBp['order']['by'] = isset($aBp['order_by']) ? $aBp['order_by'] : $this->_aOrder['by'];
         $aBp['order']['way'] = isset($aBp['order_way']) ? $aBp['order_way'] : $this->_aOrder['way'];
 
-        $aDp['type'] = isset($aDp['type']) && !empty($aDp['type']) ? $aDp['type'] : $this->_sDisplayType;
-        $aDp['blink'] = isset($aDp['blink']) && !empty($aDp['blink']) ? $aDp['blink'] : array();
+        $aDp['type'] = !empty($aDp['type']) ? $aDp['type'] : $this->_sDisplayType;
+        $aDp['blink'] = !empty($aDp['blink']) ? $aDp['blink'] : array();
         if(!is_array($aDp['blink']))
-        	$aDp['blink'] = explode(',', $aDp['blink']);
+            $aDp['blink'] = explode(',', $aDp['blink']);
+        if(!isset($aDp['min_post_form']))
+            $aDp['min_post_form'] = $this->_bMinPostForm;
 
         switch($aDp['type']) {
             case BX_CMT_DISPLAY_FLAT:

+ 20 - 2
inc/js/classes/BxDolCmts.js

@@ -15,6 +15,7 @@ function BxDolCmts (options) {
     this._iObjId = options.iObjId; // this object id comments
     this._sBaseUrl = options.sBaseUrl; // base url to view comment's listing.
 
+    this._iMinPostForm = undefined == options.iMinPostForm ? 0 : options.iMinPostForm;
     this._sPostFormPosition = undefined == options.sPostFormPosition ? 'top' : options.sPostFormPosition;
     this._sDisplayType = undefined == options.sDisplayType ? 'threaded' : options.sDisplayType;
     this._sBrowseType = undefined == options.sBrowseType ? 'tail' : options.sBrowseType;
@@ -55,6 +56,23 @@ BxDolCmts.prototype.cmtInitFormPost = function(sCmtFormId)
     });
 };
 
+BxDolCmts.prototype.cmtShowForm = function(oElement)
+{
+    var oForm = $(oElement).parents('.cmt-reply.cmt-reply-min:first');
+    oForm.find('.cmt-body-min').bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
+        oForm.find('.cmt-body').show(function() {
+            var oTextarea = oForm.find("[name='cmt_text']");
+            if(typeof bx_editor_get_htmleditable === 'function')
+                oTextarea = bx_editor_get_htmleditable(oTextarea);
+
+            if(!oTextarea || oTextarea.length == 0)
+                return;
+
+            oTextarea.focus();
+        });
+    });
+};
+
 BxDolCmts.prototype.cmtBeforePostSubmit = function(oCmtForm)
 {
 	this._loadingInButton($(oCmtForm).children().find(':submit'), true);
@@ -550,14 +568,14 @@ BxDolCmts.prototype._getCmts = function (oElement, oRequestParams, onLoad)
 
 BxDolCmts.prototype._getForm = function (e, iCmtParentId, onLoad)
 {
-	var $this = this;
-
+    var $this = this;
     var oData = this._getDefaultActions();
     oData['action'] = 'GetFormPost';
     oData['CmtType'] = 'reply';
     oData['CmtParent'] = iCmtParentId;
     oData['CmtBrowse'] = this._sBrowseType;
     oData['CmtDisplay'] = this._sDisplayType;
+    oData['CmtMinPostForm'] = this._iMinPostForm;
 
     if(e)
     	this._loadingInContent(e, true);

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

@@ -1555,6 +1555,7 @@
         <string name="_cmt_txt_do"><![CDATA[Comment]]></string>
         <string name="_cmt_txt_counter"><![CDATA[{0}]]></string>
 	<string name="_cmt_txt_counter_empty"><![CDATA[Comment]]></string>
+        <string name="_cmt_txt_min_form_placeholder"><![CDATA[{0}, leave your comment here.]]></string>
 	<string name="_copyright"><![CDATA[&copy; {0} Company]]></string>
 	<string name="_delete"><![CDATA[delete]]></string>
 	<string name="_error occured"><![CDATA[Error occurred]]></string>

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

@@ -1553,6 +1553,7 @@
         <string name="_cmt_txt_do"><![CDATA[Комментировать]]></string>
         <string name="_cmt_txt_counter"><![CDATA[{0}]]></string>
 	<string name="_cmt_txt_counter_empty"><![CDATA[Комментировать]]></string>
+        <string name="_cmt_txt_min_form_placeholder"><![CDATA[{0}, здесь Вы можете оставить комментарий.]]></string>
 	<string name="_copyright"><![CDATA[&copy; {0} Компания]]></string>
 	<string name="_delete"><![CDATA[удалить]]></string>
 	<string name="_error occured"><![CDATA[Произошла ошибка]]></string>

+ 14 - 6
template/comment_reply_box.html

@@ -1,7 +1,15 @@
-<div class="__style_prefix__-reply<bx_if:show_class> __class__</bx_if:show_class> bx-def-padding-top bx-def-margin-bottom">
-	<div class="__style_prefix__-cont __style_prefix__-post-reply">
-		<div class="__style_prefix__-cont-cnt">
-			<div class="__style_prefix__-body">__form__</div>
-		</div>
-	</div>
+<div class="__style_prefix__-reply__class__ bx-def-padding-top bx-def-margin-bottom">
+    <div class="__style_prefix__-cont __style_prefix__-post-reply">
+        <div class="__style_prefix__-cont-cnt">
+            <bx_if:show_form_min>
+                <div class="__style_prefix__-body-min">
+                    <div class="__style_prefix__-bm-user">__author_unit__</div>
+                    <div class="__style_prefix__-bm-content bx-def-thumb-size-min-height bx-def-thumb-size-left-indent bx-def-font-grayed">
+                        <div onclick="__js_object__.cmtShowForm(this)">__placeholder__</div>
+                    </div>
+                </div>
+            </bx_if:show_form_min>
+            <div class="__style_prefix__-body">__form__</div>
+        </div>
+    </div>
 </div>

+ 24 - 1
template/css/cmts.css

@@ -240,7 +240,30 @@
     div.cmts-uploader-file-preview img {
 		background-position: center center;
 		background-repeat: no-repeat;
-    }  
+    } 
+    
+    /*--- Minified Post Form ---*/
+    div.cmt-reply.cmt-reply-min div.cmt-body {
+        display: none;
+    }
+    div.cmt-reply div.cmt-body-min {
+        position: relative;
+        display: none;
+    }
+    div.cmt-reply.cmt-reply-min div.cmt-body-min {
+        display: block;
+    }
+    div.cmt-reply div.cmt-body-min .cmt-bm-user {
+        position: absolute;
+        top: 0;
+        left: 0;
+    }
+    div.cmt-reply div.cmt-body-min .cmt-bm-content {
+        display: -webkit-flex;
+        display: flex;
+        -webkit-align-items: center;
+        align-items: center;
+    }
 
     /*--- Comment Styles in Live Update Notification ---*/
 	div.cmt-notif-comment {

+ 50 - 30
template/scripts/BxBaseCmts.php

@@ -84,18 +84,21 @@ class BxBaseCmts extends BxDolCmts
      *
      * @return string
      */
-    public function getJsScript()
+    public function getJsScript($aBp = array(), $aDp = array())
     {
+        $bMinPostForm = isset($aDp['min_post_form']) ? $aDp['min_post_form'] : $this->_bMinPostForm;
+
         $aParams = array(
             'sObjName' => $this->_sJsObjName,
             'sRootUrl' => BX_DOL_URL_ROOT,
             'sSystem' => $this->getSystemName(),
             'iAuthorId' => $this->_getAuthorId(),
             'iObjId' => $this->getId(),
-        	'sBaseUrl' => $this->getBaseUrl(),
+            'sBaseUrl' => $this->getBaseUrl(),
             'sPostFormPosition' => $this->_aSystem['post_form_position'],
             'sBrowseType' => $this->_sBrowseType,
-            'sDisplayType' => $this->_sDisplayType
+            'sDisplayType' => $this->_sDisplayType,
+            'iMinPostForm' => $bMinPostForm ? 1 : 0,
         );
 
         $this->addCssJs();
@@ -107,14 +110,14 @@ class BxBaseCmts extends BxDolCmts
      */
     function getCommentsBlock($aBp = array(), $aDp = array())
     {
-		$this->_getParams($aBp, $aDp);
+        $this->_getParams($aBp, $aDp);
 
-		//add live update
-		$this->actionResumeLiveUpdate();
+        //add live update
+        $this->actionResumeLiveUpdate();
 
-		$sServiceCall = BxDolService::getSerializedService('system', 'get_live_updates_comments', array($this->_sSystem, $this->_iId, $this->_getAuthorId(), '{count}'), 'TemplCmtsServices');
-		BxDolLiveUpdates::getInstance()->add($this->_sSystem . '_live_updates_cmts_' . $this->_iId, 1, $sServiceCall);
-		//add live update
+        $sServiceCall = BxDolService::getSerializedService('system', 'get_live_updates_comments', array($this->_sSystem, $this->_iId, $this->_getAuthorId(), '{count}'), 'TemplCmtsServices');
+        BxDolLiveUpdates::getInstance()->add($this->_sSystem . '_live_updates_cmts_' . $this->_iId, 1, $sServiceCall);
+        //add live update
 
         $sCaption = _t($this->_aT['block_comments_title'], $this->getCommentsCountAll());
         $sContent = BxDolTemplate::getInstance()->parseHtmlByName('comments_block.html', array(
@@ -124,8 +127,8 @@ class BxBaseCmts extends BxDolCmts
             'comments' => $this->getComments($aBp, $aDp),
             'post_form_top' => $this->getFormBoxPost($aBp, array_merge($aDp, array('type' => $this->_sDisplayType, 'position' => BX_CMT_PFP_TOP))),
             'post_form_bottom'  => $this->getFormBoxPost($aBp, array_merge($aDp, array('type' => $this->_sDisplayType, 'position' => BX_CMT_PFP_BOTTOM))),
-        	'view_image_popup' => $this->_getViewImagePopup(),
-            'script' => $this->getJsScript()
+            'view_image_popup' => $this->_getViewImagePopup(),
+            'script' => $this->getJsScript($aBp, $aDp)
         ));
 
         return $aDp['in_designbox'] ? DesignBoxContent($sCaption, $sContent, BX_DB_DEF, $this->_getControlsBox()) : array(
@@ -173,11 +176,9 @@ class BxBaseCmts extends BxDolCmts
         if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
             return $mixedResult;
 
-        $sComment = $this->getComment(
-        	$iCmtId, 
-        	array_merge(array('type' => $this->_sBrowseType), $aBp), 
-        	array_merge(array('type' => BX_CMT_DISPLAY_THREADED), $aDp)
-        );
+        $aBp = array_merge(array('type' => $this->_sBrowseType), $aBp);
+        $aDp = array_merge(array('type' => BX_CMT_DISPLAY_THREADED), $aDp);
+        $sComment = $this->getComment($iCmtId, $aBp, $aDp);
         if (!$sComment)
             return '';
 
@@ -185,8 +186,8 @@ class BxBaseCmts extends BxDolCmts
             'system' => $this->_sSystem,
             'id' => $this->getId(),
             'comment' => $sComment,
-        	'view_image_popup' => $this->_getViewImagePopup(), 
-            'script' => $this->getJsScript()
+            'view_image_popup' => $this->_getViewImagePopup(), 
+            'script' => $this->getJsScript($aBp, $aDp)
         ));
     }
 
@@ -300,16 +301,17 @@ class BxBaseCmts extends BxDolCmts
 
     function getCommentSearch($iCmtId, &$sAddon)
     {
-        if(empty($sAddon))
-            $sAddon = $this->getJsScript();
-
-        $sComment = $this->getComment($iCmtId, array(), array(
+        $aBp = array();
+        $aDp = array(
             'type' => BX_CMT_DISPLAY_FLAT, 
             'view_only' => true
-        ));
+        );
+
+        if(empty($sAddon))
+            $sAddon = $this->getJsScript($aBp, $aDp);
 
         return BxDolTemplate::getInstance()->parseHtmlByName('comment_search.html', array(
-            'comment' => $sComment,
+            'comment' => $this->getComment($iCmtId, $aBp, $aDp),
             'view_image_popup' => $this->_getViewImagePopup(), 
         )); 
     }
@@ -670,22 +672,40 @@ class BxBaseCmts extends BxDolCmts
     {
         $iCmtParentId = isset($aBp['parent_id']) ? (int)$aBp['parent_id'] : 0;
         $sPosition = isset($aDp['position']) ? $aDp['position'] : '';
+        $bFormMin = $iCmtParentId == 0 && isset($aDp['min_post_form']) ? $aDp['min_post_form'] : false;
 
         $sPositionSystem = $this->_aSystem['post_form_position'];
         if(!empty($sPosition) && $sPositionSystem != $sPosition)
             return '';
 
+        $sClass = '';
+        if(!empty($sPosition))
+            $sClass .= ' ' . $this->_sStylePrefix . '-reply-' . $sPosition;
+        if($bFormMin)
+            $sClass .= ' ' . $this->_sStylePrefix . '-reply-min';
+
+        $aTmplVarsFormMin = array();
+        if($bFormMin) {
+            list($sAuthorName, $sAuthorLink, $sAuthorIcon, $sAuthorUnit) = $this->_getAuthorInfo($this->_getAuthorId());
+
+            $aTmplVarsFormMin = array(
+                'js_object' => $this->_sJsObjName,
+                'style_prefix' => $this->_sStylePrefix,
+                'author_unit' => $sAuthorUnit,
+                'placeholder' => _t('_cmt_txt_min_form_placeholder', $sAuthorName)
+            );
+        }
+
         $sMethod = '_getForm' . ucfirst($sType);
         $aForm = $this->$sMethod($iCmtParentId, $aDp);
 
         return BxDolTemplate::getInstance()->parseHtmlByName('comment_reply_box.html', array(
             'js_object' => $this->_sJsObjName,
             'style_prefix' => $this->_sStylePrefix,
-            'bx_if:show_class' => array(
-                'condition' => !empty($sPosition),
-                'content' => array(
-                    'class' => $this->_sStylePrefix . '-reply-' . $sPosition
-                )
+            'class' => $sClass,
+            'bx_if:show_form_min' => array(
+                'condition' => $bFormMin,
+                'content' => $aTmplVarsFormMin
             ),
             'form' => $aForm['form'],
             'form_id' => $aForm['form_id'],
@@ -952,7 +972,7 @@ class BxBaseCmts extends BxDolCmts
 
     	return array(
     	    'author_unit' => $sAuthorUnit,
-    		'bx_if:show_icon' => array(
+            'bx_if:show_icon' => array(
                 'condition' => $bAuthorIcon,
                 'content' => array(
                     'author_icon' => $sAuthorIcon