(function ($) { 'use strict'; $(function () { var $button = $('[data-action]'); var $metrika = $('[data-metrika]'); $($metrika).on('click', function () { var id = $(this).data('metrika'), action = $(this).data('action'); try { if (window.yaCounter34815135) { yaCounter34815135.reachGoal(id); } } catch (e) { var error_message = 'Error: ' + e, error = new Error(error_message); AMOFORMS.core.errors.sendError(error, { action: action, message: e.message, error_name: e.name }); } }); $($button).on('click', function (event) { event.preventDefault(); event.stopPropagation(); var notice = $(this).parents('.amoforms_notice'), action = $(this).data('action'), type = notice.attr('id'); sendAjax(action, type); notice.hide(); }); function sendAjax(action, type) { $.ajax({ type: 'POST', cache: false, url: ajaxurl + '?action=amoforms_' + action + '_notice&type=' + type, dataType: 'JSON', error: function (xhr, status, http_error) { AMOFORMS.core.errors.sendErrorAjax(xhr, status, http_error, action); } }); } }); })(jQuery);