Aleksander Machniak
2013-03-06 bc2c4380b5b754a3b13cc7d6663b2b81d2577e2e
skins/classic/functions.js
@@ -92,6 +92,7 @@
    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 @@
{
  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 @@
  };
},
open_listmenu: function(e)
open_listmenu: function()
{
  this.listmenu();
},
@@ -378,6 +379,35 @@
  });
  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)
@@ -800,8 +830,8 @@
    .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 @@
    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); });