Bugfix and improve auto-completion

release-0.6
thomascube 16 years ago
parent 0456f83bcc
commit 1553b3c701

@ -2535,7 +2535,7 @@ function rcube_webmail()
this.ksearch_display_results = function (a_results, a_result_ids, c) this.ksearch_display_results = function (a_results, a_result_ids, c)
{ {
// display search results // display search results
if (c && a_results.length) { if (c && a_results.length && this.ksearch_input) {
var p, ul, li; var p, ul, li;
// create results pane if not present // create results pane if not present
@ -2554,7 +2554,7 @@ function rcube_webmail()
// add each result line to list // add each result line to list
for (i=0; i<a_results.length; i++) { for (i=0; i<a_results.length; i++) {
li = document.createElement('LI'); li = document.createElement('LI');
li.innerHTML = a_results[i].replace(/</, '&lt;').replace(/>/, '&gt;').replace(new RegExp('('+this.ksearch_value+')', 'ig'), '<b>$1</b>'); li.innerHTML = a_results[i].replace(new RegExp('('+this.ksearch_value+')', 'ig'), '##$1%%').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/##([^%]+)%%/g, '<b>$1</b>');
li.onmouseover = function(){ ref.ksearch_select(this); }; li.onmouseover = function(){ ref.ksearch_select(this); };
li.onmouseup = function(){ ref.ksearch_click(this) }; li.onmouseup = function(){ ref.ksearch_click(this) };
li._rcm_id = a_result_ids[i]; li._rcm_id = a_result_ids[i];

@ -19,13 +19,14 @@
*/ */
$MAXNUM = 15; // same limit as in app.js
$contacts = array(); $contacts = array();
if ($search = get_input_value('_search', RCUBE_INPUT_POST)) { if ($search = get_input_value('_search', RCUBE_INPUT_POST)) {
foreach ($RCMAIL->config->get('autocomplete_addressbooks', array('sql')) as $id) { foreach ($RCMAIL->config->get('autocomplete_addressbooks', array('sql')) as $id) {
$abook = $RCMAIL->get_address_book($id); $abook = $RCMAIL->get_address_book($id);
$abook->set_pagesize(20); $abook->set_pagesize($MAXNUM);
if ($result = $abook->search(array('email','name'), $search)) { if ($result = $abook->search(array('email','name'), $search)) {
while ($sql_arr = $result->iterate()) { while ($sql_arr = $result->iterate()) {
@ -34,6 +35,9 @@ if ($search = get_input_value('_search', RCUBE_INPUT_POST)) {
} }
} }
} }
if (count($contacts) >= $MAXNUM)
break;
} }
sort($contacts); sort($contacts);

Loading…
Cancel
Save