Skip to content

Commit

Permalink
version switch
Browse files Browse the repository at this point in the history
  • Loading branch information
KDr2 committed Aug 21, 2019
1 parent 9bb27a1 commit 24770c9
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 22 deletions.
15 changes: 14 additions & 1 deletion docs/_includes/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,27 @@
<label class="md-icon md-icon--menu md-header-nav__button" for=__drawer></label>
</div>

<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__cell md-flex__cell--shrink">
<a class="md-header-nav__button md-logo" href="{{ site.url }}{{ site.baseurl }}/" title="{{ site.title }}">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component=title>
<span class=md-header-nav__topic>{{ site.title }}</span>
</div>
</a>
</div>

<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<div class="dropdown version-switch">
<a class="dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
</a>
<div class="dropdown-menu">
<!-- a class="dropdown-item" href="#">Stable</a -->
<!-- div class="dropdown-divider"></div -->
</div>
</div>
</div>
</div>

<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<a class="md-source" href="{{ site.baseurl }}/docs/using-turing/get-started" title="Go to Get Started">
Expand Down
16 changes: 11 additions & 5 deletions docs/_includes/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@

<div class="md-nav__source">
<a class="md-source" data-md-source="github" href="{{ site.repo }}" title="Go to repository">
<div class="md-source__icon">
<span class="md-source__icon">
<i class="fa fa-github fa-3x"></i>
</div>
<div class="md-source__repository">
</span>
<span class="md-source__repository">
{{ site.github_user }}/{{ site.github_repo }}
</div></a>
</div>
</span></a>
</div>

<div class="md-nav__dropdown">
<select id="version-selector">
<!-- option value="#" selected="selected">v 0.5.1</option -->
</select>
</div>

<label class="md-nav__title" for="__drawer"></label>

Expand Down
28 changes: 15 additions & 13 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,50 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="content-language" content="en">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
{% if site.author %}<meta name="author" content="{{ site.author }}">{% endif %}
<meta name="theme-color" content="{{ site.themeColor }}">
<meta name="theme-color" content="{{ site.themeColor }}">
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}">
<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copied" content="Copied to clipboard">
<meta name="lang:search.language" content="en">
<meta name="lang:search.pipeline.stopwords" content="True">
<meta name="lang:search.pipeline.trimmer" content="True">
<meta name="lang:search.result.none" content="No matching documents">
<meta name="lang:search.result.one" content="1 matching document">
<meta name="lang:search.result.other" content="# matching documents">
<meta name="lang:search.tokenizer" content="[\s\-]+">
<meta name="lang:search.tokenizer" content="[\s\-]+">
<script src="/versions.js"></script>
<script src="{{ site.baseurl }}/assets/js/modernizr.74668098.js"></script>
<link rel="shortcut icon" href="{{ site.baseurl }}/assets/img/favicon.ico">
<link rel="shortcut icon" href="{{ site.baseurl }}/assets/img/favicon.ico">
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/main.css">
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/palette.css">
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/header.css">

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

{% if page.url == "/" %}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/index.css">
{% endif %}

</head>
</head>

<body dir="ltr" data-md-color-primary="{{ site.themeColor }}" data-md-color-accent="{{ site.accentColor }}">
{% include navigation.html %}

<div class="md-container">
<div class="md-container">
<main class="md-main">
<div class="md-main__inner md-grid full-width" data-md-component="container">
{% include sidebar.html %}
Expand All @@ -55,7 +57,7 @@
</div>
</main>
</div>

{% include footer.html %}

<script src="{{ site.baseurl }}/assets/js/application.js"></script>
Expand All @@ -68,7 +70,7 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="{{ site.baseurl }}/assets/js/index.js"></script>
{% endif %}

{% include headers.html %}
{% include tags.html %}
{% include scrolltop.html %}
Expand Down
29 changes: 29 additions & 0 deletions docs/assets/css/header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.md-header-nav__button.md-logo * {
position: inherit;
}
.md-header-nav .dropdown {
margin: 1.6rem 0 0 -2rem;
}
.md-flex__cell--shrink .dropdown-item, .md-flex__cell--shrink .dropdown-item:hover {
color:#262626;
}
.dropdown-toggle {
opacity: 0.6;
}
.dropdown-note {
display: block;
width: 100%;
padding: .25rem 1.5rem;
clear: both;
font-weight: 400;
color: #999;
text-align: inherit;
white-space: nowrap;
background-color: transparent;
border: 0;
}
.md-nav__dropdown {
display: block;
padding: 1.2rem;
text-align: center;
}
37 changes: 35 additions & 2 deletions docs/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,45 @@ excluded_in_search: true
---
$(document).ready(function(){
$('.md-header').attr('data-md-state', 'none');

$(window).scroll(function() {
if ($(window).scrollTop() > 20) {
$('.md-header').attr('data-md-state', 'shadow');
} else {
$('.md-header').attr('data-md-state', 'none');
}
});
});

if (typeof(window.DOC_VERSIONS) == "undefined") {
window.DOC_VERSIONS = ["dev"];
}
var url_parts = /(.*:\/\/[^/]+\/)(.+?)(\/.*)/.exec(window.location.href);

$(".dropdown > a").text(url_parts[2]);
$.each(DOC_VERSIONS, function(index, value) {
if(value == url_parts[2]) {
// mobile
$("select#version-selector").append(
$('<option value="' + value + '" selected="selected">' + value + '</option>'));
return;
}
// desktop
$(".dropdown > div.dropdown-menu").append(
$('<a class="dropdown-item" href="#">' + value + '</a>'));
// mobile
$("select#version-selector").append(
$('<option value="' + value + '">' + value + '</option>'));
});

$(".dropdown > div.dropdown-menu > a").on("click", function() {
var target_version = $(this).text().trim();
if (target_version == url_parts[2]) return;
window.location.href = url_parts[1] + target_version + url_parts[3];
});

$("select#version-selector").change(function() {
var target_version = $("select#version-selector option:selected").text();
if (target_version == url_parts[2]) return;
window.location.href = url_parts[1] + target_version + url_parts[3];
});
});
2 changes: 1 addition & 1 deletion docs/jekyll-build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cd $DIR
bundle exec jekyll build > $OUTPUT 2>&1

if [[ $? != 0 ]]; then
rm $OUTPUT
rm -fr $OUTPUT
gem install bundler
bundle install
else
Expand Down

0 comments on commit 24770c9

Please sign in to comment.