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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/Toolbar.js

Issue 2662403002: [DevTools] Merge filter bar with the main toolbar (Closed)
Patch Set: [DevTools] Merge filter bar with the main toolbar Created 3 years, 10 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 Click: Symbol('Click'), 545 Click: Symbol('Click'),
546 MouseDown: Symbol('MouseDown'), 546 MouseDown: Symbol('MouseDown'),
547 MouseUp: Symbol('MouseUp') 547 MouseUp: Symbol('MouseUp')
548 }; 548 };
549 549
550 /** 550 /**
551 * @unrestricted 551 * @unrestricted
552 */ 552 */
553 UI.ToolbarInput = class extends UI.ToolbarItem { 553 UI.ToolbarInput = class extends UI.ToolbarItem {
554 /** 554 /**
555 * @param {string=} placeholder 555 * @param {string} placeholder
556 * @param {number=} growFactor 556 * @param {number=} growFactor
557 * @param {number=} shrinkFactor 557 * @param {number=} shrinkFactor
558 * @param {boolean=} isSearchField
558 */ 559 */
559 constructor(placeholder, growFactor, shrinkFactor) { 560 constructor(placeholder, growFactor, shrinkFactor, isSearchField) {
560 super(createElementWithClass('input', 'toolbar-item')); 561 super(createElementWithClass('div', 'toolbar-input'));
561 this.element.addEventListener('input', this._onChangeCallback.bind(this), fa lse); 562
563 this.input = this.element.createChild('input');
564 this.input.addEventListener('focus', () => this.element.classList.add('focus ed'));
565 this.input.addEventListener('blur', () => this.element.classList.remove('foc used'));
566 this.input.addEventListener('input', () => this._onChangeCallback(), false);
567 this._isSearchField = !!isSearchField;
562 if (growFactor) 568 if (growFactor)
563 this.element.style.flexGrow = growFactor; 569 this.element.style.flexGrow = growFactor;
564 if (shrinkFactor) 570 if (shrinkFactor)
565 this.element.style.flexShrink = shrinkFactor; 571 this.element.style.flexShrink = shrinkFactor;
566 if (placeholder) 572 if (placeholder)
567 this.element.setAttribute('placeholder', placeholder); 573 this.input.setAttribute('placeholder', placeholder);
568 this._value = ''; 574
575 if (isSearchField)
576 this._setupSearchControls();
577 }
578
579 _setupSearchControls() {
580 var clearButton = this.element.createChild('div', 'toolbar-input-clear-butto n');
581 clearButton.appendChild(UI.Icon.create('smallicon-clear-input', 'search-canc el-button'));
582 clearButton.addEventListener('click', () => this._internalSetValue('', true) );
583 this.input.addEventListener('keydown', event => this._onKeydownCallback(even t));
569 } 584 }
570 585
571 /** 586 /**
572 * @param {string} value 587 * @param {string} value
573 */ 588 */
574 setValue(value) { 589 setValue(value) {
575 this._value = value; 590 this._internalSetValue(value, false);
576 this.element.value = value; 591 }
592
593 /**
594 * @param {string} value
595 * @param {boolean} notify
596 */
597 _internalSetValue(value, notify) {
598 this.input.value = value;
599 if (notify)
600 this._onChangeCallback();
577 } 601 }
578 602
579 /** 603 /**
580 * @return {string} 604 * @return {string}
581 */ 605 */
582 value() { 606 value() {
583 return this.element.value; 607 return this.input.value;
608 }
609
610 /**
611 * @param {!Event} event
612 */
613 _onKeydownCallback(event) {
614 if (this.isSearchField || !isEscKey(event) || !this.input.value)
615 return;
616 this._internalSetValue('', true);
617 event.consume(true);
584 } 618 }
585 619
586 _onChangeCallback() { 620 _onChangeCallback() {
587 this.dispatchEventToListeners(UI.ToolbarInput.Event.TextChanged, this.elemen t.value); 621 this.dispatchEventToListeners(UI.ToolbarInput.Event.TextChanged, this.input. value);
588 } 622 }
589 }; 623 };
590 624
591 UI.ToolbarInput.Event = { 625 UI.ToolbarInput.Event = {
592 TextChanged: Symbol('TextChanged') 626 TextChanged: Symbol('TextChanged')
593 }; 627 };
594 628
595 /** 629 /**
596 * @unrestricted 630 * @unrestricted
597 */ 631 */
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 1032
999 /** 1033 /**
1000 * @override 1034 * @override
1001 * @param {boolean} enabled 1035 * @param {boolean} enabled
1002 */ 1036 */
1003 _applyEnabledState(enabled) { 1037 _applyEnabledState(enabled) {
1004 super._applyEnabledState(enabled); 1038 super._applyEnabledState(enabled);
1005 this.inputElement.disabled = !enabled; 1039 this.inputElement.disabled = !enabled;
1006 } 1040 }
1007 }; 1041 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698