/*
 * Backend JS Functions for dynamic messages
 */
"use strict";
jQuery(document).on('click', '.uap-admin-marketing-close', function(e){

    e.preventDefault();

    var $btn = jQuery(this);
    var id = $btn.data('id');
    var $wrapper = $btn.closest('.uap-admin-dashboard-top-news-wrap');

    if ($wrapper.length) {
        $wrapper.fadeOut(200, function(){
            jQuery(this).remove();
        });
    } else {
      var $wrapper = $btn.closest('.uap-dashboard-announcement');
      if ($wrapper.length) {
          $wrapper.fadeOut(200, function(){
              jQuery(this).remove();
              jQuery('.uap-dashboard-wrap').removeClass('uap-dashboard-show-announcement');
          });
      }
    }
    
    jQuery.post(ajaxurl, {
        action: 'uap_ajax_dismiss_dynamic_message',
        id: id
    });

});
