OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 27 matching lines...) Expand all Loading... |
38 */ | 38 */ |
39 lastQuery_: null, | 39 lastQuery_: null, |
40 | 40 |
41 initializePage: function() { | 41 initializePage: function() { |
42 OptionsPage.prototype.initializePage.call(this); | 42 OptionsPage.prototype.initializePage.call(this); |
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)); | |
54 | 53 |
55 this.addEventListener('visibleChange', this.handleVisibleChange_); | 54 this.addEventListener('visibleChange', this.handleVisibleChange_); |
56 | 55 |
57 $('cookies-view-overlay-confirm').onclick = | 56 $('cookies-view-overlay-confirm').onclick = |
58 OptionsPage.closeOverlay.bind(OptionsPage); | 57 OptionsPage.closeOverlay.bind(OptionsPage); |
59 }, | 58 }, |
60 | 59 |
61 /** | 60 /** |
62 * Search cookie using text in |cookies-search-box|. | 61 * Search cookie using text in |cookies-search-box|. |
63 */ | 62 */ |
(...skipping 23 matching lines...) Expand all Loading... |
87 | 86 |
88 /** | 87 /** |
89 * Handler for OptionsPage's visible property change event. | 88 * Handler for OptionsPage's visible property change event. |
90 * @param {Event} e Property change event. | 89 * @param {Event} e Property change event. |
91 * @private | 90 * @private |
92 */ | 91 */ |
93 handleVisibleChange_: function(e) { | 92 handleVisibleChange_: function(e) { |
94 if (!this.visible) | 93 if (!this.visible) |
95 return; | 94 return; |
96 | 95 |
97 // Resize the cookies list whenever the options page becomes visible. | |
98 this.handleResize_(null); | |
99 if (!this.initialized_) { | 96 if (!this.initialized_) { |
100 this.initialized_ = true; | 97 this.initialized_ = true; |
101 this.searchCookie(); | 98 this.searchCookie(); |
102 } else { | 99 } else { |
103 $('cookies-list').redraw(); | 100 $('cookies-list').redraw(); |
104 } | 101 } |
105 | 102 |
106 $('cookies-search-box').focus(); | 103 $('cookies-search-box').focus(); |
107 }, | 104 }, |
108 | |
109 /** | |
110 * Handler for when the window changes size. Resizes the cookies list to | |
111 * match the window height. | |
112 * @param {?Event} e Window resize event, or null if called directly. | |
113 * @private | |
114 */ | |
115 handleResize_: function(e) { | |
116 if (!this.visible) | |
117 return; | |
118 var cookiesList = $('cookies-list'); | |
119 // 25 pixels from the window bottom seems like a visually pleasing amount. | |
120 var height = window.innerHeight - cookiesList.offsetTop - 25; | |
121 cookiesList.style.height = height + 'px'; | |
122 }, | |
123 }; | 105 }; |
124 | 106 |
125 // CookiesViewHandler callbacks. | 107 // CookiesViewHandler callbacks. |
126 CookiesView.onTreeItemAdded = function(args) { | 108 CookiesView.onTreeItemAdded = function(args) { |
127 $('cookies-list').addByParentId(args[0], args[1], args[2]); | 109 $('cookies-list').addByParentId(args[0], args[1], args[2]); |
128 }; | 110 }; |
129 | 111 |
130 CookiesView.onTreeItemRemoved = function(args) { | 112 CookiesView.onTreeItemRemoved = function(args) { |
131 $('cookies-list').removeByParentId(args[0], args[1], args[2]); | 113 $('cookies-list').removeByParentId(args[0], args[1], args[2]); |
132 }; | 114 }; |
133 | 115 |
134 CookiesView.loadChildren = function(args) { | 116 CookiesView.loadChildren = function(args) { |
135 $('cookies-list').loadChildren(args[0], args[1]); | 117 $('cookies-list').loadChildren(args[0], args[1]); |
136 }; | 118 }; |
137 | 119 |
138 // Export | 120 // Export |
139 return { | 121 return { |
140 CookiesView: CookiesView | 122 CookiesView: CookiesView |
141 }; | 123 }; |
142 | 124 |
143 }); | 125 }); |
OLD | NEW |