Only match the displayed name of items when searching
Currently the search term is matched against the longname of members. Because of this most members are matched when searching for a class / module and also searching for 'mod' matches everything as all longnames start with 'module:'
This commit is contained in:
@@ -29,7 +29,7 @@ $(function () {
|
||||
var getSearchWeight = function (searchTerm, $matchedItem) {
|
||||
let weight = 0;
|
||||
// We could get smarter on the weight here
|
||||
if ($matchedItem.data('shortname') === searchTerm) {
|
||||
if ($matchedItem.data('name') === searchTerm) {
|
||||
weight++;
|
||||
}
|
||||
return weight;
|
||||
@@ -48,7 +48,7 @@ $(function () {
|
||||
.replace('module-', 'module:')
|
||||
.replace(/_/g, '/')
|
||||
.replace(/-/g, '~');
|
||||
var $currentItem = $('.navigation .item[data-name*="' + longname.toLowerCase() + '"]:eq(0)');
|
||||
var $currentItem = $('.navigation .item[data-longname="' + longname + '"]:eq(0)');
|
||||
|
||||
if ($currentItem.length) {
|
||||
$currentItem
|
||||
|
||||
@@ -15,11 +15,11 @@ function getItemCssClass(type) {
|
||||
}
|
||||
|
||||
const printList = v => { ?>
|
||||
<li data-name="<?js= v.longname.toLowerCase() ?>"><?js
|
||||
<li data-name="<?js= toShortName(v.name).toLowerCase() ?>"><?js
|
||||
}
|
||||
const printListWithStability = v => {
|
||||
const cls = v.stability && v.stability !== 'stable' ? ' class="unstable"' : ''; ?>
|
||||
<li data-name="<?js= v.longname.toLowerCase() ?>"<?js= cls ?>><?js
|
||||
<li data-name="<?js= toShortName(v.name).toLowerCase() ?>"<?js= cls ?>><?js
|
||||
}
|
||||
|
||||
function listContent(item, title, listItemPrinter) {
|
||||
@@ -42,7 +42,7 @@ function listContent(item, title, listItemPrinter) {
|
||||
</div>
|
||||
<ul class="list"><?js
|
||||
this.nav.forEach(function (item) { ?>
|
||||
<li class="item" data-name="<?js= item.longname.toLowerCase() ?>" data-shortname="<?js= item.name.toLowerCase() ?>">
|
||||
<li class="item" data-longname="<?js= item.longname ?>" data-name="<?js= item.name.toLowerCase() ?>">
|
||||
<span class="title">
|
||||
<span class="glyphicon <?js= getItemCssClass(item.type) ?> toggle"></span>
|
||||
<?js= self.linkto(item.longname, item.prettyname) ?>
|
||||
|
||||
Reference in New Issue
Block a user