2 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
16 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
20 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * @implements {WebInspector.TargetManager.Observer}
33 WebInspector.InspectElementModeController = function()
35 this._toggleSearchButton = new WebInspector.StatusBarButton(WebInspector.UIString("Select an element in the page to inspect it."), "node-search-status-bar-item");
36 this._shortcut = WebInspector.InspectElementModeController.createShortcut();
37 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.EnterInspectElementMode, this._toggleSearch, this);
38 WebInspector.targetManager.observeTargets(this);
42 * @return {!WebInspector.KeyboardShortcut.Descriptor}
44 WebInspector.InspectElementModeController.createShortcut = function()
46 return WebInspector.KeyboardShortcut.makeDescriptor("c", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift);
49 WebInspector.InspectElementModeController.prototype = {
51 * @param {!WebInspector.Target} target
53 targetAdded: function(target)
55 // When DevTools are opening in the inspect element mode, the first target comes in
56 // much later than the InspectorFrontendAPI.enterInspectElementMode event.
58 target.domModel.setInspectModeEnabled(true, WebInspector.settings.showUAShadowDOM.get());
62 * @param {!WebInspector.Target} target
64 targetRemoved: function(target)
73 return this._toggleSearchButton.toggled;
82 _toggleSearch: function()
84 var enabled = !this.enabled();
85 this._toggleSearchButton.toggled = enabled;
87 var targets = WebInspector.targetManager.targets();
88 for (var i = 0; i < targets.length; ++i)
89 targets[i].domModel.setInspectModeEnabled(enabled, WebInspector.settings.showUAShadowDOM.get());
95 * @implements {WebInspector.ActionDelegate}
97 WebInspector.InspectElementModeController.ToggleSearchActionDelegate = function()
101 WebInspector.InspectElementModeController.ToggleSearchActionDelegate.prototype = {
105 handleAction: function()
107 if (!WebInspector.inspectElementModeController)
109 WebInspector.inspectElementModeController._toggleSearch();
116 * @implements {WebInspector.StatusBarItem.Provider}
118 WebInspector.InspectElementModeController.ToggleButtonProvider = function()
122 WebInspector.InspectElementModeController.ToggleButtonProvider.prototype = {
124 * @return {?WebInspector.StatusBarItem}
128 if (!WebInspector.inspectElementModeController)
131 return WebInspector.inspectElementModeController._toggleSearchButton;
135 /** @type {?WebInspector.InspectElementModeController} */
136 WebInspector.inspectElementModeController = null;