Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sidemenu and view-source button for certain modules #35

Merged
merged 1 commit into from Jan 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions bootdoc.js
Expand Up @@ -59,6 +59,16 @@ function qualifiedModuleNameToUrl(modName) {
}
}

/**
* Returns a module name corresponding to the filesystem structure.
* May differ from module <name>; decl in the module, for example for package.d modules.
*/
function currentModuleFilesystemBasedName() {
var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/')+1);
return filename.substring(0, filename.lastIndexOf('.'));
}

/**
* Create the module list in the sidebar.
*/
Expand All @@ -78,6 +88,7 @@ function populateModuleList(modTree) {
var $listHeader = $('#module-list');

function traverser(node, $parentList) {
var currentModuleName = currentModuleFilesystemBasedName();
for(var name in node.members) {
var member = node.members[name];

Expand All @@ -97,7 +108,7 @@ function populateModuleList(modTree) {
var $elem = $(treeModuleNode(name, url));
$parentList.append($elem);

if(member.qualifiedName == Title) { // Current module.
if(member.qualifiedName == currentModuleName) {
$elem.find('a').append(' <i class="icon-asterisk"></i>');

var $up = $parentList;
Expand Down Expand Up @@ -132,7 +143,7 @@ function updateBreadcrumb(qualifiedName, sourceRepoUrl) {
var part = parts[i];

if(i == parts.length - 1) {
var sourceUrl = sourceRepoUrl + '/' + moduleNameToPath(qualifiedName);
var sourceUrl = sourceRepoUrl + '/' + moduleNameToPath(currentModuleFilesystemBasedName());
$breadcrumb.append('<li class="active"><h2>' + part + ' <a href="' + sourceUrl + '"><small>view source</small></a></h2></li>');
} else {
$breadcrumb.append('<li><h2>' + part + '<span class="divider">/</span></h2></li>');
Expand Down