From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../components/screenshots/screenshots-buttons.js | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 browser/components/screenshots/screenshots-buttons.js (limited to 'browser/components/screenshots/screenshots-buttons.js') diff --git a/browser/components/screenshots/screenshots-buttons.js b/browser/components/screenshots/screenshots-buttons.js new file mode 100644 index 0000000000..66188bd3e2 --- /dev/null +++ b/browser/components/screenshots/screenshots-buttons.js @@ -0,0 +1,60 @@ +/* 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/. */ +/* eslint-env mozilla/browser-window */ + +"use strict"; + +// This is loaded into chrome windows with the subscript loader. Wrap in +// a block to prevent accidentally leaking globals onto `window`. +{ + class ScreenshotsButtons extends MozXULElement { + static get markup() { + return ` + + + + + + + `; + } + + connectedCallback() { + const shadowRoot = this.attachShadow({ mode: "open" }); + document.l10n.connectRoot(shadowRoot); + + let fragment = MozXULElement.parseXULToFragment(this.constructor.markup); + this.shadowRoot.append(fragment); + + let button1 = shadowRoot.querySelector(".visible-page"); + button1.onclick = function () { + Services.obs.notifyObservers( + gBrowser.ownerGlobal, + "screenshots-take-screenshot", + "visible" + ); + }; + + let button2 = shadowRoot.querySelector(".full-page"); + button2.onclick = function () { + Services.obs.notifyObservers( + gBrowser.ownerGlobal, + "screenshots-take-screenshot", + "full-page" + ); + }; + } + + disconnectedCallback() { + document.l10n.disconnectRoot(this.shadowRoot); + } + + focusFirst(focusOptions) { + this.shadowRoot.querySelector("button:enabled").focus(focusOptions); + } + } + customElements.define("screenshots-buttons", ScreenshotsButtons, { + extends: "toolbar", + }); +} -- cgit v1.2.3