Making the auto-closing more granular on checkout

This commit is contained in:
Will Marshall
2014-06-03 13:06:27 +10:00
parent fc3402bbd0
commit 59c433881e
7 changed files with 19 additions and 19 deletions

View File

@@ -9,8 +9,8 @@ Darkswarm.controller "AccordionCtrl", ($scope, storage, $timeout) ->
$scope.show = (name)->
$scope.accordion[name] = true
$timeout =>
if $scope.checkout.$valid
for k, v of $scope.accordion
$scope.accordion[k] = false
#$timeout =>
#if $scope.checkout.$valid
#for k, v of $scope.accordion
#$scope.accordion[k] = false

View File

@@ -1,4 +1,4 @@
Darkswarm.controller "BillingCtrl", ($scope) ->
Darkswarm.controller "BillingCtrl", ($scope, $timeout) ->
angular.extend(this, new FieldsetMixin($scope))
$scope.name = "billing"
$scope.nextPanel = "shipping"
@@ -8,3 +8,4 @@ Darkswarm.controller "BillingCtrl", ($scope) ->
$scope.order.bill_address.city,
$scope.order.bill_address.zipcode]
#$timeout $scope.onTimeout

View File

@@ -1,6 +1,5 @@
Darkswarm.controller "DetailsCtrl", ($scope) ->
Darkswarm.controller "DetailsCtrl", ($scope, $timeout) ->
angular.extend(this, new FieldsetMixin($scope))
$scope.name = "details"
$scope.nextPanel = "billing"
@@ -12,3 +11,5 @@ Darkswarm.controller "DetailsCtrl", ($scope) ->
$scope.fullName = ->
[$scope.order.bill_address.firstname ? null,
$scope.order.bill_address.lastname ? null].join(" ").trim()
$timeout $scope.onTimeout

View File

@@ -1,4 +1,4 @@
Darkswarm.controller "PaymentCtrl", ($scope) ->
Darkswarm.controller "PaymentCtrl", ($scope, $timeout) ->
angular.extend(this, new FieldsetMixin($scope))
$scope.name = "payment"
@@ -6,3 +6,4 @@ Darkswarm.controller "PaymentCtrl", ($scope) ->
$scope.years = [moment().year()..(moment().year()+15)]
$scope.secrets.card_month = "1"
$scope.secrets.card_year = moment().year()
$timeout $scope.onTimeout

View File

@@ -1,5 +1,6 @@
Darkswarm.controller "ShippingCtrl", ($scope) ->
Darkswarm.controller "ShippingCtrl", ($scope, $timeout) ->
angular.extend(this, new FieldsetMixin($scope))
$scope.name = "shipping"
$scope.nextPanel = "payment"
$timeout $scope.onTimeout

View File

@@ -1,8 +1,12 @@
window.FieldsetMixin = ($scope)->
$scope.next = (event)->
event.preventDefault()
$scope.next = (event = false)->
event.preventDefault() if event
$scope.show $scope.nextPanel
$scope.onTimeout = ->
if $scope[$scope.name].$valid
$scope.next()
$scope.valid = ->
$scope.form().$valid

View File

@@ -30,11 +30,3 @@ describe "AccordionCtrl", ->
scope.order =
id: 129
ctrl = $controller 'AccordionCtrl', {$scope: scope}
it "automatically closes all sections if the entire form is valid", ->
waitsFor ->
(scope.accordion.details and
scope.accordion.shipping and
scope.accordion.payment and
scope.accordion.billing) == false
, "the accordion to close", 100