Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="{{{appRoot}}}/css/app.css">
<link rel="stylesheet" type="text/css" href="{{{appRoot}}}/styleguide.css">
<link rel="stylesheet" type="text/css" href="{{{appRoot}}}/styleguide_pseudo_styles.css">
<title>{{title}}</title>
<title ng-bind="$root.pageTitle"></title>
{{{extraHead}}}
{{#filesConfig}}
<script type="text/javascript">
Expand Down
10 changes: 9 additions & 1 deletion lib/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ angular.module('sgApp', [
.state('app.index.overview', {
url: '/overview',
templateUrl: 'overview.html',
controller: function($rootScope) {
controller: function($rootScope, Styleguide) {
$rootScope.currentSection = 'overview';

$rootScope.$watch(function() {
return Styleguide.config.data;
}, function(newVal, oldVal) {
if (newVal) {
$rootScope.pageTitle = newVal.title;
}
});
}
})
.state('app.index.section', {
Expand Down
24 changes: 24 additions & 0 deletions lib/app/js/controllers/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@ angular.module('sgApp')
return !/([0-9]\.)/.test(section.reference);
}

$rootScope.$watch(function() {
return Styleguide.sections.data;
}, function(newVal, oldVal) {
parseStateHeading($scope.currentSection);
});

$rootScope.$watch(function() {
return Styleguide.config.data;
}, function(newVal, oldVal) {
parseStateHeading($scope.currentSection);
});

function parseStateHeading(section) {
if (section === 'all' && typeof Styleguide.config.data !== 'undefined') {
$rootScope.pageTitle = 'All sections - ' + Styleguide.config.data.title;
} else if (typeof Styleguide.sections.data !== 'undefined') {
for (var i = 0; i < Styleguide.sections.data.length; i++) {
if (Styleguide.sections.data[i].reference == section) {
$rootScope.pageTitle = Styleguide.sections.data[i].header + ' - ' + Styleguide.config.data.title
}
};
}
}

// Check section level (main/sub/sub-sub/sub-sub-sub)
$scope.getLevel = function(section) {
if (/([0-9]\.[0-9]\.[0-9]\.)/.test(section.reference)) {
Expand Down
1 change: 0 additions & 1 deletion lib/app/views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ <h1 class="sg">{{ config.data.title }}</h1>
</div>
</div>
</header>

<div class="sg wrapper" ng-class="isNavCollapsed ? 'collapsed' : ''">
<div class="sg side-nav-toggle"
ng-click="isNavCollapsed = !isNavCollapsed">
Expand Down
4 changes: 0 additions & 4 deletions test/structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ describe('index.html', function() {
expect(indexHtml).to.be.an('object');
});

it('should contain correct title', function() {
expect(indexHtml.contents.toString()).to.contain('<title>Test Styleguide</title>');
});

it('should contain CSS style passed as parameter', function() {
expect(indexHtml.contents.toString()).to.contain('<link rel="stylesheet" type="text/css" href="your/custom/style.css">');
});
Expand Down