var App_Cart_Small = { _options: [], _listHtml: null, _containerId: 'quick-shopping-cart-container', _container: null, _loaderSrc: 'images/loading-arrow-16x16.gif', _loaderAlt: 'loading', _qtyContainerId: 'header-cart-item-count', _qtyContainerTextId: 'header-cart-item-count-text', _ajaxError: false, init: function(options) { $.extend(this._options, options); var obj = this; $(this._options.selector).hover( function() { if (!$('#' + obj._containerId).length) { obj._listHtml = null; obj._container = $('
', {'id': obj._containerId, 'style': 'display: none', 'class': 'dropdown' }); } if (!obj._container.is(':visible')) { obj.show($(this)); } }, function() { if (obj._container.is(':visible')) { timer=setTimeout(function(){ obj.hide(); }, 500); } } ); }, show: function(target) { if (!this._listHtml) { this._container.html($('', {'src': this._loaderSrc, 'alt': this._loaderAlt})); $(target).append(this._container); this._initListHtml(); } if (!this._ajaxError) { this._container.html(this._listHtml); $(target).append(this._container); $('#' + this._containerId).show(); } }, hide: function() { $('#' + this._containerId).hide(); }, _initListHtml: function() { var obj = this; $.ajax({ url: obj._options.url, data: {action: 'getListHtml'}, async: false, type: 'POST' }).fail(function (status) { obj._ajaxError = true; }).done(function (html) { obj._ajaxError = false; obj._listHtml = html; }); }, updateQty: function(qty) { $('#' + this._qtyContainerId).text(qty); $('#' + this._qtyContainerTextId).text('Item' + (parseInt(qty) != 1 ? 's' : '')); }, reset: function() { $('#' + this._containerId).remove(); } };