PageSourceSearch

https://de-la-flor.ru/js/main2.js?v=20260824-3

js de-la-flor.ru collected 2026-10-08 05:50:24 UTC 12,798 bytes, 393 lines download raw bytes

1$(function() {
2    var mobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
3
4    $(document).on('click', '.js-change-city', function (e) {
5        e.preventDefault();
6
7        var url = $(this).data('ajax-url');
8
9        $.fancybox.open({
10            src: url,
11            type: 'ajax',
12            padding: 0,
13            fitToView: !!mobile,
14            margin: mobile ? 20 : 10,
15            wrapCSS: 'fancybox-city-popup'
16        });
17    });
18
19    $('.js-show-more').on('click', function() {
20        $(".yiiPager").css({"visibility":"hidden"});
21
22        var button = $(this);
23        var need_page = parseInt(button.attr("data-current-page"));
24        var total_quantity_pages = parseInt(button.attr("data-total-pages"));
25        var name_pagen = button.attr("data-name-paginator");
26        need_page++;
27        var url = button.attr("data-url");
28        url = url+'?'+name_pagen+'='+need_page;
29
30        button.fadeOut(0).attr('data-current-page',need_page);
31        $.ajax({
32            type: "GET",
33            url: url,
34            beforeSend: function () {
35            }
36        }).done(function(data){
37            if(need_page!=total_quantity_pages)
38                button.fadeIn(0);
39
40            $(".product-list").after(data).ready(function () {
41            });
42        });
43    });
44
45    $('.js-phone, [name="feedback_models_FeedbackModel[phone]"]').mask(mobile ? '+79999999999' : '+7 ( 999 ) 999 - 99 - 99');
46
47    $('#sort-products').change(function() {
48        $(this).closest('form').submit();
49    });
50
51    $('.to-cart_custom, .to-cart_custom-add').click(function() {
52        var el = $(this);
53
54        addToCart(el);
55
56        return false;
57    });
58
59    $('.to-cart_continue').click(function () {
60        var el = $(this);
61
62        addToCart(el, '/shop/order');
63
64        return false;
65    });
66
67    function addToCart(el, href) {
68        var data = {};
69        var attributes = el.data('cart-attributes');
70        var serialize = el.data('cart-serialize');
71        var value;
72
73        if (attributes) {
74            for (var key in attributes) {
75                if($(attributes[key]).length) {
76                    value = $(attributes[key]).val();
77
78                    data[key] = value;
79                }
80            }
81        }
82
83        if (serialize) {
84            for (var key in serialize) {
85                if($(serialize[key]).length) {
86                    value = $(serialize[key]).serialize();
87
88                    data[key] = value;
89                }
90            }
91        }
92
93        var url = el.data('href') ? el.data('href') : el.attr('href');
94
95        $.post(url, {data: data}, function(data) {
96            ShopCart.update(data);
97
98            if (href != undefined) {
99                window.location.href = href;
100            }
101        }, 'json');
102    }
103
104    const toUp = document.querySelector('.to_up');
105
106    window.addEventListener('scroll', () => {
107        if (window.scrollY > window.innerHeight) {
108            toUp.classList.add('active');
109        } else {
110            toUp.classList.remove('active');
111        }
112    });
113
114    toUp.addEventListener('click', () => {
115        window.scrollTo({
116            top: 0,
117            behavior: 'smooth'
118        });
119    });
120
121
122    function getCartSelector() {
123        var newCart = $('.dlf-home-cart:visible').first();
124
125        if (newCart.length) {
126            return newCart;
127        }
128
129        return $(window).width() < 991
130            ? $('.header-cart__count-value:visible').first()
131            : $('.header-cart__count:visible').first();
132    }
133
134    function flyToCart(button, imageSelector) {
135        var cart = getCartSelector();
136        var imgtodrag = button.closest(imageSelector.parent)
137            .find(imageSelector.img)
138            .eq(0);
139
140        if (!imgtodrag.length || !cart.length) return;
141
142        var imgclone = imgtodrag.clone()
143            .offset({
144                top: imgtodrag.offset().top,
145                left: imgtodrag.offset().left
146            })
147            .css({
148                opacity: 0.5,
149                position: 'absolute',
150                height: '150px',
151                width: '150px',
152                zIndex: 10000,
153                pointerEvents: 'none',
154                borderRadius: '12px',
155                objectFit: 'cover'
156            })
157            .appendTo('body')
158            .animate({
159                top: cart.offset().top + 10,
160                left: cart.offset().left + 10,
161                width: 75,
162                height: 75
163            }, 1000)
164            .animate({
165                width: 0,
166                height: 0
167            }, function () {
168                $(this).remove();
169            });
170    }
171
172// Каталог
173    $('.fly-add').on('click', function (e) {
174        e.preventDefault();
175        flyToCart($(this), {
176            parent: '.product-item',
177            img: 'img'
178        });
179    });
180
181// Страница товара
182    $('.fly-main').on('click', function (e) {
183        e.preventDefault();
184        flyToCart($(this), {
185            parent: '.product-page',
186            img: '.product-image-main img'
187        });
188    });
189
190
191    var fancyboxImages = jQuery('a.image-full');
192
193    if (fancyboxImages.length) {
194        jQuery(fancyboxImages).fancybox({
195            overlayColor: '#333',
196            overlayOpacity: 0.8,
197            titlePosition : 'over'
198        });
199    }
200
201    jQuery('body').on('submit', '#promo-form', function(){
202    	var input = jQuery('#promo-input');
203    	var code = input.val();
204
205    	if(!code) {
206    		setPromoMessage('Введите промокод');
207    	} else{
208    		jQuery.post('/shop/updateCart', {promo: code}, function(data){
209    			data = jQuery.parseJSON(data);
210
211    			if(data.message == 'success') {
212    				jQuery('#promo-form').html('<div class="promo-code">Скидка ' + data.sale + '%. Ваш промокод: <span class="txt-color-red">' + code + '</span></div>');
213    				jQuery('#order-summary-price, #summary-price').text(data.price);
214    			} else {
215    				setPromoMessage(data.message);
216    			}
217    			
218    		});
219    	}
220
221    	return false;
222    });
223
224    function setPromoMessage(message) {
225    	var label = jQuery('#promo-message');
226    	label.text(message);
227    }
228});
229
230/* city tabs */
231
232jQuery(function ($) {
233    var body = $('body');
234
235    body.on('click', '.tabs__item', function () {
236        var $this = $(this);
237        var tabIns = $this.closest('.tab-instance');
238        if (!$this.hasClass('tabs__item--active')) {
239
240            var tabId = $this.data('tab-id');
241            console.log(tabId);
242            if (tabId) {
243                tabIns.find('.tabs__item').removeClass('tabs__item--active');
244                $this.addClass('tabs__item--active');
245                tabIns.find('.tab-wrap').removeClass('tab-wrap--active');
246                tabIns.find('.tab-wrap--' + tabId).addClass('tab-wrap--active');
247            }
248
249        }
250    });
251
252    body.on('click', '.city-tabs__item-js', function (e) {
253        e.preventDefault();
254        var self = $(this);
255        var tabWrapper = self.closest('.city-tab-wrapper');
256        var defaultTab = tabWrapper.find('.city-tabs__item--default');
257        var searchBlock = tabWrapper.find('.city-popup__search-block');
258
259        if (!self.hasClass('city-tabs__item--active')) {
260            var tabID = self.data('tab-id');
261            if (tabID) {
262                tabWrapper.find('.city-tabs__item.city-tabs__item--active').removeClass('city-tabs__item--active');
263                tabWrapper.find('.city-tab-wrap').removeClass('city-tab-wrap--active');
264                var tab = tabWrapper.find('.city-tab-wrap--' + tabID);
265                tab.addClass('city-tab-wrap--active');
266
267                if (tabID === 'countries') {
268                    searchBlock.hide();
269                    self.addClass('city-tabs__item--active');
270                    defaultTab.removeClass('city-tabs__item--active');
271                } else {
272                    defaultTab.data('tab-id', tabID);
273                    defaultTab.addClass('city-tabs__item--active');
274                    searchBlock.show();
275                    var text = self.text();
276                    defaultTab.text(text);
277                    var newUrl = tab.data('country-url');
278                    tabWrapper.find('.city-popup__all-link').attr('href', newUrl);
279                }
280            }
281        }
282    });
283
284    body.on('click', '[data-city-popup-id]', function () {
285        let $this = $(this);
286
287        $.post('/city/saveChoose', {id: 0}, function () {
288            window.location.href = $this.attr('href');
289        });
290    });
291
292    body.on('keyup', '.city-popup__search-input', function () {
293        var popupWrap = $(this).closest('.city-popup__inner-wrap');
294        var searchList = popupWrap.find('.citylist__search-result');
295        searchList.empty();
296
297        var citylist = popupWrap.find('.city-list__main-wrapper');
298
299        var cities = popupWrap.find('.city-list__main-wrapper').find('.city-list__link');
300        var fil = [];
301        var val = $(this).val().toLowerCase();
302        cities.each(function () {
303            var it = $(this).text().toLowerCase();
304            if (it.indexOf(val) !== -1) {
305                var toPush = {};
306                var country = $(this).closest('.city-tab-wrap').data('country-name');
307                if (country) {
308                    toPush.country = ' (' + country + ')';
309                }
310                toPush.element = $(this);
311
312                fil.push(toPush);
313            }
314        });
315        if (val !== '') {
316            $('.city-popup__clear-search').show();
317            citylist.addClass('citylist__main-wrap--hidden');
318            if (fil.length > 0) {
319                fil.map(function (it) {
320                    var element = it.element.clone();
321                    if (it.country) {
322                        element.text(element.text() + it.country);
323                    }
324                    searchList.append($('<div>', {'class': 'city-list__item'}).addClass('citylist__item--left').append(element));
325                });
326            } else {
327                var langText = 'Данного города нет в списке. Уточните возможность доставки у менеджера по телефону 89231788228';
328                searchList.append($('<span>').text(langText));
329            }
330            searchList.show();
331        } else {
332            $('.city-popup__clear-search').hide();
333            searchList.hide();
334            citylist.removeClass('citylist__main-wrap--hidden');
335        }
336    });
337
338    body.on('click', '.city-popup__clear-search', function (e) {
339        e.preventDefault();
340        $('.city-popup__search-input').val('').keyup();
341    });
342
343    favoriteIds.forEach(function (favoriteId) {
344        $('[data-favorite="' + favoriteId + '"]').addClass('active');
345    });
346
347    $('[data-favorite]').show();
348
349    body.on('click', '[data-favorite]', function () {
350        var $self = $(this);
351
352        $.post('/site/addFavorite', {id: $self.data('favorite')}, function (data) {
353            $('#js_header-favorites__qty').html(data.total);
354
355            $self.toggleClass('active');
356        }, 'json');
357    });
358});
359
360document.querySelectorAll('input[name="bonus_action"]').forEach(function(radio) {
361    radio.addEventListener('change', function() {
362        const amountBlock = document.getElementById('bonus-amount-wrapper');
363        if (this.value === 'deduct') {
364            amountBlock.style.display = 'block';
365        } else {
366            amountBlock.style.display = 'none';
367        }
368    });
369});
370
371const resetPasswordButton = document.getElementById('reset-password-btn');
372if (resetPasswordButton) resetPasswordButton.addEventListener('click', function () {
373    const email = document.getElementById('reset-email').value;
374    const msg   = document.getElementById('login-message');
375
376    if (!email) {
377        msg.innerText = 'Введите email';
378        return;
379    }
380
381    const xhr = new XMLHttpRequest();
382    xhr.open('POST', '/user/resetPassword', true);
383    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
384    xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
385
386    xhr.onload = function () {
387        const resp = JSON.parse(xhr.responseText);
388        msg.style.color = resp.success ? 'green' : 'red';
389        msg.innerText = resp.message;
390    };
391
392    xhr.send('email=' + encodeURIComponent(email));
393});

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.