jQuery(function($) {
  function hideBanner() {
    $('.devikit-ifirma-pro-banner').fadeOut();
  }

  function postAction(actionType) {
    if (typeof devikitIfirmaBanner === 'undefined') return;
    return $.post(devikitIfirmaBanner.ajaxurl, {
      action: 'devikit_ifirma_dismiss_banner',
      nonce: devikitIfirmaBanner.nonce,
      action_type: actionType
    });
  }

  $(document).on('click', '.devikit-ifirma-banner-remind-later', function(e) {
    e.preventDefault();
    postAction('remind_later').always(hideBanner);
  });

  $(document).on('click', '.devikit-ifirma-banner-dismiss-permanent', function(e) {
    e.preventDefault();
    postAction('dismiss_permanent').always(hideBanner);
  });
});

