Implemented text file edition, other improvements
This commit is contained in:
parent
b602913ce3
commit
ef663058c7
7 changed files with 97 additions and 11 deletions
|
@ -559,6 +559,16 @@ kolab_files_selected = function()
|
||||||
return files;
|
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 **********/
|
/********** Commands **********/
|
||||||
|
@ -666,6 +676,25 @@ rcube_webmail.prototype.files_open = function()
|
||||||
file_api.file_open(files[0], rcmail.env.viewer);
|
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)
|
rcube_webmail.prototype.files_set_quota = function(p)
|
||||||
{
|
{
|
||||||
if (p.total) {
|
if (p.total) {
|
||||||
|
@ -747,7 +776,7 @@ function kolab_files_ui()
|
||||||
var row = $('<li class="mailbox"><span class="branch"></span></li>');
|
var row = $('<li class="mailbox"><span class="branch"></span></li>');
|
||||||
|
|
||||||
row.attr('id', f.id).data('folder', i)
|
row.attr('id', f.id).data('folder', i)
|
||||||
.append($('<span class="name">').text(f.name))
|
.append($('<span class="name"></span>').text(f.name))
|
||||||
.click(function() { file_api.folder_select(i); });
|
.click(function() { file_api.folder_select(i); });
|
||||||
|
|
||||||
if (f.depth)
|
if (f.depth)
|
||||||
|
@ -776,7 +805,7 @@ function kolab_files_ui()
|
||||||
var row = $('<li class="mailbox collection ' + n + '"></li>');
|
var row = $('<li class="mailbox collection ' + n + '"></li>');
|
||||||
|
|
||||||
row.attr('id', 'folder-collection-' + n)
|
row.attr('id', 'folder-collection-' + n)
|
||||||
.append($('<span class="name">').text(rcmail.gettext('kolab_files.collection_' + n)))
|
.append($('<span class="name"></span>').text(rcmail.gettext('kolab_files.collection_' + n)))
|
||||||
.click(function() { file_api.folder_select(n, true); });
|
.click(function() { file_api.folder_select(n, true); });
|
||||||
|
|
||||||
list.append(row);
|
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});
|
var href = '?' + $.param({_task: 'files', _action: 'open', file: file, viewer: viewer == 2 ? 1 : 0});
|
||||||
rcmail.open_window(href, false, true);
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -444,7 +444,10 @@ class kolab_files_engine
|
||||||
|
|
||||||
$this->rc->output->add_gui_object('preview_frame', $attrib['id']);
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,7 +27,11 @@ $labels['getfile'] = 'Download file';
|
||||||
$labels['view'] = 'View';
|
$labels['view'] = 'View';
|
||||||
$labels['viewfile'] = 'View file';
|
$labels['viewfile'] = 'View file';
|
||||||
$labels['rename'] = 'Rename 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['fileedit'] = 'File properties';
|
||||||
|
|
||||||
$labels['collection_audio'] = 'Audio';
|
$labels['collection_audio'] = 'Audio';
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 6.8 KiB |
|
@ -31,7 +31,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#filestoolbar a.button.get {
|
#filestoolbar a.button.get {
|
||||||
background-position: center -94px;
|
background-position: center -93px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#filestoolbar a.button.open {
|
#filestoolbar a.button.open {
|
||||||
|
@ -42,6 +42,14 @@
|
||||||
background-image: url(../../../../skins/larry/images/buttons.png);
|
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 {
|
#filestoolbar form {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
@ -325,5 +333,5 @@ a.filesaveall {
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.toolbarmenu li span.saveas {
|
ul.toolbarmenu li span.saveas {
|
||||||
background: url(images/buttons.png) -5px -180px no-repeat;
|
background: url(images/buttons.png) -5px -253px no-repeat;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,8 @@
|
||||||
|
|
||||||
<div id="filestoolbar" class="toolbar">
|
<div id="filestoolbar" class="toolbar">
|
||||||
<roundcube:button command="files-get" type="link" class="button get disabled" classAct="button get" classSel="button get pressed" label="kolab_files.get" title="kolab_files.getfile" />
|
<roundcube:button command="files-get" type="link" class="button get disabled" classAct="button get" classSel="button get pressed" label="kolab_files.get" title="kolab_files.getfile" />
|
||||||
<!--
|
|
||||||
<roundcube:button command="files-edit" type="link" class="button edit disabled" classAct="button edit" classSel="button edit pressed" label="kolab_files.edit" title="kolab_files.editfile" />
|
<roundcube:button command="files-edit" type="link" class="button edit disabled" classAct="button edit" classSel="button edit pressed" label="kolab_files.edit" title="kolab_files.editfile" />
|
||||||
-->
|
<roundcube:button command="files-save" type="link" class="button save disabled" classAct="button save" classSel="button save pressed" label="kolab_files.save" title="kolab_files.savefile" style="display:none" />
|
||||||
<roundcube:button command="files-delete" type="link" class="button delete disabled" classAct="button delete" classSel="button delete pressed" label="delete" title="kolab_files.deletefile" />
|
<roundcube:button command="files-delete" type="link" class="button delete disabled" classAct="button delete" classSel="button delete pressed" label="delete" title="kolab_files.deletefile" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
function kolab_files_ui_init()
|
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',
|
var filesviewsplit = new rcube_splitter({ id:'filesopensplitter', p1:'#fileinfobox', p2:'#filecontent',
|
||||||
orientation:'v', relative:true, start:226, min:150, size:12 }).init();
|
orientation:'v', relative:true, start:226, min:150, size:12 }).init();
|
||||||
|
|
||||||
|
rcmail.addEventListener('enable-command', kolab_files_enable_command);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
var filesviewsplit = new rcube_splitter({ id:'filesviewsplitter', p1:'#folderlistbox', p2:'#filelistcontainer',
|
var filesviewsplit = new rcube_splitter({ id:'filesviewsplitter', p1:'#folderlistbox', p2:'#filelistcontainer',
|
||||||
orientation:'v', relative:true, start:226, min:150, size:12 }).init();
|
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');
|
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)
|
function kolab_files_update_quota(p)
|
||||||
{
|
{
|
||||||
return UI.update_quota(p);
|
return UI.update_quota(p);
|
||||||
}
|
};
|
||||||
|
|
||||||
function kolab_files_show_listoptions()
|
function kolab_files_show_listoptions()
|
||||||
{
|
{
|
||||||
|
@ -61,7 +73,8 @@ function kolab_files_show_listoptions()
|
||||||
close: function() {
|
close: function() {
|
||||||
$dialog.dialog('destroy').hide();
|
$dialog.dialog('destroy').hide();
|
||||||
},
|
},
|
||||||
width: 650
|
minWidth: 400,
|
||||||
|
width: $dialog.width()+20
|
||||||
}).show();
|
}).show();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue