| 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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 this._muteSettingListener = false; | 998 this._muteSettingListener = false; |
| 999 } | 999 } |
| 1000 }; | 1000 }; |
| 1001 | 1001 |
| 1002 /** | 1002 /** |
| 1003 * @unrestricted | 1003 * @unrestricted |
| 1004 */ | 1004 */ |
| 1005 UI.ToolbarCheckbox = class extends UI.ToolbarItem { | 1005 UI.ToolbarCheckbox = class extends UI.ToolbarItem { |
| 1006 /** | 1006 /** |
| 1007 * @param {string} text | 1007 * @param {string} text |
| 1008 * @param {string=} title | 1008 * @param {string=} tooltip |
| 1009 * @param {!Common.Setting=} setting | |
| 1010 * @param {function()=} listener | 1009 * @param {function()=} listener |
| 1011 */ | 1010 */ |
| 1012 constructor(text, title, setting, listener) { | 1011 constructor(text, tooltip, listener) { |
| 1013 super(UI.createCheckboxLabel(text)); | 1012 super(UI.createCheckboxLabel(text)); |
| 1014 this.element.classList.add('checkbox'); | 1013 this.element.classList.add('checkbox'); |
| 1015 this.inputElement = this.element.checkboxElement; | 1014 this.inputElement = this.element.checkboxElement; |
| 1016 if (title) | 1015 if (tooltip) |
| 1017 this.element.title = title; | 1016 this.element.title = tooltip; |
| 1018 if (setting) | |
| 1019 UI.SettingsUI.bindCheckbox(this.inputElement, setting); | |
| 1020 if (listener) | 1017 if (listener) |
| 1021 this.inputElement.addEventListener('click', listener, false); | 1018 this.inputElement.addEventListener('click', listener, false); |
| 1022 } | 1019 } |
| 1023 | 1020 |
| 1024 /** | 1021 /** |
| 1025 * @return {boolean} | 1022 * @return {boolean} |
| 1026 */ | 1023 */ |
| 1027 checked() { | 1024 checked() { |
| 1028 return this.inputElement.checked; | 1025 return this.inputElement.checked; |
| 1029 } | 1026 } |
| 1030 | 1027 |
| 1031 /** | 1028 /** |
| 1032 * @param {boolean} value | 1029 * @param {boolean} value |
| 1033 */ | 1030 */ |
| 1034 setChecked(value) { | 1031 setChecked(value) { |
| 1035 this.inputElement.checked = value; | 1032 this.inputElement.checked = value; |
| 1036 } | 1033 } |
| 1037 | 1034 |
| 1038 /** | 1035 /** |
| 1039 * @override | 1036 * @override |
| 1040 * @param {boolean} enabled | 1037 * @param {boolean} enabled |
| 1041 */ | 1038 */ |
| 1042 _applyEnabledState(enabled) { | 1039 _applyEnabledState(enabled) { |
| 1043 super._applyEnabledState(enabled); | 1040 super._applyEnabledState(enabled); |
| 1044 this.inputElement.disabled = !enabled; | 1041 this.inputElement.disabled = !enabled; |
| 1045 } | 1042 } |
| 1046 }; | 1043 }; |
| 1044 |
| 1045 UI.ToolbarSettingCheckbox = class extends UI.ToolbarCheckbox { |
| 1046 /** |
| 1047 * @param {!Common.Setting} setting |
| 1048 * @param {string=} tooltip |
| 1049 * @param {string=} alternateTitle |
| 1050 */ |
| 1051 constructor(setting, tooltip, alternateTitle) { |
| 1052 super(alternateTitle || setting.title() || '', tooltip); |
| 1053 UI.SettingsUI.bindCheckbox(this.inputElement, setting); |
| 1054 } |
| 1055 }; |
| OLD | NEW |