Created
April 17, 2018 07:29
-
-
Save pradhumnsharma/68687fb407ccda3a0ca6b29303029efe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/search" method="get" class="search-bar" role="search" style="text-align:left;"> | |
<button type="submit" class="btn" style="position:absolute; margin-left: 8px; margin-top: 6px;"> | |
<i class="fa fa-search"></i> | |
</button> | |
<input type="search" placeholder="Search articles" name="q" value="{{ search.terms | escape }}" style="height:32px; padding-left:25px; margin-top:20px; width:100%; border-radius:40px;"> | |
</form> | |
<div class="blog-newsletter"> | |
<img src="{{ 'msg_medium_blue.png' | asset_img_url: 'medium' }}" alt="No image"> | |
<h5>Join thousands of women who already have gotten stronger.</h5> | |
<p>Get free diet and workout tips and resources delivered directly to your inbox.</p> | |
<div id="mc_embed_signup"> | |
<form action="https://sayitee.us16.list-manage.com/subscribe/post?u=cbc4ba0cb6422e886a6dd10e8&id=8372fd0646" method="post" id="mc-embedded-subscribe-form-blog" name="mc-embedded-subscribe-form-blog" class="validate" target="_blank" novalidate> | |
<div id="mc_embed_signup_scroll" class="top-bar-email-subscription"> | |
<label for="mce-EMAIL"></label> | |
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="Email" required style="border-radius:0px;"> | |
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups--> | |
<div style="position: absolute; left: -5000px;"> | |
<input type="text" name="b_36c4fd991d266f23781ded980_aefe40901a" tabindex="-1" value=""> | |
</div> | |
<button type="submit" style="border-radius:0px;" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button topbar-button">GET UPDATES</button> | |
<div class="info"></div> | |
</div> | |
</form> | |
</div> | |
<!--End mc_embed_signup--> | |
<!-- <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> --> | |
<!-- <script src="jquery.ajaxchimp.js"></script> --> | |
<script> | |
(function ($) { | |
'use strict'; | |
$.ajaxChimp = { | |
responses: { | |
'Thank you for subscribing to us. We have sent you a confirmation email.' : 0, | |
'Please enter a value' : 1, | |
'An email address must contain a single @' : 2, | |
'The domain portion of the email address is invalid (the portion after the @: )' : 3, | |
'The username portion of the email address is invalid (the portion before the @: )' : 4, | |
'This email address looks fake or invalid. Please enter a real email address' : 5 | |
}, | |
translations: { | |
'en': null | |
}, | |
init: function (selector, options) { | |
$(selector).ajaxChimp(options); | |
} | |
}; | |
$.fn.ajaxChimp = function (options) { | |
$(this).each(function(i, elem) { | |
var form = $(elem); | |
var email = form.find('input[type=email]'); | |
var label = form.find('label[for=' + email.attr('id') + ']'); | |
// var label = $('.top-bar-text'); | |
var settings = $.extend({ | |
'url': form.attr('action'), | |
'language': 'en' | |
}, options); | |
var url = settings.url.replace('/post?', '/post-json?').concat('&c=?'); | |
form.attr('novalidate', 'true'); | |
email.attr('name', 'EMAIL'); | |
form.submit(function () { | |
var msg; | |
function successCallback(resp) { | |
if (resp.result === 'success') { | |
msg = 'Thank you for subscribing to us. We have sent you a confirmation email.'; | |
label.text(msg); | |
email.removeClass('error').addClass('valid'); | |
} else { | |
email.removeClass('valid').addClass('error'); | |
label.removeClass('valid').addClass('error'); | |
var index = -1; | |
try { | |
var parts = resp.msg.split(' - ', 2); | |
if (parts[1] === undefined) { | |
msg = resp.msg; | |
} else { | |
var i = parseInt(parts[0], 10); | |
if (i.toString() === parts[0]) { | |
index = parts[0]; | |
msg = parts[1]; | |
} else { | |
index = -1; | |
msg = resp.msg; | |
} | |
} | |
} | |
catch (e) { | |
index = -1; | |
msg = resp.msg; | |
} | |
} | |
// Translate and display message | |
if ( | |
settings.language !== 'en' | |
&& $.ajaxChimp.responses[msg] !== undefined | |
&& $.ajaxChimp.translations | |
&& $.ajaxChimp.translations[settings.language] | |
&& $.ajaxChimp.translations[settings.language][$.ajaxChimp.responses[msg]] | |
) { | |
msg = $.ajaxChimp.translations[settings.language][$.ajaxChimp.responses[msg]]; | |
} | |
label.html(msg); | |
label.show(2000); | |
if (settings.callback) { | |
settings.callback(resp); | |
} | |
} | |
var data = {}; | |
var dataArray = form.serializeArray(); | |
$.each(dataArray, function (index, item) { | |
data[item.name] = item.value; | |
}); | |
$.ajax({ | |
url: url, | |
data: data, | |
success: successCallback, | |
dataType: 'jsonp', | |
error: function (resp, text) { | |
console.log('mailchimp ajax submit error: ' + text); | |
} | |
}); | |
// Translate and display submit message | |
var submitMsg = 'Submitting...'; | |
if( | |
settings.language !== 'en' | |
&& $.ajaxChimp.translations | |
&& $.ajaxChimp.translations[settings.language] | |
&& $.ajaxChimp.translations[settings.language]['submit'] | |
) { | |
submitMsg = $.ajaxChimp.translations[settings.language]['submit']; | |
} | |
label.html(submitMsg).show(2000); | |
return false; | |
}); | |
}); | |
return this; | |
}; | |
$('#mc-embedded-subscribe-form-blog').ajaxChimp(); | |
})(jQuery); | |
</script> | |
<p style="margin:0px;">No charge. Unsubscribe anytime.</p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment