diff --git a/ajax/brick/infinite/row.php b/ajax/brick/infinite/row.php index a920143dbf825b85ca95ca2e78ec73d5659873b4..4ce39d2eb8851c398dadbf3f3a3b2e0c32ac6b41 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 0592f20937aeae91192a239d91cb6c2b4691407a..4ca7decd2366ab29377b034080f28a80bdfac455 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 57bca68a2f12ede52a4d1fbba4146f063852ffba..db31c6765417671b2ebd6cd682dbe7db60753ec8 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 2f75666a8267bf516747a12bc0ee5e317aa0270a..23566711f737c67f6f932e887030cffe7b37cca2 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 2e833a4761e249bd8a2f0e0192d39ff7ba31b39b..e866da3cf76a25f9e9e7b78cf69c927a0a410812 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 50f123fd63b69fa361137f93b2c329a6e3ba37ae..e1cc072421f5b025a982169f0208cdd3816de022 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 ca7b26829028b2bb461418a0d514b4507e03a20e..63fc4c31c57976f2e2f83e57033b93a239f80639 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