Sha256: ab61b635fd8bdbb203ea6502a41572c10a36fc0c193be945cd92fbd4a3539e40

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

Sprangular.controller 'ProductCtrl', ($scope, Status, product, Account, Cart) ->
  $scope.product = product
  $scope.user = Account.user
  $scope.adding = false
  $scope.selected =
    image: null
    images: []
    quantity: 1
    variant: null

  Status.pageTitle        = $scope.product.name
  Status.meta.description = $scope.product.meta_description
  Status.meta.keywords    = $scope.product.meta_keywords

  $scope.selected.variant = if product.hasVariants
    Cart.current.findVariantForProduct(product) || product.firstAvailableVariant()
  else
    product.master

  $scope.$watch 'selected.variant', (variant) ->
    if variant && variant.images.length > 0
      $scope.selected.images = variant.images
    else
      $scope.selected.images = product.images

    $scope.selected.image = $scope.selected.images[0]

  $scope.changeQuantity = (val) ->
    $scope.selected.quantity = val

  $scope.changeImage = (image) ->
    $scope.selected.image = image

  $scope.hasVariant = ->
    Cart.hasVariant($scope.selected.variant)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sprangular-0.1.0 app/assets/javascripts/sprangular/controllers/product.coffee
sprangular-0.0.1 app/assets/javascripts/sprangular/controllers/product.coffee