<?php

/**
 * @package     Joomla.Site
 * @subpackage  mod_articles_news
 *
 * @copyright   (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Helper\ModuleHelper;

if (!$list) {
    return;
}

$header = $module->title;

?>
<div class="sect-reviews page-sect outer-page-sect">
	<div class="mdl-header">
		<span><?php echo $header; ?></span>
		<a href="/otzyvy.html">Все отзывы</a>
	</div>
	<div class="mod-articles-flash mod-reviews">
		<div class="row row-reviews">
			<?php foreach ($list as $item) : ?>
				<div class="col-12 col-sm-6 col-md-4 show-more-item">
					<div class="item" itemscope itemtype="https://schema.org/Article">
						<?php require ModuleHelper::getLayoutPath('mod_articles_news', '_reviews'); ?>
					</div>
				</div>
			<?php endforeach; ?>
		</div>
		<center class="show-more">
			<button class="show-more-btn show-more-btn-review-main">Показать ещё 6 отзывов</button>
		</center>
	</div>
	<script>
		$(document).ready(function() {
			var list = $(".row-reviews .show-more-item");
			var numToShow = 6; //сколько показывать элементов
			var button = $(".show-more-btn-review-main");
			var numInList = list.length;
			list.hide();
			if (numInList > numToShow) {
				button.show();
			}
			list.slice(0, numToShow).show();
			button.click(function() {
				var showing = list.filter(':visible').length;
				list.slice(showing - 1, showing + numToShow).fadeIn();
				var nowShowing = list.filter(':visible').length;
				if (nowShowing >= numInList) {
					button.hide();
				}
			});
		});
	</script>
</div>