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

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

Issue 2666013002: DevTools: render console filter in the main console toolbar. (Closed)
Patch Set: 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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 MouseUp: Symbol('MouseUp') 546 MouseUp: Symbol('MouseUp')
547 }; 547 };
548 548
549 /** 549 /**
550 * @unrestricted 550 * @unrestricted
551 */ 551 */
552 UI.ToolbarInput = class extends UI.ToolbarItem { 552 UI.ToolbarInput = class extends UI.ToolbarItem {
553 /** 553 /**
554 * @param {string=} placeholder 554 * @param {string=} placeholder
555 * @param {number=} growFactor 555 * @param {number=} growFactor
556 * @param {number=} shrinkFactor
556 */ 557 */
557 constructor(placeholder, growFactor) { 558 constructor(placeholder, growFactor, shrinkFactor) {
558 super(createElementWithClass('input', 'toolbar-item')); 559 super(createElementWithClass('input', 'toolbar-item'));
559 this.element.addEventListener('input', this._onChangeCallback.bind(this), fa lse); 560 this.element.addEventListener('input', this._onChangeCallback.bind(this), fa lse);
560 if (growFactor) 561 if (growFactor)
561 this.element.style.flexGrow = growFactor; 562 this.element.style.flexGrow = growFactor;
563 if (shrinkFactor)
564 this.element.style.flexShrink = shrinkFactor;
562 if (placeholder) 565 if (placeholder)
563 this.element.setAttribute('placeholder', placeholder); 566 this.element.setAttribute('placeholder', placeholder);
564 this._value = ''; 567 this._value = '';
565 } 568 }
566 569
567 /** 570 /**
568 * @param {string} value 571 * @param {string} value
569 */ 572 */
570 setValue(value) { 573 setValue(value) {
571 this._value = value; 574 this._value = value;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 * @param {number} width 891 * @param {number} width
889 */ 892 */
890 setMaxWidth(width) { 893 setMaxWidth(width) {
891 this._selectElement.style.maxWidth = width + 'px'; 894 this._selectElement.style.maxWidth = width + 'px';
892 } 895 }
893 }; 896 };
894 897
895 /** 898 /**
896 * @unrestricted 899 * @unrestricted
897 */ 900 */
901 UI.ToolbarSettingComboBox = class extends UI.ToolbarComboBox {
902 /**
903 * @param {!Array.<!{value: string, label: string, title: string, default:(boo lean|undefined)}>} options
904 * @param {!Common.Setting} setting
905 * @param {string=} optGroup
906 */
907 constructor(options, setting, optGroup) {
908 super(null);
909 this._setting = setting;
910 this._options = options;
911 this._selectElement.addEventListener('change', this._filterChanged.bind(this ), false);
912 var optGroupElement = optGroup ? this._selectElement.createChild('optgroup') : null;
913 if (optGroupElement)
914 optGroupElement.label = optGroup;
915 for (var i = 0; i < options.length; ++i) {
916 var filterOption = options[i];
dgozman 2017/01/31 04:21:30 It's not a filter anymore.
pfeldman 2017/01/31 19:54:44 Done.
917 var option = this.createOption(filterOption.label, filterOption.title, fil terOption.value);
918 if (optGroupElement)
919 optGroupElement.appendChild(option);
920 else
921 this._selectElement.appendChild(option);
dgozman 2017/01/31 04:21:30 You can assign this._selectElement to optGroupElem
pfeldman 2017/01/31 19:54:44 I fixed it, but I did not reassign anything.
922 if (setting.get() === filterOption.value)
923 this.setSelectedIndex(i);
924 }
925
926 setting.addChangeListener(this._settingChanged, this);
927 }
928
929 /**
930 * @return {boolean}
931 */
932 isActive() {
dgozman 2017/01/31 04:21:30 isNonDefault
pfeldman 2017/01/31 19:54:44 Done in a way.
933 var option = this._options[this.selectedIndex()];
934 return !option || !option.default;
935 }
936
937 /**
938 * @return {string}
939 */
940 value() {
941 return this._options[this.selectedIndex()].value;
942 }
943
944 _settingChanged() {
945 if (this._muteSettingListener)
946 return;
947
948 var value = this._setting.get();
949 for (var i = 0; i < this._options.length; ++i) {
950 if (value === this._options[i].value) {
951 this.setSelectedIndex(i);
952 break;
953 }
954 }
955 }
956
957 /**
958 * @param {!Event} event
959 */
960 _filterChanged(event) {
dgozman 2017/01/31 04:21:29 _valueChanged
pfeldman 2017/01/31 19:54:45 Done.
961 var option = this._options[this.selectedIndex()];
962 this._muteSettingListener = true;
963 this._setting.set(option.value);
964 this._muteSettingListener = false;
965 }
966 };
967
968 /**
969 * @unrestricted
970 */
898 UI.ToolbarCheckbox = class extends UI.ToolbarItem { 971 UI.ToolbarCheckbox = class extends UI.ToolbarItem {
899 /** 972 /**
900 * @param {string} text 973 * @param {string} text
901 * @param {string=} title 974 * @param {string=} title
902 * @param {!Common.Setting=} setting 975 * @param {!Common.Setting=} setting
903 * @param {function()=} listener 976 * @param {function()=} listener
904 */ 977 */
905 constructor(text, title, setting, listener) { 978 constructor(text, title, setting, listener) {
906 super(UI.createCheckboxLabel(text)); 979 super(UI.createCheckboxLabel(text));
907 this.element.classList.add('checkbox'); 980 this.element.classList.add('checkbox');
(...skipping 22 matching lines...) Expand all
930 1003
931 /** 1004 /**
932 * @override 1005 * @override
933 * @param {boolean} enabled 1006 * @param {boolean} enabled
934 */ 1007 */
935 _applyEnabledState(enabled) { 1008 _applyEnabledState(enabled) {
936 super._applyEnabledState(enabled); 1009 super._applyEnabledState(enabled);
937 this.inputElement.disabled = !enabled; 1010 this.inputElement.disabled = !enabled;
938 } 1011 }
939 }; 1012 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698