-
-
Save j3ck/6d7ba073eeb9bcf4546ddd42350da06d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //= require 'modules/cart' | |
| //= require 'modules/variant' | |
| //= require 'modules/quantity_spinner' | |
| $('.catalog_i').on('mouseleave mouseout', function(){ | |
| }); | |
| $(function () { | |
| var basket = new Cart(); | |
| function selectSize($size){ | |
| var | |
| variant = new Variant($size); | |
| variant.updateVariant( $size.data('variant') ); | |
| $size.closest('.ui-size').find('.ui-size_i_a__active').removeClass('ui-size_i_a__active'); | |
| $size.addClass('ui-size_i_a__active'); | |
| } | |
| $(document).on('click', '[data-variant]', function () { | |
| selectSize( $(this) ); | |
| return false; | |
| }); | |
| $(document).on('ajax:before', '[data-populate-order]', function (xhr, l) { | |
| var variant = new Variant( $(this) ); | |
| if ( !variant.valuePresent() ) { | |
| tip = tippy(this, { | |
| arrow: true, | |
| html: '#my-template-id', | |
| trigger: 'manual', | |
| size: 'big' | |
| }) | |
| popper = tip.getPopperElement(this) | |
| tip.show(popper); | |
| // alert('Выберите вариант для покупки.'); | |
| return false; | |
| } | |
| }); | |
| $(document).on('ajax:success', '[data-populate-order]', function (e, responce) { | |
| basket.updateCounter(responce.itemsCount); | |
| $('i.fa.fa-shopping-cart').animate({ | |
| top:'20%' | |
| }, 100); | |
| $('i.fa.fa-shopping-cart').animate({ | |
| top:'50%' | |
| }, 500); | |
| var spinner = new QuantitySpinner( $(this) ); | |
| spinner.reset(); | |
| $(".cart_preview_modal").replaceWith(responce.basket_preview_html); | |
| $("#exampleModal1").arcticmodal(); | |
| return false; | |
| }); | |
| $(document).on('ajax:error', '[data-populate-order]', function (e, responce) { | |
| alert('Сожалеем, но выбранного товара нет в нужном количестве.'); | |
| return false; | |
| }); | |
| $(document).on('ajax:success', '[data-change-variant]', function (e, responce) { | |
| window.location.replace('/cart'); | |
| }); | |
| $(document).on('spin', '[data-catalog-spinner]', function (e, ui) { | |
| var spinner = new QuantitySpinner( $(this) ); | |
| spinner.clientQuantityChange(ui.value); | |
| }); | |
| $(document).on('ajax:success', '[data-delete-line-item]', function (e, responce) { | |
| window.location.reload(true); | |
| }); | |
| $(document).on('ajax:success', '[data-update-line-item]', function (e, responce) { | |
| window.location.reload(true); | |
| }); | |
| $(document).on('ajax:error', '[data-update-line-item]', function (e, responce) { | |
| alert('Сожалеем, но выбранного товара нет в нужном количестве.'); | |
| return false; | |
| }); | |
| $(document).on('spin', '[data-cart-spinner]', function (e, ui) { | |
| var spinner = new QuantitySpinner( $(this) ); | |
| spinner.serverQuantityChange(ui.value); | |
| return false; | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment