Changeset 50034 in webkit


Ignore:
Timestamp:
Oct 24, 2009 4:08:15 PM (15 years ago)
Author:
timothy@apple.com
Message:

Fix the Scope Bar in the Web Inspector's Resource panel, so that selecting
All will deselect the other filters.

https://bugs.webkit.org/show_bug.cgi?id=30744

Reviewed by Pavel Feldman.

  • inspector/front-end/ResourcesPanel.js:

(WebInspector.ResourcesPanel.createFilterElement): Better syntax.
(WebInspector.ResourcesPanel):
(WebInspector.ResourcesPanel.prototype.filter): Use a normal for loop,
and the child variable instead of target in the loop. Other clean up.

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r50033 r50034  
     12009-10-24  Timothy Hatcher  <timothy@apple.com>
     2
     3        Fix the Scope Bar in the Web Inspector's Resource panel, so that selecting
     4        All will deselect the other filters.
     5
     6        https://bugs.webkit.org/show_bug.cgi?id=30744
     7
     8        Reviewed by Pavel Feldman.
     9
     10        * inspector/front-end/ResourcesPanel.js:
     11        (WebInspector.ResourcesPanel.createFilterElement): Better syntax.
     12        (WebInspector.ResourcesPanel):
     13        (WebInspector.ResourcesPanel.prototype.filter): Use a normal for loop,
     14        and the child variable instead of target in the loop. Other clean up.
     15
    1162009-10-24  Timothy Hatcher  <timothy@apple.com>
    217
  • trunk/WebCore/inspector/front-end/ResourcesPanel.js

    r50033 r50034  
    137137    this.sortingSelectElement.addEventListener("change", this._changeSortingFunction.bind(this), false);
    138138
    139     var createFilterElement = function (category) {
     139    function createFilterElement(category)
     140    {
     141        if (category === "all")
     142            var label = WebInspector.UIString("All");
     143        else if (WebInspector.resourceCategories[category])
     144            var label = WebInspector.resourceCategories[category].title;
     145
    140146        var categoryElement = document.createElement("li");
    141147        categoryElement.category = category;
    142148        categoryElement.addStyleClass(category);
    143         var label = WebInspector.UIString("All");
    144         if (WebInspector.resourceCategories[category])
    145             label = WebInspector.resourceCategories[category].title;
    146149        categoryElement.appendChild(document.createTextNode(label));
    147150        categoryElement.addEventListener("click", this._updateFilter.bind(this), false);
    148151        this.filterBarElement.appendChild(categoryElement);
     152
    149153        return categoryElement;
    150     };
     154    }
    151155
    152156    this.allElement = createFilterElement.call(this, "all");
    153    
     157
    154158    // Add a divider
    155159    var dividerElement = document.createElement("div");
    156160    dividerElement.addStyleClass("divider");
    157161    this.filterBarElement.appendChild(dividerElement);
    158    
    159     this.filter(this.allElement);
     162
    160163    for (var category in this.categories)
    161164        createFilterElement.call(this, category);
    162165
     166    this.filter(this.allElement);
     167
    163168    this.reset();
    164169
     
    173178        if (!this._categories) {
    174179            this._categories = {documents: {color: {r: 47, g: 102, b: 236}}, stylesheets: {color: {r: 157, g: 231, b: 119}}, images: {color: {r: 164, g: 60, b: 255}}, scripts: {color: {r: 255, g: 121, b: 0}}, xhr: {color: {r: 231, g: 231, b: 10}}, fonts: {color: {r: 255, g: 82, b: 62}}, other: {color: {r: 186, g: 186, b: 186}}};
    175             for (var category in this._categories) {
     180            for (var category in this._categories)
    176181                this._categories[category].title = WebInspector.resourceCategories[category].title;
    177             }
    178         }
     182        }
     183
    179184        return this._categories;
    180185    },
    181186
    182     filter: function (target)
    183     {
    184         if (target.category === "All") {
     187    filter: function(target)
     188    {
     189        if (target === this.allElement) {
    185190            if (target.hasStyleClass("selected")) {
    186                 // We can't unselect all, so we break early here
     191                // We can't unselect All, so we break early here
    187192                return;
    188193            }
    189            
    190             // If all wasn't selected, and now is, unselect everything else.
    191             for (var child in this.filterBarElement.childNodes) {
    192                 if (target.category !== "All") {
     194
     195            // If All wasn't selected, and now is, unselect everything else.
     196            for (var i = 0; i < this.filterBarElement.childNodes.length; ++i) {
     197                var child = this.filterBarElement.childNodes[i];
     198                if (!child.category)
     199                    continue;
     200
     201                if (child !== this.allElement)
    193202                    child.removeStyleClass("selected");
    194                 }
    195              
    196                 var filterClass = "filter-" + target.category;
     203
     204                var filterClass = "filter-" + child.category.toLowerCase();
    197205                this.resourcesGraphsElement.removeStyleClass(filterClass);
    198206                this.resourcesTreeElement.childrenListElement.removeStyleClass(filterClass);
    199207            }
    200208        } else {
    201             // Something other than all is being selected, so we want to unselect all
     209            // Something other than All is being selected, so we want to unselect All.
    202210            if (this.allElement.hasStyleClass("selected")) {
    203211                this.allElement.removeStyleClass("selected");
     
    206214            }
    207215        }
    208        
     216
    209217        if (target.hasStyleClass("selected")) {
    210218            target.removeStyleClass("selected");
     219
    211220            var filterClass = "filter-" + target.category.toLowerCase();
    212            
    213221            this.resourcesGraphsElement.removeStyleClass(filterClass);
    214222            this.resourcesTreeElement.childrenListElement.removeStyleClass(filterClass);
    215223        } else {
    216224            target.addStyleClass("selected");
     225
    217226            var filterClass = "filter-" + target.category.toLowerCase();
    218          
    219227            this.resourcesGraphsElement.addStyleClass(filterClass);
    220             this.resourcesTreeElement.childrenListElement.addStyleClass(filterClass);   
    221         } 
     228            this.resourcesTreeElement.childrenListElement.addStyleClass(filterClass);
     229        }
    222230    },
    223231
Note: See TracChangeset for help on using the changeset viewer.