Changeset eeb73cc in github


Ignore:
Timestamp:
Jan 5, 2012 11:07:27 AM (17 months ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
Children:
8304e5d
Parents:
b611d3a
Message:

Implement address book widget on compose screen

Location:
program
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • program/js/app.js

    r0e530bd reeb73cc  
    44 |                                                                       | 
    55 | This file is part of the Roundcube Webmail client                     | 
    6  | Copyright (C) 2005-2011, The Roundcube Dev Team                       | 
     6 | Copyright (C) 2005-2012, The Roundcube Dev Team                       | 
    77 | Copyright (C) 2011, Kolab Systems AG                                  | 
    88 | Licensed under the GNU GPL                                            | 
     
    3131  this.onloads = []; 
    3232  this.messages = {}; 
     33  this.group2expand = {}; 
    3334 
    3435  // create protected reference to myself 
     
    247248        } 
    248249        else if (this.env.action == 'compose') { 
    249           this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'cancel', 'toggle-editor']; 
     250          this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'cancel', 'toggle-editor', 
     251            'list-adresses', 'add-recipient', 'firstpage', 'previouspage', 'nextpage', 'lastpage']; 
    250252 
    251253          if (this.env.drafts_mailbox) 
     
    266268          // init message compose form 
    267269          this.init_messageform(); 
     270 
     271          // init address book widget 
     272          if (this.gui_objects.contactslist) { 
     273            this.contact_list = new rcube_list_widget(this.gui_objects.contactslist, 
     274              { multiselect:true, draggable:false, keyboard:false }); 
     275            this.contact_list.addEventListener('select', function(o){ ref.compose_recipeint_select(o); }); 
     276            this.contact_list.addEventListener('dblclick', function(o){ ref.compose_add_recipient('to'); }); 
     277            this.contact_list.init(); 
     278          } 
     279 
     280          if (this.gui_objects.adressbookslist) { 
     281            this.gui_objects.folderlist = this.gui_objects.adressbookslist; 
     282            this.enable_command('list-adresses', true); 
     283          } 
    268284        } 
    269285        // show printing dialog 
     
    947963        break; 
    948964 
     965      case 'list-adresses': 
     966        this.list_contacts(props); 
     967        this.enable_command('add-recipient', false); 
     968        break; 
     969 
     970      case 'add-recipient': 
     971        this.compose_add_recipient(props); 
     972        break; 
     973 
    949974      case 'reply-all': 
    950975      case 'reply-list': 
     
    19782003      this.env.current_page = page; 
    19792004 
    1980       if (this.task == 'mail') 
     2005      if (this.task == 'addressbook' || this.contact_list) 
     2006        this.list_contacts(this.env.source, this.env.group, page); 
     2007      else if (this.task == 'mail') 
    19812008        this.list_mailbox(this.env.mailbox, page); 
    1982       else if (this.task == 'addressbook') 
    1983         this.list_contacts(this.env.source, this.env.group, page); 
    19842009    } 
    19852010  }; 
     
    29662991      .attr('autocomplete', 'off'); 
    29672992  }; 
     2993   
     2994  this.compose_recipeint_select = function(list) 
     2995  { 
     2996    this.enable_command('add-recipient', list.selection.length > 0); 
     2997  }; 
     2998 
     2999  this.compose_add_recipient = function(field) 
     3000  { 
     3001    var recipients = [], input = $('#_'+field); 
     3002     
     3003    if (this.contact_list && this.contact_list.selection.length) { 
     3004      for (var id, n=0; n < this.contact_list.selection.length; n++) { 
     3005        id = this.contact_list.selection[n]; 
     3006        if (id && this.env.contactdata[id]) { 
     3007          recipients.push(this.env.contactdata[id]); 
     3008 
     3009          // group is added, expand it 
     3010          if (id.charAt(0) == 'E' && this.env.contactdata[id].indexOf('@') < 0 && input.length) { 
     3011            var gid = id.substr(1); 
     3012            this.group2expand[gid] = { name:this.env.contactdata[id], input:input.get(0) }; 
     3013            this.http_request('group-expand', '_source='+urlencode(this.env.source)+'&_gid='+urlencode(gid), false); 
     3014          } 
     3015        } 
     3016      } 
     3017    } 
     3018 
     3019    if (recipients.length && input.length) { 
     3020      var oldval = input.val(); 
     3021      input.val((oldval ? oldval + this.env.recipients_delimiter : '') + recipients.join(this.env.recipients_delimiter)); 
     3022      this.triggerEvent('add-recipient', { field:field, recipients:recipients }); 
     3023    } 
     3024  }; 
    29683025 
    29693026  // checks the input fields before sending a message 
     
    36383695    if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].id) { 
    36393696      insert += this.env.contacts[id].name + this.env.recipients_delimiter; 
    3640       this.group2expand = $.extend({}, this.env.contacts[id]); 
    3641       this.group2expand.input = this.ksearch_input; 
     3697      this.group2expand[this.env.contacts[id].id] = $.extend({ input: this.ksearch_input }, this.env.contacts[id]); 
    36423698      this.http_request('mail/group-expand', '_source='+urlencode(this.env.contacts[id].source)+'&_gid='+urlencode(this.env.contacts[id].id), false); 
    36433699    } 
     
    36603716  this.replace_group_recipients = function(id, recipients) 
    36613717  { 
    3662     if (this.group2expand && this.group2expand.id == id) { 
    3663       this.group2expand.input.value = this.group2expand.input.value.replace(this.group2expand.name, recipients); 
    3664       this.triggerEvent('autocomplete_insert', { field:this.group2expand.input, insert:recipients }); 
    3665       this.group2expand = null; 
     3718    if (this.group2expand[id]) { 
     3719      this.group2expand[id].input.value = this.group2expand[id].input.value.replace(this.group2expand[id].name, recipients); 
     3720      this.triggerEvent('autocomplete_insert', { field:this.group2expand[id].input, insert:recipients }); 
     3721      this.group2expand[id] = null; 
    36663722    } 
    36673723  }; 
     
    40024058      url += '&_search='+this.env.search_request; 
    40034059 
    4004     this.http_request('list', url, lock); 
     4060    this.http_request(this.env.task == 'mail' ? 'list-contacts' : 'list', url, lock); 
    40054061  }; 
    40064062 
     
    60396095          this.enable_command('expand-all', 'expand-unread', 'collapse-all', this.env.threading && this.env.messagecount); 
    60406096 
    6041           if (response.action == 'list' || response.action == 'search') { 
     6097          if ((response.action == 'list' || response.action == 'search') && this.message_list) { 
    60426098            this.msglist_select(this.message_list); 
    60436099            this.triggerEvent('listupdate', { folder:this.env.mailbox, rowcount:this.message_list.rowcount }); 
  • program/steps/mail/compose.inc

    r1c4f23d reeb73cc  
    66 |                                                                       | 
    77 | This file is part of the Roundcube Webmail client                     | 
    8  | Copyright (C) 2005-2011, The Roundcube Dev Team                       | 
     8 | Copyright (C) 2005-2012, The Roundcube Dev Team                       | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    14721472 
    14731473 
     1474function rcmail_adressbook_list($attrib = array()) 
     1475{ 
     1476    global $RCMAIL, $OUTPUT; 
     1477 
     1478    $attrib += array('id' => 'rcmdirectorylist'); 
     1479 
     1480    $out = ''; 
     1481    $line_templ = html::tag('li', array( 
     1482        'id' => 'rcmli%s', 'class' => '%s'), 
     1483        html::a(array('href' => '#list', 
     1484            'rel' => '%s', 
     1485            'onclick' => "return ".JS_OBJECT_NAME.".command('list-adresses','%s',this)"), '%s')); 
     1486 
     1487    foreach ($RCMAIL->get_address_sources() as $j => $source) { 
     1488        $id = strval(strlen($source['id']) ? $source['id'] : $j); 
     1489        $js_id = JQ($id); 
     1490 
     1491        // set class name(s) 
     1492        $class_name = 'addressbook'; 
     1493        if ($source['class_name']) 
     1494            $class_name .= ' ' . $source['class_name']; 
     1495 
     1496        $out .= sprintf($line_templ, 
     1497            html_identifier($id), 
     1498            $class_name, 
     1499            $source['id'], 
     1500            $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id))); 
     1501    } 
     1502 
     1503    $OUTPUT->add_gui_object('adressbookslist', $attrib['id']); 
     1504 
     1505    return html::tag('ul', $attrib, $out, html::$common_attrib); 
     1506} 
     1507 
     1508// return the contacts list as HTML table 
     1509function rcmail_contacts_list($attrib = array()) 
     1510{ 
     1511    global $OUTPUT; 
     1512 
     1513    $attrib += array('id' => 'rcmAddressList'); 
     1514 
     1515    // set client env 
     1516    $OUTPUT->add_gui_object('contactslist', $attrib['id']); 
     1517    $OUTPUT->set_env('pagecount', 0); 
     1518    $OUTPUT->set_env('current_page', 0); 
     1519    $OUTPUT->include_script('list.js'); 
     1520 
     1521    return rcube_table_output($attrib, array(), array('name'), 'ID'); 
     1522} 
     1523 
     1524 
     1525 
    14741526// register UI objects 
    14751527$OUTPUT->add_handlers(array( 
     
    14851537  'dsncheckbox' => 'rcmail_dsn_checkbox', 
    14861538  'storetarget' => 'rcmail_store_target_selection', 
     1539  'adressbooks' => 'rcmail_adressbook_list', 
     1540  'addresslist' => 'rcmail_contacts_list', 
    14871541)); 
    14881542 
Note: See TracChangeset for help on using the changeset viewer.