summaryrefslogtreecommitdiff
path: root/skins/classic/functions.js
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-03-06 11:11:37 +0100
committerAleksander Machniak <alec@alec.pl>2013-03-06 11:11:37 +0100
commitbc2c4380b5b754a3b13cc7d6663b2b81d2577e2e (patch)
tree7a3c360113d21a5f7c6d0e90b252ce5965dd3589 /skins/classic/functions.js
parentac37746c2ae187edaf38c7a660213e216f90b035 (diff)
Add attachment menu with Open and Download options (#1488975)
Diffstat (limited to 'skins/classic/functions.js')
-rw-r--r--skins/classic/functions.js53
1 files changed, 44 insertions, 9 deletions
diff --git a/skins/classic/functions.js b/skins/classic/functions.js
index c59ea9bf8..499783b3f 100644
--- a/skins/classic/functions.js
+++ b/skins/classic/functions.js
@@ -92,6 +92,7 @@ function rcube_mail_ui()
forwardmenu: {id:'forwardmenu', editable:1},
searchmenu: {id:'searchmenu', editable:1},
messagemenu: {id:'messagemenu'},
+ attachmentmenu: {id:'attachmentmenu'},
listmenu: {id:'listmenu', editable:1},
dragmessagemenu:{id:'dragmessagemenu', sticky:1},
groupmenu: {id:'groupoptionsmenu', above:1},
@@ -133,24 +134,24 @@ show_popupmenu: function(popup, show)
{
var obj = this.popups[popup].obj,
above = this.popups[popup].above,
- ref = rcube_find_object(popup+'link');
+ ref = $(this.popups[popup].link ? this.popups[popup].link : rcube_find_object(popup+'link'));
if (typeof show == 'undefined')
show = obj.is(':visible') ? false : true;
else if (this.popups[popup].toggle && show && this.popups[popup].obj.is(':visible') )
show = false;
- if (show && ref) {
- var parent = $(ref).parent(),
+ if (show && ref.length) {
+ var parent = ref.parent(),
win = $(window),
- pos = parent.hasClass('dropbutton') ? parent.offset() : $(ref).offset();
+ pos = parent.hasClass('dropbutton') ? parent.offset() : ref.offset();
- if (!above && pos.top + ref.offsetHeight + obj.height() > win.height())
+ if (!above && pos.top + ref.height() + obj.height() > win.height())
above = true;
if (pos.left + obj.width() > win.width())
pos.left = win.width() - obj.width() - 30;
- obj.css({ left:pos.left, top:(pos.top + (above ? -obj.height() : ref.offsetHeight)) });
+ obj.css({ left:pos.left, top:(pos.top + (above ? -obj.height() : ref.height())) });
}
obj[show?'show':'hide']();
@@ -325,7 +326,7 @@ listmenu: function(show)
};
},
-open_listmenu: function(e)
+open_listmenu: function()
{
this.listmenu();
},
@@ -380,6 +381,35 @@ spellmenu: function(show)
this.show_popupmenu('spellmenu', show);
},
+show_attachmentmenu: function(elem)
+{
+ var id = elem.parentNode.id.replace(/^attach/, '');
+
+ $('#attachmenuopen').unbind('click').attr('onclick', '').click(function(e) {
+ return rcmail.command('open-attachment', id, this);
+ });
+
+ $('#attachmenudownload').unbind('click').attr('onclick', '').click(function() {
+ rcmail.command('download-attachment', id, this);
+ });
+
+ this.popups.attachmentmenu.link = elem;
+ rcmail.command('menu-open', {menu: 'attachmentmenu', id: id});
+},
+
+menu_open: function(p)
+{
+ if (p && p.props && p.props.menu == 'attachmentmenu')
+ this.show_popup('attachmentmenu');
+ else
+ this.open_listmenu();
+},
+
+menu_save: function(prop)
+{
+ this.save_listmenu();
+},
+
body_mouseup: function(evt, p)
{
var i, target = rcube_event.get_target(evt);
@@ -800,8 +830,8 @@ function rcube_init_mail_ui()
.contents().mouseup(function(e){rcmail_ui.body_mouseup(e)});
if (rcmail.env.task == 'mail') {
- rcmail.addEventListener('menu-open', 'open_listmenu', rcmail_ui);
- rcmail.addEventListener('menu-save', 'save_listmenu', rcmail_ui);
+ rcmail.addEventListener('menu-open', 'menu_open', rcmail_ui);
+ rcmail.addEventListener('menu-save', 'menu_save', rcmail_ui);
rcmail.addEventListener('aftersend-attachment', 'uploadmenu', rcmail_ui);
rcmail.addEventListener('aftertoggle-editor', 'resize_compose_body_ev', rcmail_ui);
rcmail.gui_object('message_dragmenu', 'dragmessagemenu');
@@ -817,6 +847,11 @@ function rcube_init_mail_ui()
if (rcmail.env.action == 'compose')
rcmail_ui.init_compose_form();
+ else if (rcmail.env.action == 'show' || rcmail.env.action == 'preview')
+ // add menu link for each attachment
+ $('#attachment-list > li[id^="attach"]').each(function() {
+ $(this).append($('<a class="drop">').click(function() { rcmail_ui.show_attachmentmenu(this); }));
+ });
}
else if (rcmail.env.task == 'addressbook') {
rcmail.addEventListener('afterupload-photo', function(){ rcmail_ui.show_popup('uploadform', false); });