Completed
Pull Request — master (#315)
by Joas
04:21 queued 02:19
created

js/admin.js (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
$(document).ready(function() {
2
	function saveSettings() {
3
		OC.msg.startSaving('#activity_notifications_msg');
4
		var post = $('#activity_notifications').serialize();
5
6
		$.post(OC.generateUrl('/apps/activity/settings/admin'), post, function(response) {
7
			OC.msg.finishedSuccess('#activity_notifications_msg', response.data.message);
8
		});
9
	}
10
11
	var $activityNotifications = $('#activity_notifications');
12
	$activityNotifications.find('input[type=checkbox]').change(saveSettings);
13
14
	$activityNotifications.find('select').change(saveSettings);
15
16
	$activityNotifications.find('.activity_select_group').click(function() {
17
		var $selectGroup = '#activity_notifications .' + $(this).attr('data-select-group');
18
		var $filteredBoxes = $($selectGroup).not(':disabled');
19
		var $checkedBoxes = $filteredBoxes.filter(':checked').length;
20
21
		$filteredBoxes.prop('checked', true);
22
		if ($checkedBoxes === $filteredBoxes.filter(':checked').length) {
23
			// All values were already selected, so invert it
24
			$filteredBoxes.prop('checked', false);
25
		}
26
27
		saveSettings();
28
	});
29
30
	$('#activity_email_enabled').on('change', function() {
31
		OCP.AppConfig.setValue(
32
			'activity', 'enable_email',
33
			$(this).attr('checked') === 'checked' ? 'yes' : 'no'
34
		);
35
	})
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
36
});
37