diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js index 9bf7b82e..5455d3b4 100644 --- a/plugins/kolab_files/kolab_files.js +++ b/plugins/kolab_files/kolab_files.js @@ -559,6 +559,16 @@ kolab_files_selected = function() return files; }; +kolab_files_frame_load = function(frame) +{ + var win = frame.contentWindow; + + rcmail.file_editor = win.file_editor && win.file_editor.editable ? win.file_editor : null; + + if (rcmail.file_editor) + rcmail.enable_command('files-edit', true); +}; + /***********************************************************/ /********** Commands **********/ @@ -666,6 +676,25 @@ rcube_webmail.prototype.files_open = function() file_api.file_open(files[0], rcmail.env.viewer); }; +// enable file editor +rcube_webmail.prototype.files_edit = function() +{ + if (this.file_editor) { + this.file_editor.enable(); + this.enable_command('files-save', true); + } +}; + +rcube_webmail.prototype.files_save = function() +{ + if (!this.file_editor) + return; + + var content = this.file_editor.getContent(); + + file_api.file_save(this.env.file, content); +}; + rcube_webmail.prototype.files_set_quota = function(p) { if (p.total) { @@ -747,7 +776,7 @@ function kolab_files_ui() var row = $('
  • '); row.attr('id', f.id).data('folder', i) - .append($('').text(f.name)) + .append($('').text(f.name)) .click(function() { file_api.folder_select(i); }); if (f.depth) @@ -776,7 +805,7 @@ function kolab_files_ui() var row = $('
  • '); row.attr('id', 'folder-collection-' + n) - .append($('').text(rcmail.gettext('kolab_files.collection_' + n))) + .append($('').text(rcmail.gettext('kolab_files.collection_' + n))) .click(function() { file_api.folder_select(n, true); }); list.append(row); @@ -1433,4 +1462,34 @@ function kolab_files_ui() var href = '?' + $.param({_task: 'files', _action: 'open', file: file, viewer: viewer == 2 ? 1 : 0}); rcmail.open_window(href, false, true); }; + + // save file + this.file_save = function(file, content) + { + rcmail.enable_command('files-save', false); + // because we currently can edit only text files + // and we do not expect them to be very big, we save + // file in a very simple way, no upload progress, etc. + this.req = this.set_busy(true, 'saving'); + this.request('file_update', {file: file, content: content, info: 1}, 'file_save_response'); + }; + + // file save response handler + this.file_save_response = function(response) + { + rcmail.enable_command('files-save', true); + + if (!this.response(response)) + return; + + // update file properties table + var table = $('#fileinfobox table'), file = response.result; + + if (file) { + $('td.filetype', table).text(file.type); + $('td.filesize', table).text(this.file_size(file.size)); + $('td.filemtime', table).text(file.mtime); + } + }; + }; diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php index 467459d1..022fd3ef 100644 --- a/plugins/kolab_files/lib/kolab_files_engine.php +++ b/plugins/kolab_files/lib/kolab_files_engine.php @@ -444,7 +444,10 @@ class kolab_files_engine $this->rc->output->add_gui_object('preview_frame', $attrib['id']); - return html::iframe(array('id' => 'file-content', 'src' => $href)); + $attrib['src'] = $href; + $attrib['onload'] = 'kolab_files_frame_load(this)'; + + return html::iframe($attrib); } /** diff --git a/plugins/kolab_files/localization/en_US.inc b/plugins/kolab_files/localization/en_US.inc index f75f9506..c1488561 100644 --- a/plugins/kolab_files/localization/en_US.inc +++ b/plugins/kolab_files/localization/en_US.inc @@ -27,7 +27,11 @@ $labels['getfile'] = 'Download file'; $labels['view'] = 'View'; $labels['viewfile'] = 'View file'; $labels['rename'] = 'Rename file'; -$labels['deletefile'] = 'Delete selected file(s)'; +$labels['deletefile'] = 'Delete file(s)'; +$labels['edit'] = 'Edit'; +$labels['editfile'] = 'Edit file'; +$labels['save'] = 'Save'; +$labels['savefile'] = 'Save file'; $labels['fileedit'] = 'File properties'; $labels['collection_audio'] = 'Audio'; diff --git a/plugins/kolab_files/skins/larry/images/buttons.png b/plugins/kolab_files/skins/larry/images/buttons.png index 661dbbcd..6c83cf7a 100644 Binary files a/plugins/kolab_files/skins/larry/images/buttons.png and b/plugins/kolab_files/skins/larry/images/buttons.png differ diff --git a/plugins/kolab_files/skins/larry/style.css b/plugins/kolab_files/skins/larry/style.css index b41c369b..9f0b5e66 100644 --- a/plugins/kolab_files/skins/larry/style.css +++ b/plugins/kolab_files/skins/larry/style.css @@ -31,7 +31,7 @@ } #filestoolbar a.button.get { - background-position: center -94px; + background-position: center -93px; } #filestoolbar a.button.open { @@ -42,6 +42,14 @@ background-image: url(../../../../skins/larry/images/buttons.png); } +#filestoolbar a.button.edit { + background-position: center -173px; +} + +#filestoolbar a.button.save { + background-position: center -213px; +} + #filestoolbar form { display: inline; } @@ -325,5 +333,5 @@ a.filesaveall { } ul.toolbarmenu li span.saveas { - background: url(images/buttons.png) -5px -180px no-repeat; + background: url(images/buttons.png) -5px -253px no-repeat; } diff --git a/plugins/kolab_files/skins/larry/templates/filepreview.html b/plugins/kolab_files/skins/larry/templates/filepreview.html index 416cbc74..4657f2cc 100644 --- a/plugins/kolab_files/skins/larry/templates/filepreview.html +++ b/plugins/kolab_files/skins/larry/templates/filepreview.html @@ -14,9 +14,8 @@
    - +
    diff --git a/plugins/kolab_files/skins/larry/ui.js b/plugins/kolab_files/skins/larry/ui.js index 374e79ec..aa2c30fb 100644 --- a/plugins/kolab_files/skins/larry/ui.js +++ b/plugins/kolab_files/skins/larry/ui.js @@ -1,8 +1,11 @@ function kolab_files_ui_init() { - if (rcmail.env.action == 'open') + if (rcmail.env.action == 'open') { var filesviewsplit = new rcube_splitter({ id:'filesopensplitter', p1:'#fileinfobox', p2:'#filecontent', orientation:'v', relative:true, start:226, min:150, size:12 }).init(); + + rcmail.addEventListener('enable-command', kolab_files_enable_command); + } else var filesviewsplit = new rcube_splitter({ id:'filesviewsplitter', p1:'#folderlistbox', p2:'#filelistcontainer', orientation:'v', relative:true, start:226, min:150, size:12 }).init(); @@ -28,10 +31,19 @@ function kolab_files_ui_init() kolab_files_upload_input('#filestoolbar a.upload'); }; +function kolab_files_enable_command(p) +{ + if (p.command == 'files-save') { + var toolbar = $('#filestoolbar'); + $('a.button.edit', toolbar).hide(); + $('a.button.save', toolbar).show(); + } +}; + function kolab_files_update_quota(p) { return UI.update_quota(p); -} +}; function kolab_files_show_listoptions() { @@ -61,7 +73,8 @@ function kolab_files_show_listoptions() close: function() { $dialog.dialog('destroy').hide(); }, - width: 650 + minWidth: 400, + width: $dialog.width()+20 }).show(); };