Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/ui/firstRun.js

Issue 10860047: New toggle button on First-run page (Closed)
Patch Set: Created June 7, 2013, 12:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/content/ui/firstRun.html ('k') | chrome/locale/en-US/firstRun.properties » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/firstRun.js
===================================================================
--- a/chrome/content/ui/firstRun.js
+++ b/chrome/content/ui/firstRun.js
@@ -93,6 +93,8 @@
var featureSubscription = featureSubscriptions[i];
updateToggleButton(featureSubscription.feature, isSubscriptionEnabled(featureSubscription));
}
+
+ setSocialLinks();
}
}
FilterNotifier.addListener(filterListener);
@@ -106,7 +108,7 @@
onWindowResize();
- initSocialLinks(null);
+ setSocialLinks();
}
function onScroll()
@@ -222,20 +224,35 @@
glassPane.className = "visible";
}
- function initSocialLinks(variant)
+ function setSocialLinks()
{
+ var isSocialFeatureEnabled = false;
+ for (var i = 0; i < featureSubscriptions.length; i++)
+ {
+ if (featureSubscriptions[i].feature == "social")
+ {
+ isSocialFeatureEnabled = isSubscriptionEnabled(featureSubscriptions[i]);
+ break;
+ }
+ }
+
var networks = ["twitter", "facebook", "gplus"];
networks.forEach(function(network)
{
var link = E("share-" + network);
- link.addEventListener("click", function(e)
- {
- e.preventDefault();
- openSharePopup(Utils.getDocLink("share-" + network) + "&variant=" + variant);
- }, false);
+ if (isSocialFeatureEnabled)
+ link.removeEventListener("click", onSocialLinkClick, false);
+ else
+ link.addEventListener("click", onSocialLinkClick, false);
});
}
+ function onSocialLinkClick(e)
+ {
+ e.preventDefault();
+ openSharePopup(Utils.getDocLink(e.target.id));
+ }
+
function setLinks(id)
{
var element = E(id);
@@ -271,8 +288,10 @@
function updateToggleButton(feature, isEnabled)
{
var button = E("toggle-" + feature);
- button.className = isEnabled ? "disable" : "enable";
- button.textContent = i18n.getMessage(isEnabled ? "firstRun_action_disable" : "firstRun_action_enable");
+ if (isEnabled)
+ button.className = button.className.replace("enable", "disable");
+ else
+ button.className = button.className.replace("disable", "enable");
Wladimir Palant 2013/06/07 14:00:04 Frankly, one class name should be sufficient here:
}
document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
« no previous file with comments | « chrome/content/ui/firstRun.html ('k') | chrome/locale/en-US/firstRun.properties » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld