浏览代码

#22 - persons module (refactoring)

Alex Trofimov 12 年之前
父节点
当前提交
3fdf451384

+ 9 - 10
inc/js/functions.js

@@ -246,22 +246,21 @@ function bx_loading (elem, b) {
 
 
 /**
- * js version on BxBaseFunction::centerContent function
+ * Center content with floating blocks.
  * sSel - jQuery selector of content to be centered
  * sBlockSel - jquery selector of blocks
  */
 function bx_center_content (sSel, sBlockStyle) {
     var sId = 'id' + (new Date()).getTime();
     $(sSel).wrap('<div id="'+sId+'"></div>');
-    //$(document).ready(function() {
-            var eCenter = $('#' + sId);
-            var iAll = $('#' + sId + ' ' + sBlockStyle).size();
-            var iWidthUnit = $('#' + sId + ' ' + sBlockStyle + ':first').outerWidth({"margin":true});            
-            var iWidthContainer = eCenter.innerWidth();           
-            var iPerRow = parseInt(iWidthContainer/iWidthUnit);
-            var iLeft = (iWidthContainer - (iAll > iPerRow ? iPerRow * iWidthUnit : iAll * iWidthUnit)) / 2;
-            eCenter.css("padding-left", iLeft);
-    //});
+
+    var eCenter = $('#' + sId);
+    var iAll = $('#' + sId + ' ' + sBlockStyle).size();
+    var iWidthUnit = $('#' + sId + ' ' + sBlockStyle + ':first').outerWidth(true);
+    var iWidthContainer = eCenter.innerWidth();           
+    var iPerRow = parseInt(iWidthContainer/iWidthUnit);
+    var iLeft = (iWidthContainer - (iAll > iPerRow ? iPerRow * iWidthUnit : iAll * iWidthUnit)) / 2;
+    eCenter.css("padding-left", iLeft);
 }
 
 /**

+ 1 - 0
modules/base/profile/classes/BxBaseModProfileSearchResult.php

@@ -16,6 +16,7 @@ class BxBaseModProfileSearchResult extends BxBaseModGeneralSearchResult
     function __construct($sMode = '', $aParams = array()) 
     {
         parent::__construct($sMode, $aParams);
+        $this->sCenterContentUnitSelector = '.bx-base-pofile-unit';
     }
 }
 

+ 4 - 13
modules/boonex/persons/classes/BxPersonsSearchResult.php

@@ -13,7 +13,6 @@ bx_import('BxBaseModProfileSearchResult');
 
 class BxPersonsSearchResult extends BxBaseModProfileSearchResult 
 {
-
     function __construct($sMode = '', $aParams = false) 
     {
         parent::__construct($sMode, $aParams);
@@ -118,7 +117,8 @@ class BxPersonsSearchResult extends BxBaseModProfileSearchResult
         parent::__construct();
     }
 
-    function getAlterOrder() {
+    function getAlterOrder() 
+    {
         switch ($this->aCurrent['sorting']) {
         case 'none':
             return array();
@@ -130,17 +130,8 @@ class BxPersonsSearchResult extends BxBaseModProfileSearchResult
         }
     }
 
-    function displayResultBlock () {        
-        $s = parent::displayResultBlock ();
-        if ($s) {
-            BxDolTemplate::getInstance()->addDynamicLocation($this->oModule->_oConfig->getHomePath(), $this->oModule->_oConfig->getHomeUrl());
-            bx_import('BxTemplFunctions');
-            return BxTemplFunctions::getInstance()->centerContent ($s, '.bx-persons-unit');
-        }
-        return '';
-    }
-
-    function _getPseud () {
+    function _getPseud () 
+    {
         return array(
             'id' => 'id',
             'fullname' => 'fullname',

+ 0 - 1
searchKeyword.php

@@ -48,7 +48,6 @@ function getSearchForm () {
             require_once($sPath);
         }
         $oClass = new $aValue['class']();
-        $oClass->addCustomParts();
     }
 
     if (isset($_GET['type'])) {

+ 4 - 2
template/css/paginate.css

@@ -1,11 +1,11 @@
 
-/* * * * Pagination * * * */
-
 .bx-paginate {
     line-height:38px;
+    line-height:2.375rem;
 }
 .bx-paginate-simple {
     line-height:22px;
+    line-height:1.375rem;
 }
 
 .bx-paginate-btns,
@@ -19,4 +19,6 @@
 
 .bx-paginate-btn-next {
     margin-left:5px;
+    margin-left:0.3rem;
 }
+

+ 1 - 1
template/scripts/BxBaseConfig.php

@@ -33,7 +33,7 @@ class BxBaseConfig extends BxDol implements iBxDolSingleton {
             'bx-size-gallery-img-width' => '300px',
             'bx-size-gallery-img-height' => '200px',
             'bx-size-gallery-unit-width' => '300px',
-            'bx-size-gallery-unit-height' => '300px',
+            'bx-size-gallery-unit-height' => '320px',
 
 			'bx-color-page' => '#fff',
 			'bx-color-block' => '#fff',

+ 0 - 23
template/scripts/BxBaseFunctions.php

@@ -352,29 +352,6 @@ class BxBaseFunctions extends BxDol implements iBxDolSingleton {
         return $sActionsList;
     }
 
-    /**
-     * alternative to GenFormWrap
-     * easy to use but javascript based
-     * $s - content to be centered
-     * $sBlockStyle - block's style, jquery selector
-     *
-     * see also bx_center_content javascript function, if you need to call this function from javascript
-     */
-    function centerContent ($s, $sBlockStyle, $isClearBoth = true) {
-        $sId = 'id' . time() . rand();
-        return  '<div id="'.$sId.'">' . $s . ($isClearBoth ? '<div class="clear_both"></div>' : '') . '</div><script>
-            $(document).ready(function() {
-                var eCenter = $("#'.$sId.'");
-                var iAll = $("#'.$sId.' '.$sBlockStyle.'").size();
-                var iWidthUnit = $("#'.$sId.' '.$sBlockStyle.':first").outerWidth({"margin":true});
-                var iWidthContainer = eCenter.width();
-                var iPerRow = parseInt(iWidthContainer/iWidthUnit);
-                var iLeft = (iWidthContainer - (iAll > iPerRow ? iPerRow * iWidthUnit : iAll * iWidthUnit)) / 2;
-                eCenter.css("padding-left", iLeft);
-            });
-        </script>';
-    }
-
     function genNotifyMessage($sMessage, $sDirection = 'left', $isButton = false, $sScript = '') {
         $sDirStyle = ($sDirection == 'left') ? '' : 'notify_message_none';
         switch ($sDirection) {

+ 16 - 3
template/scripts/BxBaseSearchResult.php

@@ -22,6 +22,8 @@ class BxBaseSearchResult extends BxDolSearchResult
 
     protected $aConstants;
 
+    protected $sCenterContentUnitSelector = false;
+
     function __construct($oFunctions = false) 
     {
         parent::__construct();
@@ -44,12 +46,23 @@ class BxBaseSearchResult extends BxDolSearchResult
         $sCode = '';
         $aData = $this->getSearchData();
         if ($this->aCurrent['paginate']['num'] > 0) {
+
             $sCode .= $this->addCustomParts();
-            foreach ($aData as $aValue) {
+
+            foreach ($aData as $aValue)
                 $sCode .= $this->displaySearchUnit($aValue);
-            }
-            $sCode = '<div class="bx-search-result-block bx-clearfix">' . $sCode . '</div>';
 
+            $sSearchResultBlockId = 'bx-search-result-block-' . rand(0, PHP_INT_MAX);
+            $sCode = '<div id="' . $sSearchResultBlockId . '" class="bx-search-result-block bx-clearfix">' . $sCode . '</div>';
+
+            if ($this->sCenterContentUnitSelector) {
+                $sCode .= "
+                    <script>
+                        $(document).ready(function() {
+                            bx_center_content('#{$sSearchResultBlockId}', '{$this->sCenterContentUnitSelector}');
+                        });
+                    </script>";
+            }
         }
         return $sCode;
     }