Patched up popovers for our nefarious purposes + cart pretties

This commit is contained in:
Will Marshall
2014-07-24 14:56:13 +10:00
parent 63807fd2cd
commit f45dd24803
8 changed files with 72 additions and 14 deletions

View File

@@ -0,0 +1,7 @@
Darkswarm.directive "cart", ->
restrict: 'A'
link: (scope, elem, attr)->
scope.open = false
elem.bind 'click', ->
scope.$apply ->
scope.open = !scope.open

View File

@@ -0,0 +1,15 @@
Darkswarm.directive "priceBreakdown", ($tooltip)->
tooltip = $tooltip 'priceBreakdown', 'priceBreakdown', 'click'
tooltip.scope =
variant: "="
tooltip
Darkswarm.directive 'priceBreakdownPopup', ()->
restrict: 'EA'
replace: true
templateUrl: 'price_breakdown.html'
scope: true
#link: (scope, elem, attrs)->
#angular.element($window).bind 'click', ->
#scope.tt_isOpen = false
#elem.remove()

View File

@@ -41,6 +41,12 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http)->
@line_items.filter (li)->
li.quantity > 0
total: =>
@line_items_present().map (li)->
li.variant.getPrice()
.reduce (total, price)->
total + price
register_variant: (variant)=>
exists = @line_items.some (li)-> li.variant == variant
@create_line_item(variant) unless exists

View File

@@ -0,0 +1,4 @@
.joyride-tip-guide{"ng-class" => "{ in: isOpen(), fade: animation() }"}
%span.joyride-nub.bottom
.joyride-content-wrapper
{{ variant.id }}

View File

@@ -1,5 +1,15 @@
@import mixins
@import branding
@import "compass/css3/user-interface"
.cart
@include user-select(none)
.joyride-tip-guide
display: block
right: 0px
top: 45px
li
float: none
#cart-detail
.cart-item-delete

View File

@@ -1,10 +1,25 @@
%a.icon{href: cart_url, "ng-controller" => "CartCtrl"}
%span.nav-branded
%i.ofn-i_027-shopping-cart
%span
{{ Cart.line_items_present().length }}
items
%ul
%li{"ng-repeat" => "line_item in Cart.line_items_present()",
"ng-controller" => "LineItemCtrl"}
{{ line_item.id }}
%span{"ng-controller" => "CartCtrl"}
%a#cart.icon{cart: true}
%span.nav-branded
%i.ofn-i_027-shopping-cart
%span
{{ Cart.line_items_present().length }}
items
.joyride-tip-guide{"ng-class" => "{ in: open }", "ng-show" => "open"}
%span.joyride-nub.top
.joyride-content-wrapper
%ul
%li{"ng-repeat" => "line_item in Cart.line_items_present()",
"ng-controller" => "LineItemCtrl"}
{{ line_item.variant.name_to_display }}
({{line_item.quantity}})
x
{{ line_item.variant.unit_to_display }}
x
{{ line_item.variant.price | currency }}
is
{{ line_item.variant.getPrice() | currency }}
%li{"ng-show" => "Cart.line_items_present().length > 0"}
Total: {{ Cart.total() | currency }}
%a.button{href: checkout_path, "ng-disabled" => "Cart.dirty"} Checkout now

View File

@@ -1,8 +1,7 @@
%products.small-12.columns{"ng-controller" => "ProductsCtrl", "ng-show" => "order_cycle.order_cycle_id != null",
"infinite-scroll" => "incrementLimit()", "infinite-scroll-distance" => "1"}
= form_for :order, :url => populate_orders_path, html: {:class => "custom"} do
%form.custom
.row
.small-12.columns
%input#search.text{"ng-model" => "query",

View File

@@ -47,8 +47,10 @@
.table-cell
%i.ofn-i_009-close
{{ product.price | currency }}
%button.graph-button{popover: "This is the popover text", "popover-title" => "The title.", "popover-animation" => "true", "popover-trigger" =>"mouseenter", "popover-placement" => "top"}
{{ $id }}
%button.graph-button{"price-breakdown" => "_",
"variant" => "product.master",
"price-breakdown-animation" => "true"}
%i.ofn-i-058-graph
.small-12.medium-2.large-2.columns.total-price.text-right