Demo/bin/Debug/front_end/components/CustomPreviewSection.js

(开头部分) 8KB

这里只显示每个文件的开头 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.

/**
 * @constructor
 * @param {!WebInspector.RemoteObject} object
 */
WebInspector.CustomPreviewSection = function(object)
{
    this._sectionElement = createElementWithClass("span", "custom-expandable-section");
    this._object = object;
    this._expanded = false;
    this._cachedContent = null;
    var customPreview = object.customPreview();

    try {
        var headerJSON = JSON.parse(customPreview.header);
    } catch (e) {
        WebInspector.console.error("Broken formatter: header is invalid json " + e);
        return;
    }
    this._header = this._renderJSONMLTag(headerJSON);
    if (this._header.nodeType === Node.TEXT_NODE) {
        WebInspector.console.error("Broken formatter: header should be an element node.");
        return;
    }

    if (customPreview.hasBody) {
        this._header.classList.add("custom-expandable-section-header");
        this._header.addEventListener("click", this._onClick.bind(this), false);
    }

    this._sectionElement.appendChild(this._header);
}

/**
 * @constructor
 * @param {!WebInspector.RemoteObject} object
 */
WebInspector.CustomPreviewComponent = function(object)
{
    this._object = object;
    this._customPreviewSection = new WebInspector.CustomPreviewSection(object);
    this.element  = createElementWithClass("span", "source-code");
    var shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element);
    this.element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), false);
    shadowRoot.appendChild(WebInspector.Widget.createStyleElement("components/customPreviewSection.css"));
    shadowRoot.appendChild(this._customPreviewSection.element());
}

WebInspector.CustomPreviewComponent.prototype = {
    expandIfPossible: function()
    {
        if (this._object.customPreview().hasBody && this._customPreviewSection)
            this._customPreviewSection._loadBody();
    },

    /**
     * @param {!Event} event
后面还有 191 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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