Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit aa7dbf0

Browse files
docs(indexPage): move latest versions to the top
Closes #7513
1 parent bd2fb3d commit aa7dbf0

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

docs/app/src/versions.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1+
"use strict";
2+
13
angular.module('versions', [])
24

35
.controller('DocsVersionsCtrl', ['$scope', '$location', '$window', 'NG_VERSIONS', function($scope, $location, $window, NG_VERSIONS) {
4-
$scope.docs_versions = NG_VERSIONS;
56
$scope.docs_version = NG_VERSIONS[0];
67

8+
for(var i=0, minor = NaN; i < NG_VERSIONS.length; i++) {
9+
var version = NG_VERSIONS[i];
10+
// NaN will give false here
11+
if (minor <= version.minor) {
12+
continue;
13+
}
14+
version.isLatest = true;
15+
minor = version.minor;
16+
}
17+
18+
$scope.docs_versions = NG_VERSIONS;
19+
$scope.getGroupName = function(v) {
20+
return v.isLatest ? 'Latest' : (v.isStable ? 'Stable' : 'Unstable');
21+
};
22+
723
$scope.jumpToDocsVersion = function(version) {
824
var currentPagePath = $location.path();
925

1026
// TODO: We need to do some munging of the path for different versions of the API...
11-
27+
1228

1329
$window.location = version.docsUrl + currentPagePath;
1430
};

docs/config/templates/indexPage.template.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ <h4 class="search-results-group-heading">{{ key }}</h4>
175175
<div class="container main-grid main-header-grid">
176176
<div class="grid-left">
177177
<div ng-controller="DocsVersionsCtrl" class="picker version-picker">
178-
<select ng-options="v as ('v' + v.version + (v.isSnapshot ? ' (snapshot)' : '')) group by (v.isStable?'Stable':'Unstable') for v in docs_versions"
178+
<select ng-options="v as ('v' + v.version + (v.isSnapshot ? ' (snapshot)' : '')) group by getGroupName(v) for v in docs_versions"
179179
ng-model="docs_version"
180180
ng-change="jumpToDocsVersion(docs_version)"
181181
class="docs-version-jump">

0 commit comments

Comments
 (0)