Skip to content

Instantly share code, notes, and snippets.

@jondkinney
Created February 15, 2013 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jondkinney/4964279 to your computer and use it in GitHub Desktop.
Save jondkinney/4964279 to your computer and use it in GitHub Desktop.
$(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