Skip to content

Commit

Permalink
add version switcher dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed May 19, 2015
1 parent c228014 commit 4e93c16
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 40 deletions.
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
15 changes: 14 additions & 1 deletion docs/versions.txt
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
master
master
v0.5.0
v0.6.0
v0.7.0
v0.7.1
v0.8.0
v0.8.1
v0.9.0
v0.10.0
v0.11.0
v0.12.0
v0.13.1
v0.13.2
v0.14.0

0 comments on commit 4e93c16

Please sign in to comment.