Skip to content

Instantly share code, notes, and snippets.

// this script adds a "for" attribtue to wildfire form elements which have labels
// this allows for easier CSS styling.
//
var inputs = $(":input").not(":checkbox").not(":hidden").not(":submit").not(":button")
$.each( inputs, function( index, element ) {
var elementLabel = $(this).parents("ol").find('label').html();
window.open('https://twitter.com/intent/tweet?url=' + encodeURIComponent(that.settings.vanityUrl), '_blank', 'width=700, height=300');
{% plugin rawtext mobile_url %}
{% plugin rawtext page_url %}
<script type="text/javascript">
$(document).ready(function(){
if(!$("body").hasClass("page_preview"))
{
// DETECT IF ON MOBILE DEVICE. IF YES...
setupSweepsMethods: function() {
var that = this;
// autofill button does a couple of things
// 1. Login to facebook if they already aren't and grab permissions for email and birthday
// 2. Extract as much data as we can for the sweepstakes form
// 3. Populate the sweepstakes with new data
$('.autofill_button').click( function(event) {
{{sweepstakes.start_date | date: "%B %-d, %Y at %I:%M %p %Z" }}
// referral url is canvas_url + reverral_id
var the_referral_url = '';
the_referral_url = "{{ canvas_url }}" + "?app_{{ sweeps_settings.referral_id }}";
@nitishn
nitishn / app.js
Last active August 29, 2015 13:56
$(document).on('didRefreshWidgetContent', function () {
// referral url is canvas_url + reverral_id
var the_referral_id = $('.ref-id').data('id');
var the_referral_url = "{{ canvas_url }}" + "?wfrs=" + the_referral_id;
});

This is the barebones sweepstakes plugins which you can use to render the forms. The bootstrap forms partial is included with error message styling as well. The javascript to add styling to sweeps inputs has also been included.

Make sure you go into the details tab and set the sweeps title, prize, description, timeline dates, privacy policy, and official rules. The plugin will NOT render until you change all these settings.

@nitishn
nitishn / app.js
Created March 19, 2014 00:20
A "deffered" bitly URL shortener.
var utility = {
app_data: {
bitlyAccessToken: 'the-key',
bitlyBaseUrl: 'https://api-ssl.bitly.com',
vanityUrl: '',
// build the google plus feed template
$.ajax({
url : that.default_settings['api_path'] + 'gplus/',
}).done(function( results ) {
// compile the facebook feed template
feed_template = $(".feed_template").html();