From f007d019831a5b53f49bf63f04eb4efd90dbeea1 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 18 Nov 2011 10:42:53 +0100 Subject: [PATCH] Improve config UI as suggested in #474 and #475 --- plugins/kolab_zpush/kolab_zpush.js | 13 +++++-- plugins/kolab_zpush/kolab_zpush_ui.php | 47 +------------------------- 2 files changed, 12 insertions(+), 48 deletions(-) diff --git a/plugins/kolab_zpush/kolab_zpush.js b/plugins/kolab_zpush/kolab_zpush.js index 76c89f4d..1605fcdb 100644 --- a/plugins/kolab_zpush/kolab_zpush.js +++ b/plugins/kolab_zpush/kolab_zpush.js @@ -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) diff --git a/plugins/kolab_zpush/kolab_zpush_ui.php b/plugins/kolab_zpush/kolab_zpush_ui.php index 1536f0a0..4abf3096 100644 --- a/plugins/kolab_zpush/kolab_zpush_ui.php +++ b/plugins/kolab_zpush/kolab_zpush_ui.php @@ -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); - } - - } - }