Skip to content

Instantly share code, notes, and snippets.

@ckahle33
Created June 4, 2014 02:35
Show Gist options
  • Save ckahle33/3b9897e2e8d2063ce598 to your computer and use it in GitHub Desktop.
Save ckahle33/3b9897e2e8d2063ce598 to your computer and use it in GitHub Desktop.
Nitrosphere JS
$(function(){
//initialize valiadation
$(".private").validationEngine();
$(".private input").focus(function(){
$(this).validationEngine('hide');
})
//loop through links before we hide them
var $registered = $('.Registered');
var $modal = $('.modal');
$registered.each(function(){
registeredLink1 = $(this).attr('href');
});
//check if cookie is set
if ($.cookie('form-1-complete') == null) {
// looop through and change hide links with #
$registered.each(function(){
$(this).attr('href', '#');
var registeredLink2 = $(this).attr('href');
});
$registered.on("click", function(e){
$modal.animate({'top': '0'});
e.preventDefault();
});
} else {
// get original link
$registered.each(function(){
if ($(this).attr('href') == '#') {
$(this).attr('href', registeredLink1 );
}
});
$modal.stop();
return true;
// });
}
//add HIDE text link
var $wrapper = $('#gform_wrapper_5');
$wrapper.prepend($('.hide'));
$('.hide').click(function(e){
$modal.animate({'top': '-2000px'});
e.preventDefault();
});
var modalInput = $('.modal input[type="submit"]');
var formInner = $('.form-box-inner');
$(".private").on('submit', function(){
formInner.html("<h3>Thanks! You can now view this Private Resource.</h3>")
$.cookie('form-1-complete', '1', { expires: 90, path: '/' });
$modal.stop('true', 'true');
function success() {
$modal.animate({'top': '-2000px'});
}
setTimeout(success, 2000);
})
//populates lead_source with resource title
$('.Registered').on('click', function(){
var title = $(this).attr('title');
if (title) {
$('input#00NE0000003lFel').attr('value', title);
} else {
var titleHtml = $(this).html();
$('input#00NE0000003lFel').attr('value', titleHtml);
}
})
//returns user to current page
var thePage = window.location;
$('#retURL').attr('value', thePage);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment