Merge branch 'master' of ssh://git.kolab.org/git/roundcubemail-plugins-kolab

This commit is contained in:
Thomas Bruederli 2013-02-21 17:34:25 +01:00
commit e1b78250da
6 changed files with 221 additions and 9 deletions

View file

@ -6,7 +6,7 @@
*/
window.rcmail && rcmail.addEventListener('init', function() {
if (rcmail.env.task == 'mail') {
if (rcmail.task == 'mail') {
// mail compose
if (rcmail.env.action == 'compose') {
var elem = $('#compose-attachments > div'),
@ -74,10 +74,10 @@ function kolab_directory_selector_dialog()
title: rcmail.gettext('kolab_files.saveall'),
// close: function() { rcmail.dialog_close(); },
buttons: buttons,
minWidth: 300,
minWidth: 400,
minHeight: 300,
height: 250,
width: 250
height: 300,
width: 350
}).show();
file_api.folder_selector();
@ -175,6 +175,18 @@ function kolab_files_ui()
rcmail.http_error(request, status, err);
};
this.file_list = function(params)
{
if (rcmail.task != 'kolab_files')
this.file_selector(params);
};
this.folder_list = function(params)
{
if (rcmail.task != 'kolab_files')
this.folder_selector(params);
};
this.folder_selector = function()
{
this.req = this.set_busy(true, 'loading');
@ -220,9 +232,9 @@ function kolab_files_ui()
first = i;
});
// select first folder
if (first)
this.selector_select(first);
// select first folder?
// if (first)
// this.selector_select(first);
// add tree icons
this.folder_list_tree(this.env.folders);
@ -244,6 +256,9 @@ function kolab_files_ui()
this.file_selector = function(params)
{
if (!this.env.folder)
return;
if (!params)
params = {};
@ -294,4 +309,46 @@ function kolab_files_ui()
// $('tr.selected', table).removeClass('selected');
$(row).addClass('selected');
};
// folder create request
this.folder_create = function(folder)
{
this.req = this.set_busy(true, 'creating');
this.get('folder_create', {folder: folder}, 'folder_create_response');
};
// folder create response handler
this.folder_create_response = function(response)
{
if (!this.response(response))
return;
// refresh folders list
if (rcmail.task == 'kolab_files')
this.folder_list();
else
this.folder_selector();
};
this.search = function()
{
var value = $(rcmail.gui_objects.filesearchbox).val();
if (value) {
this.env.search = {name: value};
this.file_list({search: this.env.search});
}
else
this.search_reset();
};
this.search_reset = function()
{
$(rcmail.gui_objects.filesearchbox).val('');
if (this.env.search) {
this.env.search = null;
this.file_list();
}
};
};

View file

@ -63,6 +63,12 @@ class kolab_files_engine
}
if (!empty($template)) {
// register template objects
$this->rc->output->add_handlers(array(
'folder-create-form' => array($this, 'folder_create_form'),
'file-search-form' => array($this, 'file_search_form'),
));
// add dialog content at the end of page body
$this->rc->output->add_footer(
$this->rc->output->parse('kolab_files.' . $template, false, false));
}
@ -82,6 +88,66 @@ class kolab_files_engine
}
}
/**
* Template object for folder creation form in "Save as" dialog
*/
public function folder_create_form($attrib)
{
$attrib['name'] = 'folder-create-form';
if (empty($attrib['id'])) {
$attrib['id'] = 'folder-create-form';
}
$input_name = new html_inputfield(array('name' => 'folder_name'));
$out = $input_name->show();
// $input_parent = new html_checkbox(array('name' => 'folder_parent', 'checked' => true, 'value' => 1));
// $out .= html::label(null, $input_parent->show() . $this->plugin->gettext('assubfolder'));
// add form tag around text field
if (empty($attrib['form'])) {
$out = $this->rc->output->form_tag($attrib, $out);
}
$this->rc->output->add_gui_object('folder-create-form', $attrib['id']);
return $out;
}
/**
* Template object for file search form in "From cloud" dialog
*/
public function file_search_form($attrib)
{
$attrib['name'] = '_q';
if (empty($attrib['id'])) {
$attrib['id'] = 'filesearchbox';
}
if ($attrib['type'] == 'search' && !$this->rc->output->browser->khtml) {
unset($attrib['type'], $attrib['results']);
}
$input_q = new html_inputfield($attrib);
$out = $input_q->show();
// add some labels to client
$this->rc->output->add_label('searching');
$this->rc->output->add_gui_object('filesearchbox', $attrib['id']);
// add form tag around text field
if (empty($attrib['form'])) {
$out = $this->rc->output->form_tag(array(
'name' => "filesearchform",
'onsubmit' => "file_api.search(); return false",
'style' => "display:inline"),
$out);
}
return $out;
}
/**
* Get API token for current user session, authenticate if needed
*/
@ -263,6 +329,8 @@ class kolab_files_engine
$this->rc->output->show_message($this->plugin->gettext('saveallerror', array('n' => $count)), 'error');
}
// @TODO: update quota indicator, make this optional in case files aren't stored in IMAP
$this->rc->output->send();
}

