diff --git a/actions/emailsettings.php b/actions/emailsettings.php index aae39f6afc..4a7dc1b871 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -79,6 +79,7 @@ class EmailsettingsAction extends AccountSettingsAction function showScripts() { parent::showScripts(); + $this->script('emailsettings.js'); $this->autofocus('email'); } @@ -159,6 +160,16 @@ class EmailsettingsAction extends AccountSettingsAction $this->elementEnd('li'); $this->elementEnd('ul'); + // Our stylesheets make the form_data list items all floats, which + // creates lots of problems with trying to wrap divs around things. + // This should force a break before the next section, which needs + // to be separate so we can disable the things in it when the + // checkbox is off. + $this->elementStart('div', array('style' => 'clear: both')); + $this->elementEnd('div'); + + $this->elementStart('div', array('id' => 'emailincoming')); + if ($user->incomingemail) { $this->elementStart('p'); $this->element('span', 'address', $user->incomingemail); @@ -186,6 +197,9 @@ class EmailsettingsAction extends AccountSettingsAction // TRANS: Button label for adding an e-mail address to send notices from. $this->submit('newincoming', _m('BUTTON','New')); + + $this->elementEnd('div'); // div#emailincoming + $this->elementEnd('fieldset'); } @@ -518,6 +532,7 @@ class EmailsettingsAction extends AccountSettingsAction $orig = clone($user); $user->incomingemail = null; + $user->emailpost = 0; if (!$user->updateKeys($orig)) { common_log_db_error($user, 'UPDATE', __FILE__); @@ -542,6 +557,7 @@ class EmailsettingsAction extends AccountSettingsAction $orig = clone($user); $user->incomingemail = mail_new_incoming_address(); + $user->emailpost = 1; if (!$user->updateKeys($orig)) { common_log_db_error($user, 'UPDATE', __FILE__); diff --git a/js/emailsettings.js b/js/emailsettings.js new file mode 100644 index 0000000000..c7f85fe9ae --- /dev/null +++ b/js/emailsettings.js @@ -0,0 +1,23 @@ +$(function() { + +function toggleIncomingOptions() { + var enabled = $('#emailpost').attr('checked'); + if (enabled) { + // Note: button style currently does not respond to disabled in our main themes. + // Graying out the whole section with a 50% transparency will do for now. :) + // @todo: add a general 'disabled' class style to the base themes. + $('#emailincoming').removeAttr('style') + .find('input').removeAttr('disabled'); + } else { + $('#emailincoming').attr('style', 'opacity: 0.5') + .find('input').attr('disabled', 'disabled'); + } +} + +toggleIncomingOptions(); + +$('#emailpost').click(function() { + toggleIncomingOptions(); +}); + +});