| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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._valueChanged.bind(this)
, false); |
| 912 var optionContainer = this._selectElement; |
| 913 var optGroupElement = optGroup ? this._selectElement.createChild('optgroup')
: null; |
| 914 if (optGroupElement) { |
| 915 optGroupElement.label = optGroup; |
| 916 optionContainer = optGroupElement; |
| 917 } |
| 918 for (var i = 0; i < options.length; ++i) { |
| 919 var dataOption = options[i]; |
| 920 var option = this.createOption(dataOption.label, dataOption.title, dataOpt
ion.value); |
| 921 optionContainer.appendChild(option); |
| 922 if (setting.get() === dataOption.value) |
| 923 this.setSelectedIndex(i); |
| 924 } |
| 925 |
| 926 setting.addChangeListener(this._settingChanged, this); |
| 927 } |
| 928 |
| 929 /** |
| 930 * @return {string} |
| 931 */ |
| 932 value() { |
| 933 return this._options[this.selectedIndex()].value; |
| 934 } |
| 935 |
| 936 _settingChanged() { |
| 937 if (this._muteSettingListener) |
| 938 return; |
| 939 |
| 940 var value = this._setting.get(); |
| 941 for (var i = 0; i < this._options.length; ++i) { |
| 942 if (value === this._options[i].value) { |
| 943 this.setSelectedIndex(i); |
| 944 break; |
| 945 } |
| 946 } |
| 947 } |
| 948 |
| 949 /** |
| 950 * @param {!Event} event |
| 951 */ |
| 952 _valueChanged(event) { |
| 953 var option = this._options[this.selectedIndex()]; |
| 954 this._muteSettingListener = true; |
| 955 this._setting.set(option.value); |
| 956 this._muteSettingListener = false; |
| 957 } |
| 958 }; |
| 959 |
| 960 /** |
| 961 * @unrestricted |
| 962 */ |
| 898 UI.ToolbarCheckbox = class extends UI.ToolbarItem { | 963 UI.ToolbarCheckbox = class extends UI.ToolbarItem { |
| 899 /** | 964 /** |
| 900 * @param {string} text | 965 * @param {string} text |
| 901 * @param {string=} title | 966 * @param {string=} title |
| 902 * @param {!Common.Setting=} setting | 967 * @param {!Common.Setting=} setting |
| 903 * @param {function()=} listener | 968 * @param {function()=} listener |
| 904 */ | 969 */ |
| 905 constructor(text, title, setting, listener) { | 970 constructor(text, title, setting, listener) { |
| 906 super(UI.createCheckboxLabel(text)); | 971 super(UI.createCheckboxLabel(text)); |
| 907 this.element.classList.add('checkbox'); | 972 this.element.classList.add('checkbox'); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 930 | 995 |
| 931 /** | 996 /** |
| 932 * @override | 997 * @override |
| 933 * @param {boolean} enabled | 998 * @param {boolean} enabled |
| 934 */ | 999 */ |
| 935 _applyEnabledState(enabled) { | 1000 _applyEnabledState(enabled) { |
| 936 super._applyEnabledState(enabled); | 1001 super._applyEnabledState(enabled); |
| 937 this.inputElement.disabled = !enabled; | 1002 this.inputElement.disabled = !enabled; |
| 938 } | 1003 } |
| 939 }; | 1004 }; |
| OLD | NEW |