From ecbadcd866aa93e86e4652e8e82e7f49e259403e Mon Sep 17 00:00:00 2001 From: Boris Gulay Date: Thu, 2 Jun 2016 15:24:08 +0300 Subject: [PATCH] Added suggestions for default values in UI (interactive). Fixed bug when Security combobox was not disabled. --- ident_switch.js | 17 +++++++++++++---- ident_switch.php | 12 ++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ident_switch.js b/ident_switch.js index a853b26..d0bcd12 100644 --- a/ident_switch.js +++ b/ident_switch.js @@ -14,14 +14,23 @@ $(function() { } } - var $enFld = $("INPUT[name='_ident_switch.form.enabled']"); - if ($enFld.size() == 1) - $enFld.change(); + $("INPUT[name='_ident_switch.form.enabled']").change(); + $("SELECT[name='_ident_switch.form.secure']").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")); + $("INPUT[name!='_ident_switch.form.enabled'], SELECT", $enFld.parents("FIELDSET")).prop("disabled", !$enFld.is(":checked")); +} + +function plugin_switchIdent_secure_onChange(e) { + var $secSel = $("SELECT[name='_ident_switch.form.secure']"); + var $portFld = $("INPUT[name='_ident_switch.form.port']"); + + if ('SSL' === $secSel.val().toUpperCase()) + $portFld.attr("placeholder", 993); + else + $portFld.attr("placeholder", 143); } function plugin_switchIdent_switch(val) { diff --git a/ident_switch.php b/ident_switch.php index ff421ed..d130c2f 100644 --- a/ident_switch.php +++ b/ident_switch.php @@ -159,13 +159,17 @@ class ident_switch extends rcube_plugin 'name' => $this->gettext('form.caption'), 'content' => array( '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' => 'select', 'options' => array('ssl' => 'SSL', 'tls' => 'TLS')), + 'ident_switch.form.label' => array('type' => 'text', 'size' => 32, 'placeholder' => $args['record']['email']), + 'ident_switch.form.host' => array('type' => 'text', 'size' => 64, 'placeholder' => 'localhost'), + 'ident_switch.form.secure' => array( + 'type' => 'select', + 'options' => array('ssl' => 'SSL', 'tls' => 'TLS'), + 'onchange' => 'plugin_switchIdent_secure_onChange();' + ), 'ident_switch.form.port' => array('type' => 'text', 'size' => 5), 'ident_switch.form.username' => array('type' => 'text', 'size' => 64), 'ident_switch.form.password' => array('type' => 'password', 'size' => 64), - 'ident_switch.form.delimiter' => array('type' => 'text', 'size' => 1), + 'ident_switch.form.delimiter' => array('type' => 'text', 'size' => 1, 'placeholder' => '.'), ), );