You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2019/06/13 14:08:01 UTC
[allura] branch master updated: [#8303] improve autocomplete
display logic
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new ad1e255 [#8303] improve autocomplete display logic
ad1e255 is described below
commit ad1e255db07e6297600ef84f83275e2447223c40
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Thu Jun 13 10:07:49 2019 -0400
[#8303] improve autocomplete display logic
---
Allura/allura/lib/widgets/resources/js/combobox.js | 18 ++++++++++++------
Allura/allura/public/nf/js/allura-base.js | 4 ++++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/Allura/allura/lib/widgets/resources/js/combobox.js b/Allura/allura/lib/widgets/resources/js/combobox.js
index b36c3df..7821476 100644
--- a/Allura/allura/lib/widgets/resources/js/combobox.js
+++ b/Allura/allura/lib/widgets/resources/js/combobox.js
@@ -107,13 +107,19 @@
response(select.children('option').map(function() {
var text = $(this).text();
if (this.value && (!request.term || matcher.test(text))) {
+ var label = escape_html(text);
+ if (request.term) {
+ // highlight the matching chars with <strong>
+ label = label.replace(
+ new RegExp('(?![^&;]+;)(?!<[^<>]*)(' +
+ $.ui.autocomplete.escapeRegex(request.term) +
+ ')(?![^<>]*>)(?![^&;]+;)', 'gi'
+ ),
+ '<strong>$1</strong>'
+ );
+ }
return {
- label: text.replace(
- new RegExp(
- '(?![^&;]+;)(?!<[^<>]*)(' +
- $.ui.autocomplete.escapeRegex(request.term) +
- ')(?![^<>]*>)(?![^&;]+;)', 'gi'
- ), '<strong>$1</strong>'),
+ label: label,
value: text,
option: this
};
diff --git a/Allura/allura/public/nf/js/allura-base.js b/Allura/allura/public/nf/js/allura-base.js
index ce813a9..6e5f876 100644
--- a/Allura/allura/public/nf/js/allura-base.js
+++ b/Allura/allura/public/nf/js/allura-base.js
@@ -166,6 +166,10 @@ function get_cm($elem) {
return $('.CodeMirror', $elem)[0].CodeMirror;
}
+function escape_html(str) {
+ return $('<i></i>').text(str).html();
+}
+
$(function(){
$('html').removeClass('no-js').addClass('js');