svncommit
2008-04-15 dbbd1f495eb4a7eff44918330043ac355e50c8ac
program/js/app.js
@@ -355,7 +355,7 @@
  // start interval for keep-alive/recent_check signal
  this.start_keepalive = function()
    {
    if (this.env.keep_alive && !this.env.framed && this.task=='mail' && this.gui_objects.messagelist)
    if (this.env.keep_alive && !this.env.framed && this.task=='mail' && this.gui_objects.mailboxlist)
      this._int = setInterval(function(){ ref.check_for_recent(); }, this.env.keep_alive * 1000);
    else if (this.env.keep_alive && !this.env.framed && this.task!='login')
      this._int = setInterval(function(){ ref.send_keep_alive(); }, this.env.keep_alive * 1000);    
@@ -405,7 +405,7 @@
      this.init_address_input_events(input_cc);
    if (input_bcc)
      this.init_address_input_events(input_bcc);
    // add signature according to selected identity
    if (input_from && input_from.type=='select-one')
      this.change_identity(input_from);
@@ -721,7 +721,7 @@
          this.attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', 'rcubemailattachment');
          if (this.attachment_win)
            {
            setTimeout(function(){ ref.attachment_win.focus(); }, 10);
            window.setTimeout(function(){ ref.attachment_win.focus(); }, 10);
            break;
            }
          }
@@ -889,7 +889,7 @@
          ref.printwin = window.open(this.env.comm_path+'&_action=print&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(this.env.safemode ? '&_safe=1' : ''));
          if (this.printwin)
          {
            setTimeout(function(){ ref.printwin.focus(); }, 20);
            window.setTimeout(function(){ ref.printwin.focus(); }, 20);
            if (this.env.action != 'show')
              this.mark_message('read', uid);
          }
@@ -902,7 +902,7 @@
          {
          ref.sourcewin = window.open(this.env.comm_path+'&_action=viewsource&_uid='+this.env.uid+'&_mbox='+urlencode(this.env.mailbox));
          if (this.sourcewin)
            setTimeout(function(){ ref.sourcewin.focus(); }, 20);
            window.setTimeout(function(){ ref.sourcewin.focus(); }, 20);
          }
        break;
@@ -1019,7 +1019,7 @@
    // set timer for requests
    if (a && this.env.request_timeout)
      this.request_timer = setTimeout(function(){ ref.request_timed_out(); }, this.env.request_timeout * 1000);
      this.request_timer = window.setTimeout(function(){ ref.request_timed_out(); }, this.env.request_timeout * 1000);
    };
@@ -1138,7 +1138,7 @@
    // start timer for message preview (wait for double click)
    if (selected && this.env.contentframe && !list.multi_selecting)
      this.preview_timer = setTimeout(function(){ ref.msglist_get_preview(); }, this.dblclick_time + 10);
      this.preview_timer = window.setTimeout(function(){ ref.msglist_get_preview(); }, this.dblclick_time + 10);
    else if (this.env.contentframe)
      this.show_contentframe(false);
    };
