Demo/bin/Debug/front_end/emulation/OverridesUI.js

(开头部分) 19KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

WebInspector.OverridesUI = {}

/**
 * @constructor
 * @param {!Element} rotateButton
 * @param {?function(!WebInspector.EmulatedDevice, !WebInspector.EmulatedDevice.Mode)} callback
 */
WebInspector.DeviceSelect = function(rotateButton, callback)
{
    this._callback = callback;
    this._rotateButton = rotateButton;
    this.element = createElement("p");

    this._deviceSelectElement = this.element.createChild("select", "device-select");
    this._deviceSelectElement.addEventListener("change", this._deviceSelected.bind(this), false);

    var container = this.element.createChild("div", "mode-container");
    container.appendChild(this._rotateButton);
    this._rotateButton.addEventListener("click", this._rotateButtonClicked.bind(this), false);
    this._rotateButton.title = WebInspector.UIString("Change orientation");

    var modeSelectContainer = container.createChild("span", "mode-select");
    this._modeSelectElement = modeSelectContainer.createChild("select");
    this._modeSelectElement.addEventListener("change", this._modeSelected.bind(this), false);
    this._modeLabelElement = modeSelectContainer.createChild("label");
    this._modeLabelElement.addEventListener("click", this._rotateButtonClicked.bind(this), false);
    this._modeLabelElement.title = WebInspector.UIString("Change orientation");

    this._emulatedSettingChangedMuted = false;
    this._lastOrientation = null;

    WebInspector.overridesSupport.settings.emulateResolution.addChangeListener(this._emulatedSettingChanged, this);
    WebInspector.overridesSupport.settings.deviceWidth.addChangeListener(this._emulatedSettingChanged, this);
    WebInspector.overridesSupport.settings.deviceHeight.addChangeListener(this._emulatedSettingChanged, this);
    WebInspector.overridesSupport.settings.deviceScaleFactor.addChangeListener(this._emulatedSettingChanged, this);
    WebInspector.overridesSupport.settings.emulateMobile.addChangeListener(this._emulatedSettingChanged, this);
    WebInspector.overridesSupport.settings.emulateTouch.addChangeListener(this._emulatedSettingChanged, this);
    WebInspector.overridesSupport.settings.userAgent.addChangeListener(this._emulatedSettingChanged, this);

    WebInspector.emulatedDevicesList.addEventListener(WebInspector.EmulatedDevicesList.Events.CustomDevicesUpdated, this._deviceListChanged, this);
    WebInspector.emulatedDevicesList.addEventListener(WebInspector.EmulatedDevicesList.Events.StandardDevicesUpdated, this._deviceListChanged, this);
    this._deviceListChanged();
}

WebInspector.DeviceSelect.prototype = {
    _deviceListChanged: function()
    {
        this._deviceSelectElement.removeChildren();

        var selectDeviceOption = new Option(WebInspector.UIString("<Select model>"), WebInspector.UIString("<Select model>"));
        selectDeviceOption.device = null;
        selectDeviceOption.lastSelectedIndex = 0;
        selectDeviceOption.disabled = true;
        this._deviceSelectElement.appendChild(selectDeviceOption);

        this._addDeviceGroup(WebInspector.UIString("Custom"), WebInspector.emulatedDevicesList.custom());
后面还有 315 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。