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

add version switcher dropdown #612

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
10 changes: 0 additions & 10 deletions docs/site/components/docs/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@
Report an Issue
</a>
</div>
<div class="col margin-vertical">
<a href="#/docs/history" ng-show="showReference"
class="v-btn">
<img src="site/img/icon-arrow-bullet.svg" />
Version History (<i>{{version}}</i>)
</a>
</div>
<div>
<div ng-if="lastBuiltDate" class="build-date">Docs last built {{lastBuiltDate}}.</div>
</div>
</div>
</header>
</script>
Expand Down
19 changes: 0 additions & 19 deletions docs/site/components/docs/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ angular
.when('/docs', {
redirectTo: '/docs/' + versions[0]
})
.when('/docs/history', {
controller: 'HistoryCtrl',
templateUrl: 'site/components/docs/docs.html'
})
.when('/docs/:version', {
controller: 'DocsCtrl',
templateUrl: 'site/components/docs/docs.html',
Expand Down Expand Up @@ -325,13 +321,6 @@ angular
return !$routeParams.class && doc.toLowerCase() === $routeParams.module;
};

if ($routeParams.version === 'master') {
$http.get('https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/commits?sha=gh-pages&per_page=1')
.then(function(resp) {
$scope.lastBuiltDate = moment(resp.data[0].commit.committer.date).format('MMMM Do, YYYY');
});
}

// Set the page title (used in the header).
var pageTitle = [];

Expand Down Expand Up @@ -359,12 +348,4 @@ angular
$scope.methods = methods;
$scope.version = $routeParams.version;
$scope.versions = versions;
})

.controller('HistoryCtrl', function($scope, versions) {
'use strict';

$scope.pageTitle = 'Node.js Docs Versions';
$scope.showHistory = true;
$scope.versions = versions;
});
16 changes: 15 additions & 1 deletion docs/site/components/subpage/subpage-directive.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular
.module('gcloud.subpage', ['gcloud.header'])
.directive('subpage', function($rootScope, $location, $parse, getLinks) {
.directive('subpage', function($rootScope, $location, $http, $parse, getLinks, versions) {
'use strict';

return {
Expand All @@ -11,6 +11,20 @@ angular
$scope.links = getLinks();
$scope.headerTemplateUrl = attrs.headerTemplateurl;

$scope.versionSelected = $rootScope.ACTIVE_VERSION;
$scope.versions = versions;

$scope.loadDocsVersion = function(newVersion) {
$location.path('docs/' + newVersion);
};

if ($scope.versionSelected === 'master') {
$http.get('https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/commits?sha=gh-pages&per_page=1')
.then(function(resp) {
$scope.lastBuiltDate = moment(resp.data[0].commit.committer.date).format('MMMM Do, YYYY');
});
}

if (attrs.isActiveUrl) {
$scope.isActiveUrl = $parse(attrs.isActiveUrl)($scope);
} else {
Expand Down
13 changes: 13 additions & 0 deletions docs/site/components/subpage/subpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ <h1 class="logo">
<section class="content" ng-transclude></section>

<nav class="side-nav">
<div class="side-nav--meta">
<small><em>Browsing Version</em></small>

<select
ng-model="versionSelected"
ng-options="version for version in versions"
ng-change="loadDocsVersion(versionSelected)"></select>

<div ng-if="lastBuiltDate">
<small><em>Docs last built {{lastBuiltDate}}.</em></small>
</div>
</div>

<ul class="page-sections">
<li ng-repeat="page in links">
<a
Expand Down
22 changes: 13 additions & 9 deletions docs/site/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,13 @@ ul {
margin: 10px;
}

.margin-left {
margin-left: 10px;
}

.margin-vertical {
margin: 10px 0;
margin-top: 10px;
margin-bottom: 10px;
}

.subtle {
Expand Down Expand Up @@ -926,6 +931,13 @@ ul {
background: #efefef;
}

.side-nav .side-nav--meta {
padding: 10px;
background-color: #f5f5f5;
text-align: center;
margin-bottom: 10px;
}

.side-nav a {
display: block;
padding: 0.3em 2em;
Expand Down Expand Up @@ -1131,10 +1143,6 @@ ul {
height: 0.6em;
}

.build-date {
margin-left: 0em;
}

}

@media only screen and (min-width: 45em) {
Expand All @@ -1143,10 +1151,6 @@ ul {
line-height: normal;
margin-left: .5em;
}

.build-date {
margin-left: 0.5em;
}
}

@media only screen and (min-width: 50em) {
Expand Down