blob: 6ea9c2eee3bd99197fb2d40d55baace579d61696 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/* 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 `
<html:link rel="stylesheet" href="chrome://browser/content/screenshots/screenshots-buttons.css"/>
<html:div id="screenshots-buttons" class="all-buttons-container">
<html:button class="visible-page" data-l10n-id="screenshots-save-visible-button"></html:button>
<html:button class="full-page" data-l10n-id="screenshots-save-page-button"></html:button>
</html:div>
`;
}
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);
}
}
customElements.define("screenshots-buttons", ScreenshotsButtons, {
extends: "toolbar",
});
}
|