Changeset 116853 in webkit


Ignore:
Timestamp:
May 12, 2012 6:09:41 AM (12 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: add tab context menu
https://bugs.webkit.org/show_bug.cgi?id=86292

Reviewed by Yury Semikhatsky.

This tab context menu will have "Close", "Close Others" and "Close All".

  • English.lproj/localizedStrings.js:
  • inspector/front-end/TabbedPane.js:

(WebInspector.TabbedPane.prototype.closeOtherTabs):
(WebInspector.TabbedPaneTab.prototype._createTabElement):
(WebInspector.TabbedPaneTab.prototype._tabClicked):
(WebInspector.TabbedPaneTab.prototype._tabContextMenu):
(WebInspector.TabbedPaneTab.prototype._tabContextMenu.closeOthers):
(WebInspector.TabbedPaneTab.prototype._tabContextMenu.closeAll):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r116852 r116853  
     12012-05-12  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Web Inspector: add tab context menu
     4        https://bugs.webkit.org/show_bug.cgi?id=86292
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        This tab context menu will have "Close", "Close Others" and "Close All".
     9
     10        * English.lproj/localizedStrings.js:
     11        * inspector/front-end/TabbedPane.js:
     12        (WebInspector.TabbedPane.prototype.closeOtherTabs):
     13        (WebInspector.TabbedPaneTab.prototype._createTabElement):
     14        (WebInspector.TabbedPaneTab.prototype._tabClicked):
     15        (WebInspector.TabbedPaneTab.prototype._tabContextMenu):
     16        (WebInspector.TabbedPaneTab.prototype._tabContextMenu.closeOthers):
     17        (WebInspector.TabbedPaneTab.prototype._tabContextMenu.closeAll):
     18
    1192012-05-12  Pavel Feldman  <pfeldman@chromium.org>
    220
  • trunk/Source/WebCore/inspector/front-end/TabbedPane.js

    r114740 r116853  
    161161    /**
    162162     * @param {string} id
     163     */
     164    closeOtherTabs: function(id)
     165    {
     166        var tabs = this._tabs.slice();
     167        for (var i = 0; i < tabs.length; ++i) {
     168            if (tabs[i].id !== id)
     169                this._innerCloseTab(tabs[i].id, true);
     170        }
     171        this._updateTabElements();
     172        this.selectTab(id, true);
     173    },
     174
     175    /**
     176     * @param {string} id
    163177     * @param {boolean=} userGesture
    164178     */
     
    615629            this._tabElement = tabElement;
    616630            tabElement.addEventListener("click", this._tabClicked.bind(this), false);
     631            if (this._closeable)
     632                tabElement.addEventListener("contextmenu", this._tabContextMenu.bind(this), false);
    617633        }
    618634       
     
    638654            this._tabbedPane.selectTab(this.id, true);
    639655        this._tabbedPane.focus();
     656    },
     657
     658    _tabContextMenu: function(event)
     659    {
     660        function close()
     661        {
     662            this._tabbedPane.closeTab(this.id, true);
     663        }
     664 
     665        function closeOthers()
     666        {
     667            this._tabbedPane.closeOtherTabs(this.id);
     668        }
     669 
     670        function closeAll()
     671        {
     672            this._tabbedPane.closeAllTabs(true);
     673        }
     674 
     675        var contextMenu = new WebInspector.ContextMenu();
     676        contextMenu.appendItem(WebInspector.UIString("Close"), close.bind(this));
     677        contextMenu.appendItem(WebInspector.UIString("Close Others"), closeOthers.bind(this));
     678        contextMenu.appendItem(WebInspector.UIString("Close All"), closeAll.bind(this));
     679        contextMenu.show(event);
    640680    }
    641681}
Note: See TracChangeset for help on using the changeset viewer.