if (Journal.ocv == 4) { $(document).ready(function () { $.fn.jbutton = function (state) { return this.each(function () { var element = this; if (state == 'loading') { this.html = $(element).html(); this.state = $(element).prop('disabled'); $(element).prop('disabled', true).addClass('disabled') } if (state == 'reset') { $(element).prop('disabled', false).removeClass('disabled') } }); } $.fn.button = $.fn.jbutton; }); } else { $.fn.jbutton = $.fn.button; } window['cart'] = window['cart'] || {}; window['cart'].add = function (product_id, quantity, quick_buy) { quantity = quantity || 1; $.ajax({ url: Journal['add_cart_url'], type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, dataType: 'json', beforeSend: function () { $('[data-toggle="tooltip"]').tooltip('hide'); $('[onclick*="cart.add(\'' + product_id + '\'"]').jbutton('loading'); }, complete: function () { $('[onclick*="cart.add(\'' + product_id + '\'"]').jbutton('reset'); }, success: function (json) { $('.alert, .text-danger').remove(); if (json['redirect']) { if (json['options_popup']) { var html = ''; html += '
'; // show modal $('.popup-wrapper').remove(); $('body').append(html); setTimeout(function () { $('html').addClass('popup-open popup-center'); }, 10); } else { location = json['redirect']; } } if (json['success']) { if (json['options_popup']) { var html = ''; html += ' '; // show modal $('.popup-wrapper').remove(); $('body').append(html); setTimeout(function () { $('html').addClass('popup-open popup-center'); }, 10); } else { if (json['notification']) { show_notification(json['notification']); if (quick_buy) { location = Journal['checkoutUrl']; } } else { $('header').after('