diff --git a/js/jquery.autocomplete.js b/js/jquery.autocomplete.js index fae15c099abad26eec6777ef71d1dc7ecee71e43..7a44b430eede0e6a2e075eaadad18d232e4bbc85 100644 --- a/js/jquery.autocomplete.js +++ b/js/jquery.autocomplete.js @@ -33,10 +33,12 @@ group += ('
' + item.group.group_name + '
'); $(group).appendTo(ul); } - return $("
  • ") + var elem = $("
  • " ) .data("item.autocomplete", item) .append("" + innerHTML + "") .appendTo(ul); + Drupal.attachBehaviors(elem); + return elem; }; $.ui.autocomplete.prototype._resizeMenu = function() { @@ -58,7 +60,7 @@ $.getJSON(Drupal.settings.search_autocomplete[key].datas, { q: request.term }, function (results) { // Only return the number of values set in the settings. if (!results.length && NoResultsLabel) { - results = [NoResultsLabel]; + results = [NoResultsLabel.replace("[search-phrase]", request.term)]; } response(results.slice(0, Drupal.settings.search_autocomplete[key].max_sug)); }); @@ -68,7 +70,7 @@ $.getJSON(Drupal.settings.search_autocomplete[key].datas + request.term, { }, function (results) { // Only return the number of values set in the settings. if (!results.length && NoResultsLabel) { - results = [NoResultsLabel]; + results = [NoResultsLabel.replace("[search-phrase]", request.term)]; } response(results.slice(0, Drupal.settings.search_autocomplete[key].max_sug)); }); @@ -77,7 +79,7 @@ else if (Drupal.settings.search_autocomplete[key].type == 'static') { var results = $.ui.autocomplete.filter(Drupal.settings.search_autocomplete[key].datas, request.term); if (!results.length && NoResultsLabel) { - results = [NoResultsLabel]; + results = [NoResultsLabel.replace("[search-phrase]", request.term)]; } // Only return the number of values set in the settings. response(results.slice(0, Drupal.settings.search_autocomplete[key].max_sug)); diff --git a/search_autocomplete.form.configure.inc b/search_autocomplete.form.configure.inc index f2d8269ebd8334f630a575a77a97328643b33ab8..13566b1aa4b5bc96a5cc99b964f5fd63b2830875 100644 --- a/search_autocomplete.form.configure.inc +++ b/search_autocomplete.form.configure.inc @@ -61,7 +61,7 @@ function search_autocomplete_form_configure($form, &$form_state) { $form['search_autocomplete_how']['no_results'] = array( '#type' => 'textfield', '#title' => t('Behavior when no suggestions are found'), - '#description' => t('Enter a message to display when no results are found. Leave empty for no message.'), + '#description' => t('Enter a message to display when no results are found. Leave empty for no message. You can use HTML tags as well as the token [search-phrase] to replace user input.'), '#default_value' => $item->no_results, '#maxlength' => 50, '#required' => FALSE, diff --git a/search_autocomplete.install b/search_autocomplete.install index 09b0ff58cd299347f26ffaffd109b47c78120d9f..49025fa3adcf578e3b34a44f5bf12ff4b2a76df0 100644 --- a/search_autocomplete.install +++ b/search_autocomplete.install @@ -77,7 +77,7 @@ function search_autocomplete_schema() { 'type' => 'varchar', 'length' => 50, 'not null' => FALSE, - 'default' => '-- no results --', + 'default' => '-- No results found for [search-phrase] --', ), 'auto_submit' => array( 'description' => 'Define if form should be autosubmitted when suggestion is choosen', @@ -329,4 +329,18 @@ function search_autocomplete_update_7408(&$sandbox) { } return (t('Update to 7.x-4.0 has been done.')); +} + +/** + * Migrate no_results field from 4.0 to 4.1 default value + */ +function search_autocomplete_update_7410(&$sandbox) { + + if (db_field_exists('search_autocomplete_forms', 'no_results')) { + db_update('search_autocomplete_forms') // Table name no longer needs {} + ->fields(array('no_results' => '-- No results found for [search-phrase] --')) + ->execute(); + } + + return (t('Update no_results field default value has been done.')); } \ No newline at end of file