function Partners( elem, params ){ this.element = jQuery(elem); this.params = params || {}; this.maxRows = this.params.maxRows || 1; this.itemsInRow = this.params.itemsInRow || 1; this.multiplier = this.params.multiplier || 1; this.classCollapsed = this.params.classCollapsed || 'JS-Partners-collapsed'; this.classExpanded = this.params.classExpanded || 'JS-Partners-expanded'; this.__construct(); } Partners.prototype.__construct = function(){ this._isBusy = false; this.list = this.element.find('.JS-Partners-List'); this.items = this.list.find('.JS-Partners-Items'); this.toolbar = this.element.find('.JS-Partners-Toolbar'); this.toggler = this.element.find('.JS-Partners-Toggler'); this.totalRows = Math.ceil(this.items.length / this.itemsInRow); if( this.totalRows <= this.maxRows ){ this.toolbar.remove(); }else{ this._init(); } }; Partners.prototype._init = function(){ var context = this; this._rowHeight = this.items.eq(0).outerHeight(true); this._minHeight = this.maxRows * this._rowHeight; this._maxHeight = this.totalRows * this._rowHeight; this[this.element.hasClass('JS-Partners-collapsed') || this.element.hasClass(this.classCollapsed) ? 'collapse' : 'expand'](); this.toggler.bind('click', function(){ return context.toggle.apply(context, arguments) }); }; Partners.prototype.expand = function( isAnim ){ var context = this; this._isBusy = true; this.element.removeClass('JS-Partners-collapsed').removeClass(this.classCollapsed) .addClass('JS-Partners-expanded').addClass(this.classExpanded); this.list.css({'height' : this._minHeight + 'px'}) .animate({'height' : this._maxHeight + 'px'}, (this._maxHeight - this._minHeight) * this.multiplier, function(){ context.cb_expand.call(context) }); }; Partners.prototype.cb_expand = function(){ this._isBusy = false; }; Partners.prototype.collapse = function( isAnim ){ var context = this; this._isBusy = true; this.list.css({'height' : this._maxHeight + 'px'}) .animate({'height' : this._minHeight + 'px'}, (this._maxHeight - this._minHeight) * this.multiplier, function(){ context.cb_collapse.call(context) }); }; Partners.prototype.cb_collapse = function(){ this._isBusy = false; this.element.removeClass('JS-Partners-expanded').removeClass(this.classExpanded) .addClass('JS-Partners-collapsed').addClass(this.classCollapsed); }; Partners.prototype.toggle = function(){ if( !this._isBusy ){ this[this.element.hasClass('JS-Partners-collapsed') ? 'expand' : 'collapse'](true); } return false; }; /*--/Partners--*/