| 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(UI.ToolbarButton.Events.Click, this._dele
teButtonClicked, this); | 40 this.deleteButton.addEventListener('click', this._deleteButtonClicked, 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(UI.ToolbarButton.Events.Click, this._ref
reshButtonClicked, this); | 43 this.refreshButton.addEventListener('click', this._refreshButtonClicked, thi
s); |
| 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); |
| 86 } | 87 } |
| 87 | 88 |
| 88 /** | 89 /** |
| 89 * @param {!Common.Event} event | 90 * @param {!Common.Event} event |
| 90 */ | 91 */ |
| 91 _domStorageItemRemoved(event) { | 92 _domStorageItemRemoved(event) { |
| 92 if (!this.isShowing() || !this._dataGrid) | 93 if (!this.isShowing() || !this._dataGrid) |
| 93 return; | 94 return; |
| 94 | 95 |
| 95 var storageData = event.data; | 96 var storageData = event.data; |
| 96 var rootNode = this._dataGrid.rootNode(); | 97 var rootNode = this._dataGrid.rootNode(); |
| 97 var children = rootNode.children; | 98 var children = rootNode.children; |
| 98 | 99 |
| 100 event.consume(true); |
| 101 |
| 99 for (var i = 0; i < children.length; ++i) { | 102 for (var i = 0; i < children.length; ++i) { |
| 100 var childNode = children[i]; | 103 var childNode = children[i]; |
| 101 if (childNode.data.key === storageData.key) { | 104 if (childNode.data.key === storageData.key) { |
| 102 rootNode.removeChild(childNode); | 105 rootNode.removeChild(childNode); |
| 103 this.deleteButton.setVisible(children.length > 1); | 106 this.deleteButton.setVisible(children.length > 1); |
| 104 return; | 107 return; |
| 105 } | 108 } |
| 106 } | 109 } |
| 107 } | 110 } |
| 108 | 111 |
| 109 /** | 112 /** |
| 110 * @param {!Common.Event} event | 113 * @param {!Common.Event} event |
| 111 */ | 114 */ |
| 112 _domStorageItemAdded(event) { | 115 _domStorageItemAdded(event) { |
| 113 if (!this.isShowing() || !this._dataGrid) | 116 if (!this.isShowing() || !this._dataGrid) |
| 114 return; | 117 return; |
| 115 | 118 |
| 116 var storageData = event.data; | 119 var storageData = event.data; |
| 117 var rootNode = this._dataGrid.rootNode(); | 120 var rootNode = this._dataGrid.rootNode(); |
| 118 var children = rootNode.children; | 121 var children = rootNode.children; |
| 119 | 122 |
| 123 event.consume(true); |
| 120 this.deleteButton.setVisible(true); | 124 this.deleteButton.setVisible(true); |
| 121 | 125 |
| 122 for (var i = 0; i < children.length; ++i) { | 126 for (var i = 0; i < children.length; ++i) { |
| 123 if (children[i].data.key === storageData.key) | 127 if (children[i].data.key === storageData.key) |
| 124 return; | 128 return; |
| 125 } | 129 } |
| 126 | 130 |
| 127 var childNode = new UI.DataGridNode({key: storageData.key, value: storageDat
a.value}, false); | 131 var childNode = new UI.DataGridNode({key: storageData.key, value: storageDat
a.value}, false); |
| 128 rootNode.insertChild(childNode, children.length - 1); | 132 rootNode.insertChild(childNode, children.length - 1); |
| 129 } | 133 } |
| 130 | 134 |
| 131 /** | 135 /** |
| 132 * @param {!Common.Event} event | 136 * @param {!Common.Event} event |
| 133 */ | 137 */ |
| 134 _domStorageItemUpdated(event) { | 138 _domStorageItemUpdated(event) { |
| 135 if (!this.isShowing() || !this._dataGrid) | 139 if (!this.isShowing() || !this._dataGrid) |
| 136 return; | 140 return; |
| 137 | 141 |
| 138 var storageData = event.data; | 142 var storageData = event.data; |
| 139 var rootNode = this._dataGrid.rootNode(); | 143 var rootNode = this._dataGrid.rootNode(); |
| 140 var children = rootNode.children; | 144 var children = rootNode.children; |
| 141 | 145 |
| 146 event.consume(true); |
| 147 |
| 142 var keyFound = false; | 148 var keyFound = false; |
| 143 for (var i = 0; i < children.length; ++i) { | 149 for (var i = 0; i < children.length; ++i) { |
| 144 var childNode = children[i]; | 150 var childNode = children[i]; |
| 145 if (childNode.data.key === storageData.key) { | 151 if (childNode.data.key === storageData.key) { |
| 146 if (keyFound) { | 152 if (keyFound) { |
| 147 rootNode.removeChild(childNode); | 153 rootNode.removeChild(childNode); |
| 148 return; | 154 return; |
| 149 } | 155 } |
| 150 keyFound = true; | 156 keyFound = true; |
| 151 if (childNode.data.value !== storageData.value) { | 157 if (childNode.data.value !== storageData.value) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 dataGrid.setName('DOMStorageItemsView'); | 202 dataGrid.setName('DOMStorageItemsView'); |
| 197 length = nodes.length; | 203 length = nodes.length; |
| 198 for (var i = 0; i < length; ++i) | 204 for (var i = 0; i < length; ++i) |
| 199 dataGrid.rootNode().appendChild(nodes[i]); | 205 dataGrid.rootNode().appendChild(nodes[i]); |
| 200 dataGrid.addCreationNode(false); | 206 dataGrid.addCreationNode(false); |
| 201 if (length > 0) | 207 if (length > 0) |
| 202 nodes[0].selected = true; | 208 nodes[0].selected = true; |
| 203 return dataGrid; | 209 return dataGrid; |
| 204 } | 210 } |
| 205 | 211 |
| 206 /** | |
| 207 * @param {!Common.Event} event | |
| 208 */ | |
| 209 _deleteButtonClicked(event) { | 212 _deleteButtonClicked(event) { |
| 210 if (!this._dataGrid || !this._dataGrid.selectedNode) | 213 if (!this._dataGrid || !this._dataGrid.selectedNode) |
| 211 return; | 214 return; |
| 212 | 215 |
| 213 this._deleteCallback(this._dataGrid.selectedNode); | 216 this._deleteCallback(this._dataGrid.selectedNode); |
| 214 } | 217 } |
| 215 | 218 |
| 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 |