Permalink
Browse files

add a stringbundle for stuff we manipulate in js

  • Loading branch information...
1 parent 727796d commit ddcde05dbda0f1961950c2e3fb2383ee4b5b54b0 @mixedpuppy mixedpuppy committed Apr 2, 2012
Showing with 36 additions and 5 deletions.
  1. +8 −4 content/overlay.xul
  2. +22 −1 content/toolbarButtonWidget.js
  3. +2 −0 locale/en-US/social.dtd
  4. +4 −0 locale/en-US/social.properties
View
@@ -17,17 +17,21 @@
{
// quick hack to move to an overlay
window.social = {};
- social.toolbarButton = new SocialToolbarButton(window);
- social.recommendButton = new SocialRecommendButton(window);
// due to what we are doing in the sidebar, we have to wait for the
// chromeWindow to load before we do our magic
window.addEventListener('load', function(e) {
+ social.recommendButton = new SocialRecommendButton(window);
social.sidebar = new SocialSidebar(window);
+ social.toolbarButton = new SocialToolbarButton(window);
});
}
]]>
</script>
+ <stringbundleset id="stringbundleset">
+ <stringbundle src="chrome://socialdev/locale/social.properties" id="socialdev-strings" />
+ </stringbundleset>
+
<commandset id="mainCommandSet">
<command id="cmd_socialRecommend" oncommand="social.recommendButton.oncommand(event);"/>
<command id="cmd_socialPreferences" oncommand="openUILink('about:social')"/>
@@ -58,8 +62,8 @@
onpopupshown="social.toolbarButton.onpopupshown(event)"
onpopupshowing="social.toolbarButton.onpopupshowing(event)"
onpopuphidden="social.toolbarButton.onpopuphidden(event)">
- <menuitem id="social-socialtoolbar-menu" label="Minimize/Show Social Sidebar" command="cmd_socialToolbarToggle"/>
- <menuitem id="social-socialbrowsing-menu" label="Enable/Disable Social Browsing" command="cmd_socialBrowsingToggle"/>
+ <menuitem id="social-socialtoolbar-menu" label="&socialtoobar.label;" command="cmd_socialToolbarToggle"/>
+ <menuitem id="social-socialbrowsing-menu" label="&socialenable.label;" command="cmd_socialBrowsingToggle"/>
<menuseparator/>
<menuseparator id="social-providers-separator"/>
<menuitem id="social-demonotification-menu" label="Fire a demo notification" oncommand="social.toolbarButton.fireDemoNotification(event)"/>
@@ -13,7 +13,17 @@ function SocialToolbarButton() {
var newset = navbar.currentSet + ",social-button-container";
navbar.currentSet = newset;
navbar.setAttribute("currentset", newset );
- window.document.persist("nav-bar", "currentset");
+ window.document.persist("nav-bar", "currentset");
+
+ // XXX i think we can use broadcasters for this state
+ let sidebar = window.social.sidebar;
+ let str = document.getElementById("socialdev-strings");
+ let label = (sidebar.visibility == "hidden" ? "browserEnable.label" : "browserDisable.label")
+ document.getElementById('social-socialbrowsing-menu').
+ setAttribute('label', str.getString(label));
+ label = (sidebar.visibility == "open" ? "minimizeSidebar.label" : "showSidebar.label")
+ document.getElementById('social-socialtoolbar-menu').
+ setAttribute('label', str.getString(label));
}
SocialToolbarButton.prototype = {
__proto__: baseWidget.prototype,
@@ -37,14 +47,20 @@ SocialToolbarButton.prototype = {
buildSocialPopupContents(aWindow, socialpanel);
},
onToggleEnabled: function() {
+ var str = document.getElementById("socialdev-strings");
if (window.social.sidebar.visibility != "hidden") {
Services.obs.notifyObservers(null, "social-browsing-disabled", null);
+ document.getElementById('social-socialbrowsing-menu').
+ setAttribute('label', str.getString("browserEnable.label"));
}
else {
Services.obs.notifyObservers(null, "social-browsing-enabled", null);
+ document.getElementById('social-socialbrowsing-menu').
+ setAttribute('label', str.getString("browserDisable.label"));
}
},
onToggleVisible: function() {
+ var str = document.getElementById("socialdev-strings");
let registry = Cc["@mozilla.org/socialProviderRegistry;1"]
.getService(Ci.mozISocialRegistry);
if (!registry.currentProvider || !registry.currentProvider.enabled) {
@@ -54,9 +70,14 @@ SocialToolbarButton.prototype = {
let sidebar = window.social.sidebar;
if (sidebar.visibility == 'hidden') {
Services.obs.notifyObservers(null, "social-browsing-enabled", null);
+ document.getElementById('social-socialbrowsing-menu').
+ setAttribute('label', str.getString("browserDisable.label"));
}
else {
sidebar.visibility = (sidebar.visibility=="open" ? "minimized" : "open");
+ let label = (sidebar.visibility == "open" ? "minimizeSidebar.label" : "showSidebar.label")
+ document.getElementById('social-socialtoolbar-menu').
+ setAttribute('label', str.getString(label));
}
}
},
View
@@ -2,3 +2,5 @@
<!ENTITY socialdev.accesskey "F2">
<!ENTITY socialdev.toolbartext "Social Browsing">
<!ENTITY socialdev.prefslabel "Preferences...">
+<!ENTITY socialtoobar.label "Minimize/Show Social Sidebar">
+<!ENTITY socialenable.label "Enable/Disable Social Browsing">
@@ -0,0 +1,4 @@
+browserEnable.label=Enable Social Browsing
+browserDisable.label=Disable Social Browsing
+minimizeSidebar.label=Minimize Social sidebar
+showSidebar.label=Show Social sidebar

0 comments on commit ddcde05

Please sign in to comment.