Skip to content

Commit

Permalink
add a stringbundle for stuff we manipulate in js
Browse files Browse the repository at this point in the history
  • Loading branch information
mixedpuppy committed Apr 2, 2012
1 parent 727796d commit ddcde05
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
12 changes: 8 additions & 4 deletions content/overlay.xul
Expand Up @@ -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')"/>
Expand Down Expand Up @@ -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)"/>
Expand Down
23 changes: 22 additions & 1 deletion content/toolbarButtonWidget.js
Expand Up @@ -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,
Expand All @@ -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) {
Expand All @@ -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));
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions locale/en-US/social.dtd
Expand Up @@ -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">
4 changes: 4 additions & 0 deletions locale/en-US/social.properties
@@ -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.