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

Side by Side Diff: Source/devtools/front_end/sources/NavigatorView.js

Issue 362273002: DevTools: Reduce code 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 * 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 * 10 *
(...skipping 17 matching lines...) Expand all
28 28
29 /** 29 /**
30 * @constructor 30 * @constructor
31 * @extends {WebInspector.VBox} 31 * @extends {WebInspector.VBox}
32 */ 32 */
33 WebInspector.NavigatorView = function() 33 WebInspector.NavigatorView = function()
34 { 34 {
35 WebInspector.VBox.call(this); 35 WebInspector.VBox.call(this);
36 this.registerRequiredCSS("navigatorView.css"); 36 this.registerRequiredCSS("navigatorView.css");
37 37
38 var scriptsTreeElement = document.createElement("ol"); 38 this.element.classList.add("navigator-container");
39 var scriptsOutlineElement = this.element.createChild("div", "outline-disclos ure navigator");
40 var scriptsTreeElement = scriptsOutlineElement.createChild("ol");
39 this._scriptsTree = new WebInspector.NavigatorTreeOutline(scriptsTreeElement ); 41 this._scriptsTree = new WebInspector.NavigatorTreeOutline(scriptsTreeElement );
40 42
41 var scriptsOutlineElement = document.createElement("div");
42 scriptsOutlineElement.classList.add("outline-disclosure");
43 scriptsOutlineElement.classList.add("navigator");
44 scriptsOutlineElement.appendChild(scriptsTreeElement);
45
46 this.element.classList.add("navigator-container");
47 this.element.appendChild(scriptsOutlineElement);
48 this.setDefaultFocusedElement(this._scriptsTree.element); 43 this.setDefaultFocusedElement(this._scriptsTree.element);
49 44
50 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.NavigatorUISource CodeTreeNode>} */ 45 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.NavigatorUISource CodeTreeNode>} */
51 this._uiSourceCodeNodes = new Map(); 46 this._uiSourceCodeNodes = new Map();
52 /** @type {!Map.<!WebInspector.NavigatorTreeNode, !StringMap.<!WebInspector. NavigatorFolderTreeNode>>} */ 47 /** @type {!Map.<!WebInspector.NavigatorTreeNode, !StringMap.<!WebInspector. NavigatorFolderTreeNode>>} */
53 this._subfolderNodes = new Map(); 48 this._subfolderNodes = new Map();
54 49
55 this._rootNode = new WebInspector.NavigatorRootTreeNode(this); 50 this._rootNode = new WebInspector.NavigatorRootTreeNode(this);
56 this._rootNode.populate(); 51 this._rootNode.populate();
57 52
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 666
672 WebInspector.BaseNavigatorTreeElement.prototype = { 667 WebInspector.BaseNavigatorTreeElement.prototype = {
673 onattach: function() 668 onattach: function()
674 { 669 {
675 this.listItemElement.removeChildren(); 670 this.listItemElement.removeChildren();
676 if (this._iconClasses) { 671 if (this._iconClasses) {
677 for (var i = 0; i < this._iconClasses.length; ++i) 672 for (var i = 0; i < this._iconClasses.length; ++i)
678 this.listItemElement.classList.add(this._iconClasses[i]); 673 this.listItemElement.classList.add(this._iconClasses[i]);
679 } 674 }
680 675
681 var selectionElement = document.createElement("div"); 676 this.listItemElement.createChild("div", "selection");
682 selectionElement.className = "selection";
683 this.listItemElement.appendChild(selectionElement);
684 677
685 if (!this._noIcon) { 678 if (!this._noIcon)
686 this.imageElement = document.createElement("img"); 679 this.imageElement = this.listItemElement.createChild("img", "icon");
687 this.imageElement.className = "icon";
688 this.listItemElement.appendChild(this.imageElement);
689 }
690 680
691 this.titleElement = document.createElement("div"); 681 this.titleElement = this.listItemElement.createChild("div", "base-naviga tor-tree-element-title");
692 this.titleElement.className = "base-navigator-tree-element-title"; 682 this.titleElement.textContent = this._titleText
693 this._titleTextNode = document.createTextNode("");
694 this._titleTextNode.textContent = this._titleText;
695 this.titleElement.appendChild(this._titleTextNode);
696 this.listItemElement.appendChild(this.titleElement);
697 }, 683 },
698 684
685 /**
686 * @param {!Array.<string>} iconClasses
687 */
699 updateIconClasses: function(iconClasses) 688 updateIconClasses: function(iconClasses)
700 { 689 {
701 for (var i = 0; i < this._iconClasses.length; ++i) 690 for (var i = 0; i < this._iconClasses.length; ++i)
702 this.listItemElement.classList.remove(this._iconClasses[i]); 691 this.listItemElement.classList.remove(this._iconClasses[i]);
703 this._iconClasses = iconClasses; 692 this._iconClasses = iconClasses;
704 for (var i = 0; i < this._iconClasses.length; ++i) 693 for (var i = 0; i < this._iconClasses.length; ++i)
705 this.listItemElement.classList.add(this._iconClasses[i]); 694 this.listItemElement.classList.add(this._iconClasses[i]);
706 }, 695 },
707 696
708 onreveal: function() 697 onreveal: function()
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 1414
1426 willRemoveChild: function(node) 1415 willRemoveChild: function(node)
1427 { 1416 {
1428 if (node._isMerged || !this.isPopulated()) 1417 if (node._isMerged || !this.isPopulated())
1429 return; 1418 return;
1430 this._treeElement.removeChild(node._treeElement); 1419 this._treeElement.removeChild(node._treeElement);
1431 }, 1420 },
1432 1421
1433 __proto__: WebInspector.NavigatorTreeNode.prototype 1422 __proto__: WebInspector.NavigatorTreeNode.prototype
1434 } 1423 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sources/JavaScriptSourceFrame.js ('k') | Source/devtools/front_end/sources/SourcesPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698