| 1 |
(function($){ |
| 2 |
$(document).ready(function(){ |
| 3 |
|
| 4 |
$(document).on('click', '.is-subscribed a', function(e){ |
| 5 |
e.preventDefault(); |
| 6 |
$(this).text( "Unsubscribing..." ); |
| 7 |
$('.bbpc-unsubscribe-link').text( "Unsubscribing..." ); |
| 8 |
setTimeout(function(){ |
| 9 |
$( ".bbp__success-subscribe" ).hide(); |
| 10 |
} |
| 11 |
, 1100); |
| 12 |
}); |
| 13 |
|
| 14 |
$(document).on('click', '.show_subscribe span:not(.is-subscribed) a', function(){ |
| 15 |
$( ".show_subscribe span:not(.is-subscribed) a" ).text( "Subscribing..." ); |
| 16 |
}); |
| 17 |
|
| 18 |
// Ensure the subscription success alert appears at most once. |
| 19 |
if ( $( ".show_subscribe .is-subscribed" ).length ) { |
| 20 |
var $existingSuccess = $( ".bbp__success-subscribe" ); |
| 21 |
|
| 22 |
if ( $existingSuccess.length > 1 ) { |
| 23 |
$existingSuccess.not( ':first' ).remove(); |
| 24 |
} |
| 25 |
|
| 26 |
if ( !$( ".bbp__success-subscribe" ).length ) { |
| 27 |
var $targetHeader = $( ".post-header" ).first(); |
| 28 |
|
| 29 |
if ( !$targetHeader.length ) { |
| 30 |
$targetHeader = $( "#bbpress-forums" ).first(); |
| 31 |
} |
| 32 |
|
| 33 |
if ( $targetHeader.length ) { |
| 34 |
var successHtml = '<div class="alert alert-success bbp__success-subscribe"><div class="mailIcon"><svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path data-name="envelope-Filled" d="M10.36 11.71 3.19 6.62A4.5 4.5 0 0 1 7 4.5h10a4.5 4.5 0 0 1 3.81 2.11l-7.15 5.08a3 3 0 0 1-3.3.02ZM21.48 8.6l-6.68 4.74a5.082 5.082 0 0 1-2.81.85 4.968 4.968 0 0 1-2.76-.84L2.52 8.6c-.01.13-.02.27-.02.4v6A4.507 4.507 0 0 0 7 19.5h10a4.507 4.507 0 0 0 4.5-4.5V9c0-.13-.01-.27-.02-.4Z" style="fill:#4c52f1"/></svg></div><div class="bbp__success-subscribe-content"><p class="bbp__success-subscribe-text">You are subscribed to this forum, and will receive emails for future topic activity.</p><p class="bbp__success-subscribe-action"><a class="bbpc-unsubscribe-link" data-forum-id='+forumax_localize_script.bbpc_subscribed_forum_id+' href="javascript:void()">Unsubscribe</a> from '+forumax_localize_script.bbpc_subscribed_forum_title+'</p></div></div>'; |
| 35 |
$targetHeader.before( successHtml ); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
$(document).on('click', '.bbpc-unsubscribe-link', function(e){ |
| 41 |
e.preventDefault(); |
| 42 |
let data_id = $(this).attr('data-forum-id'); |
| 43 |
$('#subscribe-'+data_id+' a').click().text( "Unsubscribing..." ); |
| 44 |
$(this).text( "Unsubscribing..." ); |
| 45 |
}); |
| 46 |
|
| 47 |
}); |
| 48 |
})(jQuery); |