From 4afd909938432ddd1b35bb8a7826e65d0a1d232c Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Tue, 30 Aug 2016 10:11:21 +0200 Subject: [PATCH] feat: Infinite Children Brick besitzt neue Einstellung -> rowloading, es kann bestimmt werden wieviel Reihen nachgeladen werden sollen --- ajax/brick/infinite/row.php | 34 ++++++++++++++----- bin/Controls/Children/Infinite.js | 32 ++++++++++++----- bricks.xml | 4 +++ locale.xml | 4 +++ .../Bricks/Controls/Children/Infinite.html | 2 +- src/QUI/Bricks/Controls/Children/Infinite.php | 2 +- .../Bricks/Controls/Children/InfiniteRow.html | 4 ++- 7 files changed, 63 insertions(+), 19 deletions(-) diff --git a/ajax/brick/infinite/row.php b/ajax/brick/infinite/row.php index a920143..4ce39d2 100644 --- a/ajax/brick/infinite/row.php +++ b/ajax/brick/infinite/row.php @@ -34,14 +34,32 @@ function ($brickId, $brickUID, $row) { // bad fix for getting the right attributes - like gridClass $Infinite->getBody(); - $Engine->assign(array( - 'children' => $Infinite->getRow((int)$row), - 'row' => (int)$row, - 'this' => $Infinite, - 'gridClass' => $Infinite->getAttribute('gridClass') - )); - - return $Engine->fetch($Infinite->getRowTemplate()); + + // generate rows + $loadingRows = 1; + + if (isset($settings['loadingrows']) + && !empty($settings['loadingrows']) + && (int)$settings['loadingrows'] + ) { + $loadingRows = (int)$settings['loadingrows']; + } + + $result = ''; + + for ($i = 0; $i < $loadingRows; $i++) { + $Engine->assign(array( + 'children' => $Infinite->getRow((int)$row), + 'row' => (int)$row, + 'this' => $Infinite, + 'gridClass' => $Infinite->getAttribute('gridClass') + )); + + $result .= $Engine->fetch($Infinite->getRowTemplate()); + $row++; + } + + return $result; }, array('brickId', 'brickUID', 'row'), false diff --git a/bin/Controls/Children/Infinite.js b/bin/Controls/Children/Infinite.js index 0592f20..4ca7dec 100644 --- a/bin/Controls/Children/Infinite.js +++ b/bin/Controls/Children/Infinite.js @@ -89,27 +89,43 @@ define('package/quiqqer/bricks/bin/Controls/Children/Infinite', [ html: result }); - var Row = Container.getElement( + var Rows = Container.getElements( '.quiqqer-bricks-children-infinite-row' ); - Row.setStyles({ + // no results founds + // hide more button and do nothing + if (!Rows.length) { + self.$More.removeEvents('click'); + + moofx(self.$More).animate({ + cursor : 'default', + opacity: 0 + }); + + return; + } + + Rows.setStyles({ 'float' : 'left', opacity : 0, position: 'absolute', overflow: 'hidden' }); - Row.inject(self.$More, 'before'); + Rows.each(function (Row) { + Row.inject(self.$More, 'before'); + }); + - var height = Row.getSize().y; + var height = Rows[0].getSize().y; - Row.setStyles({ + Rows.setStyles({ height : 0, position: null }); - var childrenCount = Row.getElements( + var childrenCount = Rows.getLast().getElements( '.quiqqer-bricks-children-infinite-child' ).length; @@ -123,7 +139,7 @@ define('package/quiqqer/bricks/bin/Controls/Children/Infinite', [ } - moofx(Row).animate({ + moofx(Rows).animate({ height : height, opacity: 1 }, { @@ -142,7 +158,7 @@ define('package/quiqqer/bricks/bin/Controls/Children/Infinite', [ new Fx.Scroll(window.document).start( 0, - Row.getPosition().y - 200 + Rows[0].getPosition().y - 200 ).chain(function () { self.$More.focus(); resolve(); diff --git a/bricks.xml b/bricks.xml index 57bca68..db31c67 100644 --- a/bricks.xml +++ b/bricks.xml @@ -278,6 +278,10 @@ <setting name="rows" type="number"> <locale group="quiqqer/bricks" var="brick.control.Infinite.rows" /> </setting> + + <setting name="loadingrows" type="number"> + <locale group="quiqqer/bricks" var="brick.control.Infinite.loadingrows" /> + </setting> </settings> </brick> diff --git a/locale.xml b/locale.xml index 2f75666..2356671 100644 --- a/locale.xml +++ b/locale.xml @@ -378,6 +378,10 @@ <en><![CDATA[Number of rows]]></en> <pl><![CDATA[Liczba wierszy]]></pl> </locale> + <locale name="brick.control.Infinite.loadingrows"> + <de><![CDATA[Anzahl der Zeilen welche nachgeladen werden sollen]]></de> + <en><![CDATA[Number of rows that are to be loaded]]></en> + </locale> <locale name="brick.control.Infinite.more.button"> <de><![CDATA[Mehr laden]]></de> <en><![CDATA[more]]></en> diff --git a/src/QUI/Bricks/Controls/Children/Infinite.html b/src/QUI/Bricks/Controls/Children/Infinite.html index 2e833a4..e866da3 100644 --- a/src/QUI/Bricks/Controls/Children/Infinite.html +++ b/src/QUI/Bricks/Controls/Children/Infinite.html @@ -1,6 +1,6 @@ {$children} -{if $showMoreBUtton} +{if $showMoreButton} <div class="button disabled"> {locale group="quiqqer/bricks" var="brick.control.Infinite.more.button"} </div> diff --git a/src/QUI/Bricks/Controls/Children/Infinite.php b/src/QUI/Bricks/Controls/Children/Infinite.php index 50f123f..e1cc072 100644 --- a/src/QUI/Bricks/Controls/Children/Infinite.php +++ b/src/QUI/Bricks/Controls/Children/Infinite.php @@ -112,7 +112,7 @@ public function getBody() $Engine->assign(array( 'this' => $this, 'children' => $children, - 'showMoreBUtton' => $showMoreButton + 'showMoreButton' => $showMoreButton )); return $Engine->fetch(dirname(__FILE__) . '/Infinite.html'); diff --git a/src/QUI/Bricks/Controls/Children/InfiniteRow.html b/src/QUI/Bricks/Controls/Children/InfiniteRow.html index ca7b268..63fc4c3 100644 --- a/src/QUI/Bricks/Controls/Children/InfiniteRow.html +++ b/src/QUI/Bricks/Controls/Children/InfiniteRow.html @@ -1,3 +1,4 @@ +{if count($children)} <div data-row="{$row}" class="quiqqer-bricks-children-infinite-row"> {foreach from=$children item=Child} <div class="{$gridClass} mobile-grid-50 quiqqer-bricks-children-infinite-child"> @@ -24,4 +25,5 @@ </article> </div> {/foreach} -</div> \ No newline at end of file +</div> +{/if} \ No newline at end of file -- GitLab