diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-02-21 10:01:02 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-06-02 19:22:58 +0200 |
commit | 37afab87b56fa7b2a1b0e751df72e9624663f94f (patch) | |
tree | 11252d05738f7d7ee4bdad333ee762a8a63dfad6 /apps/files_sharing/js | |
parent | c88c0b9a13231478c626296d78aac7c1f66d87d9 (diff) | |
download | nextcloud-server-37afab87b56fa7b2a1b0e751df72e9624663f94f.tar.gz nextcloud-server-37afab87b56fa7b2a1b0e751df72e9624663f94f.zip |
minimal mail template editor for administrators, refs #7177
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r-- | apps/files_sharing/js/settings-admin.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/apps/files_sharing/js/settings-admin.js b/apps/files_sharing/js/settings-admin.js new file mode 100644 index 00000000000..25950b9f4f3 --- /dev/null +++ b/apps/files_sharing/js/settings-admin.js @@ -0,0 +1,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); + }); + } + ); +}); |