зеркало из https://github.com/mozilla/gecko-dev.git
Bug 764872: add a way to toggle social functionality on/off, r=jaws
--HG-- extra : transplant_source : %C2%D1x.%B2%5C%A5%D2%B9%91J%8B%A5%2B%DB%9C%3A%A9%E7%CE
This commit is contained in:
Родитель
e4072de7a1
Коммит
31fd0ee9b6
|
@ -332,6 +332,10 @@
|
|||
label="&preferencesCmd2.label;"
|
||||
#endif
|
||||
oncommand="openPreferences();">
|
||||
<menuitem id="appmenu_socialToggle"
|
||||
type="checkbox"
|
||||
autocheck="false"
|
||||
command="Social:Toggle"/>
|
||||
<menupopup id="appmenu_customizeMenu"
|
||||
onpopupshowing="onViewToolbarsPopupShowing(event, document.getElementById('appmenu_toggleToolbarsSeparator'));">
|
||||
<menuitem id="appmenu_preferences"
|
||||
|
|
|
@ -496,6 +496,10 @@
|
|||
accesskey="&addons.accesskey;"
|
||||
key="key_openAddons"
|
||||
command="Tools:Addons"/>
|
||||
<menuitem id="menu_socialToggle"
|
||||
type="checkbox"
|
||||
autocheck="false"
|
||||
command="Social:Toggle"/>
|
||||
#ifdef MOZ_SERVICES_SYNC
|
||||
<!-- only one of sync-setup or sync-menu will be showing at once -->
|
||||
<menuitem id="sync-setup"
|
||||
|
|
|
@ -108,6 +108,7 @@
|
|||
<command id="Social:SharePage" oncommand="SocialShareButton.sharePage();"/>
|
||||
<command id="Social:UnsharePage" oncommand="SocialShareButton.unsharePage();"/>
|
||||
<command id="Social:ToggleSidebar" oncommand="Social.toggleSidebar();"/>
|
||||
<command id="Social:Toggle" oncommand="Social.toggle();" hidden="true"/>
|
||||
</commandset>
|
||||
|
||||
<commandset id="placesCommands">
|
||||
|
|
|
@ -33,6 +33,7 @@ let SocialUI = {
|
|||
observe: function SocialUI_observe(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "social:pref-changed":
|
||||
this.updateToggleCommand();
|
||||
SocialShareButton.updateButtonHiddenState();
|
||||
SocialToolbar.updateButtonHiddenState();
|
||||
SocialSidebar.updateSidebar();
|
||||
|
@ -48,17 +49,49 @@ let SocialUI = {
|
|||
}
|
||||
},
|
||||
|
||||
get toggleCommand() {
|
||||
return document.getElementById("Social:Toggle");
|
||||
},
|
||||
|
||||
// Called once Social.jsm's provider has been set
|
||||
_providerReady: function SocialUI_providerReady() {
|
||||
// If we couldn't find a provider, nothing to do here.
|
||||
if (!Social.provider)
|
||||
return;
|
||||
|
||||
this.updateToggleCommand();
|
||||
|
||||
let toggleCommand = this.toggleCommand;
|
||||
let label = gNavigatorBundle.getFormattedString("social.enable.label",
|
||||
[Social.provider.name]);
|
||||
let accesskey = gNavigatorBundle.getString("social.enable.accesskey");
|
||||
toggleCommand.setAttribute("label", label);
|
||||
toggleCommand.setAttribute("accesskey", accesskey);
|
||||
|
||||
SocialToolbar.init();
|
||||
SocialShareButton.init();
|
||||
SocialSidebar.init();
|
||||
},
|
||||
|
||||
updateToggleCommand: function SocialUI_updateToggleCommand() {
|
||||
let toggleCommand = this.toggleCommand;
|
||||
toggleCommand.setAttribute("checked", Social.enabled);
|
||||
|
||||
// FIXME: bug 772808: menu items don't inherit the "hidden" state properly,
|
||||
// need to update them manually.
|
||||
// This should just be: toggleCommand.hidden = !Social.active;
|
||||
for (let id of ["appmenu_socialToggle", "menu_socialToggle"]) {
|
||||
let el = document.getElementById(id);
|
||||
if (!el)
|
||||
continue;
|
||||
|
||||
if (Social.active)
|
||||
el.removeAttribute("hidden");
|
||||
else
|
||||
el.setAttribute("hidden", "true");
|
||||
}
|
||||
},
|
||||
|
||||
// This handles "ActivateSocialFeature" events fired against content documents
|
||||
// in this window.
|
||||
_activationEventHandler: function SocialUI_activationHandler(e) {
|
||||
|
@ -216,6 +249,14 @@ var SocialToolbar = {
|
|||
init: function SocialToolbar_init() {
|
||||
document.getElementById("social-provider-image").setAttribute("image", Social.provider.iconURL);
|
||||
|
||||
let removeItem = document.getElementById("social-remove-menuitem");
|
||||
let brandShortName = document.getElementById("bundle_brand").getString("brandShortName");
|
||||
let label = gNavigatorBundle.getFormattedString("social.remove.label",
|
||||
[brandShortName]);
|
||||
let accesskey = gNavigatorBundle.getString("social.remove.accesskey");
|
||||
removeItem.setAttribute("label", label);
|
||||
removeItem.setAttribute("accesskey", accesskey);
|
||||
|
||||
let statusAreaPopup = document.getElementById("social-statusarea-popup");
|
||||
statusAreaPopup.addEventListener("popupshowing", function(e) {
|
||||
this.button.setAttribute("open", "true");
|
||||
|
@ -298,10 +339,10 @@ var SocialToolbar = {
|
|||
panel.hidden = false;
|
||||
|
||||
function sizePanelToContent() {
|
||||
// XXX Maybe we can use nsIDOMWindowUtils.getRootBounds() here?
|
||||
// XXX need to handle dynamic sizing
|
||||
// FIXME: bug 764787: Maybe we can use nsIDOMWindowUtils.getRootBounds() here?
|
||||
// Need to handle dynamic sizing
|
||||
let doc = notifBrowser.contentDocument;
|
||||
// XXX "notif" is an implementation detail that we should get rid of
|
||||
// "notif" is an implementation detail that we should get rid of
|
||||
// eventually
|
||||
let body = doc.getElementById("notif") || doc.body.firstChild;
|
||||
if (!body)
|
||||
|
|
|
@ -676,6 +676,8 @@
|
|||
oncommand="SocialUI.showProfile(); document.getElementById('social-statusarea-popup').hidePopup();"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
<menuitem id="social-remove-menuitem"
|
||||
oncommand="Social.active = false;"/>
|
||||
<menuitem id="social-toggle-sidebar-menuitem"
|
||||
type="checkbox"
|
||||
autocheck="false"
|
||||
|
|
|
@ -373,5 +373,13 @@ social.shareButton.tooltip=Share this
|
|||
social.shareButton.sharedtooltip=You shared this
|
||||
social.pageShared.label=Page shared
|
||||
|
||||
# LOCALIZATION NOTE (social.enable.label): %S = Social networking provider
|
||||
social.enable.label=%S integration
|
||||
social.enable.accesskey=n
|
||||
|
||||
# LOCALIZATION NOTE (social.remove.label): %S = brandShortName
|
||||
social.remove.label=Remove from %S
|
||||
social.remove.accesskey=R
|
||||
|
||||
# LOCALIZATION NOTE (social.enabled.message): %1$S is the name of the social provider, %2$S is brandShortName (e.g. Firefox)
|
||||
social.activated.message=%1$S integration with %2$S has been activated.
|
||||
|
|
|
@ -54,6 +54,10 @@ let Social = {
|
|||
this.enabled = !!val;
|
||||
},
|
||||
|
||||
toggle: function Social_toggle() {
|
||||
this.enabled = !this.enabled;
|
||||
},
|
||||
|
||||
toggleSidebar: function SocialSidebar_toggle() {
|
||||
let prefValue = Services.prefs.getBoolPref("social.sidebar.open");
|
||||
Services.prefs.setBoolPref("social.sidebar.open", !prefValue);
|
||||
|
|
Загрузка…
Ссылка в новой задаче