Improve config UI as suggested in #474 and #475

This commit is contained in:
Thomas 2011-11-18 10:42:53 +01:00
parent a2f70e2dc0
commit f007d01983
2 changed files with 12 additions and 48 deletions

View file

@ -39,9 +39,18 @@ function kolab_zpush_config()
rcmail.addEventListener('plugin.zpush_data_ready', device_data_ready);
rcmail.addEventListener('plugin.zpush_save_complete', save_complete);
$('input.subscription').change(function(e){ $('#'+this.id+'_alarm').prop('disabled', !this.checked); });
$('input.alarm').change(function(e){ if (this.checked) $('#'+this.id.replace(/_alarm/, '')).prop('checked', this.checked); });
$('input.subscription').change(function(e){ if (!this.checked) $('#'+this.id+'_alarm').prop('checked', false); });
$(window).bind('resize', resize_ui);
$('.subscriptionblock thead td.subscription img, .subscriptionblock thead td.alarm img').click(function(e){
var $this = $(this);
var classname = $this.parent().get(0).className;
var check = !($this.data('checked') || false);
$this.css('cursor', 'pointer').data('checked', check)
.closest('table').find('input.'+classname).prop('checked', check).change();
});
// select the one and only device from list
if (rcmail.env.devicecount == 1) {
for (var imei in rcmail.env.devices)

View file

@ -125,7 +125,7 @@ class kolab_zpush_ui
$table->add_header('foldername', $this->config->gettext('folder'));
$checkbox_sync = new html_checkbox(array('name' => 'subscribed[]', 'class' => 'subscription'));
$checkbox_alarm = new html_checkbox(array('name' => 'alarm[]', 'class' => 'alarm', 'disabled' => true));
$checkbox_alarm = new html_checkbox(array('name' => 'alarm[]', 'class' => 'alarm'));
$names = array();
foreach ($a_folders as $folder) {
@ -168,49 +168,4 @@ class kolab_zpush_ui
return $table->show();
}
/**
* Recursively compose folders table
*/
private function render_folders($a_folders, $table, $level = 0)
{
$idx = 0;
$checkbox_sync = new html_checkbox(array('name' => 'subscribed[]', 'class' => 'subscription'));
$checkbox_alarm = new html_checkbox(array('name' => 'alarm[]', 'class' => 'alarm', 'disabled' => true));
$folders_meta = $this->config->folders_meta();
foreach ($a_folders as $key => $folder) {
$classes = array('mailbox');
if ($folder_class = rcmail_folder_classname($folder['id'])) {
$foldername = rcube_label($folder_class);
$classes[] = $folder_class;
}
else
$foldername = $folder['name'];
// visualize folder type
if ($type = $folders_meta[$folder['id']]['TYPE'])
$classes[] = $type;
if ($folder['virtual'])
$classes[] = 'virtual';
$folder_id = 'rcmf' . html_identifier($folder['id']);
$padding = str_repeat('    ', $level);
$table->add_row(array('class' => (($level+1) * $idx++) % 2 == 0 ? 'even' : 'odd'));
$table->add(join(' ', $classes), html::label($folder_id, $padding . Q($foldername)));
$table->add('subscription', $folder['virtual'] ? '' : $checkbox_sync->show('', array('value' => $folder['id'], 'id' => $folder_id)));
if (($type == 'event' || $type == 'task') && !$folder['virtual'])
$table->add('alarm', $checkbox_alarm->show('', array('value' => $folder['id'], 'id' => $folder_id.'_alarm')));
else
$table->add('alarm', '');
if (!empty($folder['folders']))
$this->render_folders($folder['folders'], $table, $level+1);
}
}
}