Demo/bin/Debug/front_end/ui/DropDownMenu.js
(开头部分) 1KB这里只显示每个文件的开头 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
* @extends {WebInspector.Object}
* @param {!Element} element
*/
WebInspector.DropDownMenu = function(element)
{
/** @type {!Array.<!WebInspector.DropDownMenu.Item>} */
this._items = [];
element.addEventListener("mousedown", this._onMouseDown.bind(this));
}
/** @typedef {{id: string, title: string}} */
WebInspector.DropDownMenu.Item;
/** @enum {string} */
WebInspector.DropDownMenu.Events = {
ItemSelected: "ItemSelected"
}
WebInspector.DropDownMenu.prototype = {
/**
* @param {!Event} event
*/
_onMouseDown: function(event)
{
if (event.which !== 1)
return;
var menu = new WebInspector.ContextMenu(event);
for (var item of this._items)
menu.appendCheckboxItem(item.title, this._itemHandler.bind(this, item.id), item.id === this._selectedItemId);
menu.show();
},
/**
* @param {string} id
*/
_itemHandler: function(id)
{
this.dispatchEventToListeners(WebInspector.DropDownMenu.Events.ItemSelected, id);
},
/**
* @param {string} id
* @param {string} title
*/
addItem: function(id, title)
{
this._items.push({id: id, title: title});
},
/**
* @param {string} id
*/
selectItem: function(id)
后面还有 12 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。