Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1676)

Side by Side Diff: chrome/common/extensions/docs/server2/static/js/branch.js

Issue 10828027: Extensions Docs Server: use addEventListener with branch.js (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/template_data_source.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /**
6 * Redirects to the same page on a different branch.
7 *
8 * @param {String} The path to redirect to.
9 */
10 (function() { 5 (function() {
11 function redirectToBranch(value) { 6 function redirectToBranch() {
7 var value = event.target.value;
12 if (!value) 8 if (!value)
13 return; 9 return;
14 var path = window.location.pathname.split('/') 10 var current_branch = window.bootstrap.branchInfo.current;
15 window.location = value + '/' + path[path.length - 1]; 11 var path = window.location.pathname.split('/');
12 var index = path.indexOf(current_branch);
13 if (index != -1)
14 path[index] = value;
15 else
16 path.splice(path.length - 1, 0, value);
17 window.location = path.join('/');
16 } 18 }
17 19
18 window.redirectToBranch = redirectToBranch; 20 document.getElementById('branchChooser').addEventListener(
21 'change',
22 redirectToBranch);
19 })() 23 })()
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/template_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698