thomascube
2006-12-01 b19097058c02f203321599bf04a5d7da7c2dafe8
program/js/app.js
@@ -32,7 +32,7 @@
  this.ref = 'rcube_webmail_client';
 
  // webmail client settings
  this.dblclick_time = 600;
  this.dblclick_time = 500;
  this.message_time = 5000;
  
  this.mbox_expression = new RegExp('[^0-9a-z\-_]', 'gi');
@@ -137,16 +137,29 @@
        // enable mail commands
        this.enable_command('list', 'checkmail', 'compose', 'add-contact', 'search', 'reset-search', true);
        
        if (this.env.action=='show')
        if (this.env.action=='show' || this.env.action=='preview')
          {
          this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'viewsource', 'print', 'load-attachment', true);
          if (this.env.next_uid)
            {
            this.enable_command('nextmessage', true);
            this.enable_command('lastmessage', true);
            }
          if (this.env.prev_uid)
            {
            this.enable_command('previousmessage', true);
            this.enable_command('firstmessage', true);
            }
          }
        // make preview/message frame visible
        if (this.env.action == 'preview' && this.env.framed && parent.rcmail)
          {
          this.enable_command('compose', 'add-contact', false);
          parent.rcmail.show_messageframe(true);
          }
        if (this.env.action=='show' && this.env.blockedobjects)
        if ((this.env.action=='show' || this.env.action=='preview') && this.env.blockedobjects)
          {
          if (this.gui_objects.remoteobjectsmsg)
            this.gui_objects.remoteobjectsmsg.style.display = 'block';
@@ -478,8 +491,16 @@
        this.list_page('next');
        break;
      case 'lastpage':
        this.list_page('last');
        break;
      case 'previouspage':
        this.list_page('prev');
        break;
      case 'firstpage':
        this.list_page('first');
        break;
      case 'expunge':
@@ -623,7 +644,7 @@
        
      case 'load-images':
        if (this.env.uid)
          this.show_message(this.env.uid, true);
          this.show_message(this.env.uid, true, this.env.action=='preview');
        break;
      case 'load-attachment':
@@ -632,7 +653,7 @@
        // open attachment in frame if it's of a supported mimetype
        if (this.env.uid && props.mimetype && find_in_array(props.mimetype, this.mimetypes)>=0)
          {
          this.attachment_win = window.open(this.env.comm_path+'&_action=get'+url+'&_frame=1', 'rcubemailattachment');
          this.attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', 'rcubemailattachment');
          if (this.attachment_win)
            {
            setTimeout(this.ref+'.attachment_win.focus()', 10);
@@ -653,12 +674,22 @@
      case 'nextmessage':
        if (this.env.next_uid)
          this.show_message(this.env.next_uid);
          this.show_message(this.env.next_uid, false, this.env.action=='preview');
        break;
     case 'lastmessage':
        if (this.env.last_uid)
          this.show_message(this.env.last_uid);
        break;
      case 'previousmessage':
        if (this.env.prev_uid)
          this.show_message(this.env.prev_uid);
          this.show_message(this.env.prev_uid, false, this.env.action=='preview');
        break;
      case 'firstmessage':
        if (this.env.first_uid)
          this.show_message(this.env.first_uid);
        break;
      
      case 'checkmail':
@@ -709,7 +740,6 @@
            url += '&_to='+a_cids.join(',');
          else
            break;
          }
        else if (props)
           url += '&_to='+urlencode(props);
@@ -717,8 +747,6 @@
        // don't know if this is necessary...
        url = url.replace(/&_framed=1/, "");
        this.set_busy(true);
        alert(url)
        // need parent in case we are coming from the contact frame
        if (this.env.framed)
@@ -1031,6 +1059,9 @@
  this.msglist_select = function(list)
    {
    if (this.preview_timer)
      clearTimeout(this.preview_timer);
    var selected = list.selection.length==1;
    if (this.env.mailbox == this.env.drafts_mailbox)
      {
@@ -1041,17 +1072,26 @@
      {
      this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', selected);
      this.enable_command('delete', 'moveto', list.selection.length>0 ? true : false);
      // start timer for message preview (wait for double click)
      if (selected && this.env.contentframe)
        this.preview_timer = setTimeout(this.ref+'.msglist_get_preview()', this.dblclick_time + 10);
      else if (this.env.contentframe)
        this.show_messageframe(false);
      }
   };
    };
  this.msglist_dbl_click = function(list)
    {
      if (this.preview_timer)
        clearTimeout(this.preview_timer);
    var uid = list.get_single_selection();
    if (uid && this.env.mailbox == this.env.drafts_mailbox)
      this.goto_url('compose', '_draft_uid='+uid+'&_mbox='+urlencode(this.env.mailbox), true);
    else if (uid)
      this.show_message(uid);
      this.show_message(uid, false, false);
    };
@@ -1064,6 +1104,15 @@
    };
  this.msglist_get_preview = function()
  {
    var uid = this.get_single_uid();
    if (uid && this.env.contentframe)
      this.show_message(uid, false, true);
    else if (this.env.contentframe)
      this.show_messageframe(false);
  };
  /*********************************************************/
  /*********     (message) list functionality      *********/
@@ -1071,11 +1120,12 @@
  // when user doble-clicks on a row
  this.show_message = function(id, safe)
  this.show_message = function(id, safe, preview)
    {
    var add_url = '';
    var action = preview ? 'preview': 'show';
    var target = window;
    if (this.env.contentframe && window.frames && window.frames[this.env.contentframe])
    if (preview && this.env.contentframe && window.frames && window.frames[this.env.contentframe])
      {
      target = window.frames[this.env.contentframe];
      add_url = '&_framed=1';
@@ -1086,11 +1136,31 @@
    if (id)
      {
      this.set_busy(true, 'loading');
      target.location.href = this.env.comm_path+'&_action=show&_uid='+id+'&_mbox='+urlencode(this.env.mailbox)+add_url;
      var url = '&_action='+action+'&_uid='+id+'&_mbox='+urlencode(this.env.mailbox)+add_url;
      if (action == 'preview' && String(target.location.href).indexOf(url) >= 0)
        this.show_messageframe(true);
      else
        {
        this.set_busy(true, 'loading');
        target.location.href = this.env.comm_path+url;
        }
      }
    };
  this.show_messageframe = function(show)
    {
    var frm;
    if (this.env.contentframe && (frm = rcube_find_object(this.env.contentframe)))
      {
      if (window.frames[this.env.contentframe] && !show)
        window.frames[this.env.contentframe].location.href = 'program/blank.gif';
      frm.style.display = show ? 'block' : 'none';
      }
    if (!show && this.busy)
      this.set_busy(false);
    };
  // list a specific page
@@ -1098,8 +1168,12 @@
    {
    if (page=='next')
      page = this.env.current_page+1;
    if (page=='last')
      page = this.env.pagecount;
    if (page=='prev' && this.env.current_page>1)
      page = this.env.current_page-1;
    if (page=='first' && this.env.current_page>1)
      page = 1;
      
    if (page > 0 && page <= this.env.pagecount)
      {
@@ -1235,17 +1309,20 @@
  // move selected messages to the specified mailbox
  this.move_messages = function(mbox)
    {
    // exit if no mailbox specified or if selection is empty
    var selection = this.message_list.get_selection();
    if (!mbox || !(selection.length || this.env.uid) || mbox==this.env.mailbox)
      return;
    // exit if current or no mailbox specified or if selection is empty
    if (!mbox || !this.env.uid || mbox==this.env.mailbox)
      {
      if (!this.message_list || !this.message_list.get_selection().length)
        return;
      }
    var a_uids = new Array();
    if (this.env.uid)
      a_uids[a_uids.length] = this.env.uid;
    else
      {
      var selection = this.message_list.get_selection();
      var id;
      for (var n=0; n<selection.length; n++)
        {
@@ -1273,16 +1350,19 @@
  this.permanently_remove_messages = function()
    {
    // exit if no mailbox specified or if selection is empty
    var selection = this.message_list.get_selection();
    if (!(selection.length || this.env.uid))
      return;
    if (!this.env.uid)
      {
      if (!this.message_list || !this.message_list.get_selection().length)
        return;
      }
    var a_uids = new Array();
    if (this.env.uid)
      a_uids[a_uids.length] = this.env.uid;
    else
      {
      var selection = this.message_list.get_selection();
      var id;
      for (var n=0; n<selection.length; n++)
        {
@@ -1303,13 +1383,22 @@
  this.delete_messages = function()
    {
    // exit if no mailbox specified or if selection is empty
    var selection = this.message_list.get_selection();
    if (!(selection.length || this.env.uid))
      return;
    if (!this.env.uid)
      {
      if (!this.message_list || !this.message_list.get_selection().length)
        return;
      }
    // if there is a trash mailbox defined and we're not currently in it:
    if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase()!=String(this.env.trash_mailbox).toLowerCase())
      this.move_messages(this.env.trash_mailbox);
      // if shift was pressed delete it immediately
      if (this.message_list && this.message_list.shiftkey)
        {
        if (confirm(this.get_label('deletemessagesconfirm')))
          this.permanently_remove_messages();
        }
      else
        this.move_messages(this.env.trash_mailbox);
    // if there is a trash mailbox defined but we *are* in it:
    else if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase() == String(this.env.trash_mailbox).toLowerCase())
      this.permanently_remove_messages();
@@ -1333,7 +1422,7 @@
  this.mark_message = function(flag, uid)
    {
    var a_uids = new Array();
    var selection = this.message_list.get_selection();
    var selection = this.message_list ? this.message_list.get_selection() : new Array();
    
    if (uid)
      a_uids[0] = uid;
@@ -2629,7 +2718,9 @@
  this.set_page_buttons = function()
    {
    this.enable_command('nextpage', (this.env.pagecount > this.env.current_page));
    this.enable_command('lastpage', (this.env.pagecount > this.env.current_page));
    this.enable_command('previouspage', (this.env.current_page > 1));
    this.enable_command('firstpage', (this.env.current_page > 1));
    }
@@ -3060,7 +3151,7 @@
  this.http_request = function(action, querystring, lock)
    {
    var request_obj = this.get_request_obj();
    querystring += '&_remote=1';
    querystring += (querystring ? '&' : '') + '_remote=1';
    
    // add timestamp to request url to avoid cacheing problems in Safari
    if (bw.safari)
@@ -3109,11 +3200,13 @@
      case 'moveto':
        if (this.env.action=='show')
          this.command('list');
        else if (this.message_list)
          this.message_list.init();
        break;
      case 'list':
        if (this.env.messagecount)
          this.enable_command('purge', (this.env.mailbox==this.env.trash_mailbox));
          this.enable_command('purge', (this.env.mailbox==this.env.trash_mailbox || this.env.mailbox==this.env.junk_mailbox));
      case 'expunge':
        this.enable_command('select-all', 'select-none', 'expunge', this.env.messagecount ? true : false);