Adding icons to checkout, focusing on first input in each panel when selected

This commit is contained in:
Will Marshall
2014-04-16 16:07:19 +10:00
parent 2b9b51de60
commit d83367486b
9 changed files with 36 additions and 11 deletions

View File

@@ -16,6 +16,7 @@
#= require ./darkswarm
#= require ./overrides
#= require_tree ./mixins
#= require_tree ./directives
#= require_tree .
$ ->

View File

@@ -0,0 +1,11 @@
Darkswarm.directive "ofnFocus", ->
restrict: "A"
link: (scope, element, attrs) ->
scope.$watch attrs.ofnFocus, ((focus) ->
console.log focus
focus and element.focus()
return
), true
return

View File

@@ -5,5 +5,8 @@ checkout
.button, table
width: 100%
dd.valid
background: green
dd
i.fi-check, &.valid i.fi-x
display: none
&.valid i.fi-check
display: inline

View File

@@ -12,10 +12,14 @@ module CheckoutHelper
end
def validated_input(name, path, args = {})
defaults = {
attributes = {
required: true,
type: :text
type: :text,
name: path,
"ng-model" => path,
"ng-class" => "{error: !fieldValid('#{path}')}"
}.merge args
render partial: "shared/validated_input", locals: {name: name, path: path}.merge(defaults)
render partial: "shared/validated_input", locals: {name: name, path: path, attributes: attributes}
end
end

View File

@@ -1,8 +1,6 @@
%label{for: path}= name
%input.medium.input-text{name: path,
"ng-model" => path,
required: required,
type: type,
"ng-class" => "{error: !fieldValid('#{path}')}"}
%input.medium.input-text{attributes}
%small.error.medium.input-text{"ng-show" => "!fieldValid('#{path}')"}
= "{{ fieldErrors('#{path}') }}"

View File

@@ -9,10 +9,12 @@
.large-6.columns.text-right
{{ order.bill_address.address1 }}
{{ order.bill_address.city }}
%i.fi-x
%i.fi-check
= f.fields_for :bill_address, @order.bill_address do |ba|
.row
.large-12.columns
= validated_input "Address", "order.bill_address.address1"
= validated_input "Address", "order.bill_address.address1", "ofn-focus" => "accordion['billing']"
.row
.large-12.columns
= validated_input "Address (contd.)", "order.bill_address.address2", required: false

View File

@@ -9,6 +9,8 @@
.large-6.columns.text-right
{{ order.bill_address.firstname }}
{{ order.bill_address.lastname }}
%i.fi-x
%i.fi-check
.row
.large-6.columns
= validated_input('Email', 'order.email', type: :email)

View File

@@ -8,6 +8,8 @@
Payment Details
.large-6.columns.text-right
{{ Order.paymentMethod().name }}
%i.fi-x
%i.fi-check
- current_order.available_payment_methods.each do |method|
.row
.large-12.columns

View File

@@ -8,6 +8,8 @@
Shipping
.large-6.columns.text-right
{{ Order.shippingMethod().name }}
%i.fi-x
%i.fi-check
- for ship_method, i in current_distributor.shipping_methods.uniq
.row
.large-12.columns