Introduces apidoc changes
- Removes modules from the apidoc navigation - Adds a weight paramater to the search to be more accurate on searchresults
This commit is contained in:
@@ -215,15 +215,21 @@ function buildNav(members) {
|
||||
return 0;
|
||||
});
|
||||
|
||||
function createEntry(type, v) {
|
||||
return {
|
||||
type: type,
|
||||
_.each(merged, function(v) {
|
||||
// exclude interfaces from sidebar
|
||||
if (v.interface !== true && v.kind === 'class') {
|
||||
nav.push({
|
||||
type: 'class',
|
||||
longname: v.longname,
|
||||
prettyname: v.longname
|
||||
.substring(0, v.longname.indexOf('~'))
|
||||
.replace('module:', '')
|
||||
.replace('ol/', ''),
|
||||
name: v.name,
|
||||
classes: find({
|
||||
kind: 'class',
|
||||
memberof: v.longname
|
||||
}).map(createEntry.bind(this, 'class')),
|
||||
module: find({
|
||||
kind: 'module',
|
||||
longname: v.memberof
|
||||
})[0],
|
||||
members: find({
|
||||
kind: 'member',
|
||||
memberof: v.longname
|
||||
@@ -236,18 +242,12 @@ function buildNav(members) {
|
||||
kind: 'typedef',
|
||||
memberof: v.longname
|
||||
}),
|
||||
fires: v.fires,
|
||||
events: find({
|
||||
kind: 'event',
|
||||
memberof: v.longname
|
||||
})
|
||||
};
|
||||
}
|
||||
_.each(merged, function(v) {
|
||||
// exclude interfaces from sidebar
|
||||
if (v.interface !== true) {
|
||||
if (v.kind == 'module') {
|
||||
nav.push(createEntry('module', v));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return nav;
|
||||
|
||||
@@ -1,29 +1,66 @@
|
||||
$(function () {
|
||||
// Search Items
|
||||
$('#include_modules').change(function (e) {
|
||||
console.log('change');
|
||||
if ($(this).is(':checked')) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var getSearchWeight = function (searchTerm, $matchedItem) {
|
||||
let weight = 0;
|
||||
// We could get smarter on the weight here
|
||||
if ($matchedItem.data('shortname')
|
||||
&& $matchedItem.data('shortname').toLowerCase() === searchTerm.toLowerCase()) {
|
||||
weight++;
|
||||
}
|
||||
return weight;
|
||||
};
|
||||
|
||||
// sort function callback
|
||||
var weightSorter = function (a, b) {
|
||||
var aW = $(a).data('weight') || 0;
|
||||
var bW = $(b).data('weight') || 0;
|
||||
return bW - aW;
|
||||
};
|
||||
|
||||
// Search Items
|
||||
$('#search').on('keyup', function (e) {
|
||||
var value = $(this).val();
|
||||
var $el = $('.navigation');
|
||||
|
||||
if (value) {
|
||||
if (value && value.length > 1) {
|
||||
var regexp = new RegExp(value, 'i');
|
||||
$el.find('li, .itemMembers').hide();
|
||||
|
||||
$el.find('li').each(function (i, v) {
|
||||
var $item = $(v);
|
||||
const $item = $(v);
|
||||
const name = $item.data('name');
|
||||
|
||||
if ($item.data('name') && regexp.test($item.data('name'))) {
|
||||
const container = $item.parent().parent().parent();
|
||||
container.show();
|
||||
container.closest('.itemMembers').show();
|
||||
container.closest('.item').show();
|
||||
if (name && regexp.test(name)) {
|
||||
const $classEntry = $item.closest('.item');
|
||||
const $members = $item.closest('.itemMembers');
|
||||
|
||||
// Do the weight thing
|
||||
$classEntry.removeData('weight');
|
||||
$classEntry.show();
|
||||
const weight = getSearchWeight(value, $classEntry);
|
||||
$classEntry.data('weight', weight);
|
||||
|
||||
$members.show();
|
||||
$classEntry.show();
|
||||
$item.show();
|
||||
$item.closest('.itemMembers').show();
|
||||
$item.closest('.item').show();
|
||||
}
|
||||
});
|
||||
|
||||
$(".navigation ul.list li.item:visible")
|
||||
.sort(weightSorter) // sort elements
|
||||
.appendTo(".navigation ul.list"); // append again to the list
|
||||
|
||||
} else {
|
||||
$el.find('.item, .itemMembers').hide();
|
||||
$('.navigation>ul>li').show();
|
||||
$el.find('.item, .itemMembers').show();
|
||||
}
|
||||
|
||||
$el.find('.list').scrollTop(0);
|
||||
|
||||
@@ -106,6 +106,15 @@ li {
|
||||
.navigation .applicationName a {
|
||||
color: #fff;
|
||||
}
|
||||
.navigation .include-modules {
|
||||
color: #e1e1e1;
|
||||
float: right;
|
||||
font-size: 0.75em;
|
||||
padding: 5px 15px;
|
||||
}
|
||||
.navigation .include-modules input {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
.navigation .search {
|
||||
padding: 10px 15px;
|
||||
}
|
||||
@@ -125,6 +134,11 @@ li {
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid #333;
|
||||
}
|
||||
|
||||
.navigation li.perfect-match {
|
||||
border: 5px solid orange;
|
||||
}
|
||||
|
||||
.navigation li.item a {
|
||||
color: #bbb;
|
||||
}
|
||||
@@ -158,6 +172,12 @@ li {
|
||||
color: #1F6B75;
|
||||
display: block;
|
||||
}
|
||||
.navigation li.item .modulelink {
|
||||
position: relative;
|
||||
font-size: 0.75em;
|
||||
padding-left: 5px;
|
||||
top: -5px;
|
||||
}
|
||||
.navigation li.item ul > li {
|
||||
font-size: 0.75em;
|
||||
padding-left: 8px;
|
||||
@@ -165,6 +185,7 @@ li {
|
||||
}
|
||||
.navigation li.item .itemMembers {
|
||||
display: none;
|
||||
padding-left: 8px;
|
||||
}
|
||||
.main {
|
||||
padding: 20px 20px;
|
||||
|
||||
@@ -10,29 +10,21 @@ function toShortName(name) {
|
||||
</div>
|
||||
<ul class="list">
|
||||
<?js
|
||||
let navbuilder;
|
||||
this.nav.forEach(navbuilder = function (item) {
|
||||
this.nav.forEach(function (item) {
|
||||
?>
|
||||
<li class="item" data-name="<?js= item.longname ?>">
|
||||
<li class="item" data-name="<?js= item.longname ?>" data-shortname="<?js= item.name.toLowerCase() ?>">
|
||||
<span class="title">
|
||||
<?js= self.linkto(item.longname, item.type === 'module' ? item.longname.replace('module:', '') : item.name) ?>
|
||||
<?js= self.linkto(item.longname, item.prettyname) ?>
|
||||
<?js if (item.type === 'namespace' &&
|
||||
(item.members.length + item.typedefs.length + item.methods.length +
|
||||
item.events.length > 0)) { ?>
|
||||
<?js } ?>
|
||||
</span>
|
||||
<ul class="members itemMembers">
|
||||
<?js
|
||||
if (item.classes.length) {
|
||||
?>
|
||||
<span class="subtitle">Classes</span>
|
||||
<?js
|
||||
item.classes.forEach(function (v) {
|
||||
navbuilder(v);
|
||||
});
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<?js if (item.module && item.module.longname) { ?>
|
||||
<span class="modulelink">
|
||||
<?js= self.linkto(item.module.longname, '↳ module') ?>
|
||||
</span>
|
||||
<?js } ?>
|
||||
<ul class="members itemMembers">
|
||||
<?js
|
||||
if (item.members.length) {
|
||||
|
||||
Reference in New Issue
Block a user