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

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: 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 unified diff | Download patch | Annotate | Revision Log
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() {
12 if (!value) 7 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.
13 return; 8 return;
14 var path = window.location.pathname.split('/') 9 var current_branch = window.bootstrap.branchInfo.current;
15 window.location = value + '/' + path[path.length - 1]; 10 var path = window.location.pathname.split('/');
11 var index = path.indexOf(current_branch);
12 if (index != -1)
13 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
14 else
15 path.splice(path.length - 1, 0, this.value);
16 window.location = path.join('/');
16 } 17 }
17 18
18 window.redirectToBranch = redirectToBranch; 19 document.getElementById('branchChooser').addEventListener(
20 'change',
21 redirectToBranch,
22 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
19 })() 23 })()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698