| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- $(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();
- }
- });
- });
- $('.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();
- }
- });
- });
- });
|