| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @param {!WebInspector.DeviceModeModel} model | 6 * @param {!WebInspector.DeviceModeModel} model |
| 7 * @param {!WebInspector.Setting} showMediaInspectorSetting | 7 * @param {!WebInspector.Setting} showMediaInspectorSetting |
| 8 * @param {!WebInspector.Setting} showRulersSetting | 8 * @param {!WebInspector.Setting} showRulersSetting |
| 9 * @param {!WebInspector.Setting} showOutlineSetting |
| 9 * @constructor | 10 * @constructor |
| 10 */ | 11 */ |
| 11 WebInspector.DeviceModeToolbar = function(model, showMediaInspectorSetting, show
RulersSetting) | 12 WebInspector.DeviceModeToolbar = function(model, showMediaInspectorSetting, show
RulersSetting, showOutlineSetting) |
| 12 { | 13 { |
| 13 this._model = model; | 14 this._model = model; |
| 14 this._showMediaInspectorSetting = showMediaInspectorSetting; | 15 this._showMediaInspectorSetting = showMediaInspectorSetting; |
| 15 this._showRulersSetting = showRulersSetting; | 16 this._showRulersSetting = showRulersSetting; |
| 17 this._showOutlineSetting = showOutlineSetting; |
| 16 /** @type {!Map<!WebInspector.EmulatedDevice, !WebInspector.EmulatedDevice.M
ode>} */ | 18 /** @type {!Map<!WebInspector.EmulatedDevice, !WebInspector.EmulatedDevice.M
ode>} */ |
| 17 this._lastMode = new Map(); | 19 this._lastMode = new Map(); |
| 18 | 20 |
| 19 this._element = createElementWithClass("div", "device-mode-toolbar"); | 21 this._element = createElementWithClass("div", "device-mode-toolbar"); |
| 20 | 22 |
| 21 var leftContainer = this._element.createChild("div", "device-mode-toolbar-sp
acer"); | 23 var leftContainer = this._element.createChild("div", "device-mode-toolbar-sp
acer"); |
| 22 leftContainer.createChild("div", "device-mode-toolbar-spacer"); | 24 leftContainer.createChild("div", "device-mode-toolbar-spacer"); |
| 23 var leftToolbar = new WebInspector.Toolbar("", leftContainer); | 25 var leftToolbar = new WebInspector.Toolbar("", leftContainer); |
| 24 leftToolbar.makeWrappable(); | 26 leftToolbar.makeWrappable(); |
| 25 this._fillLeftToolbar(leftToolbar); | 27 this._fillLeftToolbar(leftToolbar); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 function appendDeviceScaleFactorItem(title, value) | 237 function appendDeviceScaleFactorItem(title, value) |
| 236 { | 238 { |
| 237 deviceScaleFactorSubmenu.appendCheckboxItem(title, deviceScaleFactor
Setting.set.bind(deviceScaleFactorSetting, value), deviceScaleFactorValue === va
lue, deviceScaleFactorDisabled); | 239 deviceScaleFactorSubmenu.appendCheckboxItem(title, deviceScaleFactor
Setting.set.bind(deviceScaleFactorSetting, value), deviceScaleFactorValue === va
lue, deviceScaleFactorDisabled); |
| 238 } | 240 } |
| 239 | 241 |
| 240 contextMenu.appendItem(WebInspector.UIString("Reset to defaults"), this.
_model.reset.bind(this._model), this._model.type() !== WebInspector.DeviceModeMo
del.Type.Responsive); | 242 contextMenu.appendItem(WebInspector.UIString("Reset to defaults"), this.
_model.reset.bind(this._model), this._model.type() !== WebInspector.DeviceModeMo
del.Type.Responsive); |
| 241 contextMenu.appendSeparator(); | 243 contextMenu.appendSeparator(); |
| 242 | 244 |
| 243 contextMenu.appendCheckboxItem(WebInspector.UIString("Show media queries
"), this._toggleMediaInspector.bind(this), this._showMediaInspectorSetting.get()
, this._model.type() === WebInspector.DeviceModeModel.Type.None); | 245 contextMenu.appendCheckboxItem(WebInspector.UIString("Show media queries
"), this._toggleMediaInspector.bind(this), this._showMediaInspectorSetting.get()
, this._model.type() === WebInspector.DeviceModeModel.Type.None); |
| 244 contextMenu.appendCheckboxItem(WebInspector.UIString("Show rulers"), thi
s._toggleRulers.bind(this), this._showRulersSetting.get(), this._model.type() ==
= WebInspector.DeviceModeModel.Type.None); | 246 contextMenu.appendCheckboxItem(WebInspector.UIString("Show rulers"), thi
s._toggleRulers.bind(this), this._showRulersSetting.get(), this._model.type() ==
= WebInspector.DeviceModeModel.Type.None); |
| 247 contextMenu.appendCheckboxItem(WebInspector.UIString("Show device frame"
), this._toggleOutline.bind(this), (this._showOutlineSetting.get() && this._mode
l.outlineImage() !== ""), !this._model.outlineImage()); |
| 245 contextMenu.appendItem(WebInspector.UIString("Configure network\u2026"),
this._openNetworkConfig.bind(this), false); | 248 contextMenu.appendItem(WebInspector.UIString("Configure network\u2026"),
this._openNetworkConfig.bind(this), false); |
| 246 contextMenu.appendItemsAtLocation("deviceModeMenu"); | 249 contextMenu.appendItemsAtLocation("deviceModeMenu"); |
| 247 }, | 250 }, |
| 248 | 251 |
| 249 _toggleMediaInspector: function() | 252 _toggleMediaInspector: function() |
| 250 { | 253 { |
| 251 this._showMediaInspectorSetting.set(!this._showMediaInspectorSetting.get
()); | 254 this._showMediaInspectorSetting.set(!this._showMediaInspectorSetting.get
()); |
| 252 }, | 255 }, |
| 253 | 256 |
| 254 _toggleRulers: function() | 257 _toggleRulers: function() |
| 255 { | 258 { |
| 256 this._showRulersSetting.set(!this._showRulersSetting.get()); | 259 this._showRulersSetting.set(!this._showRulersSetting.get()); |
| 257 }, | 260 }, |
| 258 | 261 |
| 262 _toggleOutline: function() |
| 263 { |
| 264 this._showOutlineSetting.set(!this._showOutlineSetting.get()); |
| 265 }, |
| 266 |
| 259 _openNetworkConfig: function() | 267 _openNetworkConfig: function() |
| 260 { | 268 { |
| 261 InspectorFrontendHost.bringToFront(); | 269 InspectorFrontendHost.bringToFront(); |
| 262 // TODO(dgozman): make it explicit. | 270 // TODO(dgozman): make it explicit. |
| 263 WebInspector.actionRegistry.action("network.show-config").execute(); | 271 WebInspector.actionRegistry.action("network.show-config").execute(); |
| 264 }, | 272 }, |
| 265 | 273 |
| 266 /** | 274 /** |
| 267 * @param {!Element} element | 275 * @param {!Element} element |
| 268 * @return {!WebInspector.ToolbarItem} | 276 * @return {!WebInspector.ToolbarItem} |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 this._emulateDevice(device); | 517 this._emulateDevice(device); |
| 510 return; | 518 return; |
| 511 } | 519 } |
| 512 } | 520 } |
| 513 } | 521 } |
| 514 } | 522 } |
| 515 | 523 |
| 516 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, null,
null); | 524 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, null,
null); |
| 517 } | 525 } |
| 518 } | 526 } |
| OLD | NEW |