jQuery(document).ready(function( $ ){
    var ajaxUrl = oneNewspaperNoticeOject.ajaxUrl, _wpnonce = oneNewspaperNoticeOject._wpnonce
    var welcomeOption = oneNewspaperNoticeOject.welcomeOption

    var noticeContainer = $('.one-newspaper-admin-notice')
    if( noticeContainer.length > 0 ) {
        // dismiss notice
        noticeContainer.on('click', '.alert-dismiss, .action-button.review-never, .action-button.already-reviewed', function(){
            var _this = $(this), notice
            if( _this.parents('.one-newspaper-admin-notice').hasClass( 'one-newspaper-welcome-notice' ) ) notice = welcomeOption
            $.ajax({
                url: ajaxUrl,
                method: "POST",
                data: {
                    "action": 'one_newspaper_admin_notice_ajax_call',
                    "_wpnonce": _wpnonce,
                    "dismiss_option": notice
                },
                beforeSend: function(){
                    _this.text( 'Dismissing...' )
                },
                success: function( result ) {
                    var parsedResult = JSON.parse( result )
                    if( parsedResult.status ) _this.parents( '.one-newspaper-admin-notice' ).fadeOut()
                },
                complete: function() {
                    _this.text( 'Dismissed' )
                }
            })
        })
    }
})