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

Side by Side Diff: tracing/tracing/ui/base/list_view.html

Issue 2390373003: Change all == to === and != to !== in trace viewer. (Closed)
Patch Set: Created 4 years, 2 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2014 The Chromium Authors. All rights reserved. 3 Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="stylesheet" href="/tracing/ui/base/list_view.css"> 8 <link rel="stylesheet" href="/tracing/ui/base/list_view.css">
9 9
10 <link rel="import" href="/tracing/base/event.html"> 10 <link rel="import" href="/tracing/base/event.html">
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 Polymer.dom(item).classList.add('list-item'); 44 Polymer.dom(item).classList.add('list-item');
45 item.addEventListener('click', this.onItemClicked_, true); 45 item.addEventListener('click', this.onItemClicked_, true);
46 46
47 var listView = this; 47 var listView = this;
48 Object.defineProperty( 48 Object.defineProperty(
49 item, 49 item,
50 'selected', { 50 'selected', {
51 configurable: true, 51 configurable: true,
52 set: function(value) { 52 set: function(value) {
53 var oldSelection = listView.selectedElement; 53 var oldSelection = listView.selectedElement;
54 if (oldSelection && oldSelection != this && value) 54 if (oldSelection && oldSelection !== this && value)
55 Polymer.dom(listView.selectedElement).removeAttribute( 55 Polymer.dom(listView.selectedElement).removeAttribute(
56 'selected'); 56 'selected');
57 if (value) 57 if (value)
58 Polymer.dom(this).setAttribute('selected', 'selected'); 58 Polymer.dom(this).setAttribute('selected', 'selected');
59 else 59 else
60 Polymer.dom(this).removeAttribute('selected'); 60 Polymer.dom(this).removeAttribute('selected');
61 var newSelection = listView.selectedElement; 61 var newSelection = listView.selectedElement;
62 if (newSelection != oldSelection) 62 if (newSelection !== oldSelection)
63 tr.b.dispatchSimpleEvent(listView, 'selection-changed', false); 63 tr.b.dispatchSimpleEvent(listView, 'selection-changed', false);
64 }, 64 },
65 get: function() { 65 get: function() {
66 return this.hasAttribute('selected'); 66 return this.hasAttribute('selected');
67 } 67 }
68 }); 68 });
69 }, 69 },
70 70
71 undecorateChild_: function(item) { 71 undecorateChild_: function(item) {
72 this.selectionChanged_ |= item.selected; 72 this.selectionChanged_ |= item.selected;
(...skipping 19 matching lines...) Expand all
92 return el; 92 return el;
93 }, 93 },
94 94
95 set selectedElement(el) { 95 set selectedElement(el) {
96 if (!el) { 96 if (!el) {
97 if (this.selectedElement) 97 if (this.selectedElement)
98 this.selectedElement.selected = false; 98 this.selectedElement.selected = false;
99 return; 99 return;
100 } 100 }
101 101
102 if (el.parentElement != this) 102 if (el.parentElement !== this)
103 throw new Error( 103 throw new Error(
104 'Can only select elements that are children of this list view'); 104 'Can only select elements that are children of this list view');
105 el.selected = true; 105 el.selected = true;
106 }, 106 },
107 107
108 getElementByIndex: function(index) { 108 getElementByIndex: function(index) {
109 return Polymer.dom(this) 109 return Polymer.dom(this)
110 .querySelector('.list-item:nth-child(' + index + ')'); 110 .querySelector('.list-item:nth-child(' + index + ')');
111 }, 111 },
112 112
113 clear: function() { 113 clear: function() {
114 var changed = this.selectedElement !== undefined; 114 var changed = this.selectedElement !== undefined;
115 tr.ui.b.ContainerThatDecoratesItsChildren.prototype.clear.call(this); 115 tr.ui.b.ContainerThatDecoratesItsChildren.prototype.clear.call(this);
116 if (changed) 116 if (changed)
117 tr.b.dispatchSimpleEvent(this, 'selection-changed', false); 117 tr.b.dispatchSimpleEvent(this, 'selection-changed', false);
118 }, 118 },
119 119
120 onItemClicked_: function(e) { 120 onItemClicked_: function(e) {
121 var currentSelectedElement = this.selectedElement; 121 var currentSelectedElement = this.selectedElement;
122 if (currentSelectedElement) 122 if (currentSelectedElement)
123 Polymer.dom(currentSelectedElement).removeAttribute('selected'); 123 Polymer.dom(currentSelectedElement).removeAttribute('selected');
124 var element = e.target; 124 var element = e.target;
125 while (element.parentElement != this) 125 while (element.parentElement !== this)
126 element = element.parentElement; 126 element = element.parentElement;
127 if (element !== currentSelectedElement) 127 if (element !== currentSelectedElement)
128 Polymer.dom(element).setAttribute('selected', 'selected'); 128 Polymer.dom(element).setAttribute('selected', 'selected');
129 tr.b.dispatchSimpleEvent(this, 'selection-changed', false); 129 tr.b.dispatchSimpleEvent(this, 'selection-changed', false);
130 }, 130 },
131 131
132 onKeyDown_: function(e) { 132 onKeyDown_: function(e) {
133 if (this.selectedElement === undefined) 133 if (this.selectedElement === undefined)
134 return; 134 return;
135 135
136 if (e.keyCode == 38) { // Up arrow. 136 if (e.keyCode === 38) { // Up arrow.
137 var prev = Polymer.dom(this.selectedElement).previousSibling; 137 var prev = Polymer.dom(this.selectedElement).previousSibling;
138 if (prev) { 138 if (prev) {
139 prev.selected = true; 139 prev.selected = true;
140 tr.ui.b.scrollIntoViewIfNeeded(prev); 140 tr.ui.b.scrollIntoViewIfNeeded(prev);
141 e.preventDefault(); 141 e.preventDefault();
142 return true; 142 return true;
143 } 143 }
144 } else if (e.keyCode == 40) { // Down arrow. 144 } else if (e.keyCode === 40) { // Down arrow.
145 var next = Polymer.dom(this.selectedElement).nextSibling; 145 var next = Polymer.dom(this.selectedElement).nextSibling;
146 if (next) { 146 if (next) {
147 next.selected = true; 147 next.selected = true;
148 tr.ui.b.scrollIntoViewIfNeeded(next); 148 tr.ui.b.scrollIntoViewIfNeeded(next);
149 e.preventDefault(); 149 e.preventDefault();
150 return true; 150 return true;
151 } 151 }
152 } 152 }
153 }, 153 },
154 154
155 addItem: function(textContent) { 155 addItem: function(textContent) {
156 var item = document.createElement('div'); 156 var item = document.createElement('div');
157 Polymer.dom(item).textContent = textContent; 157 Polymer.dom(item).textContent = textContent;
158 Polymer.dom(this).appendChild(item); 158 Polymer.dom(this).appendChild(item);
159 return item; 159 return item;
160 } 160 }
161 161
162 }; 162 };
163 163
164 return { 164 return {
165 ListView: ListView 165 ListView: ListView
166 }; 166 };
167 167
168 }); 168 });
169 </script> 169 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698