RoundCube Webmail Forum  

Go Back   RoundCube Webmail Forum > SVN Releases > SVN Discussion

For more information about the ads and why they're here, please see the FAQ
Reply
  #1  
Old 11-22-2006, 08:49 AM
Registered User
 
Join Date: Aug 2006
Posts: 17
Downloads: 0
Uploads: 0
Default Change the way addresses are searched in Compose autocomplete - help needed

Hello guys,

As you well know currently roundcube searches at all positions the contact information , like when I type "dr" "Andrew" will come up.
There are some folks here who "require" this to be changed to the way their favorite best-ever gmail mail does - meaning what we input is searched for only at the beginning of first name, family name, and email address.
Currently the search function as far as I can see is located in app.js, my js is ground level, so I would be very grateful if someone gives me a hand on this.
Here is what I think does the job now:

Code:
 /*********************************************************/
 /*********   keyboard live-search methods   *********/
 /*********************************************************/


 // handler for keyboard events on address-fields
 this.ksearch_keypress = function(e, obj)
  {
  if (typeof(this.env.contacts)!='object' || !this.env.contacts.length)
   return true;

  if (this.ksearch_timer)
   clearTimeout(this.ksearch_timer);

  if (!e)
   e = window.event;
   
  var highlight;
  var key = e.keyCode ? e.keyCode : e.which;

  switch (key)
   {
   case 38: // key up
   case 40: // key down
    if (!this.ksearch_pane)
     break;
     
    var dir = key==38 ? 1 : 0;
    var next;
    
    highlight = document.getElementById('rcmksearchSelected');
    if (!highlight)
     highlight = this.ksearch_pane.ul.firstChild;
    
    if (highlight && (next = dir ? highlight.previousSibling : highlight.nextSibling))
     {
     highlight.removeAttribute('id');
     //highlight.removeAttribute('class');
     this.set_classname(highlight, 'selected', false);
     }

    if (next)
     {
     next.setAttribute('id', 'rcmksearchSelected');
     this.set_classname(next, 'selected', true);
     this.ksearch_selected = next._rcm_id;
     }

    if (e.preventDefault)
     e.preventDefault();
    return false;

   case 9: // tab
    if(e.shiftKey)
     break;

   case 13: // enter   
    if (this.ksearch_selected===null || !this.ksearch_input || !this.ksearch_value)
     break;

    // get cursor pos
    var inp_value = this.ksearch_input.value.toLowerCase();
    var cpos = this.get_caret_pos(this.ksearch_input);
    var p = inp_value.lastIndexOf(this.ksearch_value, cpos);
    
    // replace search string with full address
    var pre = this.ksearch_input.value.substring(0, p);
    var end = this.ksearch_input.value.substring(p+this.ksearch_value.length, this.ksearch_input.value.length);
    var insert = this.env.contacts[this.ksearch_selected]+', ';
    this.ksearch_input.value = pre + insert + end;
    
    //this.ksearch_input.value = this.ksearch_input.value.substring(0, p)+insert;
    
    // set caret to insert pos
    cpos = p+insert.length;
    if (this.ksearch_input.setSelectionRange)
     this.ksearch_input.setSelectionRange(cpos, cpos);
    
    // hide ksearch pane
    this.ksearch_hide();
   
    if (e.preventDefault)
     e.preventDefault();
    return false;

   case 27: // escape
    this.ksearch_hide();
    break;

   }
Please share your opinions also on whether such behavior should become the default one ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 11-22-2006, 10:28 AM
Super Moderator
 
Join Date: Jul 2006
Location: Dronten | The Netherlands
Posts: 150
Downloads: 0
Uploads: 0
Default Re: Change the way addresses are searched in Compose autocomplete - help needed

You can share this with the dev. team from RC
( http://lists.roundcube.net/ )
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

For more information about the ads and why they're here, please see the FAQ

All times are GMT. The time now is 10:13 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright © 2006-2008 RoundCube Webmail Community