diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-08-04 22:46:40 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-06 16:04:48 -0500 |
commit | e616c201a5bc311f3d9c1801bdca773735adbc3a (patch) | |
tree | 41c7d925d1d2ef70ee11a425c2554f5cc8c4aa41 /bitbake | |
parent | aad380028fb1eec0defbeced39926f4626e02855 (diff) | |
download | openembedded-core-contrib-e616c201a5bc311f3d9c1801bdca773735adbc3a.tar.gz |
bitbake: toastergui: libtoaster typeahead Add in results highlighter
Add a highlighter for the results in the typeahead, this highlights the
part of the results which is currently being matched. This is a modified
version of the bootstrap stock function with added escaping and the
addition of the details information.
(Bitbake rev: 3a6bad55a84d8d374a23f488ce42fed9b927c4f2)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/libtoaster.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 34a3fbb1fb..c04f7aba2b 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js @@ -56,10 +56,14 @@ var libtoaster = (function (){ return 1; }, highlighter: function (item) { - if (item.hasOwnProperty('detail')) - /* Use jquery to escape the value as text into a span */ - return $('<span></span>').text(item.name+' '+item.detail).get(0); - return $('<span></span>').text(item.name).get(0); + /* Use jquery to escape the item name and detail */ + var current = $("<span></span>").text(item.name + ' '+item.detail); + current = current.html(); + + var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&') + return current.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) { + return '<strong>' + match + '</strong>' + }) }, sorter: function (items) { return items; }, xhrUrl: xhrUrl, |