var vcGridStyleLazy=null;(function($){$.waypoints('extendFn','vc_grid-infinite',function(options){var $container,opts;var el=this;opts=$.extend({},$.fn.waypoint.defaults,{container:'auto',items:'.infinite-item',offset:'bottom-in-view',handle:{load:function(opts){}}},options);$container='auto'===opts.container?el:$(opts.container,el);opts.handler=function(direction){var $this;if('down'===direction||'right'===direction){$this=$(this);$this.waypoint('destroy');opts.handle.load.call(this,opts);}};return this.waypoint(opts);});vcGridStyleLazy=function(grid){this.grid=grid;this.settings=grid.settings;this.$el=false;this.filterValue=null;this.$content=false;this.isLoading=false;this.$loader=$('
');this.init();};vcGridStyleLazy.prototype.setIsLoading=function(){this.$content.append(this.$loader);this.isLoading=true;};vcGridStyleLazy.prototype.unsetIsLoading=function(){this.isLoading=false;this.$loader&&this.$loader.remove();};vcGridStyleLazy.prototype.init=function(){_.bindAll(this,'addItems','showItems');};vcGridStyleLazy.prototype.render=function(){this.$el=this.grid.$el;this.$content=this.$el;this.setIsLoading();this.grid.ajax({},this.addItems);};vcGridStyleLazy.prototype.showItems=function(){var $els=this.$content.find('.vc_grid_filter-item:not(.vc_visible-item):lt('+ this.settings.items_per_page+')');this.setIsLoading();$els.addClass('vc_visible-item '+ vcGridSettings.addItemsAnimation+' animated');this.unsetIsLoading();jQuery(window).trigger('grid:items:added',this.$el);};vcGridStyleLazy.prototype.filter=function(filter){filter=_.isUndefined(filter)||'*'===filter?'':filter;if(this.filterValue==filter){return false;} this.$content.find('.vc_visible-item, .vc_grid_filter-item').removeClass('vc_visible-item vc_grid_filter-item ' +('none'!==vcGridSettings.addItemsAnimation?vcGridSettings.addItemsAnimation+' animated':''));this.filterValue=filter;this.$content.find('.vc_grid-item'+ this.filterValue).addClass('vc_grid_filter-item');_.defer(this.showItems);this.initScroll();};vcGridStyleLazy.prototype.addItems=function(html){var els=$(html);this.$el.append(els);this.unsetIsLoading();this.$content=els.find('[data-vc-grid-content="true"]');this.grid.initFilter();this.filter();window.vc_prettyPhoto();};vcGridStyleLazy.prototype.initScroll=function(){var self=this;this.$content.unbind('waypoint').waypoint('vc_grid-infinite',{container:'auto',items:'.vc_grid-item',handle:{load:function(opts){self.showItems();self.checkNext(opts);}}});};vcGridStyleLazy.prototype.checkNext=function(opts){if(this.$content.find('.vc_grid_filter-item:not(".vc_visible-item")').length){var fn,self=this;fn=function(){return self.$content.waypoint(opts);};_.defer(fn);}};})(window.jQuery);