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

Side by Side Diff: Source/devtools/front_end/ui/TabbedPane.js

Issue 367093003: DevTools: More code reduce via using document.createElementWithClass and document.createChild. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
« no previous file with comments | « Source/devtools/front_end/ui/SuggestBox.js ('k') | Source/devtools/front_end/ui/TextPrompt.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 * @param {!WebInspector.TabbedPaneTab} tab 501 * @param {!WebInspector.TabbedPaneTab} tab
502 */ 502 */
503 _hideTabElement: function(tab) 503 _hideTabElement: function(tab)
504 { 504 {
505 this._tabsElement.removeChild(tab.tabElement); 505 this._tabsElement.removeChild(tab.tabElement);
506 tab._shown = false; 506 tab._shown = false;
507 }, 507 },
508 508
509 _createDropDownButton: function() 509 _createDropDownButton: function()
510 { 510 {
511 var dropDownContainer = document.createElement("div"); 511 var dropDownContainer = document.createElementWithClass("div", "tabbed-p ane-header-tabs-drop-down-container");
512 dropDownContainer.classList.add("tabbed-pane-header-tabs-drop-down-conta iner");
513 var dropDownButton = dropDownContainer.createChild("div", "tabbed-pane-h eader-tabs-drop-down"); 512 var dropDownButton = dropDownContainer.createChild("div", "tabbed-pane-h eader-tabs-drop-down");
514 dropDownButton.appendChild(document.createTextNode("\u00bb")); 513 dropDownButton.createTextChild("\u00bb");
515 514
516 this._dropDownMenu = new WebInspector.DropDownMenu(); 515 this._dropDownMenu = new WebInspector.DropDownMenu();
517 this._dropDownMenu.addEventListener(WebInspector.DropDownMenu.Events.Ite mSelected, this._dropDownMenuItemSelected, this); 516 this._dropDownMenu.addEventListener(WebInspector.DropDownMenu.Events.Ite mSelected, this._dropDownMenuItemSelected, this);
518 dropDownButton.appendChild(this._dropDownMenu.element); 517 dropDownButton.appendChild(this._dropDownMenu.element);
519 518
520 return dropDownContainer; 519 return dropDownContainer;
521 }, 520 },
522 521
523 /** 522 /**
524 * @param {!WebInspector.Event} event 523 * @param {!WebInspector.Event} event
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 /** 891 /**
893 * @param {!WebInspector.TabbedPaneTabDelegate} delegate 892 * @param {!WebInspector.TabbedPaneTabDelegate} delegate
894 */ 893 */
895 setDelegate: function(delegate) 894 setDelegate: function(delegate)
896 { 895 {
897 this._delegate = delegate; 896 this._delegate = delegate;
898 }, 897 },
899 898
900 _createIconElement: function(tabElement, titleElement) 899 _createIconElement: function(tabElement, titleElement)
901 { 900 {
902 var iconElement = document.createElement("span"); 901 var iconElement = document.createElementWithClass("span", "tabbed-pane-h eader-tab-icon " + this._iconClass);
903 iconElement.className = "tabbed-pane-header-tab-icon " + this._iconClass ;
904 if (this._iconTooltip) 902 if (this._iconTooltip)
905 iconElement.title = this._iconTooltip; 903 iconElement.title = this._iconTooltip;
906 tabElement.insertBefore(iconElement, titleElement); 904 tabElement.insertBefore(iconElement, titleElement);
907 return iconElement; 905 return iconElement;
908 }, 906 },
909 907
910 /** 908 /**
911 * @param {boolean} measuring 909 * @param {boolean} measuring
912 * @return {!Element} 910 * @return {!Element}
913 */ 911 */
914 _createTabElement: function(measuring) 912 _createTabElement: function(measuring)
915 { 913 {
916 var tabElement = document.createElement("div"); 914 var tabElement = document.createElementWithClass("div", "tabbed-pane-hea der-tab");
917 tabElement.classList.add("tabbed-pane-header-tab");
918 tabElement.id = "tab-" + this._id; 915 tabElement.id = "tab-" + this._id;
919 tabElement.tabIndex = -1; 916 tabElement.tabIndex = -1;
920 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabb edPane, this.id, true); 917 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabb edPane, this.id, true);
921 918
922 var titleElement = tabElement.createChild("span", "tabbed-pane-header-ta b-title"); 919 var titleElement = tabElement.createChild("span", "tabbed-pane-header-ta b-title");
923 titleElement.textContent = this.title; 920 titleElement.textContent = this.title;
924 titleElement.title = this.tooltip || ""; 921 titleElement.title = this.tooltip || "";
925 if (this._iconClass) 922 if (this._iconClass)
926 this._createIconElement(tabElement, titleElement); 923 this._createIconElement(tabElement, titleElement);
927 if (!measuring) 924 if (!measuring)
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 { 1180 {
1184 if (this._views.contains(id)) 1181 if (this._views.contains(id))
1185 return /** @type {!WebInspector.View} */ (this._views.get(id)); 1182 return /** @type {!WebInspector.View} */ (this._views.get(id));
1186 var view = this._extensions[id] ? /** @type {!WebInspector.View} */ (thi s._extensions[id].instance()) : null; 1183 var view = this._extensions[id] ? /** @type {!WebInspector.View} */ (thi s._extensions[id].instance()) : null;
1187 this._views.put(id, view); 1184 this._views.put(id, view);
1188 if (this._viewCallback && view) 1185 if (this._viewCallback && view)
1189 this._viewCallback(id, view); 1186 this._viewCallback(id, view);
1190 return view; 1187 return view;
1191 } 1188 }
1192 } 1189 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ui/SuggestBox.js ('k') | Source/devtools/front_end/ui/TextPrompt.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698