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: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 $('cookies-search-box').addEventListener('search', | 44 $('cookies-search-box').addEventListener('search', |
45 this.handleSearchQueryChange_.bind(this)); | 45 this.handleSearchQueryChange_.bind(this)); |
46 | 46 |
47 $('remove-all-cookies-button').onclick = function(e) { | 47 $('remove-all-cookies-button').onclick = function(e) { |
48 chrome.send('removeAllCookies', []); | 48 chrome.send('removeAllCookies', []); |
49 }; | 49 }; |
50 | 50 |
51 var cookiesList = $('cookies-list'); | 51 var cookiesList = $('cookies-list'); |
52 options.CookiesList.decorate(cookiesList); | 52 options.CookiesList.decorate(cookiesList); |
| 53 window.addEventListener('resize', this.handleResize_.bind(this)); |
53 | 54 |
54 this.addEventListener('visibleChange', this.handleVisibleChange_); | 55 this.addEventListener('visibleChange', this.handleVisibleChange_); |
55 }, | 56 }, |
56 | 57 |
57 /** | 58 /** |
58 * Search cookie using text in |cookies-search-box|. | 59 * Search cookie using text in |cookies-search-box|. |
59 */ | 60 */ |
60 searchCookie: function() { | 61 searchCookie: function() { |
61 this.queryDelayTimerId_ = 0; | 62 this.queryDelayTimerId_ = 0; |
62 var filter = $('cookies-search-box').value; | 63 var filter = $('cookies-search-box').value; |
(...skipping 13 matching lines...) Expand all Loading... |
76 window.clearTimeout(this.queryDelayTimerId_); | 77 window.clearTimeout(this.queryDelayTimerId_); |
77 | 78 |
78 this.queryDelayTimerId_ = window.setTimeout( | 79 this.queryDelayTimerId_ = window.setTimeout( |
79 this.searchCookie.bind(this), 500); | 80 this.searchCookie.bind(this), 500); |
80 }, | 81 }, |
81 | 82 |
82 initialized_: false, | 83 initialized_: false, |
83 | 84 |
84 /** | 85 /** |
85 * Handler for OptionsPage's visible property change event. | 86 * Handler for OptionsPage's visible property change event. |
| 87 * @param {Event} e Property change event. |
86 * @private | 88 * @private |
87 * @param {Event} e Property change event. | |
88 */ | 89 */ |
89 handleVisibleChange_: function(e) { | 90 handleVisibleChange_: function(e) { |
90 if (!this.visible) | 91 if (!this.visible) |
91 return; | 92 return; |
| 93 // Resize the cookies list whenever the options page becomes visible. |
| 94 this.handleResize_(null); |
92 if (!this.initialized_) { | 95 if (!this.initialized_) { |
93 this.initialized_ = true; | 96 this.initialized_ = true; |
94 this.searchCookie(); | 97 this.searchCookie(); |
95 } else { | 98 } else { |
96 $('cookies-list').redraw(); | 99 $('cookies-list').redraw(); |
97 } | 100 } |
98 }, | 101 }, |
| 102 |
| 103 /** |
| 104 * Handler for when the window changes size. Resizes the cookies list to |
| 105 * match the window height. |
| 106 * @param {?Event} e Window resize event, or null if called directly. |
| 107 * @private |
| 108 */ |
| 109 handleResize_: function(e) { |
| 110 if (!this.visible) |
| 111 return; |
| 112 var cookiesList = $('cookies-list'); |
| 113 // 25 pixels from the window bottom seems like a visually pleasing amount. |
| 114 var height = window.innerHeight - cookiesList.offsetTop - 25; |
| 115 cookiesList.style.height = height + 'px'; |
| 116 }, |
99 }; | 117 }; |
100 | 118 |
101 // CookiesViewHandler callbacks. | 119 // CookiesViewHandler callbacks. |
102 CookiesView.onTreeItemAdded = function(args) { | 120 CookiesView.onTreeItemAdded = function(args) { |
103 $('cookies-list').addByParentId(args[0], args[1], args[2]); | 121 $('cookies-list').addByParentId(args[0], args[1], args[2]); |
104 }; | 122 }; |
105 | 123 |
106 CookiesView.onTreeItemRemoved = function(args) { | 124 CookiesView.onTreeItemRemoved = function(args) { |
107 $('cookies-list').removeByParentId(args[0], args[1], args[2]); | 125 $('cookies-list').removeByParentId(args[0], args[1], args[2]); |
108 }; | 126 }; |
109 | 127 |
110 CookiesView.loadChildren = function(args) { | 128 CookiesView.loadChildren = function(args) { |
111 $('cookies-list').loadChildren(args[0], args[1]); | 129 $('cookies-list').loadChildren(args[0], args[1]); |
112 }; | 130 }; |
113 | 131 |
114 // Export | 132 // Export |
115 return { | 133 return { |
116 CookiesView: CookiesView | 134 CookiesView: CookiesView |
117 }; | 135 }; |
118 | 136 |
119 }); | 137 }); |
OLD | NEW |