 		@element.html $template
 
 	bindEvents: =>
-		@window.on 'vtex.qty.changed', @qtyChanged
+		$(window).on 'vtex.qty.changed', @qtyChanged
 		@element.find('.menos').on 'click', @decrementQty
 		@element.find('.mais').on 'click', @incrementQty
 


	new QtySelector(this, productId, qty, options)

# PLUGIN DEFAULTS
$.fn.qtySelector.defaults =
	readonly: true
	max: 999

# PLUGIN SHARED
$.qtySelector.template = """
	<div class="quantidade" style="display: block;">
		<p class="txtQuantidade">Selecione a quantidade:</p>
		<a href="#" class="menos">-</a>
		<input type="text" class="produtoQuantidade">
		<a href="#" class="mais">+</a>
	</div>
	"""
	qtyChanged: (evt, qty, productId) =>
		return unless @check(productId)
		@qty = qty
		@init()

	decrementQty: =>
		if @qty > 1
			@element.trigger 'vtex.qty.changed', [@qty-1, @productId]

	incrementQty: =>
		if @qty < @options.max
			@element.trigger 'vtex.qty.changed', [@qty+1, @productId]


# PLUGIN ENTRY POINT
$.fn.qtySelector = (productId, qty = 1, jsOptions) ->
	# Gather options
	domOptions = this.data()
	defaultOptions = $.fn.qtySelector.defaults
