/** * 2007-2018 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA * @copyright 2007-2018 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ function openBootstrapModal(title, element, inner, idProduct, idProductAttribute) { inner = typeof inner !== 'undefined' ? inner : false; modal = ''; $(modal).modal('show'); setTimeout(function () { $('#mrshopmailnotification-form-modal').on('hidden.bs.modal', function () { $(this).remove(); }); }, 500); } function addNotification(idProduct, idProductAttribute, customerMail) { notifyMeButton = $('#open-mrshopmailnotification-form-modal-' + idProduct + '-' + idProductAttribute); notifyMeButton.addClass('disabled'); $.ajax({ type: 'POST', url: $('div.js-mrshopmailnotification').data('url'), data: 'id_product=' + idProduct + '&id_product_attribute=' + idProductAttribute + '&customer_email=' + customerMail, success: function (resp) { resp = JSON.parse(resp); if (!!$.prototype.fancybox) { parent.jQuery.fancybox.close(); } else { $('#mrshopmailnotification-form-modal-' + idProduct + '-' + idProductAttribute + '.modal').modal('hide'); } if (!resp.error) { notifyMeButton.addClass('disabled').removeAttr("onclick").contents().last()[0].textContent = enabledAlertLabel; } else { notifyMeButton.removeClass('disabled'); } setTimeout(function () { console.log('ici2'); console.log(typeof openAlertMessage); if (!!$.prototype.fancybox) { if (typeof openAlertMessage == 'function') { openAlertMessage(moduleName, resp.message, false, closeLabel); console.log('if'); } else { console.log('else'); var content = '
' + '

' + moduleName + '

' + '

' + resp.message + '

' + '
'; $.fancybox.open({ baseClass: 'ax-notification-alert-success', type: 'html', src: content }); } } else { openBootstrapModal(moduleName, resp.message); } }, 500); } }); return false; } function removeNotification(el) { $(el).addClass('disabled').attr('disabled', true); var idProduct = $(el).data('id-product'); var idProductAttribute = $(el).data('id-product-attribute'); $.ajax({ type: 'POST', url: $(el).data('url'), data: 'id_product=' + idProduct + '&id_product_attribute=' + idProductAttribute, success: function (resp) { resp = JSON.parse(resp); if (resp) { if ($(el).parents('#alert-product').length > 0) { $(el).parents('#alert-product').fadeOut('slow'); } else { $(el).parents('li').fadeOut('slow'); } } } }); return false; } function styleRemoveNotification() { removeNotificationButton = $('.js-remove-email-alert'); if (removeNotificationButton.length > 0) { removeNotificationButton.each(function () { if (typeof is17 === 'undefined') { var is17 = true; } if (is17) { $(this).next().prepend($(this)); } else { $(this).next().find('>li').prepend($(this)); } }); } } $(document).ready(function () { styleRemoveNotification(); $('body').on('click', '[id^=open-mrshopmailnotification-form-modal]:not([onClick])', function (e) { var mrshopmailnotification = $(this).find('~[id^=mrshopmailnotification-form-modal]'); e.preventDefault(); console.log('ici'); if (!!$.prototype.fancybox) { $.fancybox.open(mrshopmailnotification, { baseClass: 'ax-notification-alert-success', smallBtn: false, buttons: [], animationDuration: 200, animationEffect: 'material' }); } else { var ids = $(this).parent('.js-mrshopmailnotification').find('> input[type=hidden]'); openBootstrapModal(false, mrshopmailnotification, true, ids[0].value, ids[1].value); } }); });