View file

@ -1,5 +1,6 @@
#files-dialog,
#files-compose-dialog {
#files-compose-dialog,
#files-folder-create {
display: none;
}
@ -16,11 +17,16 @@
#files-compose-dialog #files-folder-selector {
right: auto;
width: 190px;
top: 45px;
}
#files-dialog #files-folder-selector {
bottom: 40px;
}
#files-file-selector {
position: absolute;
top: 5px;
top: 45px;
bottom: 5px;
left: 200px;
right: 0;
@ -29,6 +35,16 @@
overflow: auto;
}
#files-dialog #files-folder-footer {
position: absolute;
height: 30px;
bottom: 0;
}
#files-dialog #files-folder-footer form {
display: inline;
}
#files-folder-selector table {
width: 100%;
border-spacing: 0;
@ -51,6 +67,19 @@
cursor: default;
}
#files-compose-dialog #searchmenulink {
width: 15px;
}
#files-compose-dialog #quicksearchbar {
top: 10px;
right: 5px;
}
#files-compose-dialog #searchreset {
cursor: pointer;
}
#filelist table {
width: 100%;
border-spacing: 0;

View file

@ -1,4 +1,12 @@
<div id="files-compose-dialog" class="uidialog">
<div id="quicksearchbar" class="searchbox">
<roundcube:object name="file-search-form" id="filesearchbox" />
<!--
<roundcube:button name="searchmenulink" id="searchmenulink" class="iconbutton searchoptions" onclick="UI.show_popup('searchmenu');return false" title="searchmod" content=" " />
-->
<a id="searchmenulink" class="iconbutton searchoptions"> </a>
<a id="searchreset" class="iconbutton reset" title="<roundcube:label name="resetsearch"/>" onclick="file_api.search_reset()"> </a>
</div>
<div id="files-folder-selector"></div>
<div id="files-file-selector">
<table id="filelist"><tbody></tbody></table>

View file

@ -1,3 +1,12 @@
<div id="files-dialog" class="uidialog">
<div id="files-folder-selector"></div>
<div id="files-folder-footer">
<input id="folder-create-start-button" onclick="kolab_files_folder_form()" type="button" value="<roundcube:label name="kolab_files.foldercreate" />">
<div id="files-folder-create">
<roundcube:object name="folder-create-form" />
<input id="folder-create-save-button" onclick="kolab_directory_create()" type="button" class="button mainaction" value="<roundcube:label name="create" />">
<input id="folder-create-cancel-button" onclick="kolab_directory_cancel()" type="button" class="button" value="<roundcube:label name="cancel" />">
</div>
</div>
</div>
<script src="plugins/kolab_files/skins/larry/ui.js" type="text/javascript"></script>

View file

@ -0,0 +1,41 @@
function kolab_files_folder_form(link)
{
var form = $('#files-folder-create'),
link = $('#folder-create-start-button');
link.hide();
form.show();
$('input[name="folder_name"]', form).val('').focus();
}
function kolab_directory_create()
{
var folder = '',
form = $('#files-folder-create'),
name = $('input[name="folder_name"]', form).val(),
parent = file_api.env.folder;
// parent = $('input[name="folder_parent"]', form).is(':checked');
if (!name)
return;
if (parent && file_api.env.folder)
folder = file_api.env.folder + file_api.env.directory_separator;
folder += name;
kolab_directory_cancel();
file_api.folder_create(folder);
// todo: select created folder
}
function kolab_directory_cancel()
{
var form = $('#files-folder-create'),
link = $('#folder-create-start-button');
link.show();
form.hide();
}