-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroundcube_structured_email.js
38 lines (31 loc) · 1.65 KB
/
roundcube_structured_email.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* This is an event listener which is triggered as soon as RC is initialized
* (i.e., the 'init' event is fired)
*
* It is responsible for setting up and registering custom event listeners and
* commands, used throughout the plugin
*/
window.rcmail && rcmail.addEventListener('init', function(evt) {
// Add an action button on each message list row insertion event
if (rcmail.gui_objects.messagelist) {
rcmail.addEventListener('insertrow', rcmail.add_action_buttons);
}
// Register an action callback that is called by the backend whenever it returns an AJAX response to us
rcmail.addEventListener('plugin.action_callback', action_callback);
// Register our custom command for sending messages via our structured message form (in compose_form task)
rcmail.register_command('sendstructuredform', send_structured_form, true);
// Register our custom command for inserting structured in a message which is being composed
rcmail.register_command('insert-structured-data', insert_structured_data, true);
if (rcmail.task === 'mail') {
// Render the structured data for a message when displaying it
rcmail.render_structured_data();
}
if (rcmail.task === 'compose_form') {
// Generate the compose form input fields, based on the selected option in the select field
rcmail.generate_compose_form_fields();
}
// If we're sending a message that was previously saved as draft, we need to fix its HTML which was sanitized by RC
rcmail.fix_structured_data_on_draft_send();
});
// A global variable which is meant to hold the username of the current user, logged into RC
var usernameVar = '';