@@ -1407,7 +1407,7 @@
  this.delete_messages = function()
    {
    var selection = this.message_list ? this.message_list.get_selection() : new Array();
    // exit if no mailbox specified or if selection is empty
    if (!this.env.uid && !selection.length)
        return;
@@ -1458,8 +1458,9 @@
  this._with_selected_messages = function(action, lock, add_url)
    {
    var a_uids = new Array();
    if (this.env.uid)
      a_uids[a_uids.length] = this.env.uid;
      a_uids[0] = this.env.uid;
    else
      {
      var selection = this.message_list.get_selection();
@@ -1468,10 +1469,11 @@
        {
        id = selection[n];
        a_uids[a_uids.length] = id;
        this.message_list.remove_row(id, (n == selection.length-1));
        }
      }
    // also send search request to get the right messages 
    if (this.env.search_request) 
      add_url += '&_search='+this.env.search_request;
@@ -1487,20 +1489,23 @@
    var a_uids = new Array();
    var r_uids = new Array();
    var selection = this.message_list ? this.message_list.get_selection() : new Array();
    if (uid)
      a_uids[0] = uid;
    else if (this.env.uid)
      a_uids[0] = this.env.uid;
    else if (this.message_list)
      {
      for (var id, n=0; n<selection.length; n++)
      for (var n=0; n<selection.length; n++)
        {
         a_uids[a_uids.length] = selection[n];
        }
      }
    for (var id, n=0; n<a_uids.length; n++)
    if (!this.message_list)
      r_uids = a_uids;
    else
      for (var id, n=0; n<a_uids.length; n++)
      {
        id = a_uids[n];
        if ((flag=='read' && this.message_list.rows[id].unread) 
@@ -1511,11 +1516,11 @@
       r_uids[r_uids.length] = id;
     }
      }
    // nothing to do
    if (!r_uids.length)
      return;
    switch (flag)
      {
        case 'read':
@@ -1555,13 +1560,13 @@
          rows[uid].classname = rows[uid].classname.replace(/\s*unread/, '');
          this.set_classname(rows[uid].obj, 'unread', false);
          if (rows[uid].replied && this.env.repliedicon)
            icn_src = this.env.repliedicon;
          else if (this.env.messageicon)
          if (this.env.messageicon)
            icn_src = this.env.messageicon;
          }
        if (rows[uid].icon && icn_src)
        if (rows[uid].icon && icn_src
       && !(rows[uid].replied && this.env.repliedicon)
            && !(rows[uid].deleted && this.env.deletedicon))
          rows[uid].icon.src = icn_src;
        }
      }
@@ -1582,6 +1587,8 @@
        if (rows[uid].replied && parent.rcmail.env.repliedicon)
         icn_src = parent.rcmail.env.repliedicon;
        else if (rows[uid].deleted && parent.rcmail.env.deletedicon)
         icn_src = parent.rcmail.env.deletedicon;
        else if (parent.rcmail.env.messageicon)
          icn_src = parent.rcmail.env.messageicon;
      
