 
     orderChanged: =>
       @unsaved()
-      $window.onBeforeUnload
       if @promise
         $timeout.cancel(@promise)
       @promise = $timeout @update, 1000
 
     update: =>
-      console.log @data()
       $http.post('/orders/populate', @data()).success (data, status)=>
         @saved()
       .error (response, status)=>


    saved: =>
      @dirty = false
      #$window.onBeforeUnload = null 

    unsaved: =>
      @dirty = true
      window.onBeforeUnload = ->
        "Your order hasn't been saved yet! Are you sure you want to leave this page?"

    line_items_present: =>
      @line_items.filter (li)->

Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http)->
  # Handles syncing of current cart/order state to server
  new class Cart
    dirty: false
