var App_Cart_Small = { _options: {}, _containerId: 'quick-shopping-cart-container', _container: null, _qtyContainerId: 'header-cart-item-count', _qtyContainerTextId: 'header-cart-item-count-text', _loaded: false, init: function(options) { $.extend(this._options, options); this._container = $('#' + this._containerId); var obj = this; $(this._options.selector).hover(function () { if (!$(obj._container).html()) { obj.reset(); } obj._loadCart(); }); }, _loadCart: function() { if (this._loaded) { return; } this._loaded = true; var obj = this; var list = ''; $.ajax({ url: obj._options.url, data: {action: 'getListHtml'}, type: 'GET', dataType: 'jsonp' }).fail(function (status) { obj._loaded = false; }).done(function (json) { if (json.success == true) { obj._container.html(json.html); } else { obj._loaded = false; } }); }, updateQty: function(qty) { $('#' + this._qtyContainerId).text(qty); $('#' + this._qtyContainerTextId).text('Item' + (parseInt(qty) != 1 ? 's' : '')); }, reset: function() { this._loaded = false; $(this._container).html($('', {'src': 'images/loading-arrow-16x16.gif', 'alt': 'Loading...'})); } };