Created
February 15, 2013 22:57
-
-
Save jondkinney/4964279 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
$(document).ready -> | |
$('.role_choices').hide() | |
revealRoles = (element) -> | |
$('.role_choices').slideDown 'fast' | |
$(element).addClass 'button_text_and_arrow_open' | |
$(element).removeClass 'button_text_and_arrow_closed' | |
$('.down_arrow').css('background-position', '0px -23px') | |
hideRoles = (element) -> | |
$('.role_choices').slideUp 'fast' | |
$(element).addClass 'button_text_and_arrow_closed' | |
$(element).removeClass 'button_text_and_arrow_open' | |
$('.down_arrow').css('background-position', '0px 0px') | |
$(document).delegate ".button_text_and_arrow_closed", 'click', (e) -> | |
revealRoles('.button_text_and_arrow_closed') | |
$(document).delegate ".button_text_and_arrow_open", 'click', (e) -> | |
hideRoles('.button_text_and_arrow_open') | |
$(document).delegate ".button_text_and_arrow_closed", 'mouseenter', (e) -> | |
revealRoles('.button_text_and_arrow_closed') | |
# Populate the other forms with the same data as we type | |
$('.required input:text, .required input[type="email"]').each (index, element) -> | |
$(@).keyup -> | |
value = $(@).val() | |
$(".#{$(@).attr('name')}").val(value) | |
# Since the home page form is hidden on the other pages, just check it (it's | |
# the only one that doesn't have a default one checked) so that makes all the | |
# forms validate | |
url = $.url() | |
path = url.attr('path') | |
if path is "/small-business" or path is "/investors" or path is "/attorneys" | |
$('#home_role_Entrepreneur').attr('checked', true) | |
if path is "/" | |
page = 'home' | |
else if path is "/small-business" | |
page = 'small_business' | |
else if path is '/investors' | |
page = 'investors' | |
else if path is '/attorneys' | |
page = 'attorneys' | |
small_business_html = $('.button_text_small_business').html() | |
investors_html = $('.button_text_investors').html() | |
attorneys_html = $('.button_text_attorneys').html() | |
$("##{page}_role_Entrepreneur").click -> | |
$(".button_text_#{page}").html(small_business_html) | |
$("##{page}_role_Investor").click -> | |
$(".button_text_#{page}").html(investors_html) | |
$("##{page}_role_Attorney").click -> | |
$(".button_text_#{page}").html(attorneys_html) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment