Main Avalanche Network server application. Built with Ruby on Rails.

start.js 7.5KB

    // get the value of the bottom of the #main element by adding the offset of that element plus its height, set it as a variable function attachHandler(jQuery) { $('#obscure_header').css('height', ($('#photo_header').height())); $('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height())); $('#obscure_subscribe').css('height', ($('#photo_subscribe').height())); $('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height())); $('#myCarousel.carousel.slide').css('height', ($('#photo_header').height())); $('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height())); $('#tagline_header').css('top', (($('#photo_header').height()/7)*-5)); $('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8)); $('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8)); $('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7)); $(window).on('load',function(){ $('#obscure_header').css('height', ($('#photo_header').height())); $('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height())); $('#obscure_subscribe').css('height', ($('#photo_subscribe').height())); $('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height())); $('#myCarousel.carousel.slide').css('height', ($('#photo_header').height())); $('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height())); $('#tagline_header').css('top', (($('#photo_header').height()/7)*-5)); $('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8)); $('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8)); $('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7)); }); $(window).on('ready',function(){ $('#obscure_header').css('height', ($('#photo_header').height())); $('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height())); $('#obscure_subscribe').css('height', ($('#photo_subscribe').height())); $('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height())); $('#myCarousel.carousel.slide').css('height', ($('#photo_header').height())); $('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height())); $('#tagline_header').css('top', (($('#photo_header').height()/7)*-5)); $('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8)); $('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8)); $('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7)); }); var mainbottom = $('#myCarousel').height(); $( window ).resize(function(){ $('#obscure_header').css('height', ($('#photo_header').height())); $('#obscure_header_mobile').css('height', ($('#photo_header_mobile').height())); $('#obscure_subscribe').css('height', ($('#photo_subscribe').height())); $('#obscure_subscribe2').css('height', ($('#photo_subscribe2').height())); $('#myCarousel.carousel.slide').css('height', ($('#photo_header').height())); $('#myCarousel2.carousel.slide').css('height', ($('#photo_header_mobile').height())); var mainbottom = $('#myCarousel').offset().top + ($('#myCarousel').height()*2)-10; $('#tagline_header').css('top', (($('#photo_header').height()/7)*-5)); $('#tagline_header_mobile').css('top', (($('#photo_header_mobile').height()/10)*-8)); $('#tagline_subscribe').css('top', (($('#photo_subscribe').height()/10)*-8)); $('#tagline_subscribe2').css('top', (($('#photo_subscribe2').height()/10)*-7)); }); $('.popup').popover('toogle') // Newsletter Subscription AJAX $('.new_subscription').submit(function() { var valuesToSubmit = $(this).serialize(); $.ajax({ type: "POST", url: $(this).attr('action'), data: valuesToSubmit, dataType: "json", async: true, error: function(request, textStatus, errorThrown){ msg = '<div class="alert alert-error span5 subscribe-alert"><h4>' + request.status + " " + errorThrown + '</h4><br>' + request.responseText + '</div>' $('.new_subscription').html(msg); }, success: function(data){ $('.subscribe-alert').remove(); switch(data.status) { case 'success': msg = '<div class="alert alert-success subscribe-alert">' + data.success + '</div>'; $('.new_subscription').html(msg); break; case 'error': msg = '<div class="alert alert-error subscribe-alert">' + data.failure + '</div>'; $('.new_subscription').html(msg); break; case 'invalid': msg = '<div class="alert alert-block subscribe-alert">' + data.invalid + '</div>'; $('.new_subscription').prepend(msg); break; } $(".subscribe-alert").bind('click', function() { $(".subscribe-alert").fadeOut(); }); setTimeout(function () {$(".subscribe-alert").fadeOut();}, 4000); } }); return false; }); // on scroll, $(window).on('scroll',function(){ // we round here to reduce a little workload stop = Math.round($(document).scrollTop()); if (stop > mainbottom) { $('.navbar-inner.nav_fx').addClass('past-main'); } else { $('.navbar-inner.nav_fx').removeClass('past-main'); } }); if ($("body").hasClass("landing-page")) { // scroll to 'header' $(".btn-logo").click(function() { event.preventDefault(); doc_with = $(document).width(); if (doc_with > 979) { $('html, body').animate({ scrollTop: $("#myCarousel").offset().top }, 1000); } else if (doc_with < 979 && doc_with > 780) { $('html, body').animate({ scrollTop: ($("#myCarousel").offset().top - 56) }, 1000); } else { $('html, body').animate({ scrollTop: ($("#myCarousel2").offset().top - 56) }, 1000); } }); // scroll to 'about' $(".btn-about").click(function() { event.preventDefault(); doc_with = $(document).width(); if (doc_with > 979) { $('html, body').animate({ scrollTop: ($("#about").offset().top - 80) }, 1000); } else if (doc_with < 979 && doc_with > 780){ $('html, body').animate({ scrollTop: ($("#about").offset().top - 270) }, 1000); } else { $('html, body').animate({ scrollTop: ($("#about").offset().top - 270) }, 1000); } }); // scroll to 'features' $(".btn-features").click(function() { event.preventDefault(); doc_with = $(document).width(); if (doc_with > 979) { $('html, body').animate({ scrollTop: ($("#features").offset().top - 50) }, 1000); } else if (doc_with < 979 && doc_with > 780){ $('html, body').animate({ scrollTop: ($("#features").offset().top - 230) }, 1000); } else { $('html, body').animate({ scrollTop: ($("#features2").offset().top - 230) }, 1000); } }); // scroll to 'subscribe' $(".btn-subscribe").click(function() { event.preventDefault(); doc_with = $(document).width(); if (doc_with > 979) { $('html, body').animate({ scrollTop: ($("#subscribe").offset().top) }, 1000); } else if (doc_with < 979 && doc_with > 780){ $('html, body').animate({ scrollTop: ($("#subscribe").offset().top - 100) }, 1000); } else { $('html, body').animate({ scrollTop: ($("#subscribe2").offset().top - 230) }, 1000); } }); } }; $(document).ready(attachHandler); $(document).load(attachHandler);