2014-02-21 13:01:02 +04:00
|
|
|
$(document).ready(function() {
|
2014-06-03 18:50:05 +04:00
|
|
|
|
2014-02-21 13:01:02 +04:00
|
|
|
var loadTemplate = function (theme, template) {
|
2014-06-03 18:50:05 +04:00
|
|
|
$.get(
|
|
|
|
OC.generateUrl('apps/files_sharing/settings/mailtemplate'),
|
|
|
|
{ theme: theme, template: template }
|
|
|
|
).done(function( result ) {
|
|
|
|
$( '#mailTemplateSettings textarea' ).val(result);
|
|
|
|
}).fail(function( result ) {
|
2014-06-04 17:01:36 +04:00
|
|
|
OC.dialogs.alert(result.message, t('files_sharing', 'Could not load template'));
|
2014-06-03 18:50:05 +04:00
|
|
|
});
|
2014-06-04 17:01:36 +04:00
|
|
|
};
|
2014-06-03 18:50:05 +04:00
|
|
|
|
2014-02-21 13:01:02 +04:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
);
|
2014-06-03 18:50:05 +04:00
|
|
|
|
2014-02-21 13:01:02 +04:00
|
|
|
$( '#mts-theme' ).change(
|
|
|
|
function() {
|
|
|
|
var theme = $( this ).val();
|
|
|
|
var template = $( '#mts-template' ).val();
|
|
|
|
loadTemplate(theme, template);
|
|
|
|
}
|
|
|
|
);
|
2014-06-03 18:50:05 +04:00
|
|
|
|
2014-02-21 13:01:02 +04:00
|
|
|
$( '#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(
|
2014-06-03 18:50:05 +04:00
|
|
|
OC.generateUrl('apps/files_sharing/settings/mailtemplate'),
|
|
|
|
{ theme: theme, template: template, content: content }
|
2014-06-04 17:01:36 +04:00
|
|
|
).done(function() {
|
2014-02-21 13:01:02 +04:00
|
|
|
var data = { status:'success', data:{message:t('files_sharing', 'Saved')} };
|
|
|
|
OC.msg.finishedSaving('#mts-msg', data);
|
2014-06-04 17:01:36 +04:00
|
|
|
}).fail(function(result) {
|
|
|
|
var data = { status: 'error', data:{message:result.responseJSON.message} };
|
2014-02-21 13:01:02 +04:00
|
|
|
OC.msg.finishedSaving('#mts-msg', data);
|
2014-06-03 18:50:05 +04:00
|
|
|
});
|
2014-02-21 13:01:02 +04:00
|
|
|
}
|
|
|
|
);
|
2014-06-03 18:50:05 +04:00
|
|
|
|
2014-02-21 13:01:02 +04:00
|
|
|
$( '#mailTemplateSettings .actions' ).on('click', '.reset',
|
|
|
|
function() {
|
|
|
|
var theme = $( '#mts-theme' ).val();
|
|
|
|
var template = $( '#mts-template' ).val();
|
|
|
|
OC.msg.startSaving('#mts-msg');
|
2014-06-03 18:50:05 +04:00
|
|
|
$.ajax({
|
|
|
|
type: "DELETE",
|
|
|
|
url: OC.generateUrl('apps/files_sharing/settings/mailtemplate'),
|
|
|
|
data: { theme: theme, template: template }
|
2014-06-04 17:01:36 +04:00
|
|
|
}).done(function() {
|
2014-02-21 13:01:02 +04:00
|
|
|
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);
|
2014-06-04 17:01:36 +04:00
|
|
|
}).fail(function(result) {
|
|
|
|
var data = { status: 'error', data:{message:result.responseJSON.message} };
|
2014-02-21 13:01:02 +04:00
|
|
|
OC.msg.finishedSaving('#mts-msg', data);
|
2014-06-03 18:50:05 +04:00
|
|
|
});
|
2014-02-21 13:01:02 +04:00
|
|
|
}
|
|
|
|
);
|
2014-06-03 18:50:05 +04:00
|
|
|
|
2014-02-21 13:01:02 +04:00
|
|
|
});
|