(function($){ $(document).ready(function(){ $(document).on('click', '.is-subscribed a', function(e){ e.preventDefault(); $(this).text( "Unsubscribing..." ); $('.bbpc-unsubscribe-link').text( "Unsubscribing..." ); setTimeout(function(){ $( ".bbp__success-subscribe" ).hide(); } , 1100); }); $(document).on('click', '.show_subscribe span:not(.is-subscribed) a', function(){ $( ".show_subscribe span:not(.is-subscribed) a" ).text( "Subscribing..." ); }); // Ensure the subscription success alert appears at most once. if ( $( ".show_subscribe .is-subscribed" ).length ) { var $existingSuccess = $( ".bbp__success-subscribe" ); if ( $existingSuccess.length > 1 ) { $existingSuccess.not( ':first' ).remove(); } if ( !$( ".bbp__success-subscribe" ).length ) { var $targetHeader = $( ".post-header" ).first(); if ( !$targetHeader.length ) { $targetHeader = $( "#bbpress-forums" ).first(); } if ( $targetHeader.length ) { var successHtml = '

You are subscribed to this forum, and will receive emails for future topic activity.

Unsubscribe from '+forumax_localize_script.bbpc_subscribed_forum_title+'

'; $targetHeader.before( successHtml ); } } } $(document).on('click', '.bbpc-unsubscribe-link', function(e){ e.preventDefault(); let data_id = $(this).attr('data-forum-id'); $('#subscribe-'+data_id+' a').click().text( "Unsubscribing..." ); $(this).text( "Unsubscribing..." ); }); }); })(jQuery);