| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 /** | |
| 32 * @constructor | |
| 33 * @extends {WebInspector.VBox} | |
| 34 */ | |
| 35 WebInspector.OverridesView = function() | |
| 36 { | |
| 37 WebInspector.VBox.call(this); | |
| 38 this.setMinimumSize(0, 30); | |
| 39 this.registerRequiredCSS("emulation/overrides.css"); | |
| 40 this.element.classList.add("overrides-view"); | |
| 41 | |
| 42 this._deviceElement = this._createDeviceElement(); | |
| 43 | |
| 44 this._splashScreenElement = this.element.createChild("div", "overrides-splas
h-screen"); | |
| 45 this._splashScreenElement.appendChild(createTextButton(WebInspector.UIString
("Enable emulation"), this._toggleEmulationEnabled.bind(this), "overrides-enable
-button")); | |
| 46 | |
| 47 this._unavailableSplashScreenElement = this.element.createChild("div", "over
rides-splash-screen"); | |
| 48 this._unavailableSplashScreenElement.createTextChild(WebInspector.UIString("
Emulation is not available.")); | |
| 49 | |
| 50 this._warningFooter = this.element.createChild("div", "overrides-footer"); | |
| 51 this._overridesWarningUpdated(); | |
| 52 | |
| 53 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); | |
| 54 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationStateChanged, this); | |
| 55 this._emulationStateChanged(); | |
| 56 } | |
| 57 | |
| 58 WebInspector.OverridesView.prototype = { | |
| 59 _createDeviceElement: function() | |
| 60 { | |
| 61 var container = this.element.createChild("div", "overrides-device"); | |
| 62 | |
| 63 var disableButtonElement = createTextButton(WebInspector.UIString("Disab
le emulation"), this._toggleEmulationEnabled.bind(this), "overrides-disable-butt
on"); | |
| 64 disableButtonElement.id = "overrides-disable-button"; | |
| 65 container.appendChild(disableButtonElement); | |
| 66 | |
| 67 var fieldsetElement = container.createChild("fieldset"); | |
| 68 fieldsetElement.id = "metrics-override-section"; | |
| 69 | |
| 70 var deviceModelElement = fieldsetElement.createChild("p", "overrides-dev
ice-model-section"); | |
| 71 deviceModelElement.createChild("span").textContent = WebInspector.UIStri
ng("Device:"); | |
| 72 | |
| 73 var rotateButton = createElement("button"); | |
| 74 rotateButton.textContent = " \u21C4 "; | |
| 75 var deviceSelect = new WebInspector.DeviceSelect(rotateButton, null); | |
| 76 deviceModelElement.appendChild(deviceSelect.element); | |
| 77 | |
| 78 var deviceModelFieldset = fieldsetElement.createChild("fieldset", "overr
ides-device-model-settings"); | |
| 79 var emulateResolutionCheckbox = WebInspector.SettingsUI.createSettingChe
ckbox(WebInspector.UIString("Emulate screen resolution"), WebInspector.overrides
Support.settings.emulateResolution, true); | |
| 80 deviceModelFieldset.appendChild(emulateResolutionCheckbox); | |
| 81 var resolutionFieldset = WebInspector.SettingsUI.createSettingFieldset(W
ebInspector.overridesSupport.settings.emulateResolution); | |
| 82 deviceModelFieldset.appendChild(resolutionFieldset); | |
| 83 | |
| 84 var tableElement = resolutionFieldset.createChild("table"); | |
| 85 var rowElement = tableElement.createChild("tr"); | |
| 86 var cellElement = rowElement.createChild("td"); | |
| 87 cellElement.createTextChild(WebInspector.UIString("Resolution:")); | |
| 88 cellElement = rowElement.createChild("td"); | |
| 89 | |
| 90 var widthOverrideInput = WebInspector.SettingsUI.createSettingInputField
("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "80px", WebIns
pector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIString("
\u2013")); | |
| 91 cellElement.appendChild(widthOverrideInput); | |
| 92 var heightOverrideInput = WebInspector.SettingsUI.createSettingInputFiel
d("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "80px", WebI
nspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIString
("\u2013")); | |
| 93 cellElement.appendChild(heightOverrideInput); | |
| 94 | |
| 95 rowElement = tableElement.createChild("tr"); | |
| 96 cellElement = rowElement.createChild("td"); | |
| 97 cellElement.colSpan = 4; | |
| 98 | |
| 99 rowElement = tableElement.createChild("tr"); | |
| 100 rowElement.title = WebInspector.UIString("Ratio between a device's physi
cal pixels and device-independent pixels"); | |
| 101 rowElement.createChild("td").createTextChild(WebInspector.UIString("Devi
ce pixel ratio:")); | |
| 102 rowElement.createChild("td").appendChild(WebInspector.SettingsUI.createS
ettingInputField("", WebInspector.overridesSupport.settings.deviceScaleFactor, t
rue, 4, "80px", WebInspector.OverridesSupport.deviceScaleFactorValidator, true,
true, WebInspector.UIString("\u2013"))); | |
| 103 | |
| 104 var mobileCheckbox = WebInspector.SettingsUI.createSettingCheckbox(WebIn
spector.UIString("Emulate mobile"), WebInspector.overridesSupport.settings.emula
teMobile, true); | |
| 105 mobileCheckbox.title = WebInspector.UIString("Enable meta viewport, over
lay scrollbars, text autosizing and default 980px body width"); | |
| 106 deviceModelFieldset.appendChild(mobileCheckbox); | |
| 107 | |
| 108 deviceModelFieldset.appendChild(WebInspector.SettingsUI.createSettingChe
ckbox(WebInspector.UIString("Emulate touch screen"), WebInspector.overridesSuppo
rt.settings.emulateTouch, true)); | |
| 109 | |
| 110 var resetButtonElement = createTextButton(WebInspector.UIString("Reset")
, WebInspector.overridesSupport.reset.bind(WebInspector.overridesSupport)); | |
| 111 resetButtonElement.id = "overrides-reset-button"; | |
| 112 deviceModelFieldset.appendChild(resetButtonElement); | |
| 113 | |
| 114 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingCheckbo
x(WebInspector.UIString("Shrink to fit"), WebInspector.overridesSupport.settings
.deviceFitWindow, true)); | |
| 115 | |
| 116 var footnote = container.createChild("p", "help-footnote"); | |
| 117 footnote.appendChild(WebInspector.linkifyDocumentationURLAsNode("iterate
/device-mode/", WebInspector.UIString("More information about screen emulation")
)); | |
| 118 | |
| 119 return container; | |
| 120 }, | |
| 121 | |
| 122 _overridesWarningUpdated: function() | |
| 123 { | |
| 124 var message = WebInspector.overridesSupport.warningMessage(); | |
| 125 this._warningFooter.classList.toggle("hidden", !message); | |
| 126 this._warningFooter.textContent = message; | |
| 127 }, | |
| 128 | |
| 129 _toggleEmulationEnabled: function() | |
| 130 { | |
| 131 WebInspector.overridesSupport.setEmulationEnabled(!WebInspector.override
sSupport.emulationEnabled()); | |
| 132 }, | |
| 133 | |
| 134 _emulationStateChanged: function() | |
| 135 { | |
| 136 this._unavailableSplashScreenElement.classList.toggle("hidden", WebInspe
ctor.overridesSupport.canEmulate()); | |
| 137 this._deviceElement.classList.toggle("hidden", !WebInspector.overridesSu
pport.emulationEnabled()); | |
| 138 this._splashScreenElement.classList.toggle("hidden", WebInspector.overri
desSupport.emulationEnabled() || !WebInspector.overridesSupport.canEmulate()); | |
| 139 }, | |
| 140 | |
| 141 __proto__: WebInspector.VBox.prototype | |
| 142 } | |
| 143 | |
| 144 /** | |
| 145 * @constructor | |
| 146 * @implements {WebInspector.Revealer} | |
| 147 */ | |
| 148 WebInspector.OverridesView.Revealer = function() | |
| 149 { | |
| 150 } | |
| 151 | |
| 152 WebInspector.OverridesView.Revealer.prototype = { | |
| 153 /** | |
| 154 * @override | |
| 155 * @param {!Object} overridesSupport | |
| 156 * @return {!Promise} | |
| 157 */ | |
| 158 reveal: function(overridesSupport) | |
| 159 { | |
| 160 WebInspector.inspectorView.showViewInDrawer("emulation"); | |
| 161 return Promise.resolve(); | |
| 162 } | |
| 163 } | |
| OLD | NEW |