Bug 837027 - Fix social UI for a multi-provider world. r=gavin

This commit is contained in:
Mark Hammond 2013-02-05 16:42:18 +11:00
Родитель 73b9ff03bf
Коммит e972173341
3 изменённых файлов: 34 добавлений и 35 удалений

Просмотреть файл

@ -162,21 +162,21 @@ let SocialUI = {
let broadcaster = document.getElementById("socialActiveBroadcaster");
broadcaster.hidden = !enabled;
if (!Social.provider)
return;
let toggleCommand = document.getElementById("Social:Toggle");
// We only need to update the command itself - all our menu items use it.
let label = gNavigatorBundle.getFormattedString(Social.provider.enabled ?
"social.turnOff.label" :
"social.turnOn.label",
[Social.provider.name]);
let accesskey = gNavigatorBundle.getString(Social.provider.enabled ?
"social.turnOff.accesskey" :
"social.turnOn.accesskey");
toggleCommand.setAttribute("label", label);
toggleCommand.setAttribute("accesskey", accesskey);
toggleCommand.setAttribute("hidden", enabled ? "false" : "true");
if (enabled) {
// We only need to update the command itself - all our menu items use it.
let label = gNavigatorBundle.getFormattedString(Social.provider.enabled ?
"social.turnOff.label" :
"social.turnOn.label",
[Social.provider.name]);
let accesskey = gNavigatorBundle.getString(Social.provider.enabled ?
"social.turnOff.accesskey" :
"social.turnOn.accesskey");
toggleCommand.setAttribute("label", label);
toggleCommand.setAttribute("accesskey", accesskey);
}
},
_updateMenuItems: function () {
@ -719,13 +719,8 @@ var SocialToolbar = {
// Called once, after window load, when the Social.provider object is
// initialized.
init: function SocialToolbar_init() {
let brandShortName = document.getElementById("bundle_brand").getString("brandShortName");
let label = gNavigatorBundle.getFormattedString("social.remove.label",
[brandShortName]);
let accesskey = gNavigatorBundle.getString("social.remove.accesskey");
let accesskey = gNavigatorBundle.getString("social.removeProvider.accesskey");
let removeCommand = document.getElementById("Social:Remove");
removeCommand.setAttribute("label", label);
removeCommand.setAttribute("accesskey", accesskey);
this.updateProvider();
@ -734,13 +729,18 @@ var SocialToolbar = {
// Called when the Social.provider changes
updateProvider: function () {
if (!SocialUI.enabled)
return;
this.button.style.listStyleImage = "url(" + Social.provider.iconURL + ")";
this.button.setAttribute("label", Social.provider.name);
this.button.setAttribute("tooltiptext", Social.provider.name);
if (Social.provider) {
let label = gNavigatorBundle.getFormattedString("social.removeProvider.label",
[Social.provider.name]);
let removeCommand = document.getElementById("Social:Remove");
removeCommand.setAttribute("label", label);
this.button.setAttribute("label", Social.provider.name);
this.button.setAttribute("tooltiptext", Social.provider.name);
this.button.style.listStyleImage = "url(" + Social.provider.iconURL + ")";
this.updateProfile();
}
this.updateButton();
this.updateProfile();
this.populateProviderMenus();
},
@ -797,10 +797,8 @@ var SocialToolbar = {
updateButton: function SocialToolbar_updateButton() {
this.updateButtonHiddenState();
let provider = Social.provider;
let icons = provider.ambientNotificationIcons;
let iconNames = Object.keys(icons);
let panel = document.getElementById("social-notification-panel");
panel.hidden = false;
panel.hidden = !SocialUI.enabled;
let command = document.getElementById("Social:ToggleNotifications");
command.setAttribute("checked", Services.prefs.getBoolPref("social.toast-notifications.enabled"));
@ -817,6 +815,8 @@ var SocialToolbar = {
Services.prefs.clearUserPref(CACHE_PREF_NAME);
return;
}
let icons = provider.ambientNotificationIcons;
let iconNames = Object.keys(icons);
if (Social.provider.profile === undefined) {
// provider has not told us about the login state yet - see if we have
// a cached version for this provider.
@ -1020,7 +1020,7 @@ var SocialToolbar = {
menu.removeChild(providerMenuSep.previousSibling);
}
// only show a selection if enabled and there is more than one
if (!SocialUI.enabled || Social.providers.length < 2) {
if (!SocialUI.enabled || providers.length < 2) {
providerMenuSep.hidden = true;
return;
}

Просмотреть файл

@ -167,13 +167,12 @@ function checkSocialUI(win) {
isbool(!win.SocialShareButton.shareButton.hidden, enabled && provider.recommendInfo, "share button visible?");
isbool(!doc.getElementById("social-toolbar-item").hidden, enabled, "toolbar items visible?");
if (enabled)
todo_is(win.SocialToolbar.button.style.listStyleImage, 'url("' + provider.iconURL + '")', "Bug 821262 - toolbar button has provider icon");
is(win.SocialToolbar.button.style.listStyleImage, 'url("' + provider.iconURL + '")', "toolbar button has provider icon");
// and for good measure, check all the social commands.
// Social:Remove - never disabled directly but parent nodes are
isbool(!doc.getElementById("Social:Toggle").hidden, enabled, "Social:Toggle visible?");
// Until bug 821262 is fixed, ToggleNotifications might not be updated correctly...
// isbool(!doc.getElementById("Social:ToggleNotifications").hidden, enabled, "Bug 821262 - Social:ToggleNotifications visible?");
isbool(!doc.getElementById("Social:ToggleNotifications").hidden, enabled, "Social:ToggleNotifications visible?");
isbool(!doc.getElementById("Social:FocusChat").hidden, enabled && Social.haveLoggedInUser(), "Social:FocusChat visible?");
isbool(doc.getElementById("Social:FocusChat").getAttribute("disabled"), enabled ? "false" : "true", "Social:FocusChat disabled?");
is(doc.getElementById("Social:SharePage").getAttribute("disabled"), enabled && provider.recommendInfo ? "false" : "true", "Social:SharePage visible?");

Просмотреть файл

@ -374,9 +374,9 @@ fullscreen.rememberDecision=Remember decision for %S
# LOCALIZATION NOTE (social.activated.description): %1$S is the name of the social provider, %2$S is brandShortName (e.g. Firefox)
social.activated.description=You've turned on %1$S for %2$S.
# LOCALIZATION NOTE (social.remove.label): %S = brandShortName
social.remove.label=Remove from %S
social.remove.accesskey=R
# LOCALIZATION NOTE (social.removeProvider.label): %S is the name of the social provider
social.removeProvider.label=Remove %S
social.removeProvider.accesskey=R
# LOCALIZATION NOTE (social.remove.confirmationLabel): %1$S is the name of the social provider, %2$S is brandShortName (e.g. Firefox)
social.remove.confirmationLabel=Are you sure you want to remove %1$S for %2$S?
# LOCALIZATION NOTE (social.remove.confirmationOK): %S is the name of the social provider