PageSourceSearch

https://www.farmagranada.com/modules/boninfinitescroll//views/js/boninfinitescroll.js

js farmagranada.com collected 2026-09-26 14:20:33 UTC 7,134 bytes, 224 lines download raw bytes

1/**
2 * 2015-2021 Bonpresta
3 *
4 * Bonpresta Infinite Scroll Module
5 *
6 * NOTICE OF LICENSE
7 *
8 * This source file is subject to the General Public License (GPL 2.0)
9 * that is bundled with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://opensource.org/licenses/GPL-2.0
12 *
13 * DISCLAIMER
14 *
15 * Do not edit or add to this file if you wish to upgrade the module to newer
16 * versions in the future.
17 *
18 *  @author    Bonpresta
19 *  @copyright 2015-2021 Bonpresta
20 *  @license   http://opensource.org/licenses/GPL-2.0 General Public License (GPL 2.0)
21*/
22
23let parentElement = document.querySelector('.products.category-animate'),
24    product_col = JSON.parse(localStorage.getItem("ProductCol")) || 3,
25    parentElemenId = 2,
26    startUrl = window.location.href,
27    gueryNumb = "",
28    queryParam = query,
29    blockpages = document.querySelector('.page-list'),
30    categorypage = document.querySelector('#js-product-list'),
31    id = 2,
32    pages = '';
33if (blockpages) {
34    pages = blockpages.children;
35}
36
37document.addEventListener("DOMContentLoaded", function (e) {
38    prestashop.on("updateProductList", () => {
39        if (SCROLL_TYPE == 'scroll') {
40            parentElemenId = $('.products.category-animate').attr('id');
41            infiniteScroll();
42        }
43        if (SCROLL_TYPE == 'button') {
44            blockpages = document.querySelector('.page-list');
45            if (!blockpages) {
46                $('.bon-scroll-button').removeClass('display');
47
48            } else {
49                $('.bon-scroll-button').addClass('display');
50            }
51            id = $('.bon-scroll-button').attr('data-id');
52            infiniteButton();
53        }
54    });
55
56    if (parentElement && blockpages) {
57        infiniteScroll();
58    }
59
60
61    if (SCROLL_TYPE == 'button'  && blockpages) {
62        infiniteButton();
63    }
64
65    if (SCROLL_TYPE == 'button'  && categorypage) {
66        //infiniteButton();
67    }
68
69});
70
71function infiniteScroll() {
72
73    if (SCROLL_TYPE == 'scroll') {
74        if (window.location.search) {
75            gueryNumb = '&page='
76        } else {
77            gueryNumb = '?page='
78        }
79        $(parentElement).attr('id', parentElemenId);
80        $(window).scroll(function addScroll() {
81            if ($(this).height() + $(this).scrollTop() >= parentElement.scrollHeight) {
82                ajax();
83                parentElemenId++
84                $(parentElement).attr('id', parentElemenId);
85                $(window).off('scroll', addScroll);
86                let parentElement2 = document.querySelector('.products.category-animate');
87                $(window).scroll(function addScrollNextPage() {
88                    if ($(this).height() + $(this).scrollTop() >= parentElement2.scrollHeight) {
89                        ajax();
90                        $(window).off('scroll', addScrollNextPage);
91                    }
92                })
93            }
94        });
95
96        function ajax() {
97            $.post(window.location.href + gueryNumb + parentElemenId, function (response) {
98                product_col = JSON.parse(localStorage.getItem("ProductCol")) || 3;
99                var $result = $(response).find('article');
100                $result.each(function (index, article) {
101
102                    setTimeout(function () {
103                        $('.products-grid').append(article);
104                        let count8 = 1;
105
106                        $('#category .product-miniature').each(function () {
107                            $(this).attr('data-timeout', count8 * 60);
108                            count8++;
109                        });
110
111                        GridAddClass();
112                        addGridCol();
113
114                    }, index * 100);
115                });
116            })
117        }
118    }
119}
120
121function GridAddClass() {
122    $(".product-miniature .thumbnail-container .thumbnail-container-images .bonthumbnails").each(function () {
123        $(this).parent().parent().parent().addClass('with_thumb');
124    });
125}
126
127function addGridCol() {
128    if (($(window).width() > 1024)) {
129
130        if (product_col == 1) {
131            localStorage.setItem("class", JSON.stringify("product-one"));
132            $("#js-product-list article").addClass("product-one");
133        } else {
134            $("#js-product-list article").removeClass("product-one");
135        }
136        if (product_col == 2) {
137            localStorage.setItem("class", JSON.stringify("product-two"));
138
139            $("#js-product-list article").addClass("product-two");
140        } else {
141            $("#js-product-list article").removeClass("product-two");
142        }
143        if (product_col == 3) {
144            localStorage.setItem("class", JSON.stringify("product-three"));
145            $("#js-product-list article").addClass("product-three");
146        } else {
147            $("#js-product-list article").removeClass("product-three");
148        }
149        if (product_col == 4) {
150            localStorage.setItem("class", JSON.stringify("product-four"));
151            $("#js-product-list article").addClass("product-four");
152        } else {
153            $("#js-product-list article").removeClass("product-four");
154        }
155    }
156}
157
158$(window).resize(function () {
159
160    if ($(window).width() <= 1024) {
161        $("#js-product-list article").removeClass("product-one");
162        $(".products-grid.active").removeClass('active');
163    } else {
164        addGridCol();
165    }
166});
167
168function changeGrid() {
169    $(".buttons-grid").on("click", "button[data-grid]", function () {
170        if (!$(this).hasClass("--active")) {
171            product_col = $(this).attr("data-grid");
172            $(".buttons-grid").find("button.--active").removeClass("--active");
173            $(this).addClass("--active");
174            localStorage.setItem("ProductCol", JSON.stringify(product_col));
175        }
176    });
177}
178
179if (!parentElement || !blockpages) {
180    $('.bon-scroll-button').removeClass('display');
181
182} else {
183    $('.bon-scroll-button').addClass('display');
184}
185
186function infiniteButton() {
187
188    $('.bon-scroll-button').on('click', function (e) {
189
190        if (window.location.search) {
191            gueryNumb = '&page='
192        } else {
193            gueryNumb = '?page='
194        }
195        e.preventDefault();
196
197        $.post(window.location.href + gueryNumb + id, function (response) {
198            product_col = JSON.parse(localStorage.getItem("ProductCol")) || 3;
199            var $result = $(response).find('.js-product-miniature-wrapper');
200            $result.each(function (index, article) {
201
202                setTimeout(function () {
203                    $('.products-grid').append(article);
204                    let count8 = 1;
205
206                    $('#category .product-miniature').each(function () {
207                        $(this).attr('data-timeout', count8 * 40);
208                        count8++;
209                    });
210
211                    GridAddClass();
212                    addGridCol();
213
214                }, index * 100);
215            });
216
217            if (id >= pages.length) {
218                $('.bon-scroll-button').css('display', 'none')
219            }
220        })
221        $(this).attr('data-id', id++);
222
223    });
224}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.