| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 30 Resources.DOMStorageItemsView = class extends UI.SimpleView { | 30 Resources.DOMStorageItemsView = class extends UI.SimpleView { |
| 31 constructor(domStorage) { | 31 constructor(domStorage) { |
| 32 super(Common.UIString('DOM Storage')); | 32 super(Common.UIString('DOM Storage')); |
| 33 | 33 |
| 34 this.domStorage = domStorage; | 34 this.domStorage = domStorage; |
| 35 | 35 |
| 36 this.element.classList.add('storage-view', 'table'); | 36 this.element.classList.add('storage-view', 'table'); |
| 37 | 37 |
| 38 this.deleteButton = new UI.ToolbarButton(Common.UIString('Delete'), 'largeic
on-delete'); | 38 this.deleteButton = new UI.ToolbarButton(Common.UIString('Delete'), 'largeic
on-delete'); |
| 39 this.deleteButton.setVisible(false); | 39 this.deleteButton.setVisible(false); |
| 40 this.deleteButton.addEventListener('click', this._deleteButtonClicked, this)
; | 40 this.deleteButton.addEventListener(UI.ToolbarButton.Events.Click, this._dele
teButtonClicked, this); |
| 41 | 41 |
| 42 this.refreshButton = new UI.ToolbarButton(Common.UIString('Refresh'), 'large
icon-refresh'); | 42 this.refreshButton = new UI.ToolbarButton(Common.UIString('Refresh'), 'large
icon-refresh'); |
| 43 this.refreshButton.addEventListener('click', this._refreshButtonClicked, thi
s); | 43 this.refreshButton.addEventListener(UI.ToolbarButton.Events.Click, this._ref
reshButtonClicked, this); |
| 44 | 44 |
| 45 this.domStorage.addEventListener( | 45 this.domStorage.addEventListener( |
| 46 Resources.DOMStorage.Events.DOMStorageItemsCleared, this._domStorageItem
sCleared, this); | 46 Resources.DOMStorage.Events.DOMStorageItemsCleared, this._domStorageItem
sCleared, this); |
| 47 this.domStorage.addEventListener( | 47 this.domStorage.addEventListener( |
| 48 Resources.DOMStorage.Events.DOMStorageItemRemoved, this._domStorageItemR
emoved, this); | 48 Resources.DOMStorage.Events.DOMStorageItemRemoved, this._domStorageItemR
emoved, this); |
| 49 this.domStorage.addEventListener(Resources.DOMStorage.Events.DOMStorageItemA
dded, this._domStorageItemAdded, this); | 49 this.domStorage.addEventListener(Resources.DOMStorage.Events.DOMStorageItemA
dded, this._domStorageItemAdded, this); |
| 50 this.domStorage.addEventListener( | 50 this.domStorage.addEventListener( |
| 51 Resources.DOMStorage.Events.DOMStorageItemUpdated, this._domStorageItemU
pdated, this); | 51 Resources.DOMStorage.Events.DOMStorageItemUpdated, this._domStorageItemU
pdated, this); |
| 52 } | 52 } |
| 53 | 53 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 76 /** | 76 /** |
| 77 * @param {!Common.Event} event | 77 * @param {!Common.Event} event |
| 78 */ | 78 */ |
| 79 _domStorageItemsCleared(event) { | 79 _domStorageItemsCleared(event) { |
| 80 if (!this.isShowing() || !this._dataGrid) | 80 if (!this.isShowing() || !this._dataGrid) |
| 81 return; | 81 return; |
| 82 | 82 |
| 83 this._dataGrid.rootNode().removeChildren(); | 83 this._dataGrid.rootNode().removeChildren(); |
| 84 this._dataGrid.addCreationNode(false); | 84 this._dataGrid.addCreationNode(false); |
| 85 this.deleteButton.setVisible(false); | 85 this.deleteButton.setVisible(false); |
| 86 event.consume(true); | |
| 87 } | 86 } |
| 88 | 87 |
| 89 /** | 88 /** |
| 90 * @param {!Common.Event} event | 89 * @param {!Common.Event} event |
| 91 */ | 90 */ |
| 92 _domStorageItemRemoved(event) { | 91 _domStorageItemRemoved(event) { |
| 93 if (!this.isShowing() || !this._dataGrid) | 92 if (!this.isShowing() || !this._dataGrid) |
| 94 return; | 93 return; |
| 95 | 94 |
| 96 var storageData = event.data; | 95 var storageData = event.data; |
| 97 var rootNode = this._dataGrid.rootNode(); | 96 var rootNode = this._dataGrid.rootNode(); |
| 98 var children = rootNode.children; | 97 var children = rootNode.children; |
| 99 | 98 |
| 100 event.consume(true); | |
| 101 | |
| 102 for (var i = 0; i < children.length; ++i) { | 99 for (var i = 0; i < children.length; ++i) { |
| 103 var childNode = children[i]; | 100 var childNode = children[i]; |
| 104 if (childNode.data.key === storageData.key) { | 101 if (childNode.data.key === storageData.key) { |
| 105 rootNode.removeChild(childNode); | 102 rootNode.removeChild(childNode); |
| 106 this.deleteButton.setVisible(children.length > 1); | 103 this.deleteButton.setVisible(children.length > 1); |
| 107 return; | 104 return; |
| 108 } | 105 } |
| 109 } | 106 } |
| 110 } | 107 } |
| 111 | 108 |
| 112 /** | 109 /** |
| 113 * @param {!Common.Event} event | 110 * @param {!Common.Event} event |
| 114 */ | 111 */ |
| 115 _domStorageItemAdded(event) { | 112 _domStorageItemAdded(event) { |
| 116 if (!this.isShowing() || !this._dataGrid) | 113 if (!this.isShowing() || !this._dataGrid) |
| 117 return; | 114 return; |
| 118 | 115 |
| 119 var storageData = event.data; | 116 var storageData = event.data; |
| 120 var rootNode = this._dataGrid.rootNode(); | 117 var rootNode = this._dataGrid.rootNode(); |
| 121 var children = rootNode.children; | 118 var children = rootNode.children; |
| 122 | 119 |
| 123 event.consume(true); | |
| 124 this.deleteButton.setVisible(true); | 120 this.deleteButton.setVisible(true); |
| 125 | 121 |
| 126 for (var i = 0; i < children.length; ++i) { | 122 for (var i = 0; i < children.length; ++i) { |
| 127 if (children[i].data.key === storageData.key) | 123 if (children[i].data.key === storageData.key) |
| 128 return; | 124 return; |
| 129 } | 125 } |
| 130 | 126 |
| 131 var childNode = new UI.DataGridNode({key: storageData.key, value: storageDat
a.value}, false); | 127 var childNode = new UI.DataGridNode({key: storageData.key, value: storageDat
a.value}, false); |
| 132 rootNode.insertChild(childNode, children.length - 1); | 128 rootNode.insertChild(childNode, children.length - 1); |
| 133 } | 129 } |
| 134 | 130 |
| 135 /** | 131 /** |
| 136 * @param {!Common.Event} event | 132 * @param {!Common.Event} event |
| 137 */ | 133 */ |
| 138 _domStorageItemUpdated(event) { | 134 _domStorageItemUpdated(event) { |
| 139 if (!this.isShowing() || !this._dataGrid) | 135 if (!this.isShowing() || !this._dataGrid) |
| 140 return; | 136 return; |
| 141 | 137 |
| 142 var storageData = event.data; | 138 var storageData = event.data; |
| 143 var rootNode = this._dataGrid.rootNode(); | 139 var rootNode = this._dataGrid.rootNode(); |
| 144 var children = rootNode.children; | 140 var children = rootNode.children; |
| 145 | 141 |
| 146 event.consume(true); | |
| 147 | |
| 148 var keyFound = false; | 142 var keyFound = false; |
| 149 for (var i = 0; i < children.length; ++i) { | 143 for (var i = 0; i < children.length; ++i) { |
| 150 var childNode = children[i]; | 144 var childNode = children[i]; |
| 151 if (childNode.data.key === storageData.key) { | 145 if (childNode.data.key === storageData.key) { |
| 152 if (keyFound) { | 146 if (keyFound) { |
| 153 rootNode.removeChild(childNode); | 147 rootNode.removeChild(childNode); |
| 154 return; | 148 return; |
| 155 } | 149 } |
| 156 keyFound = true; | 150 keyFound = true; |
| 157 if (childNode.data.value !== storageData.value) { | 151 if (childNode.data.value !== storageData.value) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 dataGrid.setName('DOMStorageItemsView'); | 196 dataGrid.setName('DOMStorageItemsView'); |
| 203 length = nodes.length; | 197 length = nodes.length; |
| 204 for (var i = 0; i < length; ++i) | 198 for (var i = 0; i < length; ++i) |
| 205 dataGrid.rootNode().appendChild(nodes[i]); | 199 dataGrid.rootNode().appendChild(nodes[i]); |
| 206 dataGrid.addCreationNode(false); | 200 dataGrid.addCreationNode(false); |
| 207 if (length > 0) | 201 if (length > 0) |
| 208 nodes[0].selected = true; | 202 nodes[0].selected = true; |
| 209 return dataGrid; | 203 return dataGrid; |
| 210 } | 204 } |
| 211 | 205 |
| 206 /** |
| 207 * @param {!Common.Event} event |
| 208 */ |
| 212 _deleteButtonClicked(event) { | 209 _deleteButtonClicked(event) { |
| 213 if (!this._dataGrid || !this._dataGrid.selectedNode) | 210 if (!this._dataGrid || !this._dataGrid.selectedNode) |
| 214 return; | 211 return; |
| 215 | 212 |
| 216 this._deleteCallback(this._dataGrid.selectedNode); | 213 this._deleteCallback(this._dataGrid.selectedNode); |
| 217 } | 214 } |
| 218 | 215 |
| 216 /** |
| 217 * @param {!Common.Event} event |
| 218 */ |
| 219 _refreshButtonClicked(event) { | 219 _refreshButtonClicked(event) { |
| 220 this._update(); | 220 this._update(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 _editingCallback(editingNode, columnIdentifier, oldText, newText) { | 223 _editingCallback(editingNode, columnIdentifier, oldText, newText) { |
| 224 var domStorage = this.domStorage; | 224 var domStorage = this.domStorage; |
| 225 if (columnIdentifier === 'key') { | 225 if (columnIdentifier === 'key') { |
| 226 if (typeof oldText === 'string') | 226 if (typeof oldText === 'string') |
| 227 domStorage.removeItem(oldText); | 227 domStorage.removeItem(oldText); |
| 228 domStorage.setItem(newText, editingNode.data.value || ''); | 228 domStorage.setItem(newText, editingNode.data.value || ''); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 246 } | 246 } |
| 247 | 247 |
| 248 _deleteCallback(node) { | 248 _deleteCallback(node) { |
| 249 if (!node || node.isCreationNode) | 249 if (!node || node.isCreationNode) |
| 250 return; | 250 return; |
| 251 | 251 |
| 252 if (this.domStorage) | 252 if (this.domStorage) |
| 253 this.domStorage.removeItem(node.data.key); | 253 this.domStorage.removeItem(node.data.key); |
| 254 } | 254 } |
| 255 }; | 255 }; |
| OLD | NEW |