OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('options', function() { | 5 cr.define('options', function() { |
6 | 6 |
7 var OptionsPage = options.OptionsPage; | 7 var OptionsPage = options.OptionsPage; |
8 | 8 |
9 ///////////////////////////////////////////////////////////////////////////// | 9 ///////////////////////////////////////////////////////////////////////////// |
10 // CookiesView class: | 10 // CookiesView class: |
(...skipping 14 matching lines...) Expand all Loading... | |
25 __proto__: OptionsPage.prototype, | 25 __proto__: OptionsPage.prototype, |
26 | 26 |
27 initializePage: function() { | 27 initializePage: function() { |
28 OptionsPage.prototype.initializePage.call(this); | 28 OptionsPage.prototype.initializePage.call(this); |
29 | 29 |
30 var cookiesTree = $('cookiesTree'); | 30 var cookiesTree = $('cookiesTree'); |
31 | 31 |
32 options.CookiesTree.decorate(cookiesTree); | 32 options.CookiesTree.decorate(cookiesTree); |
33 cookiesTree.addEventListener('change', | 33 cookiesTree.addEventListener('change', |
34 this.handleCookieTreeChange_.bind(this)); | 34 this.handleCookieTreeChange_.bind(this)); |
35 cookiesTree.addEventListener('keydown', this.handleKeyDown_); | 35 cookiesTree.addEventListener('keydown', this.handleKeyDown_.bind(this)); |
36 | 36 |
37 $('cookiesSearchBox').addEventListener('keydown', | 37 $('cookiesSearchBox').addEventListener('keydown', |
38 this.handleQueryEditKeyDown_.bind(this)); | 38 this.handleQueryEditKeyDown_.bind(this)); |
39 | 39 |
40 var self = this; | 40 var self = this; |
41 $('clearCookieSearchButton').onclick = function(e) { | 41 $('clearCookieSearchButton').onclick = function(e) { |
42 $('cookiesSearchBox').value = ''; | 42 $('cookiesSearchBox').value = ''; |
43 self.searchCookie(); | 43 self.searchCookie(); |
44 } | 44 } |
45 | 45 |
46 $('remove-cookie').onclick = function(e) { | 46 $('remove-cookie').onclick = function(e) { |
47 var selected = cookiesTree.selectedItem; | 47 self.removeSelectedCookie_(); |
48 chrome.send('removeCookie', [selected.pathId]); | |
49 } | 48 } |
50 | 49 |
51 $('remove-all-cookie').onclick = function(e) { | 50 $('remove-all-cookie').onclick = function(e) { |
52 chrome.send('removeAllCookies', []); | 51 chrome.send('removeAllCookies', []); |
53 } | 52 } |
54 | 53 |
55 this.addEventListener('visibleChange', this.handleVisibleChange_); | 54 this.addEventListener('visibleChange', this.handleVisibleChange_); |
56 | 55 |
57 this.clearCookieInfo(); | 56 this.clearCookieInfo(); |
58 }, | 57 }, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 * @param {Event} e Property change event. | 226 * @param {Event} e Property change event. |
228 */ | 227 */ |
229 handleVisibleChange_: function(e) { | 228 handleVisibleChange_: function(e) { |
230 if (!this.initalized_ && this.visible) { | 229 if (!this.initalized_ && this.visible) { |
231 this.initalized_ = true; | 230 this.initalized_ = true; |
232 this.searchCookie(); | 231 this.searchCookie(); |
233 } | 232 } |
234 }, | 233 }, |
235 | 234 |
236 /** | 235 /** |
236 * Remove currently selected cookie. | |
237 * @private | |
238 */ | |
239 removeSelectedCookie_: function() { | |
240 var selected = cookiesTree.selectedItem; | |
241 if (selected) | |
242 chrome.send('removeCookie', [selected.pathId]); | |
243 }, | |
244 | |
245 /** | |
237 * Handler for keydown event. | 246 * Handler for keydown event. |
238 * @private | 247 * @private |
239 * @param {Event} e KeyDown event. | 248 * @param {Event} e KeyDown event. |
240 */ | 249 */ |
241 handleKeyDown_: function(e) { | 250 handleKeyDown_: function(e) { |
242 // If 'Remove' button is enabled and key is 'Delete' key on all platforms | 251 // If 'Remove' button is enabled and key is 'Delete' key on all platforms |
243 // or 'Backspace' on Mac. | 252 // or 'Backspace' on Mac. |
244 if (!$('remove-cookie').disabled && | 253 if (!$('remove-cookie').disabled && |
245 (e.keyIdentifier == 'U+007F' || | 254 (e.keyIdentifier == 'U+007F' || |
246 (cr.isMac && e.keyIdentifier == 'U+0008'))) { | 255 (cr.isMac && e.keyIdentifier == 'U+0008'))) { |
256 // No further key handling to avoid navigation triggered by 'Backspace' | |
257 // on Mac. | |
arv (Not doing code reviews)
2010/12/13 20:57:29
Then you can remove the stopPropagation.
xiyuan
2010/12/13 21:12:34
Done.
| |
247 e.preventDefault(); | 258 e.preventDefault(); |
248 e.stopPropagation(); | 259 e.stopPropagation(); |
249 cr.dispatchSimpleEvent($('remove-cookie'), 'click'); | 260 |
261 this.removeSelectedCookie_(); | |
250 } | 262 } |
251 } | 263 } |
252 }; | 264 }; |
253 | 265 |
254 // CookiesViewHandler callbacks. | 266 // CookiesViewHandler callbacks. |
255 CookiesView.onTreeItemAdded = function(args) { | 267 CookiesView.onTreeItemAdded = function(args) { |
256 $('cookiesTree').addByParentId(args[0], args[1], args[2]); | 268 $('cookiesTree').addByParentId(args[0], args[1], args[2]); |
257 }; | 269 }; |
258 | 270 |
259 CookiesView.onTreeItemRemoved = function(args) { | 271 CookiesView.onTreeItemRemoved = function(args) { |
260 $('cookiesTree').removeByParentId(args[0], args[1], args[2]); | 272 $('cookiesTree').removeByParentId(args[0], args[1], args[2]); |
261 }; | 273 }; |
262 | 274 |
263 CookiesView.loadChildren = function(args) { | 275 CookiesView.loadChildren = function(args) { |
264 $('cookiesTree').loadChildren(args[0], args[1]); | 276 $('cookiesTree').loadChildren(args[0], args[1]); |
265 }; | 277 }; |
266 | 278 |
267 // Export | 279 // Export |
268 return { | 280 return { |
269 CookiesView: CookiesView | 281 CookiesView: CookiesView |
270 }; | 282 }; |
271 | 283 |
272 }); | 284 }); |
OLD | NEW |