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

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: 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
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..6348e99d8c02867b81900946799b40922e200d06 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) {
- if (!value)
+ function redirectToBranch() {
+ if (!this.value)
not at google - send to devlin 2012/07/27 03:30:39 "this" is evil. This method gets called with the e
cduvall 2012/07/27 17:51:10 Done.
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] = this.value;
not at google - send to devlin 2012/07/27 03:30:39 need to make sure that if value is empty the eleme
cduvall 2012/07/27 17:51:10 Value will never be empty, the branchChooser uses
+ else
+ path.splice(path.length - 1, 0, this.value);
+ window.location = path.join('/');
}
- window.redirectToBranch = redirectToBranch;
+ document.getElementById('branchChooser').addEventListener(
+ 'change',
+ redirectToBranch,
+ true);
not at google - send to devlin 2012/07/27 03:30:39 hm haven't seen "true" here before. Why do you nee
cduvall 2012/07/27 17:51:10 It was so I could use 'this' in the callback. Now
})()

Powered by Google App Engine
This is Rietveld 408576698