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

Side by Side Diff: Source/devtools/front_end/resources/DOMStorageItemsView.js

Issue 722713002: DevTools: get rid of getters and setters in StatusBarButton. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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) 2008 Nokia Inc. All rights reserved. 2 * Copyright (C) 2008 Nokia Inc. All rights reserved.
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
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 20 matching lines...) Expand all
31 WebInspector.DOMStorageItemsView = function(domStorage) 31 WebInspector.DOMStorageItemsView = function(domStorage)
32 { 32 {
33 WebInspector.VBox.call(this); 33 WebInspector.VBox.call(this);
34 34
35 this.domStorage = domStorage; 35 this.domStorage = domStorage;
36 36
37 this.element.classList.add("storage-view"); 37 this.element.classList.add("storage-view");
38 this.element.classList.add("table"); 38 this.element.classList.add("table");
39 39
40 this.deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString(" Delete"), "delete-storage-status-bar-item"); 40 this.deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString(" Delete"), "delete-storage-status-bar-item");
41 this.deleteButton.visible = false; 41 this.deleteButton.setVisible(false);
42 this.deleteButton.addEventListener("click", this._deleteButtonClicked, this) ; 42 this.deleteButton.addEventListener("click", this._deleteButtonClicked, this) ;
43 43
44 this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString( "Refresh"), "refresh-storage-status-bar-item"); 44 this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString( "Refresh"), "refresh-storage-status-bar-item");
45 this.refreshButton.addEventListener("click", this._refreshButtonClicked, thi s); 45 this.refreshButton.addEventListener("click", this._refreshButtonClicked, thi s);
46 46
47 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emsCleared, this._domStorageItemsCleared, this); 47 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emsCleared, this._domStorageItemsCleared, this);
48 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emRemoved, this._domStorageItemRemoved, this); 48 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emRemoved, this._domStorageItemRemoved, this);
49 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emAdded, this._domStorageItemAdded, this); 49 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emAdded, this._domStorageItemAdded, this);
50 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emUpdated, this._domStorageItemUpdated, this); 50 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emUpdated, this._domStorageItemUpdated, this);
51 } 51 }
52 52
53 WebInspector.DOMStorageItemsView.prototype = { 53 WebInspector.DOMStorageItemsView.prototype = {
54 get statusBarItems() 54 get statusBarItems()
55 { 55 {
56 return [this.refreshButton.element, this.deleteButton.element]; 56 return [this.refreshButton.element, this.deleteButton.element];
57 }, 57 },
58 58
59 wasShown: function() 59 wasShown: function()
60 { 60 {
61 this._update(); 61 this._update();
62 }, 62 },
63 63
64 willHide: function() 64 willHide: function()
65 { 65 {
66 this.deleteButton.visible = false; 66 this.deleteButton.setVisible(false);
67 }, 67 },
68 68
69 /** 69 /**
70 * @param {!WebInspector.Event} event 70 * @param {!WebInspector.Event} event
71 */ 71 */
72 _domStorageItemsCleared: function(event) 72 _domStorageItemsCleared: function(event)
73 { 73 {
74 if (!this.isShowing() || !this._dataGrid) 74 if (!this.isShowing() || !this._dataGrid)
75 return; 75 return;
76 76
77 this._dataGrid.rootNode().removeChildren(); 77 this._dataGrid.rootNode().removeChildren();
78 this._dataGrid.addCreationNode(false); 78 this._dataGrid.addCreationNode(false);
79 this.deleteButton.visible = false; 79 this.deleteButton.setVisible(false);
80 event.consume(true); 80 event.consume(true);
81 }, 81 },
82 82
83 /** 83 /**
84 * @param {!WebInspector.Event} event 84 * @param {!WebInspector.Event} event
85 */ 85 */
86 _domStorageItemRemoved: function(event) 86 _domStorageItemRemoved: function(event)
87 { 87 {
88 if (!this.isShowing() || !this._dataGrid) 88 if (!this.isShowing() || !this._dataGrid)
89 return; 89 return;
90 90
91 var storageData = event.data; 91 var storageData = event.data;
92 var rootNode = this._dataGrid.rootNode(); 92 var rootNode = this._dataGrid.rootNode();
93 var children = rootNode.children; 93 var children = rootNode.children;
94 94
95 event.consume(true); 95 event.consume(true);
96 96
97 for (var i = 0; i < children.length; ++i) { 97 for (var i = 0; i < children.length; ++i) {
98 var childNode = children[i]; 98 var childNode = children[i];
99 if (childNode.data.key === storageData.key) { 99 if (childNode.data.key === storageData.key) {
100 rootNode.removeChild(childNode); 100 rootNode.removeChild(childNode);
101 this.deleteButton.visible = (children.length > 1); 101 this.deleteButton.setVisible(children.length > 1);
102 return; 102 return;
103 } 103 }
104 } 104 }
105 }, 105 },
106 106
107 /** 107 /**
108 * @param {!WebInspector.Event} event 108 * @param {!WebInspector.Event} event
109 */ 109 */
110 _domStorageItemAdded: function(event) 110 _domStorageItemAdded: function(event)
111 { 111 {
112 if (!this.isShowing() || !this._dataGrid) 112 if (!this.isShowing() || !this._dataGrid)
113 return; 113 return;
114 114
115 var storageData = event.data; 115 var storageData = event.data;
116 var rootNode = this._dataGrid.rootNode(); 116 var rootNode = this._dataGrid.rootNode();
117 var children = rootNode.children; 117 var children = rootNode.children;
118 118
119 event.consume(true); 119 event.consume(true);
120 this.deleteButton.visible = true; 120 this.deleteButton.setVisible(true);
121 121
122 for (var i = 0; i < children.length; ++i) 122 for (var i = 0; i < children.length; ++i)
123 if (children[i].data.key === storageData.key) 123 if (children[i].data.key === storageData.key)
124 return; 124 return;
125 125
126 var childNode = new WebInspector.DataGridNode({key: storageData.key, val ue: storageData.value}, false); 126 var childNode = new WebInspector.DataGridNode({key: storageData.key, val ue: storageData.value}, false);
127 rootNode.insertChild(childNode, children.length - 1); 127 rootNode.insertChild(childNode, children.length - 1);
128 }, 128 },
129 129
130 /** 130 /**
(...skipping 18 matching lines...) Expand all
149 rootNode.removeChild(childNode); 149 rootNode.removeChild(childNode);
150 return; 150 return;
151 } 151 }
152 keyFound = true; 152 keyFound = true;
153 if (childNode.data.value !== storageData.value) { 153 if (childNode.data.value !== storageData.value) {
154 childNode.data.value = storageData.value; 154 childNode.data.value = storageData.value;
155 childNode.refresh(); 155 childNode.refresh();
156 childNode.select(); 156 childNode.select();
157 childNode.reveal(); 157 childNode.reveal();
158 } 158 }
159 this.deleteButton.visible = true; 159 this.deleteButton.setVisible(true);
160 } 160 }
161 } 161 }
162 }, 162 },
163 163
164 _update: function() 164 _update: function()
165 { 165 {
166 this.detachChildViews(); 166 this.detachChildViews();
167 this.domStorage.getItems(this._showDOMStorageItems.bind(this)); 167 this.domStorage.getItems(this._showDOMStorageItems.bind(this));
168 }, 168 },
169 169
170 _showDOMStorageItems: function(error, items) 170 _showDOMStorageItems: function(error, items)
171 { 171 {
172 if (error) 172 if (error)
173 return; 173 return;
174 174
175 this._dataGrid = this._dataGridForDOMStorageItems(items); 175 this._dataGrid = this._dataGridForDOMStorageItems(items);
176 this._dataGrid.show(this.element); 176 this._dataGrid.show(this.element);
177 this.deleteButton.visible = (this._dataGrid.rootNode().children.length > 1); 177 this.deleteButton.setVisible(this._dataGrid.rootNode().children.length > 1);
178 }, 178 },
179 179
180 _dataGridForDOMStorageItems: function(items) 180 _dataGridForDOMStorageItems: function(items)
181 { 181 {
182 var columns = [ 182 var columns = [
183 {id: "key", title: WebInspector.UIString("Key"), editable: true, wei ght: 50}, 183 {id: "key", title: WebInspector.UIString("Key"), editable: true, wei ght: 50},
184 {id: "value", title: WebInspector.UIString("Value"), editable: true, weight: 50} 184 {id: "value", title: WebInspector.UIString("Value"), editable: true, weight: 50}
185 ]; 185 ];
186 186
187 var nodes = []; 187 var nodes = [];
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 { 252 {
253 if (!node || node.isCreationNode) 253 if (!node || node.isCreationNode)
254 return; 254 return;
255 255
256 if (this.domStorage) 256 if (this.domStorage)
257 this.domStorage.removeItem(node.data.key); 257 this.domStorage.removeItem(node.data.key);
258 }, 258 },
259 259
260 __proto__: WebInspector.VBox.prototype 260 __proto__: WebInspector.VBox.prototype
261 } 261 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/resources/CookieItemsView.js ('k') | Source/devtools/front_end/resources/FileSystemView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698