thomascube
2012-01-15 e493c842a5d5915e95a22df9bc824ef786915cca
skins/larry/ui.js
@@ -58,10 +58,12 @@
   */
  function init()
  {
    rcmail.addEventListener('message', message_displayed);
    if (rcmail.env.task == 'mail') {
      rcmail.addEventListener('menu-open', show_listoptions);
      rcmail.addEventListener('menu-save', save_listoptions);
      rcmail.addEventListener('aftertoggle-editor', function(){ window.setTimeout(function(){ layout_composeview() }, 100); });
      rcmail.addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list') });
      var dragmenu = $('#dragmessagemenu');
      if (dragmenu.length) {
@@ -76,9 +78,13 @@
      if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') {
        layout_messageview();
        $("#all-headers").resizable({ handles: 's', minHeight: 50 });
        $('#previewheaderstoggle').click(function(e){ toggle_preview_headers(this); return false });
      }
      else if (rcmail.env.action == 'compose') {
        rcmail.addEventListener('aftertoggle-editor', function(){ window.setTimeout(function(){ layout_composeview() }, 100); });
        rcmail.addEventListener('aftersend-attachment', show_uploadform);
        rcmail.addEventListener('add-recipient', function(p){ show_header_row(p.field, true); });
        layout_composeview();
        $('#composeoptionstoggle').parent().click(function(){
@@ -89,7 +95,7 @@
        }).css('cursor', 'pointer');
        new rcube_splitter({ id:'composesplitterv', p1:'#composeview-left', p2:'#composeview-right',
          orientation:'v', relative:true, start:248, min:150, size:12 }).init();
          orientation:'v', relative:true, start:248, min:170, size:12 }).init();
      }
      else if (rcmail.env.action == 'list' || !rcmail.env.action) {
          mailviewsplit = new rcube_splitter({ id:'mailviewsplitter', p1:'#mailview-top', p2:'#mailview-bottom',
@@ -119,7 +125,7 @@
        new rcube_splitter({ id:'folderviewsplitter', p1:'#folderslist', p2:'#folder-details',
          orientation:'v', relative:true, start:305, min:150, size:12 }).init();
      }
      else if (rcmail.env.action.indexOf('identit') >= 0) {
      else if (rcmail.env.action == 'identities') {
        new rcube_splitter({ id:'identviewsplitter', p1:'#identitieslist', p2:'#identity-details',
          orientation:'v', relative:true, start:305, min:150, size:12 }).init();
      }
@@ -135,7 +141,7 @@
      }
    }
    else if (rcmail.env.task == 'login') {
      if (bw.ie && bw.ver < 9) {
      if (bw.ie && bw.vendver < 9) {
        var popup = $('<div>')
          .addClass('readtext')
          .html("Roundcube will not work well with the crappy browser ya' using. Get yourself a new internet browsing software and don't come back without!<p>Sincerly,<br/>the Roundcube Dev Team</p>")
@@ -179,8 +185,13 @@
        }
      }
    });
    $(window).resize(resize);
    $(window).resize(function(e) {
      // check target due to bugs in jquery
      // http://bugs.jqueryui.com/ticket/7514
      // http://bugs.jquery.com/ticket/9841
      if (e.target == window) resize();
    });
  }
  /**
@@ -195,6 +206,39 @@
      layout_composeview();
    }
  }
  /**
   * Triggered when a new user message is displayed
   */
  function message_displayed(p)
  {
    // show a popup dialog on errors
    if (p.type == 'error') {
      if (!me.messagedialog) {
        me.messagedialog = $('<div>').addClass('popupdialog');
      }
      var pos = $(p.object).offset();
      me.messagedialog.dialog('close');
      me.messagedialog.html(p.message)
        .dialog({
          resizable: false,
          closeOnEscape: true,
          dialogClass: 'popupmessage ' + p.type,
          title: null,
          close: function() {
            me.messagedialog.dialog('destroy').hide();
          },
          position: ['center', pos.top - 160],
          hide: { effect:'drop', direction:'down' },
          width: 420,
          minHeight: 90
        }).show();
      window.setTimeout(function(){ me.messagedialog.dialog('close'); }, Math.max(2000, p.timeout / 2));
    }
  }
  /**
   * Adjust UI objects of the mail view screen
@@ -213,6 +257,7 @@
  function render_mailboxlist(splitter)
  {
    // TODO: implement smart shortening of long folder names
  }
@@ -378,6 +423,26 @@
      rcmail.message_list.scrollto(uid);
    rcmail.command('save-pref', { name:'preview_pane', value:(visible?1:0) });
  }
  /**
   * Switch between short and full headers display in message preview
   */
  function toggle_preview_headers(button)
  {
    $('#preview-shortheaders').toggle();
    var full = $('#preview-allheaders').toggle();
    // add toggle button to full headers table
    if (!full.data('mod')) {
      $('<a>').attr('href', '#hide')
        .addClass('iconlink remove')
        .html('Hide')
        .appendTo($('<td>').appendTo($('tr:first', full)))
        .click(function(){ toggle_preview_headers(this);return false });
      full.data('mod', true);
    }
  }
@@ -594,11 +659,16 @@
  /**
   *
   */
  function show_header_row(which)
  function show_header_row(which, updated)
  {
    if (compose_headers[which])
    var row = $('#compose-' + which);
    if (row.is(':visible'))
      return;  // nothing to be done here
    if (compose_headers[which] && !updated)
      $('#_' + which).val(compose_headers[which]);
    $('#compose-' + which).show();
    row.show();
    $('#' + which + '-link').hide();
    layout_composeview();
    return false;
@@ -802,6 +872,14 @@
    this.p2.resize();
    this.p1.resize();
    // also resize iframe covers
    if (this.drag_active) {
      $('iframe').each(function(i, elem) {
        var pos = $(this).offset();
        $('#iframe-splitter-fix-'+i).css({ top: pos.top+'px', left: pos.left+'px', width:elem.offsetWidth+'px', height: elem.offsetHeight+'px' });
      });
    }
    if (typeof this.render == 'function')
      this.render(this);
  };
@@ -823,10 +901,12 @@
    $(document).bind('mousemove.'+this.id, onDrag).bind('mouseup.'+this.id, onDragStop);
    // enable dragging above iframes
    $('iframe').each(function() {
      $('<div class="iframe-splitter-fix"></div>')
    $('iframe').each(function(i, elem) {
      $('<div>')
        .attr('id', 'iframe-splitter-fix-'+i)
        .addClass('iframe-splitter-fix')
        .css({ background: '#fff',
          width: this.offsetWidth+'px', height: this.offsetHeight+'px',
          width: elem.offsetWidth+'px', height: elem.offsetHeight+'px',
          position: 'absolute', opacity: '0.001', zIndex: 1000
        })
        .css($(this).offset())
@@ -882,7 +962,7 @@
    me.drag_active = false;
    // remove temp divs
    $('div.iframe-splitter-fix').each(function(){ this.parentNode.removeChild(this); });
    $('div.iframe-splitter-fix').remove();
    me.set_cookie();