1305
1305
* For a given filter node, set it up properly based on mute state.
1307
function handle_mute(node, muted) {
1307
function handle_mute(node, filter_info) {
1308
1308
var control = node.one('a.mute-subscription');
1309
1309
var label = node.one('em.mute-label');
1310
1310
var description = node.one('.filter-description');
1311
if (filter_info.is_muted) {
1312
1312
control.set('text', 'Send my emails for this subscription');
1313
1313
control.replaceClass(MUTE_ICON_CLASS, UNMUTE_ICON_CLASS);
1314
1314
label.setStyle('display', null);
1335
1335
'<strong class="filter-name"></strong>'));
1337
1337
if (filter_info.can_mute) {
1338
filter_node.appendChild(Y.Node.create(
1339
'<em class="mute-label" style="padding-left: 1em;">You '+
1340
'do not receive emails from this subscription.</em>'));
1338
filter_node.append(Y.Node.create('<em/>')
1339
.set('text', 'You do not receive emails from this subscription.')
1340
.addClass('mute-label')
1341
.setStyle('paddingLeft', '1em'));
1343
1344
var control = filter_node.appendChild(
1344
1345
Y.Node.create('<span style="float: right"></span>'));
1346
1347
if (filter_info.can_mute) {
1347
var link = control.appendChild(Y.Node.create(
1348
'<a href="#" class="sprite js-action mute-subscription"></a>'));
1349
var help = control.appendChild(Y.Node.create(
1350
'<a target="help" class="sprite maybe mute-help"'+
1351
' style="visibility: hidden;"'+
1352
' href="/+help/structural-subscription-mute.html">'+
1353
' <span class="invisible-link">Delivery help</span>'+
1348
var link = control.appendChild(Y.Node.create('<a/>')
1351
.addClass('js-action')
1352
.addClass('mute-subscription'));
1353
var help = control.appendChild(Y.Node.create('<a/>')
1354
.set('href', '/+help/structural-subscription-mute.html')
1355
.set('target', 'help')
1358
.addClass('mute-help')
1359
.setStyle('visibility', 'hidden')
1360
.append(Y.Node.create('<span/>')
1361
.addClass('invisible-link')
1362
.set('text', 'Delivery help')));
1355
1363
// For some reason the help link will not appear in Chrome unless
1356
1364
// there is a non-empty element immediately after the help node.
1357
1365
control.append(Y.Node.create('<span> </span>'));
1362
1370
help.setStyle('visibility', 'visible');
1363
1371
// Every time we trigger the display of the help link we need to
1364
1372
// cancel any pending hiding of the help link so it doesn't
1365
// dissapear on us. If there isn't one pending, this is a NOP.
1373
// disappear on us. If there isn't one pending, this is a NOP.
1366
1374
clearTimeout(hide_help_timeout);
1368
1376
var hide_help = function () {
1377
1385
if (can_edit(filter_info)) {
1378
1386
// User can edit the subscription.
1379
control.append(Y.Node.create(
1380
'<a href="#" style="margin-right: 2em;"'+
1381
' class="sprite modify edit js-action edit-subscription">'+
1382
' Edit this subscription</a>'+
1383
'<a href="#" class="sprite modify remove js-action '+
1384
' delete-subscription">Unsubscribe</a>'));
1387
filter_node.appendChild(
1388
Y.Node.create('<div style="padding-left: 1em" '+
1389
'class="filter-description"></div>'));
1387
control.append(Y.Node.create('<a/>')
1389
.set('text', 'Edit this subscription')
1390
.setStyle('marginRight', '2em')
1394
.addClass('js-action')
1395
.addClass('edit-subscription'));
1396
control.append(Y.Node.create('<a/>')
1398
.set('text', 'Unsubscribe')
1402
.addClass('js-action')
1403
.addClass('delete-subscription'));
1406
if (filter_info.team_has_contact_address
1407
&& !filter_info.user_is_team_admin) {
1408
var subject = urlEncode('Team contact address and subscriptions');
1409
var user_participation;
1410
if (filter_info.user_is_on_team_mailing_list) {
1411
user_participation = 'subscribe to the team\'s mailing list';
1413
user_participation = 'be a part of the team';
1415
var message = urlEncode(
1416
'Hello. I receive email notifications about bugs in '+
1417
filter_info.target_title+' because of a team subscription for '+
1418
filter_info.subscriber_title+'. I would like to continue to '+
1419
user_participation+', but I would like to receive less email '+
1420
'from this subscription. Could you remove the team contact '+
1421
'email address so that the team members can manage their own '+
1422
'subscriptions (see '+filter_info.subscriber_url+'), or delete '+
1423
'or reduce level of the subscription itself (see '+
1424
filter_info.target_bugs_url+'/+subscriptions)?\n\nThank you.');
1425
control.append(Y.Node.create('<a/>')
1426
.set('href', filter_info.subscriber_url+'/+contactuser'+
1427
'?field.message='+message+'&field.subject='+subject)
1428
.set('text', 'Request team administrators change'));
1431
filter_node.append(Y.Node.create('<div/>')
1432
.setStyle('paddingLeft', '1em')
1433
.addClass('filter-description'));
1391
1435
if (filter_info.can_mute) {
1392
handle_mute(filter_node, filter_info.is_muted);
1436
handle_mute(filter_node, filter_info);
1395
1439
fill_filter_description(filter_node, filter_info, filter);