 
 )( jQuery, window, document )
 
-$ -> $('.portal-totalizers-ref').vtexTotalizers()
-# $ -> $('.carrinhoCompras a').vtexTotalizers()
+# $ -> $('.portal-totalizers-ref').vtexTotalizers()
+$ -> $('.carrinhoCompras a').vtexTotalizers()


      self.getCartData()

      $(window).on 'cartUpdated', ->
        self.getCartData()

      $('.amount-items-in-cart, .show-minicart-on-hover').mouseover ->
        $(window).trigger 'miniCartMouseOver'

        $(self.options.$template).removeClass 'amount-items-in-cart-loading'

      promise.success (data) ->
        self.setCartData data

      promise.fail (jqXHR, textStatus, errorThrown) ->
        console.log 'Error Message: ' + textStatus;
        console.log 'HTTP Error: ' + errorThrown;

      promise

    setCartData: (data) ->
      self = this

      amountProducts = data.items.length
      amountItems = 0;
      amountItems += item.quantity for item in data.items
      totalCart = self.formatCurrency data.value

      self.selectors.amountProducts.html amountProducts
      self.selectors.amountItems.html amountItems
      self.selectors.totalCart.html totalCart

    $.fn[pluginName] = (options) ->
      @each ->
