PageSourceSearch

https://heyamola.net/themes/bookshop_theme3/assets/field-js/jquery.field.js

js heyamola.net collected 2026-10-02 14:22:18 UTC 13,131 bytes, 322 lines download raw bytes

1/* global LANG_RTL, FIELD_stickySearch */
2
3$(window).resize(function () {
4    scrollHeader();
5    scrollMobile();
6    scrollToTop();
7    MenuMobile();
8});
9$(document).ready(function () {
10    scrollHeader();
11    scrollMobile();
12    Field_fullwidth();
13    TitleCenter();
14    MenuMobile();
15    PopupCart();
16	VmenuDropDown();
17    $("#back-top").click(function () {
18        $('html, body').animate({
19            scrollTop: 0
20        }, 1000);
21    });
22	$(document).on('click',".click-product-grid",function (e) {
23        $("#wrapper").removeClass("active_list");
24        $("#wrapper").addClass("active_grid");
25        setCookie('status_list_product', 'active_grid', 1);
26    });
27    $(document).on('click',".click-product-list",function (e) {
28        $("#wrapper").removeClass("active_grid");
29        $("#wrapper").addClass("active_list");
30        setCookie('status_list_product', 'active_list', 1);
31    });
32    if (getCookie('status_list_product') !== "" && getCookie('status_list_product') !== "active_grid") {
33        $("#wrapper").removeClass("active_grid");
34        $("#wrapper").addClass("active_list");
35    }
36});
37$(window).scroll(function () {
38    scrollHeader();
39    scrollMobile();
40    scrollToTop();
41});
42
43function scrollToTop() {
44    if ($('body').scrollTop() > 50 || $(window).scrollTop() > 50) {
45        $("#back-top").css({'display': 'block'});
46    } else {
47        $("#back-top").css({'display': 'none'});
48    }
49}
50function scrollHeader() {
51    var header_desktop = $("#header-sticky");
52    var sticky_desktop = parseInt(header_desktop.css('height'));
53    var sticky_all = 0;
54    var sticky_Cart = 0;
55    var sticky_Search = 0;
56    if (typeof (FIELD_stickySearch) != 'undefined' && FIELD_stickySearch && typeof (FIELD_stickyCart) != 'undefined' && FIELD_stickyCart) {
57        var sticky_all = 1;
58    } else {
59        if (typeof (FIELD_stickySearch) != 'undefined' && FIELD_stickySearch) {
60            var sticky_Search = 1;
61        }
62        if (typeof (FIELD_stickyCart) != 'undefined' && FIELD_stickyCart) {
63            var sticky_Cart = 1;
64        }
65    }
66    if (typeof (FIELD_stickyMenu) != 'undefined' && FIELD_stickyMenu) {
67        window.addEventListener('scroll', function () {
68            if ($(window).width() > 991) {
69                if ($(this).scrollTop() > sticky_desktop) {
70                    header_desktop.addClass("sticky-desktop");
71                    if (sticky_all) {
72                        $('#sticky_top').addClass('sticky-fixed-top');
73                    } else {
74                        if (sticky_Search) {
75                            $('#_desktop_search').addClass('sticky-fixed-top');
76                        } else {
77                            $('#_desktop_search').addClass('d-none');
78                        }
79                        if (sticky_Cart) {
80                            $('#_desktop_cart').addClass('sticky-fixed-top');
81                        } else {
82                            $('#_desktop_cart').addClass('d-none');
83                        }
84                    }
85                    if (sticky_all || sticky_Cart || sticky_Search) {
86                        if (LANG_RTL != 1) {
87                            $('.sticky-fixed-top').css({'right': '0'});
88                        } else {
89                            $('.sticky-fixed-top').css({'right': 'auto', 'left': '0'});
90                        }
91                    }
92                } else {
93                    header_desktop.removeClass("sticky-desktop");
94                    $('.sticky-fixed-top').attr('style', '');
95                    $('#sticky_top').removeClass('sticky-fixed-top');
96                    if (sticky_Search) {
97                        $('#_desktop_search').removeClass('sticky-fixed-top');
98                    } else {
99                        $('#_desktop_search').removeClass('d-none');
100                    }
101                    if (sticky_Cart) {
102                        $('#_desktop_cart').removeClass('sticky-fixed-top');
103                    } else {
104                        $('#_desktop_cart').removeClass('d-none');
105                    }
106                }
107            } else {
108                header_desktop.removeClass("sticky-desktop");
109            }
110        });
111    }
112}
113function scrollMobile() {
114    var header_mobile = $("#header-moblie");
115    var menu_mobile = $("#mobile_fieldmenu_wrapper");
116    if ($(document).width() <= 991) {
117        $(window).bind('scroll', function () {
118            if ($(window).scrollTop() > 30) {
119                header_mobile.addClass('sticky-mobile');
120                menu_mobile.addClass('sticky-menu-mobile');
121            } else {
122                header_mobile.removeClass('sticky-mobile');
123                menu_mobile.removeClass('sticky-menu-mobile');
124            }
125        });
126    }
127}
128
129$(window).load(function () {
130    /* ITEM COUNTDOWNS */
131    if (typeof (FIELD_enableCountdownTimer) != 'undefined' && FIELD_enableCountdownTimer) {
132        $('.item-countdown-time').each(function () {
133            initCountdown($(this));
134        });
135    }
136    /* Load percent CMS */
137    if (LANG_RTL != 1) {
138        LoadPercCMS();
139    } else {
140        LoadPercCMS_rtl();
141    }
142});
143function initCountdown(el) {
144    el.countdown(el.attr('data-time')).on('update.countdown', function (event) {
145        var format = '';
146        if (event.offset.totalDays > 1) {
147            format = format + '<span class="section_cout"><span class="Days">%D </span><span class="text">' + countdownDays + '</span></span>';
148        } else {
149            format = format + '<span class="section_cout"><span class="Days">%D </span><span class="text">' + countdownDay + '</span></span>';
150        }
151        if (event.offset.hours > 1) {
152            format = format + '<span class="section_cout"><span class="Hours">%H </span><span class="text">' + countdownHours + '</span></span>';
153        } else {
154            format = format + '<span class="section_cout"><span class="Hours">%H </span><span class="text">' + countdownHour + '</span></span>';
155        }
156        if (event.offset.minutes > 1) {
157            format = format + '<span class="section_cout"><span class="Minutes">%M </span><span class="text">' + countdownMinutes + '</span></span>';
158        } else {
159            format = format + '<span class="section_cout"><span class="Minutes">%M </span><span class="text">' + countdownMinute + '</span></span>';
160        }
161        if (event.offset.seconds > 1) {
162            format = format + '<span class="section_cout"><span class="Seconds">%S </span><span class="text">' + countdownSeconds + '</span></span>';
163        } else {
164            format = format + '<span class="section_cout"><span class="Seconds">%S </span><span class="text">' + countdownSecond + '</span></span>';
165        }
166        el.html(event.strftime(format)).fadeIn();
167    });
168}
169
170function LoadPercCMS() {
171    $('.cms-line').each(function () {
172        var t = $(this);
173        var dataperc = t.attr('id'), dataperc_int = dataperc.replace("a", ""), barperc = Math.round(dataperc_int);
174        t.find('.cms-line-comp').animate({width: barperc + "%"}, dataperc_int * 25);
175        t.find('.label').append('<div class="perc"></div>');
176        function perc() {
177            var t_length = parseInt($('.cms-line').css('width'));
178            var length = t.find('.cms-line-comp').css('width'), perc_div = (parseInt(length) / t_length * 100), perc = Math.round(parseInt(perc_div)), labelpos = (100 - perc);
179            t.find('.label').css('right', labelpos + '%');
180            t.find('.perc').text(perc + '%');
181        }
182        perc();
183        setInterval(perc, 0);
184    });
185}
186function LoadPercCMS_rtl() {
187    $('.cms-line').each(function () {
188        var t = $(this);
189        var dataperc = t.attr('id'), dataperc_int = dataperc.replace("a", ""), barperc = Math.round(dataperc_int);
190        t.find('.cms-line-comp').animate({width: barperc + "%"}, dataperc_int * 25);
191        t.find('.label').append('<div class="perc"></div>');
192        function perc() {
193            var t_length = parseInt($('.cms-line').css('width'));
194            var length = t.find('.cms-line-comp').css('width'), perc_div = (parseInt(length) / t_length * 100), perc = Math.round(parseInt(perc_div)), labelpos = (100 - perc);
195            t.find('.label').css('left', labelpos + '%');
196            t.find('.perc').text(perc + '%');
197        }
198        perc();
199        setInterval(perc, 0);
200    });
201}
202function Field_fullwidth() {
203    $('.fieldFullWidth').each(function () {
204        var t = $(this);
205        var fullwidth = $('main').width(),
206                margin_full = fullwidth / 2;
207        if (LANG_RTL != 1) {
208            t.css({'left': '50%', 'position': 'relative', 'width': fullwidth, 'margin-left': -margin_full});
209        } else {
210            t.css({'right': '50%', 'position': 'relative', 'width': fullwidth, 'margin-right': -margin_full});
211        }
212    });
213}
214function TitleCenter() {
215    $('.title_center').each(function () {
216        var t = $(this);
217        var widthtitle = t.find('.title_text').width(),
218                marginButton = Math.round(widthtitle / 2 + 20, 2);
219        if ($(window).width() <= marginButton * 2 + 60) {
220            marginButton = $(window).width() / 2 - 70;
221            t.find('.bx-controls-direction .prev').addClass('excess');
222            t.find('.bx-controls-direction .next').addClass('excess');
223        } else {
224            t.find('.bx-controls-direction .prev').removeClass('excess');
225            t.find('.bx-controls-direction .next').removeClass('excess');
226        }
227        t.find('.owl-nav .owl-prev').css({'margin-right': marginButton});
228        t.find('.owl-nav .owl-next').css({'margin-left': marginButton});
229        t.find('.bx-controls-direction .prev').css({'margin-right': marginButton + 10});
230        t.find('.bx-controls-direction .next').css({'margin-left': marginButton + 10});
231    });
232}
233
234function VmenuDropDown() {
235    VmenuClick = '#header-menu .v-megamenu-title,#_mobile_fieldvmegamenu .v-megamenu-title';
236    VmenuSlide = '#header-menu .v-megamenu,#_mobile_fieldvmegamenu .v-megamenu';
237    activeVmenu = 'active';
238    $(VmenuClick).on('click', function (e) {
239        e.stopPropagation();
240        var subUl = $(this).next(VmenuSlide);
241        if (subUl.is(':hidden') && !$(this).hasClass('Click')) {
242            subUl.slideDown();
243            $(this).addClass(activeVmenu);
244        } else if (!$(this).hasClass('Click')) {
245            subUl.slideUp();
246            $(this).removeClass(activeVmenu);
247        }
248    });
249    $(VmenuSlide).on('click', function (e) {
250        e.stopPropagation();
251    });
252    $(document).on('click', function (e) {
253        e.stopPropagation();
254        var elementVmenu = $(VmenuClick).next(VmenuSlide);
255        if (!$(VmenuClick).hasClass('Click')) {
256            $(VmenuClick).removeClass('active');
257            $(elementVmenu).slideUp();
258        }
259    });
260    $("#_mobile_fieldvmegamenu .v-megamenu-title").removeClass('Click');
261
262}
263
264function MenuMobile() {
265    if ($(window).width() < 992) {
266        $('#field-menu-icon').click(function () {
267            $('#popup_menu_mobile').addClass('show');
268            var html = "";
269            html = '<div class="popup-mobile"></div>';
270            $(html).appendTo("body");
271            $('body').addClass('popup-menu-open');
272        });
273        $('#close_popup_menu').click(function () {
274            $('#popup_menu_mobile').removeClass('show');
275            $('body').removeClass('popup-menu-open');
276            $('.popup-mobile').remove();
277        });
278    }
279}
280
281function PopupCart() {
282    $(document).on('click', '.click-cart', function () {
283        var html = "";
284        html = '<div class="cart-open"></div>';
285        $(html).appendTo("body");
286        $('body').addClass('body-cart-open');
287        if (prestashop.language.is_rtl === 1) {
288            $('#popup-cart').animate({left: '0'}, 500);
289        } else {
290            $('#popup-cart').animate({right: '0'}, 500);
291        }
292    });
293    $(document).on('click', '.close-cart', function () {
294        $('body').removeClass('body-cart-open');
295        $('.cart-open').remove();
296        if (prestashop.language.is_rtl === 1) {
297            $('#popup-cart').animate({left: '-100%'}, 500);
298
299        } else {
300            $('#popup-cart').animate({right: '-100%'}, 500);
301        }
302    });
303}
304
305function setCookie(cname, cvalue, exdays) {
306    var d = new Date();
307    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
308    var expires = "expires=" + d.toUTCString();
309    document.cookie = cname + "=" + cvalue + "; " + expires;
310}
311function getCookie(cname) {
312    var name = cname + "=";
313    var ca = document.cookie.split(';');
314    for (var i = 0; i < ca.length; i++) {
315        var c = ca[i];
316        while (c.charAt(0) == ' ')
317            c = c.substring(1);
318        if (c.indexOf(name) == 0)
319            return c.substring(name.length, c.length);
320    }
321    return "";
322}

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.