Merge pull request #1934 from killercup/feature/docs-version-ordering
Docs index: Sort versions in a nice way
This commit is contained in:
commit
681a3031b5
@ -34,9 +34,9 @@
|
||||
</div>
|
||||
|
||||
<ul class="list-group">
|
||||
<a class="list-group-item" ng-repeat="version in data | orderBy"
|
||||
<a class="list-group-item" ng-repeat="version in data | orderBy:versionOrder:true"
|
||||
href="./{{version}}/index.html">
|
||||
{{version}}
|
||||
{{normalizeVersion(version)}}
|
||||
</a>
|
||||
</ul>
|
||||
</article>
|
||||
@ -54,6 +54,22 @@
|
||||
.controller('docVersions', function ($scope, $http) {
|
||||
$scope.loading = true;
|
||||
|
||||
$scope.normalizeVersion = function(v) {
|
||||
return v.replace(/^v/, '');
|
||||
};
|
||||
|
||||
$scope.versionOrder = function(v) {
|
||||
if (v === 'master') { return Infinity; }
|
||||
if (v === 'current') { return Number.MAX_VALUE; }
|
||||
|
||||
return $scope.normalizeVersion(v)
|
||||
.split('.')
|
||||
.reverse()
|
||||
.reduce(function(acc, val, index) {
|
||||
return acc + (val * Math.pow(100, index));
|
||||
}, 0);
|
||||
}
|
||||
|
||||
$http.get('./versions.json')
|
||||
.success(function (data) {
|
||||
$scope.data = data;
|
||||
|
Loading…
Reference in New Issue
Block a user