Commit ad39a72e authored by Dom.'s avatar Dom.

Feature #2343185 by anilbhatt : Add behaviors to suggestions to expose

event to other JS modules such as Colorbox...
parent 599c673b
......@@ -33,10 +33,12 @@
group += ('<div class="ui-autocomplete-field-group ' + item.group.group_id + '">' + item.group.group_name + '</div>');
$(group).appendTo(ul);
}
return $("<li class=ui-menu-item-" + first + "></li>")
var elem = $("<li class=ui-menu-item-" + first + "></li>" )
.data("item.autocomplete", item)
.append("<a>" + innerHTML + "</a>")
.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));
......
......@@ -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,
......
......@@ -77,7 +77,7 @@ function search_autocomplete_schema() {
'type' => 'varchar',
'length' => 50,
'not null' => FALSE,
'default' => '-- no results --',
'default' => '-- No results found for <b>[search-phrase]</b> --',
),
'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 <b>[search-phrase]</b> --'))
->execute();
}
return (t('Update no_results field default value has been done.'));
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment