Skip to content

Commit 6bdd17f

Browse files
committed
add version select dropdown
1 parent 272704a commit 6bdd17f

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

themes/vue/layout/partials/sidebar.ejs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
<%- partial('partials/main_menu') %>
44
</ul>
55
<div class="list">
6-
<h2><%- type === 'api' ? 'API Reference' : (type.charAt(0).toUpperCase() + type.slice(1)) %></h2>
6+
<h2>
7+
<%- type === 'api' ? 'API' : (type.charAt(0).toUpperCase() + type.slice(1)) %>
8+
<select class="version-select">
9+
<option selected>1.0</option>
10+
<option>0.12</option>
11+
<option>0.11</option>
12+
</select>
13+
</h2>
714
<ul class="menu-root">
815
<% type !== 'api' && site.pages.find({type: type}).sort('order').each(function (p) { %>
916
<li>

themes/vue/source/css/page.styl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ $header-height = 40px
105105
margin 0
106106
line-height 1.8em
107107
padding-left 1em
108+
.version-select
109+
vertical-align middle
110+
margin-left 5px
108111
.menu-root
109112
padding-left 0
110113
.menu-sub

themes/vue/source/js/common.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,16 @@
169169

170170
_st('install','HgpxvBc7pUaPUWmG9sgv','2.0.0');
171171

172+
// version select
173+
document.querySelector('.version-select').addEventListener('change', function (e) {
174+
var version = e.target.value
175+
if (version.indexOf('1.') !== 0) {
176+
version = version.replace('.', '')
177+
var section = window.location.pathname.match(/\/(\w+?)\//)[1]
178+
window.location.assign('http://' + version + '.vuejs.org/' + section + '/')
179+
} else {
180+
// TODO when 1.x is out
181+
}
182+
})
183+
172184
})()

0 commit comments

Comments
 (0)