svncommit
2007-10-19 3e71ab7a6c84583f23c33c733f606fa1b5d68d4d
program/js/app.js
@@ -203,8 +203,11 @@
        this.set_page_buttons();
        // focus this window
        window.focus();
        // focus main window
        if (this.env.framed && window.parent)
          window.parent.focus();
        else
          window.focus();
        // init message compose form
        if (this.env.action=='compose')
@@ -938,8 +941,7 @@
        break;
      case 'delete-folder':
        if (confirm(this.get_label('deletefolderconfirm')))
          this.delete_folder(props);
        this.delete_folder(props);
        break;
      }
@@ -1440,10 +1442,8 @@
        {
        id = selection[n];
        a_uids[a_uids.length] = id;
        this.message_list.remove_row(id);
        this.message_list.remove_row(id, (n == selection.length-1));
        }
      this.message_list.select_next();
      }
      
    // also send search request to get the right messages 
@@ -1859,8 +1859,11 @@
      }
      
    // clear upload form
    if (!a && this.gui_objects.attachmentform && this.gui_objects.attachmentform!=this.gui_objects.messageform)
      this.gui_objects.attachmentform.reset();
   try {
      if (!a && this.gui_objects.attachmentform != this.gui_objects.messageform)
         this.gui_objects.attachmentform.reset();
   }
   catch(e){}  // ignore errors
    
    return true;  
    };
@@ -2367,7 +2370,7 @@
        {
        id = selection[n];
        a_cids[a_cids.length] = id;
        this.contact_list.remove_row(id);
        this.contact_list.remove_row(id, (n == selection.length-1));
        }
      // hide content frame if we delete the currently displayed contact
@@ -2405,12 +2408,20 @@
  this.init_subscription_list = function()
    {
    var p = this;
    this.subscription_list = new rcube_list_widget(this.gui_objects.subscriptionlist, {multiselect:false, draggable:true, keyboard:false});
    this.subscription_list = new rcube_list_widget(this.gui_objects.subscriptionlist, {multiselect:false, draggable:true, keyboard:false, toggleselect:true});
    this.subscription_list.addEventListener('select', function(o){ p.subscription_select(o); });
    this.subscription_list.addEventListener('mouseover', function(o){ p.subscription_select_parent(o); });
    this.subscription_list.addEventListener('mouseout', function(o){ p.subscription_unselect_parent(o); });
    this.subscription_list.addEventListener('dragstart', function(o){ p.drag_active = true; });
    this.subscription_list.addEventListener('dragend', function(o){ p.subscription_move_folder(o); });
    this.subscription_list.row_init = function (row)
      {
      var anchors = row.obj.getElementsByTagName('A');
      if (anchors[0])
        anchors[0].onclick = function() { p.rename_folder(row.id); };
      if (anchors[1])
        anchors[1].onclick = function() { p.delete_folder(row.id); };
      row.obj.onmouseover = function() { p.focus_subscription(row.id); };
      row.obj.onmouseout = function() { p.unfocus_subscription(row.id); };
      }
    this.subscription_list.init();
    }
@@ -2463,55 +2474,51 @@
  this.focus_subscription = function(id)
    {
    var row;
    var row, folder;
    var reg = RegExp('['+RegExp.escape(this.env.delimiter)+']?[^'+RegExp.escape(this.env.delimiter)+']+$');
    if (this.drag_active && this.check_droptarget(id) &&
        (id != this.env.folder.replace(reg, '')) &&
        (row = document.getElementById(this.get_folder_row_id(id))))
      if (find_in_array(this.env.defaultfolders, id)>=0)
    if (this.drag_active && (row = document.getElementById(id)))
      if (this.env.subscriptionrows[id] &&
          (folder = this.env.subscriptionrows[id][0]))
        {
        if (this.env.folder.replace(reg, '')!='')
        if (this.check_droptarget(folder) &&
            (folder != this.env.folder.replace(reg, '')) &&
            (!folder.match(new RegExp('^'+RegExp.escape(this.env.folder+this.env.delimiter)))))
          {
          this.set_env('dstfolder', this.env.delimiter);
          this.set_classname(this.subscription_list.frame, 'droptarget', true);
          this.set_env('dstfolder', folder);
          this.set_classname(row, 'droptarget', true);
          }
        }
      else
      else if (this.env.folder.match(new RegExp(RegExp.escape(this.env.delimiter))))
        {
        this.set_env('dstfolder', id);
        this.set_classname(row, 'droptarget', true);
        this.set_env('dstfolder', this.env.delimiter);
        this.set_classname(this.subscription_list.frame, 'droptarget', true);
        }
    }
  this.unfocus_subscription = function(id)
    {
    var row;
    if (row = document.getElementById(this.get_folder_row_id(id)))
      {
      var row;
      this.set_env('dstfolder', null);
      if (find_in_array(this.env.defaultfolders, id)>=0)
        this.set_classname(this.subscription_list.frame, 'droptarget', false);
      else
      if (this.env.subscriptionrows[id] &&
          (row = document.getElementById(id)))
        this.set_classname(row, 'droptarget', false);
      }
      else
        this.set_classname(this.subscription_list.frame, 'droptarget', false);
    }
  this.subscription_select = function(list)
    {
    var id;
    if (id = list.get_single_selection())
      {
      var folder = this.env.subscriptionrows['rcmrow'+id][0];
      if (this.env.folder && (this.env.folder==folder))
        {
        list.clear_selection();
        this.set_env('folder', null);
        }
      else
        this.set_env('folder', folder);
      }
    var id, folder;
    if ((id = list.get_single_selection()) &&
        this.env.subscriptionrows['rcmrow'+id] &&
        (folder = this.env.subscriptionrows['rcmrow'+id][0]) &&
        (find_in_array(this.env.defaultfolders, folder)!=0))
      this.set_env('folder', folder);
    else
      this.set_env('folder', null);
    };
