Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1202)

Side by Side Diff: chrome/browser/resources/md_downloads/toolbar.js

Issue 1613233003: MD Downloads: make Ctrl+f invoke in-page search (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dl-vulcanize
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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('downloads', function() { 5 cr.define('downloads', function() {
6 var Toolbar = Polymer({ 6 var Toolbar = Polymer({
7 is: 'downloads-toolbar', 7 is: 'downloads-toolbar',
8 8
9 attached: function() { 9 attached: function() {
10 // isRTL() only works after i18n_template.js runs to set <html dir>. 10 // isRTL() only works after i18n_template.js runs to set <html dir>.
11 this.overflowAlign_ = isRTL() ? 'left' : 'right'; 11 this.overflowAlign_ = isRTL() ? 'left' : 'right';
12 12
13 /** @private {!SearchFieldDelegate} */ 13 /** @private {!SearchFieldDelegate} */
14 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); 14 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this);
15 this.$['search-input'].setDelegate(this.searchFieldDelegate_); 15 this.$['search-input'].setDelegate(this.searchFieldDelegate_);
16 }, 16 },
17 17
18 properties: { 18 properties: {
19 downloadsShowing: { 19 downloadsShowing: {
20 reflectToAttribute: true, 20 reflectToAttribute: true,
21 type: Boolean, 21 type: Boolean,
22 value: false, 22 value: false,
23 observer: 'onDownloadsShowingChange_', 23 observer: 'downloadsShowingChanged_',
24 }, 24 },
25 25
26 overflowAlign_: { 26 overflowAlign_: {
27 type: String, 27 type: String,
28 value: 'right', 28 value: 'right',
29 }, 29 },
30 }, 30 },
31 31
32 /** @return {boolean} Whether removal can be undone. */ 32 /** @return {boolean} Whether removal can be undone. */
33 canUndo: function() { 33 canUndo: function() {
34 return this.$['search-input'] != this.shadowRoot.activeElement; 34 return this.$['search-input'] != this.shadowRoot.activeElement;
35 }, 35 },
36 36
37 /** @return {boolean} Whether "Clear all" should be allowed. */ 37 /** @return {boolean} Whether "Clear all" should be allowed. */
38 canClearAll: function() { 38 canClearAll: function() {
39 return !this.$['search-input'].getValue() && this.downloadsShowing; 39 return !this.$['search-input'].getValue() && this.downloadsShowing;
40 }, 40 },
41 41
42 onFindCommand: function() {
43 var searchInput = this.$ && this.$['search-input'];
michaelpg 2016/01/21 22:04:14 this should already be true anyway (the element sh
Dan Beam 2016/01/21 23:39:27 I'm not sure calling .focus() should show; I'd rat
44 if (!searchInput)
45 return;
46
47 searchInput.showingSearch = true;
48 searchInput.focus();
michaelpg 2016/01/21 22:04:14 doesn't this need to be async if showingSearch was
Dan Beam 2016/01/21 22:14:46 yeah, I think it was working because bugs. maybe
michaelpg 2016/01/21 22:19:01 i agree. or just have focus() do it... seems like
Dan Beam 2016/01/21 23:39:27 eh, I think it's more reasonable to compose out sh
michaelpg 2016/01/21 23:43:34 sgtm
49 },
50
42 /** @private */ 51 /** @private */
43 onClearAllTap_: function() { 52 onClearAllTap_: function() {
44 assert(this.canClearAll()); 53 assert(this.canClearAll());
45 downloads.ActionService.getInstance().clearAll(); 54 downloads.ActionService.getInstance().clearAll();
46 }, 55 },
47 56
48 /** @private */ 57 /** @private */
49 onDownloadsShowingChange_: function() { 58 downloadsShowingChanged_: function() {
50 this.updateClearAll_(); 59 this.updateClearAll_();
51 }, 60 },
52 61
53 /** @param {string} searchTerm */ 62 /** @param {string} searchTerm */
54 onSearchTermSearch: function(searchTerm) { 63 onSearchTermSearch: function(searchTerm) {
55 downloads.ActionService.getInstance().search(searchTerm); 64 downloads.ActionService.getInstance().search(searchTerm);
56 this.updateClearAll_(); 65 this.updateClearAll_();
57 }, 66 },
58 67
59 /** @private */ 68 /** @private */
(...skipping 27 matching lines...) Expand all
87 }; 96 };
88 97
89 return {Toolbar: Toolbar}; 98 return {Toolbar: Toolbar};
90 }); 99 });
91 100
92 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files 101 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files
93 /** @suppress {checkTypes} */ 102 /** @suppress {checkTypes} */
94 (function() { 103 (function() {
95 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; 104 Polymer.IronDropdownScrollManager.pushScrollLock = function() {};
96 })(); 105 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698