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

Side by Side Diff: chrome/browser/resources/net_internals/tabswitcherview.js

Issue 1525016: Make it possible to switch between views of the new net-internals page by usi... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix long lines Created 10 years, 8 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 | « chrome/browser/resources/net_internals/main.js ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 /** 5 /**
6 * TabSwitcher is an implementation of View that handles tab switching. 6 * TabSwitcher is an implementation of View that handles tab switching.
7 * 7 *
8 * +-----------------------------------+ 8 * +-----------------------------------+
9 * | Tab1 / Tab2 / Tab3 / .. | <- tab handle view 9 * | Tab1 / Tab2 / Tab3 / .. | <- tab handle view
10 * +-----------------------------------+ 10 * +-----------------------------------+
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 }; 57 };
58 58
59 /** 59 /**
60 * Adds a new tab (initially hidden). 60 * Adds a new tab (initially hidden).
61 * 61 *
62 * @param {String} id The ID for DOM node that will be made clickable to select 62 * @param {String} id The ID for DOM node that will be made clickable to select
63 * this tab. This is also the ID we use to identify the 63 * this tab. This is also the ID we use to identify the
64 * "tab". 64 * "tab".
65 * @param {!View} view The tab's actual contents. 65 * @param {!View} view The tab's actual contents.
66 */ 66 */
67 TabSwitcherView.prototype.addTab = function(id, contentView) { 67 TabSwitcherView.prototype.addTab = function(id, contentView, switchOnClick) {
68 var tab = new TabEntry(id, contentView); 68 var tab = new TabEntry(id, contentView);
69 this.tabs_.push(tab); 69 this.tabs_.push(tab);
70 70
71 // Attach a click handler, used to switch to the tab. 71 if (switchOnClick) {
72 var self = this; 72 // Attach a click handler, used to switch to the tab.
73 tab.getTabHandleNode().onclick = function() { 73 var self = this;
74 self.switchToTab(id); 74 tab.getTabHandleNode().onclick = function() {
75 }; 75 self.switchToTab(id);
76 };
77 }
76 78
77 // Start tabs off as hidden. 79 // Start tabs off as hidden.
78 tab.contentView.show(false); 80 tab.contentView.show(false);
79 }; 81 };
80 82
81 /** 83 /**
82 * Returns the currently selected tab, or null if there is none. 84 * Returns the currently selected tab, or null if there is none.
83 * @returns {!TabEntry} 85 * @returns {!TabEntry}
84 */ 86 */
85 TabSwitcherView.prototype.findActiveTab = function() { 87 TabSwitcherView.prototype.findActiveTab = function() {
(...skipping 23 matching lines...) Expand all
109 */ 111 */
110 TabSwitcherView.prototype.switchToTab = function(id) { 112 TabSwitcherView.prototype.switchToTab = function(id) {
111 var oldTab = this.findActiveTab(); 113 var oldTab = this.findActiveTab();
112 if (oldTab) 114 if (oldTab)
113 oldTab.setSelected(false); 115 oldTab.setSelected(false);
114 116
115 var newTab = this.findTabById(id); 117 var newTab = this.findTabById(id);
116 newTab.setSelected(true); 118 newTab.setSelected(true);
117 }; 119 };
118 120
121 TabSwitcherView.prototype.getAllTabIds = function() {
122 var ids = [];
123 for (var i = 0; i < this.tabs_.length; ++i)
124 ids.push(this.tabs_[i].id);
125 return ids;
126 };
127
119 //----------------------------------------------------------------------------- 128 //-----------------------------------------------------------------------------
120 129
121 /** 130 /**
122 * @constructor 131 * @constructor
123 */ 132 */
124 function TabEntry(id, contentView) { 133 function TabEntry(id, contentView) {
125 this.id = id; 134 this.id = id;
126 this.contentView = contentView; 135 this.contentView = contentView;
127 } 136 }
128 137
129 TabEntry.prototype.setSelected = function(isSelected) { 138 TabEntry.prototype.setSelected = function(isSelected) {
130 this.active = isSelected; 139 this.active = isSelected;
131 changeClassName(this.getTabHandleNode(), 'selected', isSelected); 140 changeClassName(this.getTabHandleNode(), 'selected', isSelected);
132 this.contentView.show(isSelected); 141 this.contentView.show(isSelected);
133 }; 142 };
134 143
135 /** 144 /**
136 * Returns the DOM node that is used to select the tab. 145 * Returns the DOM node that is used to select the tab.
137 */ 146 */
138 TabEntry.prototype.getTabHandleNode = function() { 147 TabEntry.prototype.getTabHandleNode = function() {
139 return document.getElementById(this.id); 148 return document.getElementById(this.id);
140 }; 149 };
141 150
OLDNEW
« no previous file with comments | « chrome/browser/resources/net_internals/main.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698