/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict";
class MeatballMenu extends PureComponent { static get propTypes() { return { // The id of the currently selected tool, e.g. "inspector"
currentToolId: PropTypes.string,
// List of possible docking options.
hostTypes: PropTypes.arrayOf(
PropTypes.shape({
position: PropTypes.string.isRequired,
switchHost: PropTypes.func.isRequired,
})
),
// Current docking type. Typically one of the position values in // |hostTypes| but this is not always the case (e.g. for "browsertoolbox").
currentHostType: PropTypes.string,
// Is the split console currently visible?
isSplitConsoleActive: PropTypes.bool,
// Are we disabling the behavior where pop-ups are automatically closed // when clicking outside them? // // This is a tri-state value that may be true/false or undefined where // undefined means that the option is not relevant in this context // (i.e. we're not in a browser toolbox).
disableAutohide: PropTypes.bool,
// Apply a pseudo-locale to the Firefox UI. This is only available in the browser // toolbox. This value can be undefined, "accented", "bidi", "none".
pseudoLocale: PropTypes.string,
// Function to turn the options panel on / off.
toggleOptions: PropTypes.func.isRequired,
// Function to turn the split console on / off.
toggleSplitConsole: PropTypes.func,
// Function to turn the disable pop-up autohide behavior on / off.
toggleNoAutohide: PropTypes.func,
// Bug 1709191 - The help shortcut key is localized without Fluent, and still needs // to be migrated. This is the only remaining use of the legacy L10N object. // Everything else should prefer the Fluent API.
L10N: PropTypes.object.isRequired,
// Callback function that will be invoked any time the component contents // update in such a way that its bounding box might change.
onResize: PropTypes.func,
};
}
componentDidUpdate(prevProps) { if (!this.props.onResize) { return;
}
// We are only expecting the following kinds of dynamic changes when a popup // is showing: // // - The "Disable pop-up autohide" menu item being added after the Browser // Toolbox is connected. // - The pseudo locale options being added after the Browser Toolbox is connected. // - The split console label changing between "Show Split Console" and "Hide // Split Console". // - The "Show/Hide Split Console" entry being added removed or removed. // // The latter two cases are only likely to be noticed when "Disable pop-up // autohide" is active, but for completeness we handle them here. const didChange = typeofthis.props.disableAutohide !== typeof prevProps.disableAutohide || this.props.pseudoLocale !== prevProps.pseudoLocale || this.props.currentToolId !== prevProps.currentToolId || this.props.isSplitConsoleActive !== prevProps.isSplitConsoleActive;
if (didChange) { this.props.onResize();
}
}
render() { const items = [];
// Dock options for (const hostType of this.props.hostTypes) { // This is more verbose than it needs to be but lets us easily search for // l10n entities.
let l10nID; switch (hostType.position) { case"window":
l10nID = "toolbox-meatball-menu-dock-separate-window-label"; break;
// Settings
items.push(
MenuItem({
id: "toolbox-meatball-menu-settings",
key: "settings",
l10nID: "toolbox-meatball-menu-settings-label", // Bug 1709191 - The help key is localized without Fluent, and still needs to // be migrated.
accelerator: this.props.L10N.getStr("toolbox.help.key"),
onClick: this.props.toggleOptions,
className: "iconic",
})
);
// Disable pop-up autohide // // If |disableAutohide| is undefined, it means this feature is not available // in this context. if (typeofthis.props.disableAutohide !== "undefined") {
items.push(
MenuItem({
id: "toolbox-meatball-menu-noautohide",
key: "noautohide",
l10nID: "toolbox-meatball-menu-noautohide-label",
type: "checkbox",
checked: this.props.disableAutohide,
onClick: this.props.toggleNoAutohide,
className: "iconic",
})
);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.