Created
October 30, 2010 10:18
-
-
Save rickerbh/655169 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module CheckoutsHelper | |
def checkout_progress | |
steps = Checkout.state_names.reject { |n| n == "complete" }.map do |state| | |
next if state == "confirm" and not (Gateway.current && Gateway.current.payment_profiles_supported?) | |
text = t("checkout_steps.#{state}") | |
css_classes = [] | |
current_index = Checkout.state_names.index(@checkout.state) | |
state_index = Checkout.state_names.index(state) | |
if state_index < current_index | |
css_classes << 'completed' | |
text = link_to text, edit_order_checkout_url(@order, :step => state) | |
end | |
css_classes << 'next' if state_index == current_index + 1 | |
css_classes << 'current' if state == @checkout.state | |
css_classes << 'first' if state_index == 0 | |
css_classes << 'last' if state_index == Checkout.state_names.length - 1 | |
# It'd be nice to have separate classes but combining them with a dash helps out for IE6 which only sees the last class | |
content_tag('li', content_tag('span', text), :class => css_classes.join('-')) | |
end | |
content_tag('ol', steps.join("\n"), :class => 'progress-steps', :id => "checkout-step-#{@checkout.state}") + '<br clear="left" />' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment