Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

feat(docs): version selection #2916

Closed
wants to merge 10 commits into from
34 changes: 32 additions & 2 deletions docs/app/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ code:not(.highlight) {
.docs-menu > li {
border-top: 1px solid rgba(0, 0, 0, 0.12);
}
.docs-menu > li:nth-child(-n+2) {
border-top: none;
}

.docs-menu .md-button {
border-radius: 0;
color: inherit;
Expand All @@ -233,6 +237,30 @@ code:not(.highlight) {
white-space: normal;
width: 100%;
}

.docs-menu md-select {

/* Override md-select margins. With margins the menu will look incorrect and causes mobile list
to not be scrollable.
*/
margin: 0;
width: 100%;
}

.docs-menu md-select md-select-label {
justify-content: flex-end;
padding-top: 10px;
}

.docs-menu md-select md-select-label span {
margin-right: auto;
padding-left: 13px;
}

.docs-menu md-select .md-select-icon {
margin-right: 28px;
}

.docs-menu button.md-button::-moz-focus-inner {
padding: 0;
}
Expand All @@ -241,11 +269,12 @@ code:not(.highlight) {
}
.menu-heading {
display: block;
line-height: 40px;
line-height: 32px;
margin: 0;
padding: 0px 16px;
padding: 8px 16px 0;
text-align: left;
width: 100%;
color: rgba(0,0,0, 0.54)
}
.docs-menu li.parentActive,
.docs-menu li.parentActive .menu-toggle-list {
Expand Down Expand Up @@ -287,6 +316,7 @@ code:not(.highlight) {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
}

/* End Docs Menu */

.docs-logo:focus {
Expand Down
50 changes: 30 additions & 20 deletions docs/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,33 +463,43 @@ function($scope, COMPONENTS, BUILDCONFIG, $mdSidenav, $timeout, $mdDialog, menu,
}
}])

.controller('HomeCtrl', [
.controller('DocsVersionsCtrl', [
'$scope',
'$rootScope',
'$window',
'$http',
function($scope, $rootScope, $http) {
$rootScope.currentComponent = $rootScope.currentDoc = null;

$scope.version = "";
$scope.versionURL = "";
function($scope, $window, $http) {
var versionFromPath = $window.location.pathname.match(/^\/([^\/]+)/);

// Load build version information; to be
// used in the header bar area
var now = Math.round(new Date().getTime()/1000);
var versionFile = "version.json" + "?ts=" + now;
$scope.versions = [];
$scope.showVersionSelection = true;

$http.get("version.json")
.then(function(response){
var sha = response.data.sha || "";
var url = response.data.url;
$http.get("/docs.json")
.success(function(response) {
var commonVersions = [{ version: 'HEAD', label: 'HEAD'}];
var knownVersions = response.versions.map(function(version) {
return { version: version, label: 'v' + version };
});

if (sha) {
$scope.versionURL = url + sha;
$scope.version = sha.substr(0,6);
}
});
$scope.versions = commonVersions.concat(knownVersions);
if (versionFromPath) {
var version = versionFromPath[1];
$scope.version = version == 'latest' ? response.latest : version;
}
})
.error(function() {
$scope.showVersionSelection = false;
});

$scope.redirectToVersion = function(version) {
window.location = '/' + version;
};
}])

.controller('HomeCtrl', [
'$scope',
'$rootScope',
function($scope, $rootScope) {
$rootScope.currentComponent = $rootScope.currentDoc = null;
}])


Expand Down
5 changes: 0 additions & 5 deletions docs/app/version.json

This file was deleted.

10 changes: 9 additions & 1 deletion docs/config/template/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html ng-app="docsApp" ng-controller="DocsCtrl" lang="en" ng-strict-di>
<head>
<title ng-bind="(menu.currentSection.name || 'Material Design') + (menu.currentPage ? (' > ' + (menu.currentPage | humanizeDoc)) : '')">Material Design</title>
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<meta name="viewport" content="initial-scale=1" />

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=RobotoDraft:300,400,500,700,400italic">
<link rel="stylesheet" href="angular-material.min.css">
<link rel="stylesheet" href="docs.css">
Expand Down Expand Up @@ -31,6 +31,14 @@ <h1 class="md-toolbar-tools">

<md-content flex role="navigation">
<ul class="docs-menu">
<li class="parent-list-item" ng-show="showVersionSelection"
ng-controller="DocsVersionsCtrl">
<h2 class="menu-heading md-subhead" id="version">Current API
Version</h2>
<md-select ng-model="version" placeholder="Version">
<md-option ng-value="v.version" ng-click="redirectToVersion(v.version)" ng-repeat="v in versions">{{v.label}}</md-option>
</md-select>
</li>
<li ng-repeat="section in menu.sections" class="parent-list-item" ng-class="{'parentActive' : isSectionSelected(section)}">
<h2 class="menu-heading md-subhead" ng-if="section.type === 'heading'" id="heading_{{ section.name | nospace }}">
{{section.name}}
Expand Down
2 changes: 1 addition & 1 deletion src/components/tooltip/demoBasicUsage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h2 class="md-toolbar-tools">
<md-tooltip>
Refresh
</md-tooltip>
<md-icon md-svg-src="/img/icons/ic_refresh_24px.svg" style="width: 24px; height: 24px;">
<md-icon md-svg-src="img/icons/ic_refresh_24px.svg" style="width: 24px; height: 24px;">
</md-icon>
</md-button>
</h2>
Expand Down