1+ <%@ page import =" com.liferay.commerce.product.content.util.CPContentHelper" %>
2+ <%@ page import =" com.liferay.commerce.product.content.constants.CPContentWebKeys" %>
3+ <%@ page import =" com.liferay.commerce.product.util.CPInstanceHelper" %>
4+ <%@ page import =" com.liferay.commerce.product.data.source.CPDataSourceResult" %>
5+ <%@ page import =" com.liferay.commerce.product.constants.CPWebKeys" %>
6+ <%@ page import =" com.liferay.commerce.product.catalog.CPCatalogEntry" %>
7+ <%@ page import =" com.liferay.commerce.context.CommerceContext" %>
8+ <%@ page import =" com.liferay.commerce.constants.CommerceWebKeys" %>
9+ <%@ page import =" com.liferay.commerce.product.catalog.CPSku" %>
10+ <%@ page import =" java.util.List" %>
111<%@ include file =" /META-INF/resources/init.jsp" %>
212
313<%
818 List<CPCatalogEntry > cpCatalogEntries = cpDataSourceResult. getCPCatalogEntries();
919 CommerceContext commerceContext = (CommerceContext )request. getAttribute(CommerceWebKeys . COMMERCE_CONTEXT );
1020
21+ int counter = 0 ;
22+
1123% >
24+
1225<c:choose >
1326 <c:when test =" <%= ! cpCatalogEntries. isEmpty() % >" >
27+ <div class =" container text-center my-3" >
28+ <div class =" row mx-auto my-auto" >
29+ <div id =" myCarousel" class =" carousel slide w-100" data-interval =" false" >
30+ <div class =" carousel-inner w-100" role =" listbox" >
31+
1432 <%
1533 for (CPCatalogEntry cpCatalogEntry : cpCatalogEntries) {
1634 String friendlyURL = cpContentHelper. getFriendlyURL(cpCatalogEntry, themeDisplay);
1735 List<CPSku > cpSkus = cpCatalogEntry. getCPSkus();
1836 long cpInstanceId = cpSkus. get(0 ). getCPInstanceId();
19- String thumbnailSrc = cpInstanceHelper. getCPInstanceThumbnailSrc(cpInstanceId);
37+ String thumbnailSrc = cpInstanceHelper. getCPInstanceThumbnailSrc(cpInstanceId);
38+ String active = " active" ;
39+
40+ if (counter > 0 ){
41+ active = " " ;
42+ }
2043 % >
21- <div >
22- <div >
23- <img src =" <%= thumbnailSrc % >" ></img >
24- </div >
25- <div >
26- <a href =" <%= friendlyURL % >" ><%= cpCatalogEntry. getName() % > </a >
27- </div >
28- </div >
44+
45+ <div class =" carousel-item <%= active % >" >
46+ <div class =" col-lg-2" >
47+ <a href =" <%= friendlyURL % >" ><img class =" img-fluid" src =" <%= thumbnailSrc % >" ></a >
48+ <div class- " product-name" >
49+ <a href =" <%= friendlyURL % >" ><%= cpCatalogEntry. getName() % > </a >
50+ </div >
51+ </div >
52+ </div >
53+
2954 <%
55+ counter++ ;
3056 }
3157 % >
32-
58+ </div >
59+ <a class =" carousel-control-prev bg-dark w-auto" href =" #myCarousel" role =" button" data-slide =" prev" >
60+ <span class =" carousel-control-prev-icon" aria-hidden =" true" ></span >
61+ <span class =" sr-only" >Previous</span >
62+ </a >
63+ <a class =" carousel-control-next bg-dark w-auto" href =" #myCarousel" role =" button" data-slide =" next" >
64+ <span class =" carousel-control-next-icon" aria-hidden =" true" ></span >
65+ <span class =" sr-only" >Next</span >
66+ </a >
67+ </div >
68+ </div >
69+ </div >
3370 </c:when >
3471
3572 <c:otherwise >
3673 <div class =" alert alert-info" >
3774 <liferay-ui:message key =" no-products-were-found" />
3875 </div >
3976 </c:otherwise >
40- </c:choose >
77+ </c:choose >
78+
79+
80+ <script >
81+
82+ console .log (" In the script" );
83+ $ (' #myCarousel' ).carousel ({
84+ interval: 10000
85+ })
86+
87+ $ (' .carousel .carousel-item' ).each (function (){
88+
89+ console .log (" In the item" );
90+
91+ var minPerSlide = 3 ;
92+ var next = $ (this ).next ();
93+ if (! next .length ) {
94+ next = $ (this ).siblings (' :first' );
95+ }
96+ next .children (' :first-child' ).clone ().appendTo ($ (this ));
97+
98+ for (var i= 0 ;i< minPerSlide;i++ ) {
99+ next= next .next ();
100+ if (! next .length ) {
101+ next = $ (this ).siblings (' :first' );
102+ }
103+
104+ next .children (' :first-child' ).clone ().appendTo ($ (this ));
105+ }
106+ });
107+ </script >
0 commit comments