OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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: |
11 | 11 |
12 /** | 12 /** |
13 * Encapsulated handling of the cookies and other site data page. | 13 * Encapsulated handling of the cookies and other site data page. |
14 * @constructor | 14 * @constructor |
15 */ | 15 */ |
16 function CookiesView(model) { | 16 function CookiesView(model) { |
17 OptionsPage.call(this, 'cookies', | 17 OptionsPage.call(this, 'cookies', |
18 templateData.cookiesViewPageTabTitle, | 18 templateData.cookiesViewPageTabTitle, |
19 'cookiesViewPage'); | 19 'cookiesViewPage'); |
20 } | 20 } |
21 | 21 |
22 cr.addSingletonGetter(CookiesView); | 22 cr.addSingletonGetter(CookiesView); |
23 | 23 |
24 CookiesView.prototype = { | 24 CookiesView.prototype = { |
25 __proto__: OptionsPage.prototype, | 25 __proto__: OptionsPage.prototype, |
26 | 26 |
| 27 /** |
| 28 * The timer id of the timer set on search query change events. |
| 29 * @type {number} |
| 30 * @private |
| 31 */ |
| 32 queryDelayTimerId_: 0, |
| 33 |
| 34 /** |
| 35 * The most recent search query, or null if the query is empty. |
| 36 * @type {?string} |
| 37 * @private |
| 38 */ |
| 39 lastQuery_ : null, |
| 40 |
27 initializePage: function() { | 41 initializePage: function() { |
28 OptionsPage.prototype.initializePage.call(this); | 42 OptionsPage.prototype.initializePage.call(this); |
29 | 43 |
30 $('cookies-search-box').addEventListener('search', | 44 $('cookies-search-box').addEventListener('search', |
31 this.handleSearchQueryChange_.bind(this)); | 45 this.handleSearchQueryChange_.bind(this)); |
32 | 46 |
33 $('remove-all-cookies-button').onclick = function(e) { | 47 $('remove-all-cookies-button').onclick = function(e) { |
34 chrome.send('removeAllCookies', []); | 48 chrome.send('removeAllCookies', []); |
35 }; | 49 }; |
36 | 50 |
37 var cookiesList = $('cookies-list'); | 51 var cookiesList = $('cookies-list'); |
38 options.CookiesList.decorate(cookiesList); | 52 options.CookiesList.decorate(cookiesList); |
39 | 53 |
40 this.addEventListener('visibleChange', this.handleVisibleChange_); | 54 this.addEventListener('visibleChange', this.handleVisibleChange_); |
41 }, | 55 }, |
42 | 56 |
43 lastQuery_ : null, | |
44 | |
45 /** | 57 /** |
46 * Search cookie using text in |cookies-search-box|. | 58 * Search cookie using text in |cookies-search-box|. |
47 */ | 59 */ |
48 searchCookie: function() { | 60 searchCookie: function() { |
49 this.queryDelayTimerId_ = 0; | 61 this.queryDelayTimerId_ = 0; |
50 var filter = $('cookies-search-box').value; | 62 var filter = $('cookies-search-box').value; |
51 if (this.lastQuery_ != filter) { | 63 if (this.lastQuery_ != filter) { |
52 this.lastQuery_ = filter; | 64 this.lastQuery_ = filter; |
53 chrome.send('updateCookieSearchResults', [filter]); | 65 chrome.send('updateCookieSearchResults', [filter]); |
54 } | 66 } |
55 }, | 67 }, |
56 | 68 |
57 queryDelayTimerId_: 0, | |
58 | |
59 /** | 69 /** |
60 * Handles search query changes. | 70 * Handles search query changes. |
| 71 * @param {!Event} e The event object. |
61 * @private | 72 * @private |
62 * @param {!Event} e The event object. | |
63 */ | 73 */ |
64 handleSearchQueryChange_: function(e) { | 74 handleSearchQueryChange_: function(e) { |
65 if (this.queryDelayTimerId_) | 75 if (this.queryDelayTimerId_) |
66 window.clearTimeout(this.queryDelayTimerId_); | 76 window.clearTimeout(this.queryDelayTimerId_); |
67 | 77 |
68 this.queryDelayTimerId_ = window.setTimeout( | 78 this.queryDelayTimerId_ = window.setTimeout( |
69 this.searchCookie.bind(this), 500); | 79 this.searchCookie.bind(this), 500); |
70 }, | 80 }, |
71 | 81 |
72 initialized_: false, | 82 initialized_: false, |
(...skipping 27 matching lines...) Expand all Loading... |
100 CookiesView.loadChildren = function(args) { | 110 CookiesView.loadChildren = function(args) { |
101 $('cookies-list').loadChildren(args[0], args[1]); | 111 $('cookies-list').loadChildren(args[0], args[1]); |
102 }; | 112 }; |
103 | 113 |
104 // Export | 114 // Export |
105 return { | 115 return { |
106 CookiesView: CookiesView | 116 CookiesView: CookiesView |
107 }; | 117 }; |
108 | 118 |
109 }); | 119 }); |
OLD | NEW |