зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1495861 - Lazify panic panel and convert it to use FTL r=flod,Gijs
This is the only <radiogroup> and <radio> consumer in browser.xul. By making the DOM get constructed on demand, we can avoid connecting radios at startup, and it also gives us a chance to migrate the strings to Fluent. Differential Revision: https://phabricator.services.mozilla.com/D24914 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e86d5d39e0
Коммит
42fd8f47e3
|
@ -793,11 +793,54 @@ if (Services.prefs.getBoolPref("privacy.panicButton.enabled")) {
|
|||
}
|
||||
},
|
||||
onViewShowing(aEvent) {
|
||||
let win = aEvent.target.ownerGlobal;
|
||||
let doc = win.document;
|
||||
let eventBlocker = null;
|
||||
if (!doc.querySelector("#PanelUI-panic-timeframe")) {
|
||||
win.MozXULElement.insertFTLIfNeeded("browser/panicButton.ftl");
|
||||
let frag = win.MozXULElement.parseXULToFragment(`
|
||||
<vbox class="panel-subview-body">
|
||||
<hbox id="PanelUI-panic-timeframe">
|
||||
<image id="PanelUI-panic-timeframe-icon" alt=""/>
|
||||
<vbox flex="1">
|
||||
<description data-l10n-id="panic-main-timeframe-desc" id="PanelUI-panic-mainDesc"></description>
|
||||
<radiogroup id="PanelUI-panic-timeSpan" aria-labelledby="PanelUI-panic-mainDesc" closemenu="none">
|
||||
<radio id="PanelUI-panic-5min" data-l10n-id="panic-button-5min" selected="true"
|
||||
value="5" class="subviewradio"/>
|
||||
<radio id="PanelUI-panic-2hr" data-l10n-id="panic-button-2hr"
|
||||
value="2" class="subviewradio"/>
|
||||
<radio id="PanelUI-panic-day" data-l10n-id="panic-button-day"
|
||||
value="6" class="subviewradio"/>
|
||||
</radiogroup>
|
||||
</vbox>
|
||||
</hbox>
|
||||
<vbox id="PanelUI-panic-explanations">
|
||||
<label id="PanelUI-panic-actionlist-main-label" data-l10n-id="panic-button-action-desc"></label>
|
||||
|
||||
<label id="PanelUI-panic-actionlist-windows" class="PanelUI-panic-actionlist" data-l10n-id="panic-button-delete-tabs-and-windows"></label>
|
||||
<label id="PanelUI-panic-actionlist-cookies" class="PanelUI-panic-actionlist" data-l10n-id="panic-button-delete-cookies"></label>
|
||||
<label id="PanelUI-panic-actionlist-history" class="PanelUI-panic-actionlist" data-l10n-id="panic-button-delete-history"></label>
|
||||
<label id="PanelUI-panic-actionlist-newwindow" class="PanelUI-panic-actionlist" data-l10n-id="panic-button-open-new-window"></label>
|
||||
|
||||
<label id="PanelUI-panic-warning" data-l10n-id="panic-button-undo-warning"></label>
|
||||
</vbox>
|
||||
<button id="PanelUI-panic-view-button"
|
||||
data-l10n-id="panic-button-forget-button"/>
|
||||
</vbox>
|
||||
`);
|
||||
|
||||
aEvent.target.appendChild(frag);
|
||||
eventBlocker = doc.l10n.translateElements([aEvent.target]);
|
||||
}
|
||||
|
||||
let forgetButton = aEvent.target.querySelector("#PanelUI-panic-view-button");
|
||||
let doc = aEvent.target.ownerDocument;
|
||||
let group = doc.getElementById("PanelUI-panic-timeSpan");
|
||||
group.selectedItem = doc.getElementById("PanelUI-panic-5min");
|
||||
forgetButton.addEventListener("command", this);
|
||||
|
||||
if (eventBlocker) {
|
||||
aEvent.detail.addBlocker(eventBlocker);
|
||||
}
|
||||
},
|
||||
onViewHiding(aEvent) {
|
||||
let forgetButton = aEvent.target.querySelector("#PanelUI-panic-view-button");
|
||||
|
|
|
@ -633,34 +633,7 @@
|
|||
|
||||
<panelview id="PanelUI-panicView" flex="1"
|
||||
descriptionheightworkaround="true">
|
||||
<vbox class="panel-subview-body">
|
||||
<hbox id="PanelUI-panic-timeframe">
|
||||
<image id="PanelUI-panic-timeframe-icon" alt=""/>
|
||||
<vbox flex="1">
|
||||
<description id="PanelUI-panic-mainDesc">&panicButton.view.mainTimeframeDesc;</description>
|
||||
<radiogroup id="PanelUI-panic-timeSpan" aria-labelledby="PanelUI-panic-mainDesc" closemenu="none">
|
||||
<radio id="PanelUI-panic-5min" label="&panicButton.view.5min;" selected="true"
|
||||
value="5" class="subviewradio"/>
|
||||
<radio id="PanelUI-panic-2hr" label="&panicButton.view.2hr;"
|
||||
value="2" class="subviewradio"/>
|
||||
<radio id="PanelUI-panic-day" label="&panicButton.view.day;"
|
||||
value="6" class="subviewradio"/>
|
||||
</radiogroup>
|
||||
</vbox>
|
||||
</hbox>
|
||||
<vbox id="PanelUI-panic-explanations">
|
||||
<label id="PanelUI-panic-actionlist-main-label">&panicButton.view.mainActionDesc;</label>
|
||||
|
||||
<label id="PanelUI-panic-actionlist-windows" class="PanelUI-panic-actionlist">&panicButton.view.deleteTabsAndWindows;</label>
|
||||
<label id="PanelUI-panic-actionlist-cookies" class="PanelUI-panic-actionlist">&panicButton.view.deleteCookies;</label>
|
||||
<label id="PanelUI-panic-actionlist-history" class="PanelUI-panic-actionlist">&panicButton.view.deleteHistory;</label>
|
||||
<label id="PanelUI-panic-actionlist-newwindow" class="PanelUI-panic-actionlist">&panicButton.view.openNewWindow;</label>
|
||||
|
||||
<label id="PanelUI-panic-warning">&panicButton.view.undoWarning;</label>
|
||||
</vbox>
|
||||
<button id="PanelUI-panic-view-button"
|
||||
label="&panicButton.view.forgetButton;"/>
|
||||
</vbox>
|
||||
<!-- This is constructed in CustomizableWidgets.jsm -->
|
||||
</panelview>
|
||||
|
||||
<panelview id="appMenu-moreView" title="&moreMenu.label;" class="PanelUI-subView">
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# 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/.
|
||||
|
||||
panic-button-open-new-window = Open a new clean Window
|
||||
panic-button-undo-warning = This action cannot be undone.
|
||||
panic-button-forget-button =
|
||||
.label = Forget!
|
||||
|
||||
## These strings are combined to form a complete sentence starting with
|
||||
## panic-main-timeframe-desc. For example: "Forget the last: Five minutes".
|
||||
## Please ensure that this remains the case in the translation.
|
||||
|
||||
panic-main-timeframe-desc = Forget the last:
|
||||
panic-button-5min =
|
||||
.label = Five minutes
|
||||
panic-button-2hr =
|
||||
.label = Two hours
|
||||
panic-button-day =
|
||||
.label = 24 hours
|
||||
|
||||
## These strings are combined to form a complete sentence starting with
|
||||
## panic-button-action-desc. For example: "Proceeding will: Delete Recent Cookies".
|
||||
## Please ensure that this remains the case in the translation.
|
||||
## Note also that some strings include <strong> tags for emphasis on the
|
||||
## words "Cookies", "History", "Tabs" and "Windows". The translation should do the same.
|
||||
|
||||
panic-button-action-desc = Proceeding will:
|
||||
panic-button-delete-cookies = Delete Recent <strong>Cookies</strong>
|
||||
panic-button-delete-history = Delete Recent <strong>History</strong>
|
||||
panic-button-delete-tabs-and-windows = Close all <strong>Tabs</strong> and <strong>Windows</strong>
|
|
@ -968,27 +968,6 @@ you can use these alternative items. Otherwise, their values should be empty. -
|
|||
|
||||
<!ENTITY uiTour.infoPanel.close "Close">
|
||||
|
||||
<!-- LOCALIZATION NOTE: (panicButton.view.mainTimeframeDesc, panicButton.view.5min, panicButton.view.2hr, panicButton.view.day):
|
||||
The .mainTimeframeDesc string combined with any of the 3 others is meant to form a complete sentence, e.g. "Forget the last: Five minutes".
|
||||
Please ensure that this remains the case in the translation. -->
|
||||
<!ENTITY panicButton.view.mainTimeframeDesc "Forget the last:">
|
||||
<!ENTITY panicButton.view.5min "Five minutes">
|
||||
<!ENTITY panicButton.view.2hr "Two hours">
|
||||
<!ENTITY panicButton.view.day "24 hours">
|
||||
|
||||
<!-- LOCALIZATION NOTE: (panicButton.view.mainLabel, panicButton.view.deleteCookies, panicButton.view.deleteHistory, panicButton.view.deleteTabsAndWindows, panicButton.view.openNewWindow):
|
||||
The .mainActionDesc string combined with any of the 4 others is meant to form a complete sentence, e.g. "Proceeding will: Delete Recent Cookies".
|
||||
Note also that the deleteCookies, deleteHistory and deleteTabsAndWindows strings include <html:strong> tags for emphasis on the words "Cookies", "History", "Tabs" and "Windows".
|
||||
The translation should do the same. -->
|
||||
<!ENTITY panicButton.view.mainActionDesc "Proceeding will:">
|
||||
<!ENTITY panicButton.view.deleteCookies "Delete Recent <html:strong>Cookies</html:strong>">
|
||||
<!ENTITY panicButton.view.deleteHistory "Delete Recent <html:strong>History</html:strong>">
|
||||
<!ENTITY panicButton.view.deleteTabsAndWindows "Close all <html:strong>Tabs</html:strong> and <html:strong>Windows</html:strong>">
|
||||
<!ENTITY panicButton.view.openNewWindow "Open a new clean Window">
|
||||
|
||||
<!ENTITY panicButton.view.undoWarning "This action cannot be undone.">
|
||||
<!ENTITY panicButton.view.forgetButton "Forget!">
|
||||
|
||||
<!ENTITY panicButton.thankyou.msg1 "Your recent history is cleared.">
|
||||
<!ENTITY panicButton.thankyou.msg2 "Safe browsing!">
|
||||
<!ENTITY panicButton.thankyou.buttonlabel "Thanks!">
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
# coding=utf8
|
||||
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
from __future__ import absolute_import
|
||||
import fluent.syntax.ast as FTL
|
||||
from fluent.migrate.helpers import transforms_from
|
||||
from fluent.migrate import COPY, REPLACE
|
||||
|
||||
def migrate(ctx):
|
||||
"""Bug 1517508 - Migrate panicButton to use Fluent for localization, part {index}."""
|
||||
|
||||
ctx.add_transforms(
|
||||
"browser/browser/panicButton.ftl",
|
||||
"browser/browser/panicButton.ftl",
|
||||
transforms_from(
|
||||
"""
|
||||
panic-button-open-new-window = { COPY("browser/chrome/browser/browser.dtd", "panicButton.view.openNewWindow") }
|
||||
panic-button-undo-warning = { COPY("browser/chrome/browser/browser.dtd", "panicButton.view.undoWarning") }
|
||||
panic-button-forget-button =
|
||||
.label = { COPY("browser/chrome/browser/browser.dtd", "panicButton.view.forgetButton") }
|
||||
panic-main-timeframe-desc = { COPY("browser/chrome/browser/browser.dtd", "panicButton.view.mainTimeframeDesc") }
|
||||
panic-button-5min =
|
||||
.label = { COPY("browser/chrome/browser/browser.dtd", "panicButton.view.5min") }
|
||||
panic-button-2hr =
|
||||
.label = { COPY("browser/chrome/browser/browser.dtd", "panicButton.view.2hr") }
|
||||
panic-button-day =
|
||||
.label = { COPY("browser/chrome/browser/browser.dtd", "panicButton.view.day") }
|
||||
panic-button-action-desc = { COPY("browser/chrome/browser/browser.dtd", "panicButton.view.mainActionDesc") }
|
||||
""")
|
||||
)
|
||||
|
||||
ctx.add_transforms(
|
||||
"browser/browser/panicButton.ftl",
|
||||
"browser/browser/panicButton.ftl", [
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("panic-button-delete-cookies"),
|
||||
value=REPLACE(
|
||||
"browser/chrome/browser/browser.dtd",
|
||||
"panicButton.view.deleteCookies",
|
||||
{
|
||||
"html:strong>": FTL.TextElement('strong>')
|
||||
}
|
||||
)
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("panic-button-delete-history"),
|
||||
value=REPLACE(
|
||||
"browser/chrome/browser/browser.dtd",
|
||||
"panicButton.view.deleteHistory",
|
||||
{
|
||||
"html:strong>": FTL.TextElement('strong>')
|
||||
}
|
||||
)
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("panic-button-delete-tabs-and-windows"),
|
||||
value=REPLACE(
|
||||
"browser/chrome/browser/browser.dtd",
|
||||
"panicButton.view.deleteTabsAndWindows",
|
||||
{
|
||||
"html:strong>": FTL.TextElement('strong>')
|
||||
}
|
||||
)
|
||||
)
|
||||
])
|
Загрузка…
Ссылка в новой задаче