Skip to content

Commit

Permalink
De-inline new_user_dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
pabzm committed Jun 21, 2024
1 parent 7f5291c commit 61f1775
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
29 changes: 29 additions & 0 deletions plugins/new_user_dialog/new_user_dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
rcmail.addEventListener('plugin.new_user_dialog_open', function (title) {
var newuserdialog = rcmail.show_popup_dialog($('#newuserdialog'), title, [{
text: rcmail.get_label('save'),
'class': 'mainaction save',
click: function() {
var request = {};
$.each($('form', this).serializeArray(), function() {
request[this.name] = this.value;
});

rcmail.http_post('plugin.newusersave', request, true);
return false;
}
}],
{
resizable: false,
closeOnEscape: false,
width: 500,
open: function() { $('#newuserdialog').show(); $('#newuserdialog-name').focus(); },
beforeClose: function() {
return false;
}
}
);

rcmail.addEventListener('plugin.new_user_dialog_close', function (title) {
newuserdialog.dialog('destroy');
})
});
32 changes: 3 additions & 29 deletions plugins/new_user_dialog/new_user_dialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,34 +104,8 @@ public function render_page($p)
));

$title = rcube::JQ($this->gettext('identitydialogtitle'));
$script = "
var newuserdialog = rcmail.show_popup_dialog($('#newuserdialog'), '{$title}', [{
text: rcmail.get_label('save'),
'class': 'mainaction save',
click: function() {
var request = {};
$.each($('form', this).serializeArray(), function() {
request[this.name] = this.value;
});
rcmail.http_post('plugin.newusersave', request, true);
return false;
}
}],
{
resizable: false,
closeOnEscape: false,
width: 500,
open: function() { $('#newuserdialog').show(); $('#newuserdialog-name').focus(); },
beforeClose: function() {
return false;
}
}
);
rcube_webmail.prototype.new_user_dialog_close = function() { newuserdialog.dialog('destroy'); };
";
// disable keyboard events for messages list (#1486726)
$rcmail->output->add_script($script, 'docready');
$rcmail->output->command('plugin.new_user_dialog_open', $title);
$this->include_script('new_user_dialog.js');
}
}

Expand Down Expand Up @@ -187,7 +161,7 @@ public function save_data()
// save prefs to not show dialog again
$rcmail->user->save_prefs(['newuserdialog' => null]);
// hide dialog
$rcmail->output->command('new_user_dialog_close');
$rcmail->output->command('plugin.new_user_dialog_close');
$rcmail->output->show_message('successfullysaved', 'confirmation');
} else {
// show error
Expand Down

0 comments on commit 61f1775

Please sign in to comment.