diff --git a/plugins/kolab_2fa/kolab2fa.js b/plugins/kolab_2fa/kolab2fa.js index 9114a3f3..cec01651 100644 --- a/plugins/kolab_2fa/kolab2fa.js +++ b/plugins/kolab_2fa/kolab2fa.js @@ -1,372 +1,372 @@ /** * Kolab 2-Factor-Authentication plugin client functions * * @author Thomas Bruederli * * @licstart The following is the entire license notice for the * JavaScript code in this page. * * Copyright (C) 2015, Kolab Systems AG * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * * @licend The above is the entire license notice * for the JavaScript code in this page. */ window.rcmail && rcmail.addEventListener('init', function(evt) { var highsec_call_stack = []; var highsec_dialog; var factor_dialog; if (!rcmail.env.kolab_2fa_factors) { rcmail.env.kolab_2fa_factors = {}; } /** * Equivalend of PHP time() */ function time() { return Math.round(new Date().getTime() / 1000); } /** * Render the settings UI */ function render() { var table = $('#kolab2fa-factors tbody'); table.html(''); var rows = 0; $.each(rcmail.env.kolab_2fa_factors, function(id, props) { if (props.active) { var tr = $('').addClass(props.method).appendTo(table), button = $('').attr({href: '#', rel: id}) .append($('').text(rcmail.get_label('remove','kolab_2fa'))); $('').addClass('name').text(props.label || props.name).appendTo(tr); $('').addClass('created').text(props.created || '??').appendTo(tr); $('').addClass('actions buttons-cell').append(button).appendTo(tr); rows++; } }); table.parent()[(rows > 0 ? 'show' : 'hide')](); } /** * Open dialog to add the given authentication factor */ function add_factor(method) { var lock, form = $('#kolab2fa-prop-' + method), props = rcmail.env.kolab_2fa_factors[method]; if (form.length) { form.get(0).reset(); form.find('img.qrcode').attr('src', 'data:image/gif;base64,R0lGODlhDwAPAIAAAMDAwAAAACH5BAEAAAAALAAAAAAPAA8AQAINhI+py+0Po5y02otnAQA7'); form.off('submit'); factor_dialog = rcmail.show_popup_dialog( form.show(), rcmail.get_label('addfactor', 'kolab_2fa'), [ { text: rcmail.gettext('save', 'kolab_2fa'), 'class': 'mainaction save', click: function(e) { save_data(method); } }, { text: rcmail.gettext('cancel'), 'class': 'cancel', click: function() { factor_dialog.dialog('close'); } } ], { open: function(event, ui) { $(event.target).find('input[name="_verify_code"]').keypress(function(e) { if (e.which == 13) { - $(e.target).closest('.ui-dialog').find('.ui-button.mainaction').click(); + $(e.target).closest('.ui-dialog').find('button.mainaction').click(); } }); }, close: function(event, ui) { form.hide().appendTo(document.body); factor_dialog = null; } } ) .data('method', method) .data('timestamp', time()); form.on('submit', function(e) { save_data(method); return false; }); // load generated data lock = rcmail.set_busy(true, 'loading'); rcmail.http_post('plugin.kolab-2fa-data', { _method: method }, lock); } } /** * Remove the given factor from the account */ function remove_factor(id) { if (rcmail.env.kolab_2fa_factors[id]) { rcmail.env.kolab_2fa_factors[id].active = false; } render(); var lock = rcmail.set_busy(true, 'saving'); rcmail.http_post('plugin.kolab-2fa-save', { _method: id, _data: 'false' }, lock); } /** * Submit factor settings form */ function save_data(method) { var lock, data, form = $('#kolab2fa-prop-' + method), verify = form.find('input[name="_verify_code"]'); if (verify.length && !verify.val().length) { alert(rcmail.get_label('verifycodemissing','kolab_2fa')); verify.select(); return false; } data = form_data(form); lock = rcmail.set_busy(true, 'saving'); rcmail.http_post('plugin.kolab-2fa-save', { _method: data.id || method, _data: JSON.stringify(data), _verify_code: verify.val(), _timestamp: factor_dialog ? factor_dialog.data('timestamp') : null }, lock); } /** * Collect all factor properties from the form */ function form_data(form) { var data = {}; form.find('input, select').each(function(i, elem) { if (elem.name.indexOf('_prop') === 0) { k = elem.name.match(/\[([a-z0-9_.-]+)\]$/i) ? RegExp.$1 : null; if (k) { data[k] = elem.tagName == 'SELECT' ? $('option:selected', elem).val() : $(elem).val(); } } }); return data; } /** * Execute the given function after the user authorized the session with a 2nd factor */ function require_high_security(func, exclude) { // request 2nd factor auth if (!rcmail.env.session_secured || rcmail.env.session_secured < time() - 120) { var method, name; // find an active factor $.each(rcmail.env.kolab_2fa_factors, function(id, prop) { if (prop.active && !method || method == exclude) { method = id; name = prop.label || prop.name; if (!exclude || id !== exclude) { return true; } } }); // we have a registered factor, use it if (method) { highsec_call_stack.push(func); // TODO: list all active factors to choose from var html = String($('#kolab2fa-highsecuritydialog').html()).replace('$name', name); highsec_dialog = rcmail.show_popup_dialog( html, rcmail.get_label('highsecurityrequired', 'kolab_2fa'), [ { text: rcmail.gettext('enterhighsecurity', 'kolab_2fa'), click: function(e) { var lock, code = highsec_dialog.find('input[name="_code"]').val(); if (code && code.length) { lock = rcmail.set_busy(true, 'verifying'); rcmail.http_post('plugin.kolab-2fa-verify', { _method: method, _code: code, _session: 1, _timestamp: highsec_dialog.data('timestamp') }, lock); } else { highsec_dialog.find('input[name="_code"]').select(); } }, 'class': 'mainaction save' }, { text: rcmail.gettext('cancel'), 'class': 'cancel', click: function() { highsec_dialog.dialog('close'); } } ], { open: function(event, ui) { // submit code on $(event.target).find('input[name="_code"]').keypress(function(e) { if (e.which == 13) { - $(e.target).closest('.ui-dialog').find('.ui-button.mainaction').click(); + $(e.target).closest('.ui-dialog').find('button.mainaction').click(); } }).select(); }, close: function(event, ui) { $(this).remove(); highsec_dialog = null; highsec_call_stack.pop(); } } ).data('timestamp', time()); return false; } } // just trigger the callback func.call(this); }; // callback for factor data provided by the server rcmail.addEventListener('plugin.render_data', function(data) { var method = data.method, form = $('#kolab2fa-prop-' + method); if (form.length) { $.each(data, function(field, value) { form.find('[name="_prop[' + field + ']"]').val(value); }); if (data.qrcode) { $('img.qrcode[rel='+method+']').attr('src', "data:image/png;base64," + data.qrcode); } } else if (window.console) { console.error("Cannot assign auth data", data); } }); // callback for save action rcmail.addEventListener('plugin.save_success', function(data) { if (!data.active && rcmail.env.kolab_2fa_factors[data.id]) { delete rcmail.env.kolab_2fa_factors[data.id]; } else if (rcmail.env.kolab_2fa_factors[data.id]) { $.extend(rcmail.env.kolab_2fa_factors[data.id], data); } else { rcmail.env.kolab_2fa_factors[data.id] = data; } if (factor_dialog) { factor_dialog.dialog('close'); } render(); }); // callback for verify action rcmail.addEventListener('plugin.verify_response', function(data) { // execute high-security call stack and close dialog if (data.success && highsec_dialog && highsec_dialog.is(':visible')) { var func; while (highsec_call_stack.length) { func = highsec_call_stack.pop(); func(); } highsec_dialog.dialog('close'); rcmail.env.session_secured = time(); } else { rcmail.display_message(data.message, data.success ? 'confirmation' : 'warning'); if (highsec_dialog && highsec_dialog.is(':visible')) { highsec_dialog.find('input[name="_code"]').val('').select(); } else { $('#kolab2fa-prop-' + data.method + ' input.k2fa-verify').val('').select(); } } }); // callback for save failure rcmail.addEventListener('plugin.reset_form', function(method) { if (rcmail.env.kolab_2fa_factors[method]) { rcmail.env.kolab_2fa_factors[method].active = false; } render(); }); // handler for selections $('#kolab2fa-add').change(function() { var method = $('option:selected', this).val(); // require auth verification require_high_security(function() { add_factor(method); }); this.selectedIndex = 0; }); // handler for delete button clicks $('#kolab2fa-factors tbody').on('click', '.button.delete', function(e) { var id = $(this).attr('rel'); // require auth verification require_high_security(function() { if (confirm(rcmail.get_label('authremoveconfirm', 'kolab_2fa'))) { remove_factor(id); } }, id); return false; }); // submit verification code on $('.propform input.k2fa-verify').keypress(function(e) { if (e.which == 13) { $(this).closest('.propform').find('.button.verify').click(); } }); // render list initially render(); }); \ No newline at end of file diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js index af4e13a6..9ff0f456 100644 --- a/plugins/kolab_files/kolab_files.js +++ b/plugins/kolab_files/kolab_files.js @@ -1,4376 +1,4376 @@ /** * Kolab files plugin * * @author Aleksander Machniak * * @licstart The following is the entire license notice for the * JavaScript code in this file. * * Copyright (C) 2011-2015, Kolab Systems AG * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * * @licend The above is the entire license notice * for the JavaScript code in this file. */ window.rcmail && window.files_api && rcmail.addEventListener('init', function() { if (rcmail.task == 'mail') { // mail compose if (rcmail.env.action == 'compose') { kolab_files_from_cloud_widget($('#compose-attachments > div')); // register some commands to skip warning message on compose page $.merge(rcmail.env.compose_commands, ['files-list', 'files-sort', 'files-search', 'files-search-reset']); } // mail preview else if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') { var attachment_list = $('#attachment-list'); if ($('li', attachment_list).length) { var link = $('') .text(rcmail.gettext('kolab_files.saveall')) .click(function() { kolab_directory_selector_dialog(); }) .insertAfter($('.header-content > .header-links').length ? $('.header-links > a:last') : attachment_list); } rcmail.addEventListener('menu-open', kolab_files_attach_menu_open); rcmail.enable_command('folder-create', true); } // attachment preview else if (rcmail.env.action == 'get') { rcmail.enable_command('folder-create', true); } if (!rcmail.env.action || rcmail.env.action == 'show' || rcmail.env.action == 'preview') { // add "attach from cloud" button for event/task dialog in mail rcmail.addEventListener('plugin.mail2event_dialog', function() { if (!$('#calendar-attachment-form a.fromcloud').length) kolab_files_from_cloud_widget($('#calendar-attachment-form > div.buttons')); }); } } else if (rcmail.task == 'calendar') { // add "attach from cloud" button for event dialog if (!rcmail.env.action) kolab_files_from_cloud_widget($('#calendar-attachment-form > div.buttons, #edit-attachments-form')); } else if (rcmail.task == 'tasks') { // add "attach from cloud" button for task dialog if (!rcmail.env.action) kolab_files_from_cloud_widget($('#taskedit-attachment-form > div.buttons, #taskedit-attachments-form')); } else if (rcmail.task == 'files') { if (rcmail.gui_objects.fileslist) { rcmail.fileslist = new rcube_list_widget(rcmail.gui_objects.fileslist, { multiselect: true, draggable: true, keyboard: true, column_movable: rcmail.env.files_col_movable, dblclick_time: rcmail.dblclick_time }); rcmail.fileslist.addEventListener('dblclick', function(o) { kolab_files_list_dblclick(o); }) .addEventListener('select', function(o) { kolab_files_list_select(o); }) .addEventListener('keypress', function(o) { kolab_files_list_keypress(o); }) .addEventListener('dragstart', function(e) { kolab_files_drag_start(e); }) .addEventListener('dragmove', function(e) { kolab_files_drag_move(e); }) .addEventListener('dragend', function(e) { kolab_files_drag_end(e); }) .addEventListener('column_replace', function(e) { kolab_files_set_coltypes(e, 'files'); }); rcmail.enable_command('menu-open', 'menu-save', 'files-sort', 'files-search', 'files-search-reset', 'folder-create', true); rcmail.fileslist.init(); kolab_files_list_coltypes('files'); kolab_files_drag_drop_init($(rcmail.gui_objects.fileslist).parents('.droptarget')); } if (rcmail.gui_objects.sessionslist) { rcmail.sessionslist = new rcube_list_widget(rcmail.gui_objects.sessionslist, { keyboard: true, column_movable: rcmail.env.sessions_col_movable, dblclick_time: rcmail.dblclick_time }); rcmail.sessionslist.addEventListener('dblclick', function(o) { kolab_files_sessions_list_dblclick(o); }) .addEventListener('select', function(o) { kolab_files_sessions_list_select(o); }) .addEventListener('keypress', function(o) { kolab_files_sessions_list_keypress(o); }) .addEventListener('column_replace', function(e) { kolab_files_set_coltypes(e, 'sessions'); }); rcmail.sessionslist.init(); kolab_files_list_coltypes('sessions'); } // "one file only" commands rcmail.env.file_commands = ['files-get', 'files-rename']; // "one or more file" commands rcmail.env.file_commands_all = ['files-delete', 'files-move', 'files-copy']; if (rcmail.env.action == 'open' || rcmail.env.action == 'edit') { rcmail.enable_command('files-get', true); rcmail.enable_command('files-delete', rcmail.env.file_data.writable); } else { rcmail.enable_command('folder-mount', rcmail.env.external_sources); } } kolab_files_init(); }); /**********************************************************/ /********* Shared functionality **********/ /**********************************************************/ // Initializes API object function kolab_files_init() { if (window.file_api) return; var editor_config = {}; // Initialize application object (don't change var name!) file_api = $.extend(new files_api(), new kolab_files_ui()); file_api.set_env({ token: kolab_files_token(), url: rcmail.env.files_url, sort_col: 'name', sort_reverse: false, search_threads: rcmail.env.search_threads, resources_dir: rcmail.env.files_url.replace(/\/api\/?$/, '/resources'), caps: rcmail.env.files_caps, supported_mimetypes: rcmail.env.file_mimetypes }); file_api.translations = rcmail.labels; if (rcmail.task == 'files') { if (rcmail.env.action == 'edit' && rcmail.env.editor_type) { // Extract the domain here, it can't be done by Chwala // when using WOPI, which does not set iframe src attribute var domain, href = rcmail.env.file_data.viewer.href; if (href && /^(https?:\/\/[^/]+)/i.test(href)) domain = RegExp.$1; editor_config = { // UI elements iframe: $('#fileframe').get(0), domain: domain, export_menu: rcmail.gui_objects.exportmenu ? $('ul', rcmail.gui_objects.exportmenu).get(0) : null, title_input: $('#document-title').get(0), members_list: $('#members').get(0), photo_url: '?_task=addressbook&_action=photo&_error=1&_email=%email', photo_default_url: rcmail.env.photo_placeholder, // events ready: function(data) { document_editor_init(); }, sessionClosed: function(data) { return document_editor_close(); } }; if (rcmail.env.file_data.writable) editor_config.documentChanged = function(data) { rcmail.enable_command('document-save', true); }; } else if (rcmail.env.action == 'open') { // initialize folders list (for dialogs) // file_api.folder_list(); // get ongoing sessions file_api.request('folder_info', {folder: file_api.file_path(rcmail.env.file), sessions: 1}, 'folder_info_response'); } else if (rcmail.env.action == 'share') { kolab_files_share_form_init(); } else { file_api.env.init_folder = rcmail.env.folder; file_api.env.init_collection = rcmail.env.collection; file_api.folder_list(); file_api.browser_capabilities_check(); if (rcmail.env.contextmenu) { rcmail.env.folders_cm = rcmail.contextmenu.init({menu_name: 'foldercontextmenu', menu_source: '#folderoptions > ul', list_object: 'folder_list'}, { addmenuitem: function(p) { // don't add Mount option to the menu var str = $(p.el).children('a').first().attr('onclick'); if (str && str.match(/folder-mount/)) return {result: false, abort: true}; }, activate: function(p) { var folder = rcmail.env.context_menu_source_id; switch (p.command) { case 'files-folder-delete': case 'folder-rename': return !folder.match(/^folder-collection-(.*)$/); case 'folder-share': return !folder.match(/^folder-collection-(.*)$/) && file_api.is_shareable(folder); case 'folder-create': case 'folder-mount': return true; } }, beforecommand: function(e) { rcmail.env.file_api_context = [file_api.env.folder, file_api.env.collection]; file_api.env.folder = rcmail.env.context_menu_source_id; }, aftercommand: function(e) { file_api.env.folder = rcmail.env.file_api_context[0]; file_api.env.collection = rcmail.env.file_api_context[1]; } }); } } } if (rcmail.env.files_caps && !rcmail.env.framed && rcmail.env.files_caps.DOCEDIT) $.extend(editor_config, { // invitation notifications api: file_api, owner: rcmail.env.files_user, interval: rcmail.env.files_interval || 60, invitationMore: true, invitationChange: document_editor_invitation_handler }); $.extend(editor_config, { // notifications/alerts gettext: function(label) { return rcmail.get_label('kolab_files.' + label); }, set_busy: function(state, message) { return rcmail.set_busy(state, message ? 'kolab_files.' + message : ''); }, hide_message: function(id) { return rcmail.hide_message(id); }, display_message: function(label, type, is_txt, timeout) { if (!is_txt) label = 'kolab_files.' + label; return rcmail.display_message(label, type, timeout * 1000); } }); if (window.document_editor_api) document_editor = new document_editor_api(editor_config); else document_editor = new manticore_api(editor_config); rcmail.addEventListener('responseafterreset', function(o) { // update caps/mountpoints on reset file_api.set_env({caps: rcmail.env.files_caps}); }); }; // returns API authorization token function kolab_files_token() { // consider the token from parent window more reliable (fresher) than in framed window // it's because keep-alive is not requested in frames return rcmail.is_framed() && parent.rcmail.env.files_token ? parent.rcmail.env.files_token : rcmail.env.files_token; }; function kolab_files_from_cloud_widget(elem) { $('') .attr('tabindex', $('button,input', elem).first().attr('tabindex') || 0) .text(rcmail.gettext('kolab_files.fromcloud')) .click(function() { kolab_files_selector_dialog(); }) .appendTo(elem); if (rcmail.gui_objects.fileslist) { rcmail.fileslist = new rcube_list_widget(rcmail.gui_objects.fileslist, { multiselect: true, keyboard: true, column_movable: false, dblclick_time: rcmail.dblclick_time }); rcmail.fileslist.addEventListener('select', function(o) { kolab_files_list_select(o); }); rcmail.enable_command('files-sort', 'files-search', 'files-search-reset', true); rcmail.fileslist.init(); kolab_files_list_coltypes(); } } // folder selection dialog function kolab_directory_selector_dialog(id) { var dialog = $('#files-dialog'), input = $('#file-save-as-input'), form = $('#file-save-as'), list = $('#folderlistbox'), buttons = {}, label = 'saveto', win = window, fn; // attachment is specified if (id) { var attach = $('#attach' + id + '> a').first(), filename = attach.attr('title'); if (!filename) { attach = attach.clone(); $('.attachment-size', attach).remove(); filename = $.trim(attach.text()); } form.show(); dialog.addClass('saveas'); input.val(filename); } // attachment preview page else if (rcmail.env.action == 'get') { id = rcmail.env.part; form.show(); dialog.addClass('saveas'); input.val(rcmail.env.filename); } else { form.hide(); dialog.removeClass('saveas'); label = 'saveall'; } $('#foldercreatelink').attr('tabindex', 0); buttons[rcmail.gettext('kolab_files.save')] = function () { if (!file_api.env.folder) return; var lock = rcmail.set_busy(true, 'saving'), request = { act: 'save-file', source: rcmail.env.mailbox, uid: rcmail.env.uid, dest: file_api.env.folder }; if (id) { request.id = id; request.name = input.val(); } rcmail.http_post('plugin.kolab_files', request, lock); kolab_dialog_close(this); }; buttons[rcmail.gettext('kolab_files.cancel')] = function () { kolab_dialog_close(this); }; if (!rcmail.env.folders_loaded) { fn = function() { rcmail.env.folder_list_selector = '#files-dialog #files-folder-list'; rcmail.env.folder_search_selector = '#files-dialog #foldersearch'; file_api.folder_list({writable: 1}); rcmail.env.folders_loaded = true; }; } // show dialog window kolab_dialog_show(dialog, { title: rcmail.gettext('kolab_files.' + label), buttons: buttons, button_classes: ['mainaction save', 'cancel'], classes: {'ui-dialog': 'selection-dialog files-dialog'}, minWidth: 250, minHeight: 300, height: 400, width: 300 }, fn); // add link for "more options" drop-down if (!dialog.find('foldercreatelink').length) $('') .attr({href: '#', 'class': 'btn btn-link options add-folder'}) .text(rcmail.gettext('kolab_files.addfolder')) .click(function(e) { rcmail.command('folder-create', '', this, e); }) .prependTo(dialog.parent().parent().find('.ui-dialog-buttonset')); // "enable" folder creation when dialog is displayed in parent window if (rcmail.is_framed()) { parent.rcmail.enable_command('folder-create', true); parent.rcmail.folder_create = function() { win.kolab_files_folder_create_dialog(); }; } }; // file selection dialog function kolab_files_selector_dialog() { var dialog = $('#files-compose-dialog'), buttons = {}; buttons[rcmail.gettext('kolab_files.attachsel')] = function () { var list = []; $('#filelist tr.selected').each(function() { list.push($(this).data('file')); }); kolab_dialog_close(this); if (list.length) { // display upload indicator and cancel button var content = '' + rcmail.get_label('kolab_files.attaching') + '', id = new Date().getTime(); rcmail.add2attachment_list(id, {name:'', html:content, classname:'uploading', complete:false}); // send request rcmail.http_post('plugin.kolab_files', { act: 'attach-file', files: list, id: rcmail.env.compose_id, uploadid: id }); } }; buttons[rcmail.gettext('kolab_files.cancel')] = function () { kolab_dialog_close(this); }; // show dialog window kolab_dialog_show(dialog, { title: rcmail.gettext('kolab_files.selectfiles'), buttons: buttons, button_classes: ['mainaction save', 'cancel'], classes: {'ui-dialog': 'selection-dialog files-dialog'}, minWidth: 500, minHeight: 300, width: 700, height: 500 }, function() { rcmail.fileslist.resize(); }); if (!rcmail.env.files_loaded) { rcmail.env.folder_list_selector = '#files-compose-dialog #files-folder-list'; rcmail.env.folder_search_selector = '#files-compose-dialog #foldersearch'; file_api.folder_list(); rcmail.env.files_loaded = true; } else { rcmail.fileslist.clear_selection(); } }; function kolab_files_attach_menu_open(p) { if (!p || !p.props || p.props.menu != 'attachmentmenu') return; var id = p.props.id; $('#attachmenusaveas').unbind('click').attr('onclick', '').click(function(e) { return kolab_directory_selector_dialog(id); }); }; // folder creation dialog function kolab_files_folder_create_dialog() { var dialog = $('#files-folder-create-dialog'), buttons = {}, select = $('select[name="parent"]', dialog).html(''), input = $('input[name="name"]', dialog).val(''); buttons[rcmail.gettext('kolab_files.create')] = function () { var folder = '', name = input.val(), parent = select.val(); if (!name) return; if (parent) folder = parent + file_api.env.directory_separator; folder += name; file_api.folder_create(folder); kolab_dialog_close(this); }; buttons[rcmail.gettext('kolab_files.cancel')] = function () { kolab_dialog_close(this); }; // show dialog window kolab_dialog_show(dialog, { title: rcmail.gettext('kolab_files.foldercreate'), buttons: buttons, button_classes: ['mainaction save', 'cancel'], height: 200 }); // Fix submitting form with Enter $('form', dialog).submit(kolab_dialog_submit_handler); // build parent selector file_api.folder_select_element(select, {empty: !rcmail.env.files_caps.NOROOT, writable: true}); }; // folder edit dialog function kolab_files_folder_edit_dialog() { var dialog = $('#files-folder-edit-dialog'), buttons = {}, separator = file_api.env.directory_separator, current_folder = file_api.env.folder, arr = current_folder.split(separator), folder = arr.pop(), path = arr.join(separator), select = $('select[name="parent"]', dialog).html(''), input = $('input[name="name"]', dialog).val(folder); buttons[rcmail.gettext('kolab_files.save')] = function () { var folder = '', name = input.val(), parent = select.val(); if (!name) return; if (parent) folder = parent + separator; folder += name; file_api.folder_rename(current_folder, folder); kolab_dialog_close(this); }; buttons[rcmail.gettext('kolab_files.cancel')] = function () { kolab_dialog_close(this); }; // show dialog window kolab_dialog_show(dialog, { title: rcmail.gettext('kolab_files.folderedit'), buttons: buttons, button_classes: ['mainaction save', 'cancel'], height: 200 }); // Fix submitting form with Enter $('form', dialog).submit(kolab_dialog_submit_handler); // build parent selector file_api.folder_select_element(select, {selected: path, empty: !rcmail.env.files_caps.NOROOT}); }; // folder sharing dialog function kolab_files_folder_share_dialog() { var dialog = $(''; document.body.insertAdjacentHTML('BeforeEnd', html); } // for standards-compliant browsers else $('