Commit a3b059af authored by cduvall@chromium.org's avatar cduvall@chromium.org

Extensions Docs Server: use addEventListener with branch.js

Clean up branch.js to use addEventListener.

BUG=131095

Review URL: https://chromiumcodereview.appspot.com/10828027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148773 0039d316-1c4b-4281-b951-d872f2087c98
parent c856bd3a
......@@ -2,18 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Redirects to the same page on a different branch.
*
* @param {String} The path to redirect to.
*/
(function() {
function redirectToBranch(value) {
function redirectToBranch() {
var value = event.target.value;
if (!value)
return;
var path = window.location.pathname.split('/')
window.location = value + '/' + path[path.length - 1];
var current_branch = window.bootstrap.branchInfo.current;
var path = window.location.pathname.split('/');
var index = path.indexOf(current_branch);
if (index != -1)
path[index] = value;
else
path.splice(path.length - 1, 0, value);
window.location = path.join('/');
}
window.redirectToBranch = redirectToBranch;
document.getElementById('branchChooser').addEventListener(
'change',
redirectToBranch);
})()
......@@ -13,10 +13,10 @@ def _MakeBranchDict(branch):
return {
'showWarning': branch != 'stable',
'branches': [
{ 'name': 'Stable', 'path': EXTENSIONS_URL + '/stable' },
{ 'name': 'Dev', 'path': EXTENSIONS_URL + '/dev' },
{ 'name': 'Beta', 'path': EXTENSIONS_URL + '/beta' },
{ 'name': 'Trunk', 'path': EXTENSIONS_URL + '/trunk' }
{ 'name': 'Stable', 'path': 'stable' },
{ 'name': 'Dev', 'path': 'dev' },
{ 'name': 'Beta', 'path': 'beta' },
{ 'name': 'Trunk', 'path': 'trunk' }
],
'current': branch
}
......
......@@ -55,5 +55,6 @@
}, true);
</script>
<script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script>
<script>window.bootstrap = { branchInfo: {{*branchInfo}} };</script>
</div>
</div>
{{?branchInfo.showWarning}}
<div id="branchWarning" class="displayModeWarning">
<span>WARNING: this is the {{branchInfo.current}} documentation. It may not work with the stable release of Chrome.</span>
<select id="branchChooser" onchange="redirectToBranch(this.value)">
<select id="branchChooser">
<option value="">Choose a different version...</option>
{{#branchInfo.branches}}
<option value="{{path}}">{{name}}</option>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment