$(document).ready(function() {
$.fn.editable.defaults.mode = 'inline';
$.fn.editableform.buttons =
''+
'';
$('.editable-element-text').editable({
escape: false,
success: function(response, newValue) {
console.log(response); // Debug output from ajax.php
if(response.status == 'error') return response.msg; //msg will be shown in editable form
},
error: function (xhr, status, error) {
//var err = eval("(" + xhr.responseText + ")");
return xhr.statusText;
},
params: function(params) {
params.action = 'updateMailaccounts';
return params;
}
});
$('.editable-element-select-protocol').editable({
defaultValue: 'imap',
source: [
{value: 'imap', text: 'IMAP'},
{value: 'pop3', text: 'POP3'}
],
success: function(response, newValue) {
console.log(response); // Debug output from ajax.php
if(response.status == 'error') return response.msg; //msg will be shown in editable form
},
error: function (xhr, status, error) {
//var err = eval("(" + xhr.responseText + ")");
return xhr.statusText;
},
params: function(params) {
params.action = 'updateMailaccounts';
return params;
}
});
$('.editable-element-select-use-ssl').editable({
defaultValue: '1',
source: [
{value: '1', text: 'On'},
{value: '0', text: 'Off'}
],
success: function(response, newValue) {
console.log(response); // Debug output from ajax.php
if(response.status == 'error') return response.msg; //msg will be shown in editable form
},
error: function (xhr, status, error) {
//var err = eval("(" + xhr.responseText + ")");
return xhr.statusText;
},
params: function(params) {
params.action = 'updateMailaccounts';
return params;
}
});
$('.editable-element-select-no-valid-cert').editable({
defaultValue: '0',
source: [
{value: '0', text: 'On'},
{value: '1', text: 'Off'}
],
success: function(response, newValue) {
console.log(response); // Debug output from ajax.php
if(response.status == 'error') return response.msg; //msg will be shown in editable form
},
error: function (xhr, status, error) {
//var err = eval("(" + xhr.responseText + ")");
return xhr.statusText;
},
params: function(params) {
params.action = 'updateMailaccounts';
return params;
}
});
$('#add-mailaccount').on('click', function(e) {
e.preventDefault();
var uId = $(this).attr('data-uid');
$.ajax({
url: 'ajax.php',
type: 'POST',
data: {'action': 'addDefaultMailaccount', 'user-id': uId},
success: function (result) {
console.log(result);
location.reload();
}
});
});
function fancyBoxLoader() {
$.ajax({
url: 'ajax.php',
data: {'action': 'getMailAccountsByUid', 'uId': $('.manage-mailboxfolder').attr('data-uid')},
type: 'GET',
global: false,
async: true,
dataType: 'json',
success: function(data) {
result = data;
$('.editable-element-select-mailaccount').editable({
//defaultValue: '0',
source: result,
success: function(response, newValue) {
console.log(response); // Debug output from ajax.php
if(response.status == 'error') return response.msg; //msg will be shown in editable form
},
error: function (xhr, status, error) {
//var err = eval("(" + xhr.responseText + ")");
return xhr.statusText;
},
params: function(params) {
params.action = 'updateMailfolder';
return params;
}
});
}
});
$('.editable-element-text').editable({
escape: false,
success: function(response, newValue) {
console.log(response); // Debug output from ajax.php
if(response.status == 'error') return response.msg; //msg will be shown in editable form
},
error: function (xhr, status, error) {
//var err = eval("(" + xhr.responseText + ")");
return xhr.statusText;
},
params: function(params) {
params.action = 'updateMailfolder';
return params;
}
});
}
$('.remove-mailaccount').on('click', function(e) {
e.preventDefault();
var id = $(this).attr('data-id');
$.ajax({
url: 'ajax.php',
type: 'POST',
data: {'action': 'removeMailaccount', 'id': id},
success: function (result) {
console.log(result);
location.reload();
}
});
});
$('.remove-mailboxfolder').on('click', function(e) {
e.preventDefault();
var id = $(this).attr('data-id');
$.ajax({
url: 'ajax.php',
type: 'POST',
data: {'action': 'removeMailboxFolder', 'id': id},
success: function (result) {
console.log(result);
location.reload();
}
});
});
$('.manage-mailboxfolder').on('click', function(e) {
e.preventDefault();
$.get($(this).attr('href'), function(r) {
try {
editBox = $.parseJSON(r);
console.log(editBox['options']); // DBG
var optionsContainer = document.createElement('div');
console.log(optionsContainer);
$.each(editBox['options'], function(i) {
console.log("jo");
$(optionsContainer).append(this.name + "
")
});
console.log(optionsContainer);
$.fancybox({
maxWidth : 800,
maxHeight : 600,
fitToView : true,
width : '70%',
height : '70%',
autoSize : false,
title : "