-
Notifications
You must be signed in to change notification settings - Fork 33
/
bp-activity-subscription-js.js
127 lines (102 loc) · 3.38 KB
/
bp-activity-subscription-js.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
jQuery(document).ready( function($) {
var groupRow = $( '#groups-list li' );
if ( groupRow.find( 'div.ges-panel' ).length ) {
repositionGESPanel();
$( window ).on('resize', function() {
repositionGESPanel();
});
}
// If positioned right, ensure panel is aligned right as well.
function repositionGESPanel() {
if ( 'right' === groupRow.find('div.action').css('float') || 'right' === groupRow.find('div.action, div.item-actions').css('text-align') ) {
groupRow.find('.group-subscription-div').addClass( 'ges-panel-right' );
} else {
groupRow.find('.group-subscription-div').removeClass( 'ges-panel-right' );
}
}
// topic follow/mute
$( document ).on("click", '.ass-topic-subscribe > a', function() {
var it = $(this),
theid = $(this).attr('id'),
stheid = theid.split('-'),
data;
//$('.pagination .ajax-loader').toggle();
data = {
action: 'ass_ajax',
a: stheid[0],
topic_id: stheid[1],
group_id: stheid[2]
//,_ajax_nonce: stheid[2]
};
// TODO: add ajax code to give status feedback that will fade out
$.post( ajaxurl, data, function( response ) {
var m, theid;
if ( response == 'follow' ) {
m = bp_ass.mute;
theid = theid.replace( 'follow', 'mute' );
} else if ( response == 'mute' ) {
m = bp_ass.follow;
theid = theid.replace( 'mute', 'follow' );
} else {
m = bp_ass.error;
}
$(it).html(m);
$(it).attr('id', theid);
$(it).attr('title', '');
//$('.pagination .ajax-loader').toggle();
});
});
// group subscription options
$( document ).on("click", '.group-sub', function(e) {
e.preventDefault();
var it = $(this),
theid = $(this).attr('id'),
stheid = theid.split('-'),
group_id = stheid[1],
current = $( '#gsubstat-' + group_id ).html(),
newBtn = $('button.js-tooltip[data-tooltip-content-id="ges-panel-' + group_id + '"]'),
data;
$('#gsubajaxload-' + group_id).css('display','inline-block');
newBtn.hide();
data = {
action: 'ass_group_ajax',
a: stheid[0],
group_id: stheid[1],
_ajax_nonce: it.parent().data( 'security' )
};
$( '#js-tooltip-close' ).click();
$.post( ajaxurl, data, function( response ) {
var status = $(it).html();
if ( !current || current == 'No Email' ) {
$( '#gsublink-' + group_id ).html('change');
//status = status + ' / ';
}
$( '#gsubstat-' + group_id ).html( status ); //add .animate({opacity: 1.0}, 2000) to slow things down for testing
$( '#gsubstat-' + group_id ).addClass( 'gemail_icon' );
$( '#gsubopt-' + group_id ).slideToggle('fast');
$( '#gsubajaxload-' + group_id ).hide();
newBtn.show();
});
});
$( document ).on("click", '.group-subscription-options-link', function() {
var stheid = $(this).attr('id').split('-'),
group_id = stheid[1];
$( '#gsubopt-' + group_id ).slideToggle('fast');
});
$( document ).on("click", '.group-subscription-close', function() {
var stheid = $(this).attr('id').split('-'),
group_id = stheid[1];
$( '#gsubopt-' + group_id ).slideToggle('fast');
});
//$( document ).on("click", '.ass-settings-advanced-link', function() {
// $( '.ass-settings-advanced' ).slideToggle('fast');
//});
// Toggle welcome email fields on group email options page
$( document ).on("change", '#ass-welcome-email-enabled', function() {
if ( $(this).prop('checked') ) {
$('.ass-welcome-email-field').show();
} else {
$('.ass-welcome-email-field').hide();
}
});
});