Commit 03afb35510b9dfd3d710c2335bc7bbf8daf5189e
1 parent
c7b6386e
conflict
Showing
2 changed files
with
4 additions
and
399 deletions
Show diff stats
frontend/web/js/custom.js
frontend/web/js/script.js
1 | -<<<<<<< HEAD | ||
2 | -$(function() { | ||
3 | - | ||
4 | - function scrollToMenu() { | ||
5 | - $('.main-nav-item') | ||
6 | - } | ||
7 | - var basket = new ArtboxBasket({ | ||
8 | - 'cartSelector': '#cart' | ||
9 | - }); | ||
10 | - | ||
11 | - /** | ||
12 | - * Modal form submit code | ||
13 | - */ | ||
14 | - $(document) | ||
15 | - .on('beforeSubmit', '#feedback-form', function(e) { | ||
16 | - var f = this; | ||
17 | - var form = $(this); | ||
18 | - var formData = form.serialize(); | ||
19 | - $.ajax({ | ||
20 | - url: form.attr("action"), | ||
21 | - type: form.attr("method"), | ||
22 | - data: formData, | ||
23 | - success: function(data) { | ||
24 | - f.reset(); | ||
25 | - $('#feedback-modal') | ||
26 | - .modal('hide'); | ||
27 | - $('#success-modal') | ||
28 | - .modal('show'); | ||
29 | - }, | ||
30 | - error: function() { | ||
31 | - $('#feedback-modal') | ||
32 | - .modal('hide'); | ||
33 | - } | ||
34 | - }); | ||
35 | - }) | ||
36 | - .on('submit', '#feedback-form', function(e) { | ||
37 | - e.preventDefault(); | ||
38 | - }); | ||
39 | - | ||
40 | - /** | ||
41 | - * Contact form submitting | ||
42 | - */ | ||
43 | - $(document) | ||
44 | - .on('beforeSubmit', '#contact-form', function(e) { | ||
45 | - var f = this; | ||
46 | - var form = $(this); | ||
47 | - var formData = form.serialize(); | ||
48 | - $.ajax({ | ||
49 | - url: form.attr("action"), | ||
50 | - type: form.attr("method"), | ||
51 | - data: formData, | ||
52 | - success: function(data) { | ||
53 | - f.reset(); | ||
54 | - form.replaceWith(data.alert); | ||
55 | - }, | ||
56 | - error: function() { | ||
57 | - | ||
58 | - } | ||
59 | - }); | ||
60 | - }) | ||
61 | - .on('submit', '#contact-form', function(e) { | ||
62 | - e.preventDefault(); | ||
63 | - }); | ||
64 | - | ||
65 | - /** | ||
66 | - * Button UP code | ||
67 | - */ | ||
68 | - if ($('#back-to-top').length) { | ||
69 | - var scrollTrigger = 100, // px | ||
70 | - backToTop = function() { | ||
71 | - var scrollTop = $(window) | ||
72 | - .scrollTop(); | ||
73 | - if (scrollTop > scrollTrigger) { | ||
74 | - $('#back-to-top') | ||
75 | - .addClass('show'); | ||
76 | - } else { | ||
77 | - $('#back-to-top') | ||
78 | - .removeClass('show'); | ||
79 | - } | ||
80 | - }; | ||
81 | - backToTop(); | ||
82 | - $(window) | ||
83 | - .on('scroll', function() { | ||
84 | - backToTop(); | ||
85 | - }); | ||
86 | - $('#back-to-top') | ||
87 | - .on('click', function(e) { | ||
88 | - e.preventDefault(); | ||
89 | - $('html,body') | ||
90 | - .animate({ | ||
91 | - scrollTop: 0 | ||
92 | - }, 700); | ||
93 | - }); | ||
94 | - } | ||
95 | - | ||
96 | - $(document) | ||
97 | - .on('click', '.add-to-basket', function(e) { | ||
98 | - e.preventDefault(); | ||
99 | - var id = $(this) | ||
100 | - .data('id'); | ||
101 | - var xhr = basket.add(id, 1); | ||
102 | - xhr.done(function() { | ||
103 | - $.pjax.reload({ | ||
104 | - container: '#basket-modal', | ||
105 | - fragment: '#basket-modal', | ||
106 | - timeout: 5000 | ||
107 | - }); | ||
108 | - }); | ||
109 | - if ($('.alert-cart').length > 0) { | ||
110 | - } else { | ||
111 | - $('body') | ||
112 | - .prepend($("<div class='alert-cart alert alert-success alert-dismissible'>Товар добавлен в корзину.</div>")); | ||
113 | - setTimeout(function() { | ||
114 | - $(".alert-cart") | ||
115 | - .addClass("active"); | ||
116 | - }, 100); | ||
117 | - setTimeout(function() { | ||
118 | - $(".alert-cart") | ||
119 | - .removeClass("active"); | ||
120 | - }, 3500); | ||
121 | - setTimeout(function() { | ||
122 | - $(".alert-cart") | ||
123 | - .remove(); | ||
124 | - }, 3600); | ||
125 | - } | ||
126 | - }); | ||
127 | - | ||
128 | - $(document) | ||
129 | - .on('click', '.remove-product-cart', function(e) { | ||
130 | - e.preventDefault(); | ||
131 | - var id = $(this) | ||
132 | - .parents('.product-row-basket') | ||
133 | - .data('id'); | ||
134 | - showLoader('#basket'); | ||
135 | - var xhr = basket.remove(id); | ||
136 | - xhr.done(function() { | ||
137 | - $.pjax.reload({ | ||
138 | - container: '#basket', | ||
139 | - fragment: '#basket', | ||
140 | - timeout: 5000 | ||
141 | - }); | ||
142 | - }) | ||
143 | - }); | ||
144 | - | ||
145 | - $(document) | ||
146 | - .on('change', '.increase-product-basket', function(e) { | ||
147 | - var id = $(this) | ||
148 | - .parents('.product-row-basket') | ||
149 | - .data('id'); | ||
150 | - showLoader('#basket'); | ||
151 | - showLoader('#basket-modal'); | ||
152 | - var xhr = basket.set(id, $(this) | ||
153 | - .val()); | ||
154 | - xhr.done(function() { | ||
155 | - if ($('#basket').length) { | ||
156 | - $.pjax.reload({ | ||
157 | - container: '#basket', | ||
158 | - fragment: '#basket', | ||
159 | - timeout: 5000 | ||
160 | - }); | ||
161 | - } | ||
162 | - $.pjax.reload({ | ||
163 | - container: '#basket-modal', | ||
164 | - fragment: '#basket-modal', | ||
165 | - timeout: 5000 | ||
166 | - }); | ||
167 | - }); | ||
168 | - }); | ||
169 | - | ||
170 | - $(document) | ||
171 | - .on('click', 'li.disabled a', function(e) { | ||
172 | - e.preventDefault(); | ||
173 | - }); | ||
174 | - | ||
175 | - $(document) | ||
176 | - .on('submit', '#fast-buy-form', function(e) { | ||
177 | - e.preventDefault(); | ||
178 | - }); | ||
179 | - | ||
180 | - $(document) | ||
181 | - .on('afterValidate', '#fast-buy-form', function(e, m, errors) { | ||
182 | - if (!errors.length) { | ||
183 | - var form = $(e.target); | ||
184 | - var action = form.attr('action'); | ||
185 | - $.post(action, form.serialize(), function(data) { | ||
186 | - if (data.success) { | ||
187 | - $('#oneclick-modal') | ||
188 | - .find('.modal-body') | ||
189 | - .text(data.msg); | ||
190 | - } | ||
191 | - }); | ||
192 | - } | ||
193 | - }.bind(this)); | ||
194 | - | ||
195 | - $(document) | ||
196 | - .on( | ||
197 | - 'click', '.wishlist-rm, .wishlist-add', function() { | ||
198 | - var button = $(this); | ||
199 | - $.ajax( | ||
200 | - { | ||
201 | - url: button.data('url'), | ||
202 | - type: "POST", | ||
203 | - data: { | ||
204 | - 'variant': button.data('variant'), | ||
205 | - 'product': button.data('product'), | ||
206 | - 'user': button.data('user') | ||
207 | - }, | ||
208 | - success: function(data) { | ||
209 | - button.replaceWith(data.button); | ||
210 | - new PNotify( | ||
211 | - { | ||
212 | - title: 'Info', | ||
213 | - text: data.message, | ||
214 | - type: 'info', | ||
215 | - styling: 'fontawesome' | ||
216 | - } | ||
217 | - ); | ||
218 | - | ||
219 | - } | ||
220 | - } | ||
221 | - ) | ||
222 | - } | ||
223 | - ); | ||
224 | - | ||
225 | - $(document) | ||
226 | - .on( | ||
227 | - 'click', '.wishlist-delete', function(e) { | ||
228 | - e.preventDefault(); | ||
229 | - var button = $(this); | ||
230 | - $.ajax( | ||
231 | - { | ||
232 | - url: button.data('url'), | ||
233 | - type: "POST", | ||
234 | - data: { | ||
235 | - 'product': button.data('product'), | ||
236 | - 'variant': button.data('variant'), | ||
237 | - 'user': button.data('user') | ||
238 | - }, | ||
239 | - success: function(data) { | ||
240 | - if (data.success) { | ||
241 | - $.pjax.reload({container: '#wishlist-products'}); | ||
242 | - new PNotify( | ||
243 | - { | ||
244 | - title: 'Info', | ||
245 | - text: data.message, | ||
246 | - type: 'info', | ||
247 | - styling: 'fontawesome' | ||
248 | - } | ||
249 | - ); | ||
250 | - } | ||
251 | - } | ||
252 | - } | ||
253 | - ); | ||
254 | - } | ||
255 | - ); | ||
256 | - | ||
257 | -}); | ||
258 | -function showLoader(container) { | ||
259 | - $(container) | ||
260 | - .prepend('<div class="loader-wrapper"><div class="loader"></div></div>'); | ||
261 | -} | ||
262 | - | ||
263 | -$(document).ready(function ($) { | ||
264 | - $('.vcovers').perfectScrollbar({wheelSpeed: 0.5}); | ||
265 | -======= | ||
266 | $(function() { | 1 | $(function() { |
267 | - clickMenuButton(); | ||
268 | - openMobMenu(); | ||
269 | - closeMobMenu(); | ||
270 | - addArrowMobMenuAndOpen(); | ||
271 | - | ||
272 | - function clickMenuButton() { | ||
273 | - var menuButtonParent = $('.main-nav-item') | ||
274 | - menuButtonParent.find('.btn-like').click(function (e) { | ||
275 | - if(menuButtonParent.hasClass('home-page-menu')) { | ||
276 | - e.preventDefault; | ||
277 | - $('body, html').animate({scrollTop:$('.dropdown-menu.sidebar').offset().top + 2},500) | ||
278 | - } else { | ||
279 | - | ||
280 | - $('body').append('<div class="catalog-overlay"></div>') | ||
281 | - $('.catalog-menu-wrapper-start').addClass('opened'); | ||
282 | - setTimeout(function () { | ||
283 | - $('.catalog-menu-wrapper-start').addClass('visible_catalog') | ||
284 | - },10) | ||
285 | - } | ||
286 | - }) | ||
287 | - | ||
288 | - $('body').on('click','.catalog-overlay',function () { | ||
289 | - $(this).remove(); | ||
290 | - $('.main-nav-item').removeClass('open'); | ||
291 | - $('.catalog-menu-wrapper-start').removeClass('visible_catalog opened') | ||
292 | - }) | ||
293 | - } | ||
294 | - | ||
295 | - | ||
296 | - | ||
297 | - function mobOverlayAdd() { | ||
298 | - $('body').append('<div class="mob-overlay visible-xs visible-sm"></div>') | ||
299 | - } | ||
300 | - function mobOverlayRemove() { | ||
301 | - $('.mob-overlay').remove() | ||
302 | - } | ||
303 | - | ||
304 | - function openMobMenu() { | ||
305 | - $('.menu_mob').click(function () { | ||
306 | - mobOverlayAdd() | ||
307 | - $('body').addClass('off-scroll') | ||
308 | - $('#menu-mob-hidden').addClass('opens') | ||
309 | - setTimeout(function () { | ||
310 | - $('#menu-mob-hidden').addClass('visible') | ||
311 | - },10) | ||
312 | - }) | ||
313 | - } | ||
314 | - | ||
315 | - function closeMobMenu() { | ||
316 | - $('body').on('click','.mob-overlay',function () { | ||
317 | - mobOverlayRemove() | ||
318 | - if($('#menu-mob-hidden').hasClass('visible')) { | ||
319 | - $('#menu-mob-hidden').removeClass('visible') | ||
320 | - setTimeout(function () { | ||
321 | - $('#menu-mob-hidden').removeClass('opens') | ||
322 | - },200) | ||
323 | - $('body').removeClass('off-scroll') | ||
324 | - } | ||
325 | - if($('.btn_call').hasClass('close')) { | ||
326 | - $('.btn_call').removeClass('close') | ||
327 | - closeCallMobileHide() | ||
328 | - } | ||
329 | - | ||
330 | - }) | ||
331 | - $('.close-menu-mob .close_mob').click(function () { | ||
332 | - mobOverlayRemove() | ||
333 | - $('#menu-mob-hidden').removeClass('visible') | ||
334 | - setTimeout(function () { | ||
335 | - $('#menu-mob-hidden').removeClass('opens') | ||
336 | - },200) | ||
337 | - $('body').removeClass('off-scroll') | ||
338 | - $('#menu-mob-hidden ul li.has_ul').removeClass('open') | ||
339 | - }) | ||
340 | - } | ||
341 | - | ||
342 | - function closeCallMobileHide() { | ||
343 | - $('.call-mobile-wr').removeClass('visible') | ||
344 | - setTimeout(function () { | ||
345 | - $('.call-mobile-wr').removeClass('open') | ||
346 | - },200) | ||
347 | - } | ||
348 | - | ||
349 | - function addArrowMobMenuAndOpen() { | ||
350 | - $('#menu-mob-hidden ul li').each(function () { | ||
351 | - if($(this).find('ul').length>0){ | ||
352 | - $(this).addClass('has_ul') | ||
353 | - $(this).parent().addClass('sub_m') | ||
354 | - $('#menu-mob-hidden>ul').removeClass('sub_m').addClass('sub_m-first'); | ||
355 | - } | ||
356 | - }) | ||
357 | - | ||
358 | - | ||
359 | - | ||
360 | - $('body').on('click','#menu-mob-hidden ul li.has_ul a',function () { | ||
361 | - if($(this).parent().parent().hasClass('sub_m')){ //если li элемент вложженый | ||
362 | - if($(this).parent().hasClass('open')){ | ||
363 | - $(this).parent().removeClass('open') | ||
364 | - } else { | ||
365 | - $('.sub_m').find('.has_ul').removeClass('open') | ||
366 | - $(this).parent().addClass('open') | ||
367 | - } | ||
368 | - } | ||
369 | - | ||
370 | - if($(this).parent().parent().hasClass('sub_m-first')) { //если ли родительский открываем/закрываем | ||
371 | - if($(this).parent().hasClass('open')) { | ||
372 | - $(this).parent().removeClass('open') | ||
373 | - $(this).parent().find('.open').removeClass('open') | ||
374 | - } else { | ||
375 | - $(this).parent().addClass('open') | ||
376 | - } | ||
377 | - | ||
378 | - } | ||
379 | - | ||
380 | - }) | ||
381 | - | ||
382 | - | ||
383 | - | 2 | + |
3 | + function scrollToMenu() { | ||
4 | + $('.main-nav-item') | ||
384 | } | 5 | } |
385 | - | ||
386 | - | ||
387 | - | ||
388 | - | ||
389 | - | ||
390 | - | ||
391 | - | ||
392 | - | ||
393 | var basket = new ArtboxBasket({ | 6 | var basket = new ArtboxBasket({ |
394 | 'cartSelector': '#cart' | 7 | 'cartSelector': '#cart' |
395 | }); | 8 | }); |
@@ -646,7 +259,3 @@ function showLoader(container) { | @@ -646,7 +259,3 @@ function showLoader(container) { | ||
646 | .prepend('<div class="loader-wrapper"><div class="loader"></div></div>'); | 259 | .prepend('<div class="loader-wrapper"><div class="loader"></div></div>'); |
647 | } | 260 | } |
648 | 261 | ||
649 | -$(document).ready(function ($) { | ||
650 | - $('.vcovers').perfectScrollbar({wheelSpeed: 0.5}); | ||
651 | ->>>>>>> 783eb6592414578ef89358f667fc9a8f2540d10f | ||
652 | -}); | ||
653 | \ No newline at end of file | 262 | \ No newline at end of file |