| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 WebInspector.SettingsUI = {}; | 30 UI.SettingsUI = {}; |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * @param {string} name | 33 * @param {string} name |
| 34 * @param {!WebInspector.Setting} setting | 34 * @param {!Common.Setting} setting |
| 35 * @param {boolean=} omitParagraphElement | 35 * @param {boolean=} omitParagraphElement |
| 36 * @param {string=} tooltip | 36 * @param {string=} tooltip |
| 37 * @return {!Element} | 37 * @return {!Element} |
| 38 */ | 38 */ |
| 39 WebInspector.SettingsUI.createSettingCheckbox = function(name, setting, omitPara
graphElement, tooltip) { | 39 UI.SettingsUI.createSettingCheckbox = function(name, setting, omitParagraphEleme
nt, tooltip) { |
| 40 var label = createCheckboxLabel(name); | 40 var label = createCheckboxLabel(name); |
| 41 if (tooltip) | 41 if (tooltip) |
| 42 label.title = tooltip; | 42 label.title = tooltip; |
| 43 | 43 |
| 44 var input = label.checkboxElement; | 44 var input = label.checkboxElement; |
| 45 input.name = name; | 45 input.name = name; |
| 46 WebInspector.SettingsUI.bindCheckbox(input, setting); | 46 UI.SettingsUI.bindCheckbox(input, setting); |
| 47 | 47 |
| 48 if (omitParagraphElement) | 48 if (omitParagraphElement) |
| 49 return label; | 49 return label; |
| 50 | 50 |
| 51 var p = createElement('p'); | 51 var p = createElement('p'); |
| 52 p.appendChild(label); | 52 p.appendChild(label); |
| 53 return p; | 53 return p; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * @param {!Element} input | 57 * @param {!Element} input |
| 58 * @param {!WebInspector.Setting} setting | 58 * @param {!Common.Setting} setting |
| 59 */ | 59 */ |
| 60 WebInspector.SettingsUI.bindCheckbox = function(input, setting) { | 60 UI.SettingsUI.bindCheckbox = function(input, setting) { |
| 61 function settingChanged() { | 61 function settingChanged() { |
| 62 if (input.checked !== setting.get()) | 62 if (input.checked !== setting.get()) |
| 63 input.checked = setting.get(); | 63 input.checked = setting.get(); |
| 64 } | 64 } |
| 65 setting.addChangeListener(settingChanged); | 65 setting.addChangeListener(settingChanged); |
| 66 settingChanged(); | 66 settingChanged(); |
| 67 | 67 |
| 68 function inputChanged() { | 68 function inputChanged() { |
| 69 if (setting.get() !== input.checked) | 69 if (setting.get() !== input.checked) |
| 70 setting.set(input.checked); | 70 setting.set(input.checked); |
| 71 } | 71 } |
| 72 input.addEventListener('change', inputChanged, false); | 72 input.addEventListener('change', inputChanged, false); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * @param {string} name | 76 * @param {string} name |
| 77 * @param {!Element} element | 77 * @param {!Element} element |
| 78 * @return {!Element} | 78 * @return {!Element} |
| 79 */ | 79 */ |
| 80 WebInspector.SettingsUI.createCustomSetting = function(name, element) { | 80 UI.SettingsUI.createCustomSetting = function(name, element) { |
| 81 var p = createElement('p'); | 81 var p = createElement('p'); |
| 82 var fieldsetElement = p.createChild('fieldset'); | 82 var fieldsetElement = p.createChild('fieldset'); |
| 83 fieldsetElement.createChild('label').textContent = name; | 83 fieldsetElement.createChild('label').textContent = name; |
| 84 fieldsetElement.appendChild(element); | 84 fieldsetElement.appendChild(element); |
| 85 return p; | 85 return p; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @param {!WebInspector.Setting} setting | 89 * @param {!Common.Setting} setting |
| 90 * @return {!Element} | 90 * @return {!Element} |
| 91 */ | 91 */ |
| 92 WebInspector.SettingsUI.createSettingFieldset = function(setting) { | 92 UI.SettingsUI.createSettingFieldset = function(setting) { |
| 93 var fieldset = createElement('fieldset'); | 93 var fieldset = createElement('fieldset'); |
| 94 fieldset.disabled = !setting.get(); | 94 fieldset.disabled = !setting.get(); |
| 95 setting.addChangeListener(settingChanged); | 95 setting.addChangeListener(settingChanged); |
| 96 return fieldset; | 96 return fieldset; |
| 97 | 97 |
| 98 function settingChanged() { | 98 function settingChanged() { |
| 99 fieldset.disabled = !setting.get(); | 99 fieldset.disabled = !setting.get(); |
| 100 } | 100 } |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * @interface | 104 * @interface |
| 105 */ | 105 */ |
| 106 WebInspector.SettingUI = function() {}; | 106 UI.SettingUI = function() {}; |
| 107 | 107 |
| 108 WebInspector.SettingUI.prototype = { | 108 UI.SettingUI.prototype = { |
| 109 /** | 109 /** |
| 110 * @return {?Element} | 110 * @return {?Element} |
| 111 */ | 111 */ |
| 112 settingElement: function() {} | 112 settingElement: function() {} |
| 113 }; | 113 }; |
| OLD | NEW |