@@ -1594,17 +1601,11 @@
  // mark all message rows as deleted/undeleted
  this.toggle_delete_status = function(a_uids)
  {
    if (this.env.read_when_deleted)
      this.mark_message('read',a_uids);
    // if deleting message from "view message" don't bother with delete icon
    if (this.env.action == "show")
      return false;
    var rows = this.message_list.rows;
    var rows = this.message_list ? this.message_list.rows : new Array();
    if (a_uids.length==1)
    {
      if (rows[a_uids[0]] && rows[a_uids[0]].classname.indexOf('deleted') < 0)
      if (!rows.length || (rows[a_uids[0]] && rows[a_uids[0]].classname.indexOf('deleted') < 0))
        this.flag_as_deleted(a_uids);
      else
        this.flag_as_undeleted(a_uids);
@@ -1636,12 +1637,8 @@
  this.flag_as_undeleted = function(a_uids)
  {
    // if deleting message from "view message" don't bother with delete icon
    if (this.env.action == "show")
      return false;
    var icn_src;
    var rows = this.message_list.rows;
    var rows = this.message_list ? this.message_list.rows : new Array();
      
    for (var i=0; i<a_uids.length; i++)
    {
@@ -1660,6 +1657,7 @@
          icn_src = this.env.repliedicon;
        else if (this.env.messageicon)
          icn_src = this.env.messageicon;
        if (rows[uid].icon && icn_src)
          rows[uid].icon.src = icn_src;
      }
@@ -1672,30 +1670,66 @@
  
  this.flag_as_deleted = function(a_uids)
  {
    // if deleting message from "view message" don't bother with delete icon
    if (this.env.action == "show")
      return false;
    var rows = this.message_list.rows;
    var add_url = '';
    var r_uids = new Array();
    var rows = this.message_list ? this.message_list.rows : new Array();
    for (var i=0; i<a_uids.length; i++)
    {
      {
      uid = a_uids[i];
      if (rows[uid]) {
      if (rows[uid])
        {
        rows[uid].deleted = true;
        
        if (rows[uid].classname.indexOf('deleted')<0) {
        if (rows[uid].classname.indexOf('deleted')<0)
     {
          rows[uid].classname += ' deleted';
          this.set_classname(rows[uid].obj, 'deleted', true);
        }
        if (rows[uid].icon && this.env.deletedicon)
          }
   if (rows[uid].icon && this.env.deletedicon)
          rows[uid].icon.src = this.env.deletedicon;
      }
    }
    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=delete');
   if (rows[uid].unread)
     r_uids[r_uids.length] = uid;
        }
      }
    if (r_uids.length)
      add_url = '&_ruid='+r_uids.join(',');
    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=delete'+add_url);
    return true;  
  };
  // flag as read without mark request (called from backend)
  // argument should be a coma-separated list of uids
  this.flag_deleted_as_read = function(uids)
  {
    var icn_src;
    var rows = this.message_list ? this.message_list.rows : new Array();
    var str = String(uids);
    var a_uids = new Array();
    a_uids = str.split(',');
    for (var uid, i=0; i<a_uids.length; i++)
      {
      uid = a_uids[i];
      if (rows[uid])
        {
        rows[uid].unread = false;
   rows[uid].read = true;
        rows[uid].classname = rows[uid].classname.replace(/\s*unread/, '');
        this.set_classname(rows[uid].obj, 'unread', false);
        if (rows[uid].icon)
          rows[uid].icon.src = this.env.deletedicon;
        }
      }
  };
  /*********************************************************/
  /*********           login form methods          *********/
@@ -1863,25 +1897,17 @@
      }
    else
      {
      var eid = tinyMCE.getEditorId('_message');
      // editor is a TinyMCE_Control object
      var editor = tinyMCE.getInstanceById(eid);
      // if this is null, we should exit
      if (editor == null) {
        return false;
      }
      var msgDoc = editor.getDoc();
      var msgBody = msgDoc.body;
      var editor = tinyMCE.get('compose-body');
      if (this.env.signatures && this.env.signatures[id])
        {
        // Append the signature as a span within the body
        var sigElem = msgDoc.getElementById("_rc_sig");
        var sigElem = editor.dom.get("_rc_sig");
        if (!sigElem)
          {
          sigElem = msgDoc.createElement("span");
          sigElem = editor.getDoc().createElement("span");
          sigElem.setAttribute("id", "_rc_sig");
          msgBody.appendChild(sigElem);
          editor.getBody().appendChild(sigElem);
          }
        if (this.env.signatures[id]['is_html'])
          {
@@ -2132,7 +2158,7 @@
      }
    // start timer
    this.ksearch_timer = setTimeout(function(){ ref.ksearch_get_results(); }, 200);
    this.ksearch_timer = window.setTimeout(function(){ ref.ksearch_get_results(); }, 200);
    this.ksearch_input = obj;
    
    return true;
@@ -2324,7 +2350,7 @@
      var id, frame, ref = this;
      if (id = list.get_single_selection())
        this.preview_timer = setTimeout(function(){ ref.load_contact(id, 'show'); }, this.dblclick_time + 10);
        this.preview_timer = window.setTimeout(function(){ ref.load_contact(id, 'show'); }, this.dblclick_time + 10);
      else if (this.env.contentframe)
        this.show_contentframe(false);
@@ -3136,7 +3162,7 @@
      this.gui_objects.message.onmousedown = function(){ _rcube.hide_message(); return true; };
    
    if (!hold)
      this.message_timer = setTimeout(function(){ ref.hide_message(); }, this.message_time);
      this.message_timer = window.setTimeout(function(){ ref.hide_message(); }, this.message_time);
    };
@@ -3362,16 +3388,16 @@
    };
  this.toggle_editor = function(checkbox, textElementName)
  this.toggle_editor = function(checkbox, textAreaId)
    {
    var ischecked = checkbox.checked;
    if (ischecked)
      {
        tinyMCE.execCommand('mceAddControl', true, textElementName);
        tinyMCE.execCommand('mceAddControl', true, textAreaId);
      }
    else
      {
        tinyMCE.execCommand('mceRemoveControl', true, textElementName);
        tinyMCE.execCommand('mceRemoveControl', true, textAreaId);
      }
    };
@@ -3801,7 +3827,7 @@
// helper function to call the init method with a delay
function call_init(o)
  {
  if (window[o] && window[o].init)
    setTimeout(o+'.init()', 200);
    window.setTimeout('if (window[\''+o+'\'] && window[\''+o+'\'].init) { '+o+'.init(); }',
                      bw.win ? 500 : 200);
  }