| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 /** | 30 /** |
| 31 * @constructor | 31 * @constructor |
| 32 * @extends {WebInspector.SidebarPane} | 32 * @extends {WebInspector.SidebarPane} |
| 33 * @param {!WebInspector.ComputedStyleSidebarPane} computedStylePane | 33 * @param {!WebInspector.ComputedStyleSidebarPane} computedStylePane |
| 34 * @param {function(!DOMAgent.NodeId, string, boolean)} setPseudoClassCallback | 34 * @param {function(!DOMAgent.NodeId, string, boolean)} setPseudoClassCallback |
| 35 */ | 35 */ |
| 36 WebInspector.StylesSidebarPane = function(computedStylePane, setPseudoClassCallb
ack) | 36 WebInspector.StylesSidebarPane = function(computedStylePane, setPseudoClassCallb
ack) |
| 37 { | 37 { |
| 38 WebInspector.SidebarPane.call(this, WebInspector.UIString("Styles")); | 38 WebInspector.SidebarPane.call(this, WebInspector.UIString("Styles")); |
| 39 | 39 |
| 40 this.settingsSelectElement = document.createElement("select"); | |
| 41 this.settingsSelectElement.className = "select-settings"; | |
| 42 | |
| 43 var option = document.createElement("option"); | |
| 44 option.value = WebInspector.Color.Format.Original; | |
| 45 option.label = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ?
"As authored" : "As Authored"); | |
| 46 this.settingsSelectElement.appendChild(option); | |
| 47 | |
| 48 option = document.createElement("option"); | |
| 49 option.value = WebInspector.Color.Format.HEX; | |
| 50 option.label = WebInspector.UIString("Hex Colors"); | |
| 51 this.settingsSelectElement.appendChild(option); | |
| 52 | |
| 53 option = document.createElement("option"); | |
| 54 option.value = WebInspector.Color.Format.RGB; | |
| 55 option.label = WebInspector.UIString("RGB Colors"); | |
| 56 this.settingsSelectElement.appendChild(option); | |
| 57 | |
| 58 option = document.createElement("option"); | |
| 59 option.value = WebInspector.Color.Format.HSL; | |
| 60 option.label = WebInspector.UIString("HSL Colors"); | |
| 61 this.settingsSelectElement.appendChild(option); | |
| 62 | |
| 63 // Prevent section from collapsing. | |
| 64 var muteEventListener = function(event) { event.consume(true); }; | |
| 65 | |
| 66 this.settingsSelectElement.addEventListener("click", muteEventListener, true
); | |
| 67 this.settingsSelectElement.addEventListener("change", this._changeSetting.bi
nd(this), false); | |
| 68 this._updateColorFormatFilter(); | |
| 69 | |
| 70 this.titleElement.appendChild(this.settingsSelectElement); | |
| 71 | |
| 72 this._elementStateButton = document.createElement("button"); | 40 this._elementStateButton = document.createElement("button"); |
| 73 this._elementStateButton.className = "pane-title-button element-state"; | 41 this._elementStateButton.className = "pane-title-button element-state"; |
| 74 this._elementStateButton.title = WebInspector.UIString("Toggle Element State
"); | 42 this._elementStateButton.title = WebInspector.UIString("Toggle Element State
"); |
| 75 this._elementStateButton.addEventListener("click", this._toggleElementStateP
ane.bind(this), false); | 43 this._elementStateButton.addEventListener("click", this._toggleElementStateP
ane.bind(this), false); |
| 76 this.titleElement.appendChild(this._elementStateButton); | 44 this.titleElement.appendChild(this._elementStateButton); |
| 77 | 45 |
| 78 var addButton = document.createElement("button"); | 46 var addButton = document.createElement("button"); |
| 79 addButton.className = "pane-title-button add"; | 47 addButton.className = "pane-title-button add"; |
| 80 addButton.id = "add-style-button-test-id"; | 48 addButton.id = "add-style-button-test-id"; |
| 81 addButton.title = WebInspector.UIString("New Style Rule"); | 49 addButton.title = WebInspector.UIString("New Style Rule"); |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 var property = properties[i]; | 708 var property = properties[i]; |
| 741 // Does this style contain non-overridden inherited property? | 709 // Does this style contain non-overridden inherited property? |
| 742 if (property.isLive && WebInspector.CSSMetadata.isPropertyInherited(
property.name)) | 710 if (property.isLive && WebInspector.CSSMetadata.isPropertyInherited(
property.name)) |
| 743 return true; | 711 return true; |
| 744 } | 712 } |
| 745 return false; | 713 return false; |
| 746 }, | 714 }, |
| 747 | 715 |
| 748 _colorFormatSettingChanged: function(event) | 716 _colorFormatSettingChanged: function(event) |
| 749 { | 717 { |
| 750 this._updateColorFormatFilter(); | |
| 751 for (var pseudoId in this.sections) { | 718 for (var pseudoId in this.sections) { |
| 752 var sections = this.sections[pseudoId]; | 719 var sections = this.sections[pseudoId]; |
| 753 for (var i = 0; i < sections.length; ++i) | 720 for (var i = 0; i < sections.length; ++i) |
| 754 sections[i].update(true); | 721 sections[i].update(true); |
| 755 } | 722 } |
| 756 }, | 723 }, |
| 757 | 724 |
| 758 _updateColorFormatFilter: function() | |
| 759 { | |
| 760 // Select the correct color format setting again, since it needs to be s
elected. | |
| 761 var selectedIndex = 0; | |
| 762 var value = WebInspector.settings.colorFormat.get(); | |
| 763 var options = this.settingsSelectElement.options; | |
| 764 for (var i = 0; i < options.length; ++i) { | |
| 765 if (options[i].value === value) { | |
| 766 selectedIndex = i; | |
| 767 break; | |
| 768 } | |
| 769 } | |
| 770 this.settingsSelectElement.selectedIndex = selectedIndex; | |
| 771 }, | |
| 772 | |
| 773 _changeSetting: function(event) | |
| 774 { | |
| 775 var options = this.settingsSelectElement.options; | |
| 776 var selectedOption = options[this.settingsSelectElement.selectedIndex]; | |
| 777 WebInspector.settings.colorFormat.set(selectedOption.value); | |
| 778 }, | |
| 779 | |
| 780 _createNewRule: function(event) | 725 _createNewRule: function(event) |
| 781 { | 726 { |
| 782 event.consume(); | 727 event.consume(); |
| 783 this.expand(); | 728 this.expand(); |
| 784 this.addBlankSection().startEditingSelector(); | 729 this.addBlankSection().startEditingSelector(); |
| 785 }, | 730 }, |
| 786 | 731 |
| 787 addBlankSection: function() | 732 addBlankSection: function() |
| 788 { | 733 { |
| 789 var blankSection = new WebInspector.BlankStylePropertiesSection(this, th
is.node ? WebInspector.DOMPresentationUtils.appropriateSelectorFor(this.node, tr
ue) : ""); | 734 var blankSection = new WebInspector.BlankStylePropertiesSection(this, th
is.node ? WebInspector.DOMPresentationUtils.appropriateSelectorFor(this.node, tr
ue) : ""); |
| (...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3042 return; | 2987 return; |
| 3043 } | 2988 } |
| 3044 | 2989 |
| 3045 var results = this._cssCompletions.startsWith(prefix); | 2990 var results = this._cssCompletions.startsWith(prefix); |
| 3046 var selectedIndex = this._cssCompletions.mostUsedOf(results); | 2991 var selectedIndex = this._cssCompletions.mostUsedOf(results); |
| 3047 completionsReadyCallback(results, selectedIndex); | 2992 completionsReadyCallback(results, selectedIndex); |
| 3048 }, | 2993 }, |
| 3049 | 2994 |
| 3050 __proto__: WebInspector.TextPrompt.prototype | 2995 __proto__: WebInspector.TextPrompt.prototype |
| 3051 } | 2996 } |
| OLD | NEW |