summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/js/settings-admin.js
blob: 25950b9f4f3862143a89fb0bdfd59a3a5346a268 (plain)
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
$(document).ready(function() {
	
	var loadTemplate = function (theme, template) {
			$.get(
				OC.filePath( 'files_sharing', 'ajax', 'getmailtemplate.php' )
				, { theme: theme, template: template }
			).done(function( result ) {
				$( '#mailTemplateSettings textarea' ).val(result);
			}).fail(function( result ) {
				alert(result);
			});
		
	}
	
	// load default template
	var theme = $( '#mts-theme' ).val();
	var template = $( '#mts-template' ).val();
	loadTemplate(theme, template);

	$( '#mts-template' ).change(
		function() {
			var theme = $( '#mts-theme' ).val();
			var template = $( this ).val();
			loadTemplate(theme, template);
		}
	);
	$( '#mts-theme' ).change(
		function() {
			var theme = $( this ).val();
			var template = $( '#mts-template' ).val();
			loadTemplate(theme, template);
		}
	);
	$( '#mailTemplateSettings .actions' ).on('click', '.save',
		function() {
			var theme = $( '#mts-theme' ).val();
			var template = $( '#mts-template' ).val();
			var content = $( '#mailTemplateSettings textarea' ).val();
			OC.msg.startSaving('#mts-msg');
			$.post(
				OC.filePath( 'files_sharing', 'ajax', 'setmailtemplate.php' )
				, { theme: theme, template: template, content: content }
			).done(function( result ) {
				var data = { status:'success', data:{message:t('files_sharing', 'Saved')} };
				OC.msg.finishedSaving('#mts-msg', data);
			}).fail(function( result ) {
				var data = { status:'error', data:{message:t('files_sharing', 'Error')} };
				OC.msg.finishedSaving('#mts-msg', data);
			});	
		}
	);
	$( '#mailTemplateSettings .actions' ).on('click', '.reset',
		function() {
			var theme = $( '#mts-theme' ).val();
			var template = $( '#mts-template' ).val();
			var content = $( '#mailTemplateSettings textarea' ).val();
			OC.msg.startSaving('#mts-msg');
			$.post(
				OC.filePath( 'files_sharing', 'ajax', 'resetmailtemplate.php' )
				, { theme: theme, template: template }
			).done(function( result ) {
				var data = { status:'success', data:{message:t('files_sharing', 'Reset')} };
				OC.msg.finishedSaving('#mts-msg', data);

				// load default template
				var theme = $( '#mts-theme' ).val();
				var template = $( '#mts-template' ).val();
				loadTemplate(theme, template);
			}).fail(function( result ) {
				var data = { status:'error', data:{message:t('files_sharing', 'Error')} };
				OC.msg.finishedSaving('#mts-msg', data);
			});	
		}
	);
});