@@ -2527,7 +2534,7 @@
      this.http_post('rename-folder', '_folder_oldname='+urlencode(this.env.folder)+'&_folder_newname='+urlencode(newname));
      }
    this.drag_active = false;
    this.unfocus_subscription(this.env.dstfolder);
    this.unfocus_subscription(this.get_folder_row_id(this.env.dstfolder));
    };
@@ -2540,6 +2547,8 @@
    var form;
    if ((form = this.gui_objects.editform) && form.elements['_folder_name'])
      name = form.elements['_folder_name'].value;
    if (this.env.folder)
      name = this.env.folder+this.env.delimiter+name;
    if (name)
      this.http_post('create-folder', '_name='+urlencode(name), true);
@@ -2548,33 +2557,12 @@
    };
  // entry point for folder renaming
  this.rename_folder = function(props)
    {
    var form, oldname, newname;
    // rename a specific mailbox
    if (props)
      this.edit_foldername(props);
    // use a dropdown and input field (old behavior)
    else if ((form = this.gui_objects.editform) && form.elements['_folder_oldname'] && form.elements['_folder_newname'])
      {
      oldname = form.elements['_folder_oldname'].value;
      newname = form.elements['_folder_newname'].value;
      }
    if (oldname && newname)
      this.http_post('rename-folder', '_folder_oldname='+urlencode(oldname)+'&_folder_newname='+urlencode(newname));
    };
  // start editing the mailbox name.
  // start renaming the mailbox name.
  // this will replace the name string with an input field
  this.edit_foldername = function(folder)
  this.rename_folder = function(id)
    {
    var temp, row, form;
    var id = this.get_folder_row_id(folder);
    var folder = this.env.subscriptionrows[id][0];
    // reset current renaming
  if (temp = this.edit_folder)
@@ -2641,13 +2629,18 @@
  // delete a specific mailbox with all its messages
  this.delete_folder = function(folder)
  this.delete_folder = function(id)
    {
  if (this.edit_folder)
    this.reset_folder_rename();
    if (folder)
    var folder = this.env.subscriptionrows[id][0];
    if (this.edit_folder)
      this.reset_folder_rename();
    if (folder && confirm(this.get_label('deletefolderconfirm')))
      {
      this.http_post('delete-folder', '_mboxes='+urlencode(folder));
      this.set_env('folder', null);
      }
    };
@@ -2664,7 +2657,8 @@
    var refrow, form;
    var tbody = this.gui_objects.subscriptionlist.tBodies[0];
    var id = replace && replace.id ? replace.id : tbody.childNodes.length+1;
    var id = replace && replace.id ? replace.id : 'rcmrow'+(tbody.childNodes.length+1);
    var selection = this.subscription_list.get_single_selection();
    if (!id || !(refrow = document.getElementById(refid)))
      {
@@ -2675,7 +2669,7 @@
      {
      // clone a table row if there are existing rows
      var row = this.clone_table_row(refrow);
      row.id = 'rcmrow'+id;
      row.id = id;
      if (replace)
        tbody.replaceChild(row, replace);
      else
@@ -2693,11 +2687,6 @@
      row.cells[1].firstChild.checked = true;
      }
       
    if (row.cells[2] && row.cells[2].firstChild.tagName=='A')
      row.cells[2].firstChild.onclick = new Function(this.ref+".command('rename-folder','"+name.replace('\'','\\\'')+"')");
    if (row.cells[3] && row.cells[3].firstChild.tagName=='A')
      row.cells[3].firstChild.onclick = new Function(this.ref+".command('delete-folder','"+name.replace('\'','\\\'')+"')");
    // add new folder to rename-folder list and clear input field
    if (!replace && (form = this.gui_objects.editform))
      {
@@ -2709,9 +2698,11 @@
    this.sort_subscription_list();
    this.init_subscription_list();
    if (selection && document.getElementById('rcmrow'+selection))
      this.subscription_list.select_row(selection);
    if (document.getElementById('rcmrow'+id).scrollIntoView)
      document.getElementById('rcmrow'+id).scrollIntoView();
    if (document.getElementById(id).scrollIntoView)
      document.getElementById(id).scrollIntoView();
    };
@@ -2723,7 +2714,6 @@
    
    // replace an existing table row (if found)
    this.add_folder_row(newfolder, display_name, row);
    this.env.subscriptionrows[id] = null;
    
    // rename folder in rename-folder dropdown
    var form, elm;
@@ -3451,6 +3441,7 @@
      case 'list':
        if (this.env.messagecount)
          this.enable_command('purge', (this.env.mailbox==this.env.trash_mailbox || this.env.mailbox==this.env.junk_mailbox));
        this.msglist_select(this.message_list);
      case 'expunge':
        this.enable_command('select-all', 'select-none', 'expunge', this.env.messagecount ? true : false);