thomascube
2010-04-07 53d62616190ae4ffee1b0d6eae543fda8d85cdd9
program/js/app.js
@@ -3238,9 +3238,11 @@
    var insert = '';
    
    // insert all members of a group
    if (typeof this.env.contacts[id] == 'object' && this.env.contacts[id].members) {
      for (var i=0; i < this.env.contacts[id].members.length; i++)
        insert += this.env.contacts[id].members[i] + ', ';
    if (typeof this.env.contacts[id] == 'object' && this.env.contacts[id].id) {
      insert += this.env.contacts[id].name + ', ';
      this.group2expand = $.extend({}, this.env.contacts[id]);
      this.group2expand.input = this.ksearch_input;
      this.http_request('group-expand', '_source='+urlencode(this.env.contacts[id].source)+'&_gid='+urlencode(this.env.contacts[id].id), false);
    }
    else if (typeof this.env.contacts[id] == 'string')
      insert = this.env.contacts[id] + ', ';
@@ -3251,6 +3253,14 @@
    cpos = p+insert.length;
    if (this.ksearch_input.setSelectionRange)
      this.ksearch_input.setSelectionRange(cpos, cpos);
  };
  this.replace_group_recipients = function(id, recipients)
  {
    if (this.group2expand && this.group2expand.id == id) {
      this.group2expand.input.value = this.group2expand.input.value.replace(this.group2expand.name, recipients);
      this.group2expand = null;
    }
  };
  // address search processor
@@ -3286,7 +3296,7 @@
    if (old_value && old_value.length && this.env.contacts && !this.env.contacts.length && q.indexOf(old_value) == 0)
      return;
    
    this.display_message(this.get_label('searching'), 'loading', true);
    this.display_message(this.get_label('searching'), 'loading', false);
    this.http_post('autocomplete', '_search='+urlencode(q));
  };
@@ -3408,8 +3418,7 @@
    // currently all groups belong to the local address book
    if (group)
      src = 0;
    if (!src)
    else if (!src)
      src = this.env.source;
    
    if (page && this.current_page == page && src == this.env.source && group == this.env.group)
@@ -3632,6 +3641,7 @@
      return;
    
    if (!this.name_input) {
      this.enable_command('list', 'listgroup', false);
      this.name_input = document.createElement('input');
      this.name_input.type = 'text';
      this.name_input.value = this.env.contactgroups['G'+this.env.group].name;
@@ -3659,10 +3669,14 @@
  {
    var li, key = 'G'+id;
    if ((li = this.get_folder_li(key))) {
      this.triggerEvent('removegroup', { id:id, li:li });
      li.parentNode.removeChild(li);
      delete this.env.contactfolders[key];
      delete this.env.contactgroups[key];
    }
    this.list_contacts(null, 0);
  };
  
  // handler for keyboard events on the input field
@@ -3702,6 +3716,8 @@
      this.name_input.parentNode.removeChild(this.name_input);
      this.name_input = null;
    }
    this.enable_command('list', 'listgroup', true);
  };
  
  // callback for creating a new contact group
@@ -3716,6 +3732,8 @@
    var link = $('<a>').attr('href', '#').attr('onclick', "return rcmail.command('listgroup','"+prop.id+"',this)").html(prop.name);
    var li = $('<li>').attr('id', 'rcmli'+key).addClass('contactgroup').append(link);
    $(this.gui_objects.folderlist).append(li);
    this.triggerEvent('insertgroup', { id:prop.id, name:prop.name, li:li[0] });
  };
  
  // callback for renaming a contact group
@@ -3729,6 +3747,7 @@
      link.innerHTML = name;
    
    this.env.contactfolders[key].name = this.env.contactgroups[key].name = name;
    this.triggerEvent('updategroup', { id:id, name:name, li:li[0] });
  };