Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

Commit 85dc94c

Browse files
committed
Merge branch 'nc-version-select'
* nc-version-select: Add multi-version support.
2 parents b7975dc + bd8baa6 commit 85dc94c

File tree

7 files changed

+98
-24
lines changed

7 files changed

+98
-24
lines changed

_assets/css/theme.css.less

+36-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ body {
7777

7878
body.home {
7979
#header {
80-
height: 235px;
80+
height: 275px;
8181

8282
h1 {
8383
font-size: 60px;
@@ -89,6 +89,19 @@ body.home {
8989
font-size: 20px;
9090
display: block;
9191
}
92+
93+
.dropdown {
94+
margin-top: 12px;
95+
button {
96+
font-size: 17px;
97+
}
98+
.dropdown-menu {
99+
left:41%;
100+
}
101+
a {
102+
color: #333;
103+
}
104+
}
92105
}
93106
}
94107

@@ -173,13 +186,19 @@ body.home {
173186
.select2-chosen, .select2-choice > span:first-child {
174187
padding-top: 7px;
175188
}
176-
.input-group .form-control-feedback {
189+
.input .form-control-feedback, .input-group .form-control-feedback {
177190
top: 0;
178191
}
179-
.input-group-lg .form-control-feedback {
192+
.input-lg .form-control-feedback, .input-group-lg .form-control-feedback {
180193
top: 7px;
181194
right: 7px;
182195
}
196+
#home-select.col-xs-3 {
197+
padding-right: 5px;
198+
}
199+
#home-search.col-xs-9 {
200+
padding-left: 3px;
201+
}
183202

184203
#wrapper .select2-arrow { display: none; }
185204

@@ -192,6 +211,20 @@ body.home {
192211
margin: 35px 0 0;
193212
width: 100%;
194213
}
214+
215+
.dropdown {
216+
margin-top: 8px;
217+
font-weight: normal;
218+
font-size: 14px;
219+
220+
.btn-default {
221+
background: transparent;
222+
}
223+
}
224+
225+
#select-container {
226+
width: 100%;
227+
}
195228

196229
#accordion {
197230
display: none;

_assets/js/swift-site.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,15 @@ $(function() {
125125
if (shouldHideInherited) hideInherited(true);
126126
}
127127

128-
// revise link to alternate version
128+
// revise links to alternate version
129+
$('.dropdown-menu a').each(function(i, item) {
130+
item.href = (item.href + location.href).replace(/(v[.a-z0-9]+\/).+?(\/v[.a-z0-9]+\/|$)/, '$1')
131+
});
132+
/*
129133
$('#version a').each(function(i, item) {
130134
item.href = (item.href + location.href).replace(/(v[.a-z0-9]+\/).+?(\/v[.a-z0-9]+\/|$)/, '$1');
131135
});
136+
*/
132137

133138
// highlight key parts of identifiers
134139
$('.toggle-link').each(function(i, link) {

_data/versions.csv

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
path,name,note
2+
/v3.0/,Swift 3.0,swift/master
3+
/v2.2/,Swift 2.2,Xcode 7.3 beta
4+
/v2.1/,Swift 2.1,Xcode 7.2
5+
/v1.2/,Swift 1.2,Xcode 6.3+

_includes/header.html

+21-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
{% capture homeUrl %}{% if page.url contains 'swift-2' %}/swift-2{% endif %}/{% endcapture %}
1+
{% capture homeUrl %}{% if page.url contains 'swift-2' %}/swift-2{% endif %}/{% endcapture %}
2+
{% assign current = 'Swift 2.2 (Xcode 7.3 beta)' %}
3+
{% for version in site.data.versions %}
4+
{% if page.url contains version.path %}
5+
{% capture current %}{{ version.name }} ({{ version.note }}){% endcapture %}
6+
{% endif %}
7+
{% endfor %}
8+
29
<nav class="navbar navbar-default" role="navigation" id="navbar">
310
<div class="container-fluid">
411
<!-- Brand and toggle get grouped for better mobile display -->
@@ -41,18 +48,19 @@ <h1><a href="{{ homeUrl }}">{{ site.title }}</a></h1>
4148
<input type="hidden" class="form-control select2">
4249
<span class="glyphicon glyphicon-search form-control-feedback"></span>
4350
</div>
44-
{% endif %}
45-
</div>
46-
</div>
51+
52+
<div class="dropdown">
53+
<button class="btn btn-default dropdown-toggle" type="button" id="versionMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
54+
{{ current }}
55+
<span class="caret"></span>
56+
</button>
57+
<ul class="dropdown-menu" aria-labelledby="versionMenu">
58+
{% for version in site.data.versions %}
59+
<li><a href="{{ version.path }}">{{ version.name }} ({{ version.note }})</a></li>
60+
{% endfor %}
61+
</ul>
62+
</div>
4763

48-
{% unless page.url contains "/news" or page.noversions %}
49-
<div id="version">
50-
<div class="container">
51-
{% if page.url contains "/v1.2" %}
52-
Swift version: <strong>1.2</strong> &nbsp;|&nbsp; <a href="/v2.1/">2.1</a>
53-
{% else %}
54-
Swift version: <a href="/v1.2/">1.2</a> &nbsp;|&nbsp; <strong>2.1</strong>
5564
{% endif %}
5665
</div>
57-
</div>
58-
{% endunless %}
66+
</div>

_includes/sidebar.html

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
{% if page.isdoc %}
2+
{% assign current = 'Swift 2.2 (Xcode 7.3 beta)' %}
3+
{% for version in site.data.versions %}
4+
{% if page.url contains version.path %}
5+
{% capture current %}{{ version.name }} ({{ version.note }}){% endcapture %}
6+
{% endif %}
7+
{% endfor %}
18
<div id="intranav">
29
<h4>On this page</h4>
310
<ul id="chapters">
@@ -7,4 +14,18 @@ <h4>On this page</h4>
714
<h4>Display</h4>
815
<ul id="display">
916
</ul>
10-
</div>
17+
18+
<h4>Swift Version</h4>
19+
<div class="dropdown">
20+
<button class="btn btn-default dropdown-toggle" type="button" id="versionMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
21+
{{ current }}
22+
<span class="caret"></span>
23+
</button>
24+
<ul class="dropdown-menu" aria-labelledby="versionMenu">
25+
{% for version in site.data.versions %}
26+
<li><a href="{{ version.path }}">{{ version.name }} ({{ version.note }})</a></li>
27+
{% endfor %}
28+
</ul>
29+
</div>
30+
</div>
31+
{% endif %}

_layouts/default.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: wrapper
3-
3+
isdoc: true
44
---
55
<header>
66
<h2>{{ page.title }}</h2>

_layouts/wrapper.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212

1313
<div id="fixed-sidebar" data-spy="">
1414

15-
<div class="form-group input-group has-feedback">
16-
<input type="hidden" class="form-control select2">
17-
<span class="glyphicon glyphicon-search form-control-feedback"></span>
18-
</div>
19-
15+
<div class="form-group">
16+
<div class="input-group has-feedback" id="select-container">
17+
<input type="hidden" class="form-control select2">
18+
<span class="glyphicon glyphicon-search form-control-feedback"></span>
19+
</div>
20+
</div>
21+
2022
{% include sidebar.html %}
2123

2224
</div>

0 commit comments

Comments
 (0)