AntonLV 7 лет назад
Родитель
Сommit
33371b3cb8

+ 1 - 0
modules/base/text/classes/BxBaseModTextConfig.php

@@ -59,6 +59,7 @@ class BxBaseModTextConfig extends BxBaseModGeneralConfig
         $this->_aHtmlIds = array(
             'add_poll_popup' =>  $sPrefix . '-add-poll-popup',
             'add_poll_form_field' => $sPrefix . '-add-poll-form-field',
+            'polls_showcase' => $sPrefix . '-polls-showcase-',
             'poll' => $sPrefix . '-poll-',
             'poll_content' => $sPrefix . '-poll-content-',
             'poll_view_menu' => $sPrefix . '-poll-view-menu',

+ 10 - 9
modules/base/text/classes/BxBaseModTextModule.php

@@ -331,6 +331,8 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
     {
         $CNF = &$this->_oConfig->CNF;
 
+        $iMaxNumber = 1;
+
         if(!$this->_oConfig->isAttachmentsInTimeline() || empty($CNF['OBJECT_STORAGE_VIDEOS']) || empty($CNF['OBJECT_VIDEOS_TRANSCODERS']))
             return parent::_getVideosForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
 
@@ -341,6 +343,9 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
         if(!$aGhostFiles)
             return array();
 
+        if($iMaxNumber > 0)
+            $aGhostFiles = array_slice($aGhostFiles, 0, $iMaxNumber);
+
         $oTcPoster = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['poster']);
         $oTcMp4 = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4']);
         $oTcWebm = BxDolTranscoderVideo::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['webm']);
@@ -348,15 +353,13 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
             return array();
 
         $aResults = array();
-        foreach ($aGhostFiles as $k => $a) {
-
+        foreach ($aGhostFiles as $k => $a) 
             $aResults[$a['id']] = array(
                 'id' => $a['id'],
                 'src_poster' => $oTcPoster->getFileUrl($a['id']),
                 'src_mp4' => $oTcMp4->getFileUrl($a['id']),
                 'src_webm' => $oTcWebm->getFileUrl($a['id']),
             );
-        }
 
         return $aResults;
     }
@@ -385,17 +388,15 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
 
                 $sPolls .= $sPoll;
             }
-        
+
             if(!empty($sPolls)) {
                 $sInclude = '';
                 $sInclude .= $this->_oTemplate->addJs(array('polls.js'), $bDynamic);
                 $sInclude .= $this->_oTemplate->addCss(array('polls.css'), $bDynamic);
 
-                $aResult['raw'] = ($bDynamic ? $sInclude : '') . $this->_oTemplate->parseHtmlByName('poll_items.html', array(
-                    'bx_if:show_autosizing' => array(
-                        'condition' => false,
-                        'content' => array()
-                    ),
+                $aResult['raw'] = ($bDynamic ? $sInclude : '') . $this->_oTemplate->parseHtmlByName('poll_items_showcase.html', array(
+                    'js_object' => $this->_oConfig->getJsObject('poll'),
+                    'html_id' => $this->_oConfig->getHtmlIds('polls_showcase') . $aEvent['id'],
                     'polls' => $sPolls
                 )) . $this->_oTemplate->getJsCode('poll');
             }

+ 0 - 4
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -143,10 +143,6 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         $this->addCss(array('polls.css'));
         $this->addJs(array('polls.js'));
         return $this->parseHtmlByName('poll_items.html', array(
-            'bx_if:show_autosizing' => array(
-                'condition' => true,
-                'content' => array()
-            ),
             'polls' => $sPolls
         ));
     }

+ 9 - 0
modules/base/text/template/css/polls.css

@@ -52,6 +52,15 @@
     overflow:hidden;
 }
 
+.bx-base-text-polls-showcase {
+    position: relative;
+}
+
+.bx-base-text-polls-showcase .bx-base-text-poll {
+    position: relative;
+    width: 100%;
+}
+
 /* Media: phone2 */
 .bx-media-phone2 .bx-layout-column-half .bx-base-text-polls.bx-base-text-autosizing .bx-base-text-poll,
 .bx-media-phone2 .bx-layout-column-thin .bx-base-text-polls.bx-base-text-autosizing .bx-base-text-poll {

+ 1 - 1
modules/base/text/template/poll_items.html

@@ -1 +1 @@
-<div class="bx-base-text-polls<bx_if:show_autosizing> bx-base-text-autosizing</bx_if:show_autosizing> bx-def-margin-sec-leftright-neg">__polls__</div>
+<div class="bx-base-text-polls bx-base-text-autosizing bx-def-margin-sec-leftright-neg">__polls__</div>

+ 6 - 0
modules/base/text/template/poll_items_showcase.html

@@ -0,0 +1,6 @@
+<div id="__html_id__" class="bx-base-text-polls-showcase bx-def-margin-sec-leftright-neg">__polls__</div>
+<script>
+    $(document).ready(function() {
+        __js_object__.initFlickity('#__html_id__');
+    });
+</script>

+ 22 - 0
modules/boonex/posts/js/polls.js

@@ -19,6 +19,28 @@ function BxPostsPolls(oOptions) {
     this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams;
 }
 
+BxPostsPolls.prototype.initFlickity = function(oParent) {
+    if(!oParent)
+        return;
+
+    if(typeof(oParent) == 'string')
+        oParent = $(oParent);
+
+    var sItemClass = 'bx-base-text-poll';
+    var sItemsClass = 'bx-base-text-polls-showcase';
+
+    var oItems = $(oParent).hasClass(sItemsClass) ? oParent : oParent.find('.' + sItemsClass);
+    if(oItems.find('.' + sItemClass).length <= 1)
+        return;
+
+    oItems.flickity({
+        cellSelector: 'div.' + sItemClass,
+        cellAlign: 'left',
+        pageDots: false,
+        imagesLoaded: true
+    });
+};
+
 BxPostsPolls.prototype.initPollForm = function(sFormId)
 {
     var $this = this;

+ 1 - 0
modules/boonex/posts/template/poll_items_showcase.html

@@ -0,0 +1 @@
+<bx_include_base:../modules/base/text/template/poll_items_showcase.html />