Skip to content

Instantly share code, notes, and snippets.

@mosheeshel
Forked from MichelleGlauser/gist:5323089
Last active December 19, 2015 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosheeshel/6007484 to your computer and use it in GitHub Desktop.
Save mosheeshel/6007484 to your computer and use it in GitHub Desktop.
getsatisfaction customization code how to add a button to subscribe to a feed (not real product feed)
<!-- Subscribe to all topics. -->
<!-- Steps to a subscribe-to-all-topics button:
1. make a product for all topics, get ID number (87939: http://michelleglauser.jarg0n.com/gsfnmichelle/products/gsfnmichelle_all_topics)
2. make all new topics automatically be assigned to that product by ID number (through a jQuery click on that element)
3. hide that product by ID number
4. make a subscribe button on the front page
5. give the subscribe button a call to the product page's follow button -->
<!-- Header HTML: -->
<div class="sb_pod" id="notifs">
<div class="clearfix" id="email_notifications">
<!-- Personalize this text: -->
<h3>Want to subscribe to every topic?</h3>
<div class="inner_content">
<a href="#" class="button" id="email_subscription" style="margin-top:4px; ">Checking status . . .</a>
</div>
</div>
</div>
<!-- Footer HTML: -->
<script type="text/javascript" language="javascript">
// Only show subscribe button if the user is logged in and on the front page.
var isFrontPage = $j("div.community_topic_box").size() > 0;
var loggedOut = $j("ul.logged_in").attr("style") != undefined;
jQuery(document).ready(function () {
// Checks if the user is logged in and if it's the front page.
if (!loggedOut && isFrontPage) {
// Position subscribe button.
//jQuery("#notifs").insertBefore("#community_info_sidebar");
// mosheeshel: Changed position to match position in product pages...
jQuery("#notifs").insertAfter("#latest_company_update");
// Personalize the address with the canonical name of your product:
jQuery.ajax("/[companyname]/products/[productcanonicalname]/", {
success: function (data) {
var button = jQuery("a#email_subscription");
var update = function (url, nextText, nextFunction) {
button.unbind("click").text("Updating...");
// Makes an ajax call to the product page that was created for all topics, and causes the same follow function to occur
// Personalize the address with the canonical name of your product:
jQuery.ajax("/[companyname]/products/[productcanonicalname]/" + url, {
success: function () {
button.text(nextText).click(nextFunction);
}
});
};
// Changed button text to "Unfollow/Follow Updates"
var subscribe = function () {
update("follow", "Unfollow Updates", unsubscribe);
};
var unsubscribe = function () {
update("unfollow", "Follow Updates", subscribe);
};
data = jQuery(data);
// Users who haven't yet posted might be loggedin, but not able to see the button
// Added a try/catch block to avoid the button displayed as "Checking...." for those users
// found bug while testing (users added through fast api?)
try
{
var following = data.find("#follow_product_button").css("display").toLowerCase() == "none";
// Changed text again
button.text(following ? "Unfollow Updates" : "Follow Updates").click(following ? unsubscribe : subscribe);
}
catch(err)
{
jQuery("#notifs").hide();
}
}
});
} else if (!loggedOut && window.location.pathname == "/openni/updates/recent") {
// New code to display button in the Updates page itself (not only in the home widget)
// Find New Topic Button in Page
newTopicButton = jQuery('.button:contains("Create a new topic")');
// Position subscribe button.
jQuery("#notifs").insertBefore(newTopicButton);
// Personalize the address with the canonical name of your product:
jQuery.ajax("/openni/products/openni_follow_updates/", {
success: function (data) {
var button = jQuery("a#email_subscription");
var update = function (url, nextText, nextFunction) {
button.unbind("click").text("Updating...");
// Makes an ajax call to the product page that was created for all topics, and causes the same follow function to occur
// Personalize the address with the canonical name of your product:
jQuery.ajax("/openni/products/openni_follow_updates/" + url, {
success: function () {
button.text(nextText).click(nextFunction);
}
});
};
var subscribe = function () {
update("follow", "Unfollow Updates", unsubscribe);
};
var unsubscribe = function () {
update("unfollow", "Follow Updates", subscribe);
};
data = jQuery(data);
try
{
var following = data.find("#follow_product_button").css("display").toLowerCase() == "none";
button.text(following ? "Unfollow Updates" : "Follow Updates").click(following ? unsubscribe : subscribe);
}
catch(err)
{
jQuery("#notifs").hide();
}
}
});
} else {
jQuery("#notifs").hide();
}
// On new topic page, automatically assign every topic to the hidden "all topics" product, and hide that from view.
// Personalize the address and the ID numbers:
console.log(window.location.pathname);
if (window.location.pathname == "/[companyname]/topics/new") {
jQuery("#product_[number]").click();
jQuery("#product_grid li.Updates").hide();
jQuery("#-updates-").hide();
}
// Personalize the ID numbers here to hide them:
jQuery("#product_[number]").hide();
jQuery(".product_[number]").hide();
jQuery(".product_[number]:parent").parent().hide()
jQuery("ul.product_grid li.product_[number]").hide();
jQuery("#product_grid li #product_[number]").hide()
jQuery("#product_grid li #product_[number]").parent().hide();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment