summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique CLAUSE2014-09-20 16:54:03 (GMT)
committerDominique CLAUSE2014-09-24 12:58:50 (GMT)
commitad39a72eb49e026773178b6b0accacb4ad7d9d7b (patch)
treeb003779de9591404a111c20432752944b91aaae3
parent599c673b5907d5c4eace9cb3b869944d295b622c (diff)
Feature #2343185 by anilbhatt : Add behaviors to suggestions to expose
event to other JS modules such as Colorbox...
-rw-r--r--js/jquery.autocomplete.js10
-rw-r--r--search_autocomplete.form.configure.inc2
-rw-r--r--search_autocomplete.install16
3 files changed, 22 insertions, 6 deletions
diff --git a/js/jquery.autocomplete.js b/js/jquery.autocomplete.js
index fae15c0..7a44b43 100644
--- a/js/jquery.autocomplete.js
+++ b/js/jquery.autocomplete.js
@@ -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));
diff --git a/search_autocomplete.form.configure.inc b/search_autocomplete.form.configure.inc
index f2d8269..13566b1 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 09b0ff5..49025fa 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 <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