| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- $(document).ready(function() {
- $.fn.editable.defaults.mode = 'inline';
- $.fn.editableform.buttons =
- '<button type="submit" class="btn btn-primary btn-sm editable-submit">'+
- '<i class="fa fa-fw fa-check"></i>'+
- '</button>'+
- '<button type="button" class="btn btn-default btn-sm editable-cancel">'+
- '<i class="fa fa-fw fa-times"></i>'+
- '</button>';
- $('.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) {
- editBox = $.parseJSON(r);
- console.log(editBox);
- });
- });
- $('#add-mailboxfolder').on('click', function(e) {
- e.preventDefault();
- var uId = $(this).attr('data-uid');
- var lId = $(this).attr('data-lid');
- $.ajax({
- url: 'ajax.php',
- type: 'POST',
- data: {'action': 'addDefaultMailfolder', 'user-id': uId, 'label-id': lId},
- success: function (result) {
- console.log(result);
- location.reload();
- },
- error: function(result) {
- console.log(result);
- }
- });
- });
- $('#new-document').fancybox({
- beforeShow : fancyBoxLoader,
- maxWidth : 800,
- maxHeight : 600,
- fitToView : false,
- width : '50%',
- height : '70%',
- autoSize : false,
- closeClick : false,
- openEffect : 'none',
- closeEffect : 'none'
- });
- });
|