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

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

Issue 2011943005: MD History/Downloads: Update toolbar and background color (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Downloads toolbar buttons Created 4 years, 6 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 | chrome/browser/resources/md_downloads/toolbar.css » ('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 10315 matching lines...) Expand 10 before | Expand all | Expand 10 after
10326 10326
10327 _altChanged: function(newValue, oldValue) { 10327 _altChanged: function(newValue, oldValue) {
10328 var label = this.getAttribute('aria-label'); 10328 var label = this.getAttribute('aria-label');
10329 10329
10330 // Don't stomp over a user-set aria-label. 10330 // Don't stomp over a user-set aria-label.
10331 if (!label || oldValue == label) { 10331 if (!label || oldValue == label) {
10332 this.setAttribute('aria-label', newValue); 10332 this.setAttribute('aria-label', newValue);
10333 } 10333 }
10334 } 10334 }
10335 }); 10335 });
10336 // Copyright 2016 The Chromium Authors. All rights reserved.
10337 // Use of this source code is governed by a BSD-style license that can be
10338 // found in the LICENSE file.
10339
10340 /** @interface */
10341 var SearchFieldDelegate = function() {};
10342
10343 SearchFieldDelegate.prototype = {
10344 /**
10345 * @param {string} value
10346 */
10347 onSearchTermSearch: assertNotReached,
10348 };
10349
10350 /**
10351 * Implements an incremental search field which can be shown and hidden.
10352 * Canonical implementation is <cr-search-field>.
10353 * @polymerBehavior
10354 */
10355 var CrSearchFieldBehavior = {
10356 properties: {
10357 label: {
10358 type: String,
10359 value: '',
10360 },
10361
10362 clearLabel: {
10363 type: String,
10364 value: '',
10365 },
10366
10367 showingSearch: {
10368 type: Boolean,
10369 value: false,
10370 notify: true,
10371 observer: 'showingSearchChanged_',
10372 reflectToAttribute: true
10373 },
10374
10375 hasSearchText: Boolean,
10376 },
10377
10378 /**
10379 * @return {string} The value of the search field.
10380 */
10381 getValue: function() {
10382 return this.$.searchInput.value;
10383 },
10384
10385 /**
10386 * Sets the value of the search field, if it exists.
10387 * @param {string} value
10388 */
10389 setValue: function(value) {
10390 // Use bindValue when setting the input value so that changes propagate
10391 // correctly.
10392 this.$.searchInput.bindValue = value;
10393 this.hasSearchText = value != '';
10394 },
10395
10396 /** @param {SearchFieldDelegate} delegate */
10397 setDelegate: function(delegate) {
10398 this.delegate_ = delegate;
10399 },
10400
10401 showAndFocus: function() {
10402 this.showingSearch = true;
10403 this.focus_();
10404 },
10405
10406 /** @private */
10407 focus_: function() {
10408 this.$.searchInput.focus();
10409 },
10410
10411 /** @private */
10412 onSearchTermSearch_: function() {
10413 this.hasSearchText = this.getValue() != '';
10414 if (this.delegate_)
10415 this.delegate_.onSearchTermSearch(this.getValue());
10416 },
10417
10418 /** @private */
10419 onSearchTermKeydown_: function(e) {
10420 if (e.key == 'Escape')
10421 this.showingSearch = false;
10422 },
10423
10424 /** @private */
10425 showingSearchChanged_: function() {
10426 if (this.showingSearch) {
10427 this.focus_();
10428 return;
10429 }
10430
10431 this.setValue('');
10432 this.$.searchInput.blur();
10433 this.onSearchTermSearch_();
10434 },
10435
10436 /** @private */
10437 toggleShowingSearch_: function() {
10438 this.showingSearch = !this.showingSearch;
10439 },
10440 };
10336 (function() { 10441 (function() {
10337 'use strict'; 10442 'use strict';
10338 10443
10339 Polymer.IronA11yAnnouncer = Polymer({ 10444 Polymer.IronA11yAnnouncer = Polymer({
10340 is: 'iron-a11y-announcer', 10445 is: 'iron-a11y-announcer',
10341 10446
10342 properties: { 10447 properties: {
10343 10448
10344 /** 10449 /**
10345 * The value of mode is used to set the `aria-live` attribute 10450 * The value of mode is used to set the `aria-live` attribute
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
11091 } else if (focused) { 11196 } else if (focused) {
11092 cls += ' is-highlighted' 11197 cls += ' is-highlighted'
11093 } 11198 }
11094 return cls; 11199 return cls;
11095 } 11200 }
11096 }); 11201 });
11097 // Copyright 2015 The Chromium Authors. All rights reserved. 11202 // Copyright 2015 The Chromium Authors. All rights reserved.
11098 // Use of this source code is governed by a BSD-style license that can be 11203 // Use of this source code is governed by a BSD-style license that can be
11099 // found in the LICENSE file. 11204 // found in the LICENSE file.
11100 11205
11101 /** @interface */
11102 var SearchFieldDelegate = function() {};
11103
11104 SearchFieldDelegate.prototype = {
11105 /**
11106 * @param {string} value
11107 */
11108 onSearchTermSearch: assertNotReached,
11109 };
11110
11111 var SearchField = Polymer({ 11206 var SearchField = Polymer({
11112 is: 'cr-search-field', 11207 is: 'cr-search-field',
11113 11208 behaviors: [CrSearchFieldBehavior]
11114 properties: {
11115 label: {
11116 type: String,
11117 value: '',
11118 },
11119
11120 clearLabel: {
11121 type: String,
11122 value: '',
11123 },
11124
11125 showingSearch_: {
11126 type: Boolean,
11127 value: false,
11128 observer: 'showingSearchChanged_',
11129 },
11130 },
11131
11132 /**
11133 * Returns the value of the search field.
11134 * @return {string}
11135 */
11136 getValue: function() {
11137 var searchInput = this.getSearchInput_();
11138 return searchInput ? searchInput.value : '';
11139 },
11140
11141 /**
11142 * Sets the value of the search field, if it exists.
11143 * @param {string} value
11144 */
11145 setValue: function(value) {
11146 var searchInput = this.getSearchInput_();
11147 if (searchInput)
11148 searchInput.value = value;
11149 },
11150
11151 /** @param {SearchFieldDelegate} delegate */
11152 setDelegate: function(delegate) {
11153 this.delegate_ = delegate;
11154 },
11155
11156 /** @return {Promise<boolean>} */
11157 showAndFocus: function() {
11158 this.showingSearch_ = true;
11159 return this.focus_();
11160 },
11161
11162 /**
11163 * @return {Promise<boolean>}
11164 * @private
11165 */
11166 focus_: function() {
11167 return new Promise(function(resolve) {
11168 this.async(function() {
11169 if (this.showingSearch_) {
11170 var searchInput = this.getSearchInput_();
11171 if (searchInput)
11172 searchInput.focus();
11173 }
11174 resolve(this.showingSearch_);
11175 });
11176 }.bind(this));
11177 },
11178
11179 /**
11180 * @return {?Element}
11181 * @private
11182 */
11183 getSearchInput_: function() {
11184 return this.$$('#search-input');
11185 },
11186
11187 /** @private */
11188 onSearchTermSearch_: function() {
11189 if (this.delegate_)
11190 this.delegate_.onSearchTermSearch(this.getValue());
11191 },
11192
11193 /** @private */
11194 onSearchTermKeydown_: function(e) {
11195 if (e.keyIdentifier == 'U+001B') // Escape.
11196 this.showingSearch_ = false;
11197 },
11198
11199 /** @private */
11200 showingSearchChanged_: function() {
11201 if (this.showingSearch_) {
11202 this.focus_();
11203 return;
11204 }
11205
11206 var searchInput = this.getSearchInput_();
11207 if (!searchInput)
11208 return;
11209
11210 searchInput.value = '';
11211 this.onSearchTermSearch_();
11212 },
11213
11214 /** @private */
11215 toggleShowingSearch_: function() {
11216 this.showingSearch_ = !this.showingSearch_;
11217 },
11218 }); 11209 });
11219 // Copyright 2015 The Chromium Authors. All rights reserved. 11210 // Copyright 2015 The Chromium Authors. All rights reserved.
11220 // Use of this source code is governed by a BSD-style license that can be 11211 // Use of this source code is governed by a BSD-style license that can be
11221 // found in the LICENSE file. 11212 // found in the LICENSE file.
11222 11213
11223 cr.define('downloads', function() { 11214 cr.define('downloads', function() {
11224 var Toolbar = Polymer({ 11215 var Toolbar = Polymer({
11225 is: 'downloads-toolbar', 11216 is: 'downloads-toolbar',
11226 11217
11227 attached: function() { 11218 attached: function() {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
11498 Manager.get().updateItem_(index, data); 11489 Manager.get().updateItem_(index, data);
11499 }; 11490 };
11500 11491
11501 return {Manager: Manager}; 11492 return {Manager: Manager};
11502 }); 11493 });
11503 // Copyright 2015 The Chromium Authors. All rights reserved. 11494 // Copyright 2015 The Chromium Authors. All rights reserved.
11504 // Use of this source code is governed by a BSD-style license that can be 11495 // Use of this source code is governed by a BSD-style license that can be
11505 // found in the LICENSE file. 11496 // found in the LICENSE file.
11506 11497
11507 window.addEventListener('load', downloads.Manager.onLoad); 11498 window.addEventListener('load', downloads.Manager.onLoad);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_downloads/toolbar.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698