diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js index 57c5472d..2aa5bcf3 100644 --- a/plugins/kolab_files/kolab_files.js +++ b/plugins/kolab_files/kolab_files.js @@ -191,7 +191,7 @@ function kolab_files_init() file_api.request('folder_info', {folder: file_api.file_path(rcmail.env.file), sessions: 1}, 'folder_info_response'); } else if (rcmail.env.action == 'share') { - // do nothing + kolab_files_share_form_init(); } else { file_api.env.init_folder = rcmail.env.folder; @@ -1324,6 +1324,22 @@ function kolab_files_progress_str(param) .replace(/\$total/, total); }; +function kolab_files_share_form_init() +{ + $('fieldset > table', rcmail.gui_objects.shareform).each(function() { + var mode = $(this).data('mode'); + $('tbody > tr', this).each(function(i, row) { + if (!i) { + $('button.submit', row).on('click', function() { file_api.sharing_submit(rcmail.env.folder, row, mode); }); + } + else { + $('button.delete', row).on('click', function() { file_api.sharing_delete(rcmail.env.folder, row, mode); }); + $('select,input[type=text]', row).on('change', function() { file_api.sharing_update(rcmail.env.folder, row, mode); }); + } + }); + }); +}; + /**********************************************************/ /********* document editor functionality **********/ @@ -2694,6 +2710,103 @@ function kolab_files_ui() this.quota(); }; + this.sharing_submit = function(folder, row, mode) + { + var post = this.sharing_data(row, {action: 'submit', folder: folder, mode: mode}); + + this.sharing_submit_post = post; + this.sharing_submit_row = row; + this.req = this.set_busy(true, 'kolab_files.updatingfolder' + mode); + this.post('sharing', post, 'sharing_submit_response'); + }; + + this.sharing_submit_response = function(response) + { + if (!this.response(response)) + return; + + // reset inputs + $(this.sharing_submit_row).find('input[type=text]').val(''); + + var hidden = [], + post = $.extend({}, this.sharing_submit_post, response.data || {}), + form_info = rcmail.env.form_info[post.mode], + row = $('