| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * | 10 * |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @constructor | 30 * @constructor |
| 31 */ | 31 */ |
| 32 WebInspector.InspectElementModeController = function() | 32 WebInspector.InspectElementModeController = function() |
| 33 { | 33 { |
| 34 this.toggleSearchButton = new WebInspector.StatusBarButton(WebInspector.UISt
ring("Select an element in the page to inspect it."), "node-search-status-bar-it
em"); | 34 this._toggleSearchButton = new WebInspector.StatusBarButton(WebInspector.UIS
tring("Select an element in the page to inspect it."), "node-search-status-bar-i
tem"); |
| 35 this.toggleSearchButton.addEventListener("click", this.toggleSearch, this); | |
| 36 this._shortcut = WebInspector.InspectElementModeController.createShortcut(); | 35 this._shortcut = WebInspector.InspectElementModeController.createShortcut(); |
| 37 } | 36 } |
| 38 | 37 |
| 39 WebInspector.InspectElementModeController.createShortcut = function() | 38 WebInspector.InspectElementModeController.createShortcut = function() |
| 40 { | 39 { |
| 41 return WebInspector.KeyboardShortcut.makeDescriptor("c", WebInspector.Keyboa
rdShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift)
; | 40 return WebInspector.KeyboardShortcut.makeDescriptor("c", WebInspector.Keyboa
rdShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift)
; |
| 42 } | 41 } |
| 43 | 42 |
| 44 WebInspector.InspectElementModeController.prototype = { | 43 WebInspector.InspectElementModeController.prototype = { |
| 45 /** | 44 /** |
| 46 * @return {boolean} | 45 * @return {boolean} |
| 47 */ | 46 */ |
| 48 enabled: function() | 47 enabled: function() |
| 49 { | 48 { |
| 50 return this.toggleSearchButton.toggled; | 49 return this._toggleSearchButton.toggled; |
| 51 }, | 50 }, |
| 52 | 51 |
| 53 disable: function() | 52 disable: function() |
| 54 { | 53 { |
| 55 if (this.enabled()) | 54 if (this.enabled()) |
| 56 this.toggleSearch(); | 55 this.toggleSearch(); |
| 57 }, | 56 }, |
| 58 | 57 |
| 59 toggleSearch: function() | 58 toggleSearch: function() |
| 60 { | 59 { |
| 61 var enabled = !this.enabled(); | 60 var enabled = !this.enabled(); |
| 62 this.toggleSearchButton.toggled = enabled; | 61 this._toggleSearchButton.toggled = enabled; |
| 63 | 62 |
| 64 var targets = WebInspector.targetManager.targets(); | 63 var targets = WebInspector.targetManager.targets(); |
| 65 for (var i = 0; i < targets.length; ++i) | 64 for (var i = 0; i < targets.length; ++i) |
| 66 targets[i].domModel.setInspectModeEnabled(enabled, WebInspector.sett
ings.showUAShadowDOM.get()); | 65 targets[i].domModel.setInspectModeEnabled(enabled, WebInspector.sett
ings.showUAShadowDOM.get()); |
| 67 } | 66 } |
| 68 } | 67 } |
| 69 | 68 |
| 70 /** | 69 /** |
| 71 * @constructor | 70 * @constructor |
| 72 * @implements {WebInspector.ActionDelegate} | 71 * @implements {WebInspector.ActionDelegate} |
| 73 */ | 72 */ |
| 74 WebInspector.InspectElementModeController.ToggleSearchActionDelegate = function(
) | 73 WebInspector.InspectElementModeController.ToggleSearchActionDelegate = function(
) |
| 75 { | 74 { |
| 76 } | 75 } |
| 77 | 76 |
| 78 WebInspector.InspectElementModeController.ToggleSearchActionDelegate.prototype =
{ | 77 WebInspector.InspectElementModeController.ToggleSearchActionDelegate.prototype =
{ |
| 79 /** | 78 /** |
| 80 * @return {boolean} | 79 * @return {boolean} |
| 81 */ | 80 */ |
| 82 handleAction: function() | 81 handleAction: function() |
| 83 { | 82 { |
| 84 if (!WebInspector.inspectElementModeController) | 83 if (!WebInspector.inspectElementModeController) |
| 85 return false; | 84 return false; |
| 86 WebInspector.inspectElementModeController.toggleSearch(); | 85 WebInspector.inspectElementModeController.toggleSearch(); |
| 87 return true; | 86 return true; |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 | 89 |
| 91 /** @type {!WebInspector.InspectElementModeController} */ | 90 /** |
| 92 WebInspector.inspectElementModeController; | 91 * @constructor |
| 92 * @implements {WebInspector.StatusBarButton.Provider} |
| 93 */ |
| 94 WebInspector.InspectElementModeController.ToggleButtonProvider = function() |
| 95 { |
| 96 } |
| 97 |
| 98 WebInspector.InspectElementModeController.ToggleButtonProvider.prototype = { |
| 99 /** |
| 100 * @return {?WebInspector.StatusBarButton} |
| 101 */ |
| 102 button: function() |
| 103 { |
| 104 if (!WebInspector.inspectElementModeController) |
| 105 return null; |
| 106 |
| 107 return WebInspector.inspectElementModeController._toggleSearchButton; |
| 108 } |
| 109 } |
| 110 |
| 111 /** @type {?WebInspector.InspectElementModeController} */ |
| 112 WebInspector.inspectElementModeController = null; |
| OLD | NEW |