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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/template_data_source.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/server2/static/js/branch.js
diff --git a/chrome/common/extensions/docs/server2/static/js/branch.js b/chrome/common/extensions/docs/server2/static/js/branch.js
index 1b1206b45b5248b95b7f0007c17b7bbe56d90c43..3efea694089790ac3f453b6a3a2e3072f0173525 100644
--- a/chrome/common/extensions/docs/server2/static/js/branch.js
+++ b/chrome/common/extensions/docs/server2/static/js/branch.js
@@ -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);
})()
« 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