Sha256: 09de25385e6710a5a5e56a723727c98056b94429d440c27fa9dba7c951cd8efa
Contents?: true
Size: 1.53 KB
Versions: 139
Compression:
Stored size: 1.53 KB
Contents
var Heroku = Heroku || {}; var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; Heroku.NewsletterSignup = (function() { function NewsletterSignup() { this.handleSubmit = bind(this.handleSubmit, this); this.$container = $('#bookends-newsletter'); this.$honeyPot = this.$container.find('#bookends-website'); this.$input = this.$container.find('input[type=email]'); this.$submit = this.$container.find(':submit'); this.$resultContainer = $('#bookends-newsletter-result'); this.$container.on('submit', this.handleSubmit); } NewsletterSignup.prototype.handleSubmit = function(e) { var val; var self; e.preventDefault(); if(this.$honeyPot.val() !== '') { return this.handleSuccess(); } val = this.$input.val(); self = this; $.ajax({ url: 'https://www.heroku.com/newsletter_signups', type: 'POST', crossDomain: true, data: { newsletter_signup: { email: val } } }) .done(function(res) { return self.handleSuccess(); }) .fail(function(err) { return self.handleFailure(); }); }; NewsletterSignup.prototype.handleSuccess = function() { this.$input.replaceWith('<p>Check your email now to confirm your sign-up.</p>'); }; NewsletterSignup.prototype.handleFailure = function() { this.$input.val(""); this.$resultContainer .removeClass('hide') .text('There was an error registering you. Please refresh.'); }; return NewsletterSignup; })();
Version data entries
139 entries across 139 versions & 1 rubygems