Add mail actions to contextmenu if loaded

This commit is contained in:
Thomas Bruederli 2013-10-30 16:05:07 +01:00
parent c46493856d
commit fa480dfa2c
4 changed files with 30 additions and 13 deletions

View file

@ -163,6 +163,8 @@ class calendar extends rcube_plugin
'innerclass' => 'icon calendar',
))),
'messagemenu');
$this->api->output->add_label('calendar.createfrommail');
}
}

View file

@ -6,7 +6,7 @@
* @author Thomas Bruederli <bruederli@kolabsys.com>
*
* Copyright (C) 2010, Lazlo Westerhof <hello@lazlo.me>
* Copyright (C) 2012, Kolab Systems AG <contact@kolabsys.com>
* Copyright (C) 2013, Kolab Systems AG <contact@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@ -36,10 +36,9 @@ function rcube_calendar(settings)
var me = this;
// create new event from current mail message
this.create_from_mail = function()
this.create_from_mail = function(uid)
{
var uid;
if ((uid = rcmail.get_single_uid())) {
if (uid || (uid = rcmail.get_single_uid())) {
// load calendar UI (scripts and edit dialog template)
if (!this.ui_loaded) {
$.when(
@ -53,7 +52,7 @@ function rcube_calendar(settings)
me.ui_loaded = true;
me.ui = new rcube_calendar_ui(me.settings);
me.create_from_mail(); // start over
me.create_from_mail(uid); // start over
});
return;
}
@ -156,9 +155,6 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
// register create-from-mail command to message_commands array
if (rcmail.env.task == 'mail') {
// place link above 'view source'
$('#messagemenu a.calendarlink').parent().insertBefore($('#messagemenu a.sourcelink').parent());
rcmail.register_command('calendar-create-from-mail', function() { cal.create_from_mail() });
rcmail.addEventListener('plugin.mail2event_dialog', function(p){ cal.mail2event_dialog(p) });
rcmail.addEventListener('plugin.unlock_saving', function(p){ cal.ui && cal.ui.unlock_saving(); });
@ -169,6 +165,15 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
}
else
rcmail.enable_command('calendar-create-from-mail', true);
// add contextmenu item
if (window.rcm_contextmenu_register_command) {
rcm_contextmenu_register_command(
'calendar-create-from-mail',
function(cmd,el){ cal.create_from_mail() },
'calendar.createfrommail',
'moveto');
}
}
}

View file

@ -113,6 +113,8 @@ class tasklist extends rcube_plugin
'innerclass' => 'icon taskadd',
))),
'messagemenu');
$this->api->output->add_label('tasklist.createfrommail');
}
}

View file

@ -4,7 +4,7 @@
* @version @package_version@
* @author Thomas Bruederli <bruederli@kolabsys.com>
*
* Copyright (C) 2012, Kolab Systems AG <contact@kolabsys.com>
* Copyright (C) 2013, Kolab Systems AG <contact@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@ -37,10 +37,9 @@ function rcube_tasklist(settings)
/**
* Open a new task dialog prefilled with contents from the currently selected mail message
*/
function create_from_mail()
function create_from_mail(uid)
{
var uid;
if ((uid = rcmail.get_single_uid())) {
if (uid || (uid = rcmail.get_single_uid())) {
// load calendar UI (scripts and edit dialog template)
if (!ui_loaded) {
$.when(
@ -53,7 +52,7 @@ function rcube_tasklist(settings)
ui_loaded = true;
me.ui = new rcube_tasklist_ui(settings);
create_from_mail(); // start over
create_from_mail(uid); // start over
});
return;
}
@ -90,5 +89,14 @@ window.rcmail && rcmail.env.task == 'mail' && rcmail.addEventListener('init', fu
rcmail.env.message_commands.push('tasklist-create-from-mail');
else
rcmail.enable_command('tasklist-create-from-mail', true);
// add contextmenu item
if (window.rcm_contextmenu_register_command) {
rcm_contextmenu_register_command(
'tasklist-create-from-mail',
function(cmd,el){ tasks.create_from_mail() },
'tasklist.createfrommail',
'moveto');
}
});