diff --git a/ident_switch.js b/ident_switch.js index 553969f..0c04bc3 100644 --- a/ident_switch.js +++ b/ident_switch.js @@ -1,14 +1,24 @@ /* * This is part of identity_imap plugin */ + $(function() { if ($('#plugin-ident_switch-account').size() > 0) { $('#plugin-ident_switch-account').prependTo('.topright'); $('.topright .username').hide(); $('#plugin-ident_switch-account').show(); } + + var $enFld = $("INPUT[name='_ident_switch.form.enabled']"); + if ($enFld.size() == 1) + $enFld.change(); }); +function plugin_switchIdent_enabled_onChange(e) { + var $enFld = $("INPUT[name='_ident_switch.form.enabled']"); + $("INPUT[name!='_ident_switch.form.enabled']", $enFld.parents("FIELDSET")).prop("disabled", !$enFld.is(":checked")); +} + function plugin_switchIdent_switch(val) { console.log("qwe1"); rcmail.http_post('plugin.ident_switch.switch', { '_ident-id': val }); diff --git a/ident_switch.php b/ident_switch.php index d7391b5..83d22e1 100644 --- a/ident_switch.php +++ b/ident_switch.php @@ -131,7 +131,7 @@ class ident_switch extends rcube_plugin $args['form']['ident_switch'] = array( 'name' => $this->gettext('form.caption'), 'content' => array( - 'ident_switch.form.enabled' => array('type' => 'checkbox'), + 'ident_switch.form.enabled' => array('type' => 'checkbox', 'onchange' => 'plugin_switchIdent_enabled_onChange();'), 'ident_switch.form.label' => array('type' => 'text', 'size' => 32), 'ident_switch.form.host' => array('type' => 'text', 'size' => 64), 'ident_switch.form.secure' => array('type' => 'checkbox'),