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

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

Issue 2180843006: MD WebUI: Remove local DOM access from CrSearchFieldBehavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cr_search_field_clear
Patch Set: Vulcanize Created 4 years, 4 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
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_search_field/cr_search_field.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 /** 5 /**
6 * @fileoverview Assertion support. 6 * @fileoverview Assertion support.
7 */ 7 */
8 8
9 /** 9 /**
10 * Verify |condition| is truthy and return |condition| if so. 10 * Verify |condition| is truthy and return |condition| if so.
(...skipping 10489 matching lines...) Expand 10 before | Expand all | Expand 10 after
10500 }, 10500 },
10501 10501
10502 /** @private */ 10502 /** @private */
10503 lastValue_: { 10503 lastValue_: {
10504 type: String, 10504 type: String,
10505 value: '', 10505 value: '',
10506 }, 10506 },
10507 }, 10507 },
10508 10508
10509 /** 10509 /**
10510 * @abstract
10511 * @return {!HTMLInputElement} The input field element the behavior should
10512 * use.
10513 */
10514 getSearchInput: function() {},
10515
10516 /**
10510 * @return {string} The value of the search field. 10517 * @return {string} The value of the search field.
10511 */ 10518 */
10512 getValue: function() { 10519 getValue: function() {
10513 return this.$.searchInput.value; 10520 return this.getSearchInput().value;
10514 }, 10521 },
10515 10522
10516 /** 10523 /**
10517 * Sets the value of the search field. 10524 * Sets the value of the search field.
10518 * @param {string} value 10525 * @param {string} value
10519 */ 10526 */
10520 setValue: function(value) { 10527 setValue: function(value) {
10521 // Use bindValue when setting the input value so that changes propagate 10528 // Use bindValue when setting the input value so that changes propagate
10522 // correctly. 10529 // correctly.
10523 this.$.searchInput.bindValue = value; 10530 this.getSearchInput().bindValue = value;
10524 this.onValueChanged_(value); 10531 this.onValueChanged_(value);
10525 }, 10532 },
10526 10533
10527 showAndFocus: function() { 10534 showAndFocus: function() {
10528 this.showingSearch = true; 10535 this.showingSearch = true;
10529 this.focus_(); 10536 this.focus_();
10530 }, 10537 },
10531 10538
10532 /** @private */ 10539 /** @private */
10533 focus_: function() { 10540 focus_: function() {
10534 this.$.searchInput.focus(); 10541 this.getSearchInput().focus();
10535 }, 10542 },
10536 10543
10537 onSearchTermSearch: function() { 10544 onSearchTermSearch: function() {
10538 this.onValueChanged_(this.getValue()); 10545 this.onValueChanged_(this.getValue());
10539 }, 10546 },
10540 10547
10541 /** 10548 /**
10542 * Updates the internal state of the search field based on a change that has 10549 * Updates the internal state of the search field based on a change that has
10543 * already happened. 10550 * already happened.
10544 * @param {string} newValue 10551 * @param {string} newValue
(...skipping 13 matching lines...) Expand all
10558 }, 10565 },
10559 10566
10560 /** @private */ 10567 /** @private */
10561 showingSearchChanged_: function() { 10568 showingSearchChanged_: function() {
10562 if (this.showingSearch) { 10569 if (this.showingSearch) {
10563 this.focus_(); 10570 this.focus_();
10564 return; 10571 return;
10565 } 10572 }
10566 10573
10567 this.setValue(''); 10574 this.setValue('');
10568 this.$.searchInput.blur(); 10575 this.getSearchInput().blur();
10569 },
10570
10571 /** @return {boolean} */
10572 isSearchFocused: function() {
10573 return this.$.searchTerm.focused;
10574 } 10576 }
10575 }; 10577 };
10576 (function() { 10578 (function() {
10577 'use strict'; 10579 'use strict';
10578 10580
10579 Polymer.IronA11yAnnouncer = Polymer({ 10581 Polymer.IronA11yAnnouncer = Polymer({
10580 is: 'iron-a11y-announcer', 10582 is: 'iron-a11y-announcer',
10581 10583
10582 properties: { 10584 properties: {
10583 10585
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
11340 11342
11341 var SearchField = Polymer({ 11343 var SearchField = Polymer({
11342 is: 'cr-search-field', 11344 is: 'cr-search-field',
11343 11345
11344 behaviors: [CrSearchFieldBehavior], 11346 behaviors: [CrSearchFieldBehavior],
11345 11347
11346 properties: { 11348 properties: {
11347 value_: String, 11349 value_: String,
11348 }, 11350 },
11349 11351
11352 /** @return {!HTMLInputElement} */
11353 getSearchInput: function() {
11354 return this.$.searchInput;
11355 },
11356
11350 /** @private */ 11357 /** @private */
11351 clearSearch_: function() { 11358 clearSearch_: function() {
11352 this.setValue(''); 11359 this.setValue('');
11353 this.$.searchInput.focus(); 11360 this.getSearchInput().focus();
11354 }, 11361 },
11355 11362
11356 /** @private */ 11363 /** @private */
11357 toggleShowingSearch_: function() { 11364 toggleShowingSearch_: function() {
11358 this.showingSearch = !this.showingSearch; 11365 this.showingSearch = !this.showingSearch;
11359 }, 11366 },
11360 }); 11367 });
11361 // Copyright 2015 The Chromium Authors. All rights reserved. 11368 // Copyright 2015 The Chromium Authors. All rights reserved.
11362 // Use of this source code is governed by a BSD-style license that can be 11369 // Use of this source code is governed by a BSD-style license that can be
11363 // found in the LICENSE file. 11370 // found in the LICENSE file.
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
11659 Manager.get().updateItem_(index, data); 11666 Manager.get().updateItem_(index, data);
11660 }; 11667 };
11661 11668
11662 return {Manager: Manager}; 11669 return {Manager: Manager};
11663 }); 11670 });
11664 // Copyright 2015 The Chromium Authors. All rights reserved. 11671 // Copyright 2015 The Chromium Authors. All rights reserved.
11665 // Use of this source code is governed by a BSD-style license that can be 11672 // Use of this source code is governed by a BSD-style license that can be
11666 // found in the LICENSE file. 11673 // found in the LICENSE file.
11667 11674
11668 window.addEventListener('load', downloads.Manager.onLoad); 11675 window.addEventListener('load', downloads.Manager.onLoad);
OLDNEW
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_search_field/cr_search_field.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698