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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/SidebarPane.js

Issue 2153153003: DevTools: remove dead code, disambiguate expand for sections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 toolbar: function() 49 toolbar: function()
50 { 50 {
51 if (!this._toolbar) { 51 if (!this._toolbar) {
52 this._toolbar = new WebInspector.Toolbar(""); 52 this._toolbar = new WebInspector.Toolbar("");
53 this._toolbar.element.addEventListener("click", consumeEvent); 53 this._toolbar.element.addEventListener("click", consumeEvent);
54 this.element.insertBefore(this._toolbar.element, this.element.firstC hild); 54 this.element.insertBefore(this._toolbar.element, this.element.firstC hild);
55 } 55 }
56 return this._toolbar; 56 return this._toolbar;
57 }, 57 },
58 58
59 /** 59 expandPane: function()
60 * @return {string}
61 */
62 title: function()
63 {
64 return this._title;
65 },
66
67 expand: function()
68 { 60 {
69 this.onContentReady(); 61 this.onContentReady();
70 }, 62 },
71 63
72 onContentReady: function() 64 onContentReady: function()
73 { 65 {
74 if (this._expandCallback) 66 if (this._expandCallback)
75 this._expandCallback(); 67 this._expandCallback();
76 else 68 else
77 this._expandPending = true; 69 this._expandPending = true;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 /** 101 /**
110 * @constructor 102 * @constructor
111 * @param {!Element} container 103 * @param {!Element} container
112 * @param {!WebInspector.SidebarPane} pane 104 * @param {!WebInspector.SidebarPane} pane
113 */ 105 */
114 WebInspector.SidebarPaneTitle = function(container, pane) 106 WebInspector.SidebarPaneTitle = function(container, pane)
115 { 107 {
116 this._pane = pane; 108 this._pane = pane;
117 109
118 this.element = container.createChild("div", "sidebar-pane-title"); 110 this.element = container.createChild("div", "sidebar-pane-title");
119 this.element.textContent = pane.title(); 111 this.element.textContent = pane._title;
120 this.element.tabIndex = 0; 112 this.element.tabIndex = 0;
121 this.element.addEventListener("click", this._toggleExpanded.bind(this), fals e); 113 this.element.addEventListener("click", this._toggleExpanded.bind(this), fals e);
122 this.element.addEventListener("keydown", this._onTitleKeyDown.bind(this), fa lse); 114 this.element.addEventListener("keydown", this._onTitleKeyDown.bind(this), fa lse);
123 } 115 }
124 116
125 WebInspector.SidebarPaneTitle.prototype = { 117 WebInspector.SidebarPaneTitle.prototype = {
126 _expand: function() 118 _expand: function()
127 { 119 {
128 this.element.classList.add("expanded"); 120 this.element.classList.add("expanded");
129 this._pane.show(this.element.parentElement, /** @type {?Element} */ (thi s.element.nextSibling)); 121 this._pane.show(this.element.parentElement, /** @type {?Element} */ (thi s.element.nextSibling));
130 }, 122 },
131 123
132 _collapse: function() 124 _collapse: function()
133 { 125 {
134 this.element.classList.remove("expanded"); 126 this.element.classList.remove("expanded");
135 if (this._pane.element.parentNode === this.element.parentNode) 127 if (this._pane.element.parentNode === this.element.parentNode)
136 this._pane.detach(); 128 this._pane.detach();
137 }, 129 },
138 130
139 _toggleExpanded: function() 131 _toggleExpanded: function()
140 { 132 {
141 if (this.element.classList.contains("expanded")) 133 if (this.element.classList.contains("expanded"))
142 this._collapse(); 134 this._collapse();
143 else 135 else
144 this._pane.expand(); 136 this._pane.expandPane();
145 }, 137 },
146 138
147 /** 139 /**
148 * @param {!Event} event 140 * @param {!Event} event
149 */ 141 */
150 _onTitleKeyDown: function(event) 142 _onTitleKeyDown: function(event)
151 { 143 {
152 if (isEnterKey(event) || event.keyCode === WebInspector.KeyboardShortcut .Keys.Space.code) 144 if (isEnterKey(event) || event.keyCode === WebInspector.KeyboardShortcut .Keys.Space.code)
153 this._toggleExpanded(); 145 this._toggleExpanded();
154 } 146 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 WebInspector.TabbedPane.call(this); 198 WebInspector.TabbedPane.call(this);
207 this.element.classList.add("sidebar-tabbed-pane"); 199 this.element.classList.add("sidebar-tabbed-pane");
208 } 200 }
209 201
210 WebInspector.SidebarTabbedPane.prototype = { 202 WebInspector.SidebarTabbedPane.prototype = {
211 /** 203 /**
212 * @param {!WebInspector.SidebarPane} pane 204 * @param {!WebInspector.SidebarPane} pane
213 */ 205 */
214 addPane: function(pane) 206 addPane: function(pane)
215 { 207 {
216 var title = pane.title(); 208 var title = pane._title;
217 this.appendTab(title, title, pane); 209 this.appendTab(title, title, pane);
218 if (pane._toolbar) 210 if (pane._toolbar)
219 pane.element.insertBefore(pane._toolbar.element, pane.element.firstC hild); 211 pane.element.insertBefore(pane._toolbar.element, pane.element.firstC hild);
220 pane._attached(this._setPaneVisible.bind(this, pane), this.selectTab.bin d(this, title)); 212 pane._attached(this._setPaneVisible.bind(this, pane), this.selectTab.bin d(this, title));
221 }, 213 },
222 214
223 /** 215 /**
224 * @param {!WebInspector.SidebarPane} pane 216 * @param {!WebInspector.SidebarPane} pane
225 * @param {boolean} visible 217 * @param {boolean} visible
226 */ 218 */
227 _setPaneVisible: function(pane, visible) 219 _setPaneVisible: function(pane, visible)
228 { 220 {
229 var title = pane._title; 221 var title = pane._title;
230 if (visible) { 222 if (visible) {
231 if (!this.hasTab(title)) 223 if (!this.hasTab(title))
232 this.appendTab(title, title, pane); 224 this.appendTab(title, title, pane);
233 } else { 225 } else {
234 if (this.hasTab(title)) 226 if (this.hasTab(title))
235 this.closeTab(title); 227 this.closeTab(title);
236 } 228 }
237 }, 229 },
238 230
239 __proto__: WebInspector.TabbedPane.prototype 231 __proto__: WebInspector.TabbedPane.prototype
240 } 232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698